Редакция 506 | Редакция 510 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 506 | Редакция 509 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | /**
|
3 | /**
|
4 | *
|
4 | *
|
5 | * Codename: ant-ng - generator of sources.list for Debian and
|
5 | * Codename: ant-ng - generator of sources.list for Debian and
|
6 | * distributives, based on Debian
|
6 | * distributives, based on Debian
|
7 | * http://alex-w.org.ru/p/antng/
|
7 | * http://alex-w.org.ru/p/antng/
|
8 | *
|
8 | *
|
9 | * Copyright (c) 2009 Alexander Wolf
|
9 | * Copyright (c) 2009 Alexander Wolf
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
11 | * http://alex-w.org.ru/p/antng/license
|
11 | * http://alex-w.org.ru/p/antng/license
|
12 | *
|
12 | *
|
13 | */
|
13 | */
|
14 | 14 | ||
15 | class Core { |
15 | class Core { |
16 | protected $db = NULL; |
16 | protected $db = NULL; |
17 | protected $prefix = NULL; |
17 | protected $prefix = NULL; |
18 | protected $secure = NULL; |
18 | protected $secure = NULL; |
19 | protected $cookie = NULL; |
19 | protected $cookie = NULL; |
20 | 20 | ||
21 | /**
|
21 | /**
|
22 | * Конструктор класса Core - ядро генератора
|
22 | * Конструктор класса Core - ядро генератора
|
23 | *
|
23 | *
|
24 | * @author Alexander Wolf
|
24 | * @author Alexander Wolf
|
25 | * @category Core
|
25 | * @category Core
|
26 | *
|
26 | *
|
27 | * @param string $database
|
27 | * @param string $database
|
28 | * @param string $prefix
|
28 | * @param string $prefix
|
29 | * @param object $secure
|
29 | * @param object $secure
|
30 | * @param string $cookie
|
30 | * @param string $cookie
|
31 | */
|
31 | */
|
32 | public function __construct($database, $prefix, $secure, $cookie) { |
32 | public function __construct($database, $prefix, $secure, $cookie) { |
33 | $this->db = $database; |
33 | $this->db = $database; |
34 | $this->prefix = $prefix; |
34 | $this->prefix = $prefix; |
35 | $this->secure = $secure; |
35 | $this->secure = $secure; |
36 | $this->cookie = $cookie; |
36 | $this->cookie = $cookie; |
37 | }
|
37 | }
|
38 | 38 | ||
39 | /**
|
39 | /**
|
40 | * Получение данных о настройке
|
40 | * Получение данных о настройке
|
41 | *
|
41 | *
|
42 | * @author Alexander Wolf
|
42 | * @author Alexander Wolf
|
43 | * @category Core
|
43 | * @category Core
|
44 | *
|
44 | *
|
45 | * @param string $attr
|
45 | * @param string $attr
|
46 | * @return array
|
46 | * @return array
|
47 | */
|
47 | */
|
48 | public function getOption($attr) { |
48 | public function getOption($attr) { |
49 | $result = array(); |
49 | $result = array(); |
50 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
50 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
51 | $rq =& $this->db->query($query); |
51 | $rq =& $this->db->query($query); |
52 | if ($rq->numRows()!=0) { |
52 | if ($rq->numRows()!=0) { |
53 | $rq->fetchInto($element); |
53 | $rq->fetchInto($element); |
54 | $result["ERR"] = 0; |
54 | $result["ERR"] = 0; |
55 | $result["OptValue"] = $element["optvalue"]; |
55 | $result["OptValue"] = $element["optvalue"]; |
56 | } else { |
56 | } else { |
57 | $result["ERR"] = 1; |
57 | $result["ERR"] = 1; |
58 | $result["ERRINFO"] = "Empty result"; |
58 | $result["ERRINFO"] = "Empty result"; |
59 | }
|
59 | }
|
60 | return $result; |
60 | return $result; |
61 | }
|
61 | }
|
62 | 62 | ||
63 | /**
|
63 | /**
|
64 | * Установка данных о настройке
|
64 | * Установка данных о настройке
|
65 | *
|
65 | *
|
66 | * @author Alexander Wolf
|
66 | * @author Alexander Wolf
|
67 | * @category Core
|
67 | * @category Core
|
68 | *
|
68 | *
|
69 | * @param string $attr
|
69 | * @param string $attr
|
70 | * @param string $value
|
70 | * @param string $value
|
71 | * @return array
|
71 | * @return array
|
72 | */
|
72 | */
|
73 | public function setOption($attr, $value) { |
73 | public function setOption($attr, $value) { |
74 | $result = array(); |
74 | $result = array(); |
75 | 75 | ||
76 | if ($attr != "passwd") { |
76 | if ($attr != "passwd") { |
77 | $sValue = $this->secure->checkStr($value); |
77 | $sValue = $this->secure->checkStr($value); |
78 | } else { |
78 | } else { |
79 | $sValue = $value; |
79 | $sValue = $value; |
80 | }
|
80 | }
|
81 | 81 | ||
82 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
82 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
83 | $rq =& $this->db->query($query); |
83 | $rq =& $this->db->query($query); |
84 | if (PEAR::isError($this->db)) { |
84 | if (PEAR::isError($this->db)) { |
85 | $result["ERR"] = 1; |
85 | $result["ERR"] = 1; |
86 | $result["ERRINFO"] = $this->db->getMessage(); |
86 | $result["ERRINFO"] = $this->db->getMessage(); |
87 | } else { |
87 | } else { |
88 | $result["ERR"] = 0; |
88 | $result["ERR"] = 0; |
89 | }
|
89 | }
|
90 | 90 | ||
91 | return $result; |
91 | return $result; |
92 | }
|
92 | }
|
93 | 93 | ||
94 | /**
|
94 | /**
|
95 | * Создание настройки
|
95 | * Создание настройки
|
96 | *
|
96 | *
|
97 | * @author Alexander Wolf
|
97 | * @author Alexander Wolf
|
98 | * @category Core
|
98 | * @category Core
|
99 | *
|
99 | *
|
100 | * @param string $attr
|
100 | * @param string $attr
|
101 | * @param string $value
|
101 | * @param string $value
|
102 | * @return array
|
102 | * @return array
|
103 | */
|
103 | */
|
104 | public function addOption($attr, $value) { |
104 | public function addOption($attr, $value) { |
105 | $result = array(); |
105 | $result = array(); |
106 | $sValue = $this->secure->checkStr($value); |
106 | $sValue = $this->secure->checkStr($value); |
107 | 107 | ||
108 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
108 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
109 | $rq =& $this->db->query($query); |
109 | $rq =& $this->db->query($query); |
110 | if (PEAR::isError($this->db)) { |
110 | if (PEAR::isError($this->db)) { |
111 | $result["ERR"] = 1; |
111 | $result["ERR"] = 1; |
112 | $result["ERRINFO"] = $this->db->getMessage(); |
112 | $result["ERRINFO"] = $this->db->getMessage(); |
113 | } else { |
113 | } else { |
114 | $result["ERR"] = 0; |
114 | $result["ERR"] = 0; |
115 | }
|
115 | }
|
116 | 116 | ||
117 | return $result; |
117 | return $result; |
118 | }
|
118 | }
|
119 | 119 | ||
120 | /**
|
120 | /**
|
121 | * Получение и отображение списка дистрибутвов
|
121 | * Получение и отображение списка дистрибутвов
|
122 | *
|
122 | *
|
123 | * @author Alexander Wolf
|
123 | * @author Alexander Wolf
|
124 | * @category Core
|
124 | * @category Core
|
125 | * @deprecated may be deprecated XXX
|
125 | * @deprecated may be deprecated XXX
|
126 | *
|
126 | *
|
127 | * @param string $name
|
127 | * @param string $name
|
128 | * @param string $heads
|
128 | * @param string $heads
|
129 | * @param string $info
|
129 | * @param string $info
|
130 | * @param string $format
|
130 | * @param string $format
|
131 | * @return string
|
131 | * @return string
|
132 | */
|
132 | */
|
133 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
133 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
134 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
134 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
135 | $rq =& $this->db->query($query); |
135 | $rq =& $this->db->query($query); |
136 | switch ($format) { |
136 | switch ($format) { |
137 | case 'html': |
137 | case 'html': |
138 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
138 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
139 | $show .= "<option value=''>".$info."</option>\n"; |
139 | $show .= "<option value=''>".$info."</option>\n"; |
140 | while ($rq->fetchInto($element)) { |
140 | while ($rq->fetchInto($element)) { |
141 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
141 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
142 | }
|
142 | }
|
143 | $show .= "</select></fieldset>"; |
143 | $show .= "</select></fieldset>"; |
144 | break; |
144 | break; |
145 | case 'json': |
145 | case 'json': |
146 | $show = '[{value:"",text:"'.$info.'"}'; |
146 | $show = '[{value:"",text:"'.$info.'"}'; |
147 | while ($rq->fetchInto($element)) { |
147 | while ($rq->fetchInto($element)) { |
148 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
148 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
149 | }
|
149 | }
|
150 | $show .= ']'; |
150 | $show .= ']'; |
151 | break; |
151 | break; |
152 | case 'innerhtml': |
152 | case 'innerhtml': |
153 | $show = "<select id='".$name."' name='".$name."'>\n"; |
153 | $show = "<select id='".$name."' name='".$name."'>\n"; |
154 | while ($rq->fetchInto($element)) { |
154 | while ($rq->fetchInto($element)) { |
155 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
155 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
156 | }
|
156 | }
|
157 | $show .= "</select>"; |
157 | $show .= "</select>"; |
158 | break; |
158 | break; |
159 | case 'list': |
159 | case 'list': |
160 | $show = "<ul>"; |
160 | $show = "<ul>"; |
161 | while ($rq->fetchInto($element)) { |
161 | while ($rq->fetchInto($element)) { |
162 | $show .= "<li>[<a href='".$heads."?mode=distributions&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."'>править</a>][<a href='".$heads."?mode=distributions&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n"; |
162 | $show .= "<li>[<a href='".$heads."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n"; |
163 | }
|
163 | }
|
164 | $show .= "</ul>"; |
164 | $show .= "</ul>"; |
165 | break; |
165 | break; |
166 | }
|
166 | }
|
167 | return $show; |
167 | return $show; |
168 | }
|
168 | }
|
169 | 169 | ||
170 | /**
|
170 | /**
|
171 | * Получение названия дистрибутива
|
171 | * Получение названия дистрибутива
|
172 | *
|
172 | *
|
173 | * @author Alexander Wolf
|
173 | * @author Alexander Wolf
|
174 | * @category Core
|
174 | * @category Core
|
175 | *
|
175 | *
|
176 | * @param integer $distID
|
176 | * @param integer $distID
|
177 | * @return array
|
177 | * @return array
|
178 | */
|
178 | */
|
179 | public function getDistName($distID) { |
179 | public function getDistName($distID) { |
180 | $result = array(); |
180 | $result = array(); |
181 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
181 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
182 | $rq =& $this->db->query($query); |
182 | $rq =& $this->db->query($query); |
183 | if (PEAR::isError($this->db)) { |
183 | if (PEAR::isError($this->db)) { |
184 | $result["ERR"] = 1; |
184 | $result["ERR"] = 1; |
185 | $result["ERRINFO"] = $this->db->getMessage(); |
185 | $result["ERRINFO"] = $this->db->getMessage(); |
186 | } else { |
186 | } else { |
187 | $rq->fetchInto($element); |
187 | $rq->fetchInto($element); |
188 | $result["ERR"] = 0; |
188 | $result["ERR"] = 0; |
189 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
189 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
190 | }
|
190 | }
|
191 | 191 | ||
192 | return $result; |
192 | return $result; |
193 | }
|
193 | }
|
194 | 194 | ||
195 | /**
|
195 | /**
|
196 | * Получение названия программы, ее версии и описания
|
196 | * Получение названия программы, ее версии и описания
|
197 | *
|
197 | *
|
198 | * @author Alexander Wolf
|
198 | * @author Alexander Wolf
|
199 | * @category Core
|
199 | * @category Core
|
200 | *
|
200 | *
|
201 | * @param string $attr
|
201 | * @param string $attr
|
202 | * @return string
|
202 | * @return string
|
203 | */
|
203 | */
|
204 | public function getEngineAttr($attr = 'codename') { |
204 | public function getEngineAttr($attr = 'codename') { |
205 | $cname = $this->getOption($attr); |
205 | $cname = $this->getOption($attr); |
206 | return $this->secure->checkStr($cname["OptValue"],1); |
206 | return $this->secure->checkStr($cname["OptValue"],1); |
207 | }
|
207 | }
|
208 | 208 | ||
209 | /**
|
209 | /**
|
210 | * Получение и отображение списка версий дистрибутива
|
210 | * Получение и отображение списка версий дистрибутива
|
211 | *
|
211 | *
|
212 | * @author Alexander Wolf
|
212 | * @author Alexander Wolf
|
213 | * @category Core
|
213 | * @category Core
|
214 | *
|
214 | *
|
215 | * @param string $name
|
215 | * @param string $name
|
216 | * @param integer $distID
|
216 | * @param integer $distID
|
217 | * @param string $format
|
217 | * @param string $format
|
218 | * @return string
|
218 | * @return string
|
219 | */
|
219 | */
|
220 | public function showDistVersionsList($name, $distID, $format = 'html') { |
220 | public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') { |
221 | $distname = $this->getDistName($distID); |
221 | $distname = $this->getDistName($distID); |
- | 222 | if ($distID == 0) { |
|
- | 223 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ORDER BY d.dist_id,v.version ASC"; |
|
- | 224 | } else { |
|
222 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
225 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
- | 226 | }
|
|
223 | $rq =& $this->db->query($query); |
227 | $rq =& $this->db->query($query); |
224 | switch ($format) { |
228 | switch ($format) { |
225 | case 'html': |
229 | case 'html': |
226 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
230 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
227 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
231 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
228 | while ($rq->fetchInto($element)) { |
232 | while ($rq->fetchInto($element)) { |
229 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
233 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
230 | }
|
234 | }
|
231 | $show .= "</select></fieldset>"; |
235 | $show .= "</select></fieldset>"; |
232 | break; |
236 | break; |
233 | case 'json': |
237 | case 'json': |
234 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
238 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
235 | while ($rq->fetchInto($element)) { |
239 | while ($rq->fetchInto($element)) { |
236 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
240 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
237 | }
|
241 | }
|
238 | $show .= ']'; |
242 | $show .= ']'; |
239 | break; |
243 | break; |
- | 244 | case 'list': |
|
- | 245 | $show = "<ul>\n"; |
|
- | 246 | while ($rq->fetchInto($element)) { |
|
- | 247 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." “<em>".$this->secure->checkStr($element["vname"],1)."</em>”</li>\n"; |
|
- | 248 | }
|
|
- | 249 | $show .= "</ul>"; |
|
- | 250 | break; |
|
240 | }
|
251 | }
|
241 | return $show; |
252 | return $show; |
242 | }
|
253 | }
|
243 | 254 | ||
244 | /**
|
255 | /**
|
245 | * Получение и отображение списка секций основного (официального) репозитория
|
256 | * Получение и отображение списка секций основного (официального) репозитория
|
246 | *
|
257 | *
|
247 | * @author Alexander Wolf
|
258 | * @author Alexander Wolf
|
248 | * @category Core
|
259 | * @category Core
|
249 | *
|
260 | *
|
250 | * @param integer $version
|
261 | * @param integer $version
|
251 | * @param string $format
|
262 | * @param string $format
|
252 | * @return string
|
263 | * @return string
|
253 | */
|
264 | */
|
254 | public function showBranchesList($version, $format = 'html') { |
265 | public function showBranchesList($version, $format = 'html') { |
255 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
266 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
256 | $rq =& $this->db->query($query); |
267 | $rq =& $this->db->query($query); |
257 | $rq->fetchInto($types); |
268 | $rq->fetchInto($types); |
258 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
269 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
259 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
270 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
260 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
271 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
261 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
272 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
262 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
273 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
263 | $rq =& $this->db->query($query); |
274 | $rq =& $this->db->query($query); |
264 | switch ($format) { |
275 | switch ($format) { |
265 | case 'html': |
276 | case 'html': |
266 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
277 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
267 | while ($rq->fetchInto($element)) { |
278 | while ($rq->fetchInto($element)) { |
268 | $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." — ".$this->secure->checkStr($element["sectinfo"],1)."</div>\n"; |
279 | $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." — ".$this->secure->checkStr($element["sectinfo"],1)."</div>\n"; |
269 | }
|
280 | }
|
270 | $show .= "</fieldset>\n"; |
281 | $show .= "</fieldset>\n"; |
271 | break; |
282 | break; |
272 | case 'json': |
283 | case 'json': |
273 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
284 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
274 | break; |
285 | break; |
275 | }
|
286 | }
|
276 | 287 | ||
277 | return $show; |
288 | return $show; |
278 | }
|
289 | }
|
279 | 290 | ||
280 | /**
|
291 | /**
|
281 | * Получение и отображение списка репозиториев
|
292 | * Получение и отображение списка репозиториев
|
282 | *
|
293 | *
|
283 | * @author Alexander Wolf
|
294 | * @author Alexander Wolf
|
284 | * @category Core
|
295 | * @category Core
|
285 | *
|
296 | *
|
286 | * @param integer $version
|
297 | * @param integer $version
|
287 | * @param integer $reptype
|
298 | * @param integer $reptype
|
288 | * @param string $format
|
299 | * @param string $format
|
289 | * @return string
|
300 | * @return string
|
290 | */
|
301 | */
|
291 | public function showRepList($version, $reptype, $format = 'html') { |
302 | public function showRepList($version, $reptype, $format = 'html') { |
292 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
303 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
293 | $rq =& $this->db->query($query); |
304 | $rq =& $this->db->query($query); |
294 | $rq->fetchInto($types); |
305 | $rq->fetchInto($types); |
295 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
306 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
296 | $rq =& $this->db->query($query); |
307 | $rq =& $this->db->query($query); |
297 | switch ($format) { |
308 | switch ($format) { |
298 | case 'html': |
309 | case 'html': |
299 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
310 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
300 | while ($rq->fetchInto($types)) { |
311 | while ($rq->fetchInto($types)) { |
301 | $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." — ".$this->secure->checkStr($element["repinfo"],1)."</div>\n"; |
312 | $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." — ".$this->secure->checkStr($element["repinfo"],1)."</div>\n"; |
302 | }
|
313 | }
|
303 | $show .= "</fieldset>\n"; |
314 | $show .= "</fieldset>\n"; |
304 | break; |
315 | break; |
305 | case 'json': |
316 | case 'json': |
306 | //TODO Доделать JSON-вывод списка репозиториев
|
317 | //TODO Доделать JSON-вывод списка репозиториев
|
307 | break; |
318 | break; |
308 | }
|
319 | }
|
309 | 320 | ||
310 | return $show; |
321 | return $show; |
311 | }
|
322 | }
|
312 | 323 | ||
313 | /**
|
324 | /**
|
314 | * Добавление поддержки нового apt-дистрибутива
|
325 | * Добавление поддержки нового apt-дистрибутива
|
315 | *
|
326 | *
|
316 | * @author Alexander Wolf
|
327 | * @author Alexander Wolf
|
317 | * @category Core
|
328 | * @category Core
|
318 | *
|
329 | *
|
319 | * @param string $distname
|
330 | * @param string $distname
|
320 | * @param integer $disttype
|
331 | * @param integer $disttype
|
321 | * @param string $distua
|
332 | * @param string $distua
|
322 | * @param byte $distlogo
|
333 | * @param byte $distlogo
|
323 | * @return array
|
334 | * @return array
|
324 | */
|
335 | */
|
325 | public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) { |
336 | public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) { |
326 | $result = array(); |
337 | $result = array(); |
327 | $sDName = $this->secure->checkStr($distname); |
338 | $sDName = $this->secure->checkStr($distname); |
328 | $sDType = $this->secure->checkInt($disttype); |
339 | $sDType = $this->secure->checkInt($disttype); |
329 | $sDUAgt = $this->secure->checkStr($distua); |
340 | $sDUAgt = $this->secure->checkStr($distua); |
330 | $sDLogo = $this->secure->checkInt($distname); |
341 | $sDLogo = $this->secure->checkInt($distname); |
331 | 342 | ||
332 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
343 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
333 | $rq =& $this->db->query($query); |
344 | $rq =& $this->db->query($query); |
334 | if (PEAR::isError($this->db)) { |
345 | if (PEAR::isError($this->db)) { |
335 | $result["ERR"] = 1; |
346 | $result["ERR"] = 1; |
336 | $result["ERRINFO"] = $this->db->getMessage(); |
347 | $result["ERRINFO"] = $this->db->getMessage(); |
337 | } else { |
348 | } else { |
338 | $rq->fetchInto($element); |
349 | $rq->fetchInto($element); |
339 | $result["ERR"] = 0; |
350 | $result["ERR"] = 0; |
340 | }
|
351 | }
|
341 | 352 | ||
342 | return $result; |
353 | return $result; |
343 | }
|
354 | }
|
344 | 355 | ||
345 | /**
|
356 | /**
|
346 | * Добавление поддержки новой версии apt-дистрибутива
|
357 | * Добавление поддержки новой версии apt-дистрибутива
|
347 | *
|
358 | *
|
348 | * @author Alexander Wolf
|
359 | * @author Alexander Wolf
|
349 | * @category Core
|
360 | * @category Core
|
350 | *
|
361 | *
|
351 | * @param integer $distID
|
362 | * @param integer $distID
|
352 | * @param integer $version
|
363 | * @param integer $version
|
353 | * @param string $vname
|
364 | * @param string $vname
|
354 | * @param integer $vcodename
|
365 | * @param integer $vcodename
|
355 | * @return array
|
366 | * @return array
|
356 | */
|
367 | */
|
357 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
368 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
358 | $result = array(); |
369 | $result = array(); |
359 | $sDistID = $this->secure->checkInt($distID); |
370 | $sDistID = $this->secure->checkInt($distID); |
360 | $sDVersion = $this->secure->checkStr($version); |
371 | $sDVersion = $this->secure->checkStr($version); |
361 | $sDVName = $this->secure->checkStr($vname); |
372 | $sDVName = $this->secure->checkStr($vname); |
362 | $sDVCName = $this->secure->checkInt($vcodename); |
373 | $sDVCName = $this->secure->checkInt($vcodename); |
363 | 374 | ||
364 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
375 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
365 | $rq =& $this->db->query($query); |
376 | $rq =& $this->db->query($query); |
366 | if (PEAR::isError($this->db)) { |
377 | if (PEAR::isError($this->db)) { |
367 | $result["ERR"] = 1; |
378 | $result["ERR"] = 1; |
368 | $result["ERRINFO"] = $this->db->getMessage(); |
379 | $result["ERRINFO"] = $this->db->getMessage(); |
369 | } else { |
380 | } else { |
370 | $rq->fetchInto($element); |
381 | $rq->fetchInto($element); |
371 | $result["ERR"] = 0; |
382 | $result["ERR"] = 0; |
372 | }
|
383 | }
|
373 | 384 | ||
374 | return $result; |
385 | return $result; |
375 | }
|
386 | }
|
376 | 387 | ||
377 | /**
|
388 | /**
|
378 | * Отображение типа дистрибутива
|
389 | * Отображение типа дистрибутива
|
379 | *
|
390 | *
|
380 | * @author Alexander Wolf
|
391 | * @author Alexander Wolf
|
381 | * @category Core
|
392 | * @category Core
|
382 | *
|
393 | *
|
383 | * @param string $name
|
394 | * @param string $name
|
384 | * @param byte $type
|
395 | * @param byte $type
|
385 | * @return string
|
396 | * @return string
|
386 | */
|
397 | */
|
387 | public function showDistTypeForm($name = "dtype",$type = 0) { |
398 | public function showDistTypeForm($name = "dtype",$type = 0) { |
388 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
399 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
389 | $rq =& $this->db->query($query); |
400 | $rq =& $this->db->query($query); |
390 | $show = "<select name='".$name."' id='".$name."'>\n"; |
401 | $show = "<select name='".$name."' id='".$name."'>\n"; |
391 | while ($rq->fetchInto($element)) { |
402 | while ($rq->fetchInto($element)) { |
392 | if ($element["type_id"] == $type) { |
403 | if ($element["type_id"] == $type) { |
393 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
404 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
394 | } else { |
405 | } else { |
395 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
406 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
396 | }
|
407 | }
|
397 | }
|
408 | }
|
398 | $show .= "</select>"; |
409 | $show .= "</select>"; |
399 | 410 | ||
400 | return $show; |
411 | return $show; |
401 | }
|
412 | }
|
402 | 413 | ||
403 | /**
|
414 | /**
|
404 | * Отображение формы создания и редактирования apt-дистрибутива
|
415 | * Отображение формы создания и редактирования apt-дистрибутива
|
405 | *
|
416 | *
|
406 | * @author Alexander Wolf
|
417 | * @author Alexander Wolf
|
407 | * @category Core
|
418 | * @category Core
|
408 | *
|
419 | *
|
409 | * @param integer $distID
|
420 | * @param integer $distID
|
410 | * @return string
|
421 | * @return string
|
411 | */
|
422 | */
|
412 | public function showDistributionForm($distID = 0) { |
423 | public function showDistributionForm($distID = 0) { |
413 | $sDistID = $this->secure->checkInt($distID); |
424 | $sDistID = $this->secure->checkInt($distID); |
414 | if ($sDistID != 0) { |
425 | if ($sDistID != 0) { |
415 | // Режим редактирования
|
426 | // Режим редактирования
|
416 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
427 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
417 | $rq =& $this->db->query($query); |
428 | $rq =& $this->db->query($query); |
418 | $rq->fetchInto($element); |
429 | $rq->fetchInto($element); |
419 | }
|
430 | }
|
420 | 431 | ||
421 | if ($element["distlogo"] == 1) { |
432 | if ($element["distlogo"] == 1) { |
422 | $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>"; |
433 | $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>"; |
423 | } else { |
434 | } else { |
424 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
435 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
425 | }
|
436 | }
|
426 | 437 | ||
427 | $show = "<fieldset><legend>Дистрибутив</legend>\n"; |
438 | $show = "<fieldset><legend>Дистрибутив</legend>\n"; |
428 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
439 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
429 | $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n"; |
440 | $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n"; |
430 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n"; |
441 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n"; |
431 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
442 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
432 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
443 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
433 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
444 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
434 | 445 | ||
435 | return $show; |
446 | return $show; |
436 | }
|
447 | }
|
437 | 448 | ||
438 | // sourses.list
|
449 | // sourses.list
|
439 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
450 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
440 | //TODO Написать генератор sources.list
|
451 | //TODO Написать генератор sources.list
|
441 | }
|
452 | }
|
442 | 453 | ||
443 | /**
|
454 | /**
|
444 | * Проверка пароля (из формы авторизации)
|
455 | * Проверка пароля (из формы авторизации)
|
445 | *
|
456 | *
|
446 | * @author Alexander Wolf
|
457 | * @author Alexander Wolf
|
447 | * @category Core
|
458 | * @category Core
|
448 | *
|
459 | *
|
449 | * @param string $word
|
460 | * @param string $word
|
450 | * @return array
|
461 | * @return array
|
451 | */
|
462 | */
|
452 | public function checkSign($word) { |
463 | public function checkSign($word) { |
453 | $result = array(); |
464 | $result = array(); |
454 | 465 | ||
455 | $sHash = $this->secure->encryptStr($word); |
466 | $sHash = $this->secure->encryptStr($word); |
456 | $pwd = $this->getOption("passwd"); |
467 | $pwd = $this->getOption("passwd"); |
457 | if ($sHash == $pwd["OptValue"]) { |
468 | if ($sHash == $pwd["OptValue"]) { |
458 | $result["ERR"] = 0; |
469 | $result["ERR"] = 0; |
459 | $result["Location"] = "manager.php"; |
470 | $result["Location"] = "manager.php"; |
460 | setcookie($this->cookie, $sHash); |
471 | setcookie($this->cookie, $sHash); |
461 | } else { |
472 | } else { |
462 | $result["ERR"] = 1; |
473 | $result["ERR"] = 1; |
463 | $result["ERRINFO"] = "Password not valid"; |
474 | $result["ERRINFO"] = "Password not valid"; |
464 | $result["Location"] = "manager.php?error=1"; |
475 | $result["Location"] = "manager.php?error=1"; |
465 | }
|
476 | }
|
466 | 477 | ||
467 | return $result; |
478 | return $result; |
468 | }
|
479 | }
|
469 | 480 | ||
470 | /**
|
481 | /**
|
471 | * Проверка пароля (из cookies)
|
482 | * Проверка пароля (из cookies)
|
472 | *
|
483 | *
|
473 | * @author Alexander Wolf
|
484 | * @author Alexander Wolf
|
474 | * @category Core
|
485 | * @category Core
|
475 | *
|
486 | *
|
476 | * @param string $hash
|
487 | * @param string $hash
|
477 | * @return array
|
488 | * @return array
|
478 | */
|
489 | */
|
479 | public function checkCookieSign($hash) { |
490 | public function checkCookieSign($hash) { |
480 | $result = array(); |
491 | $result = array(); |
481 | 492 | ||
482 | $pwd = $this->getOption("passwd"); |
493 | $pwd = $this->getOption("passwd"); |
483 | if ($hash == $pwd["OptValue"]) { |
494 | if ($hash == $pwd["OptValue"]) { |
484 | $result["ERR"] = 0; |
495 | $result["ERR"] = 0; |
485 | } else { |
496 | } else { |
486 | $result["ERR"] = 1; |
497 | $result["ERR"] = 1; |
487 | $result["ERRINFO"] = "Hash not valid"; |
498 | $result["ERRINFO"] = "Hash not valid"; |
488 | $result["Location"] = "manager.php"; |
499 | $result["Location"] = "manager.php"; |
489 | }
|
500 | }
|
490 | 501 | ||
491 | return $result; |
502 | return $result; |
492 | }
|
503 | }
|
493 | 504 | ||
494 | /**
|
505 | /**
|
495 | * Форма ввода пароля
|
506 | * Форма ввода пароля
|
496 | *
|
507 | *
|
497 | * @author Alexander Wolf
|
508 | * @author Alexander Wolf
|
498 | * @category Core
|
509 | * @category Core
|
499 | *
|
510 | *
|
500 | * @return string
|
511 | * @return string
|
501 | */
|
512 | */
|
502 | public function showSigninForm() { |
513 | public function showSigninForm() { |
503 | $show = "<div id='regform'>"; |
514 | $show = "<div id='regform'>"; |
504 | $show .= "<form action='process.php' method='post'>\n"; |
515 | $show .= "<form action='process.php' method='post'>\n"; |
505 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
516 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
506 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
517 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
507 | $show .= "<input type='password' name='word' value=''>\n"; |
518 | $show .= "<input type='password' name='word' value=''>\n"; |
508 | $show .= "<input type='submit' value=' Войти '>\n"; |
519 | $show .= "<input type='submit' value=' Войти '>\n"; |
509 | $show .= "</fieldset>\n</form></div>\n"; |
520 | $show .= "</fieldset>\n</form></div>\n"; |
510 | 521 | ||
511 | return $show; |
522 | return $show; |
512 | }
|
523 | }
|
513 | 524 | ||
514 | /**
|
525 | /**
|
515 | * Обновление пароля
|
526 | * Обновление пароля
|
516 | *
|
527 | *
|
517 | * @author Alexander Wolf
|
528 | * @author Alexander Wolf
|
518 | * @category Core
|
529 | * @category Core
|
519 | *
|
530 | *
|
520 | * @param string $word1
|
531 | * @param string $word1
|
521 | * @param string $word2
|
532 | * @param string $word2
|
522 | * @return array
|
533 | * @return array
|
523 | */
|
534 | */
|
524 | public function updatePassword($word1, $word2) { |
535 | public function updatePassword($word1, $word2) { |
525 | $result = array(); |
536 | $result = array(); |
526 | 537 | ||
527 | if ($word1 == $word2) { |
538 | if ($word1 == $word2) { |
528 | $sWord = $this->secure->encryptStr($word1); |
539 | $sWord = $this->secure->encryptStr($word1); |
529 | $r = $this->setOption("passwd", $sWord); |
540 | $r = $this->setOption("passwd", $sWord); |
530 | $result = $r; |
541 | $result = $r; |
531 | } else { |
542 | } else { |
532 | $result["ERR"] = 1; |
543 | $result["ERR"] = 1; |
533 | $result["ERRINFO"] = "Passwords is mismatch"; |
544 | $result["ERRINFO"] = "Passwords is mismatch"; |
534 | }
|
545 | }
|
535 | 546 | ||
536 | return $result; |
547 | return $result; |
537 | }
|
548 | }
|
538 | 549 | ||
539 | /**
|
550 | /**
|
540 | * Показ формы редактирования версии дистрибутива или его списка
|
- | |
541 | *
|
- | |
542 | * @author Alexander Wolf
|
- | |
543 | * @category Core
|
- | |
544 | *
|
- | |
545 | * @param string $name
|
- | |
546 | * @param string $actor
|
- | |
547 | * @param integer $versionID
|
- | |
548 | * @return string
|
- | |
549 | */
|
- | |
550 | public function showDistVersionsEditor($name, $actor, $versionID = 0) { |
- | |
551 | if ($versionID == 0) { |
- | |
552 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ORDER BY d.dist_id,v.version ASC"; |
- | |
553 | $rq =& $this->db->query($query); |
- | |
554 | $show = "<ul>\n"; |
- | |
555 | while ($rq->fetchInto($element)) { |
- | |
556 | $show .= "<li>[<a href='".$actor."?mode=versions&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."'>править</a>][<a href='".$actor."?mode=versions&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." “<em>".$this->secure->checkStr($element["vname"],1)."</em>”</li>\n"; |
551 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
557 | }
|
- | |
558 | $show .= "</ul>"; |
- | |
559 | } else { |
- | |
560 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$versionID."'"; |
- | |
561 | $rq =& $this->db->query($query); |
- | |
562 | $rq->fetchInto($element); |
- | |
563 | $show = "<form action='".$actor."' method='post'>\n"; |
- | |
564 | $show .= "<fieldset><legend>Редактирование описания версии дистрибутива</legend>\n"; |
- | |
565 | $show .= "<input type='hidden' name='mode' value='".$name."-edit'>\n"; |
- | |
566 | $show .= "<input type='hidden' name='".$name."ID' value='".$versionID."'>\n"; |
- | |
567 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
- | |
568 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
- | |
569 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
- | |
570 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
- | |
571 | $show .= "<div class='inputbox'><input type='submit' value=' Править '></div></fieldset></form>\n"; |
- | |
572 | }
|
- | |
573 | return $show; |
- | |
574 | }
|
- | |
575 | - | ||
576 | /**
|
- | |
577 | * Вывод формы добавления и удаления версии дистрибутива
|
- | |
578 | *
|
552 | *
|
579 | * @author Alexander Wolf
|
553 | * @author Alexander Wolf
|
580 | * @category Core
|
554 | * @category Core
|
581 | *
|
555 | *
|
582 | * @param string $name
|
556 | * @param string $name
|
583 | * @param string $actor
|
557 | * @param string $actor
|
584 | * @param integer $versionID
|
558 | * @param integer $versionID
|
585 | * @return string
|
559 | * @return string
|
586 | */
|
560 | */
|
587 | public function showDistVersionsForm($name, $actor, $versionID = 0) { |
561 | public function showDistVersionsForm($versionID = 0) { |
588 | $show = "<form action='".$actor."' method='post'>"; |
562 | $sVersionID = $this->secure->checkInt($versionID); |
589 | if ($versionID == 0) { |
563 | if ($sVersionID != 0) { |
590 | $show .= "<fieldset><legend>Добавить описание новой версии дистрибутива</legend>\n"; |
- | |
591 | $show .= "<input type='hidden' name='mode' value='".$name."-add'>\n"; |
564 | // Режим редактирования
|
592 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml") ."</div>\n"; |
- | |
593 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value=''></div>\n"; |
- | |
594 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value=''></div>\n"; |
- | |
595 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value=''></div>\n"; |
- | |
596 | $show .= "<div class='inputbox'><input type='submit' value=' Добавить '></div></fieldset>\n"; |
- | |
597 | } else { |
- | |
598 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$versionID."'"; |
565 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$versionID."'"; |
599 | $rq =& $this->db->query($query); |
566 | $rq =& $this->db->query($query); |
600 | $rq->fetchInto($element); |
567 | $rq->fetchInto($element); |
- | 568 | }
|
|
- | 569 | ||
601 | $show .= "<fieldset><legend>Удалить описание существующей версии дистрибутива</legend>\n"; |
570 | $show = "<fieldset><legend>Версия дистрибутива</legend>\n"; |
602 | $show .= "<input type='hidden' name='mode' value='".$name."-delete'>\n"; |
- | |
603 | $show .= "<input type='hidden' name='".$name."ID' value='".$versionID."'>\n"; |
- | |
604 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
571 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
605 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."' readonly='readonly'></div>\n"; |
572 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
606 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."' readonly='readonly'></div>\n"; |
573 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
607 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."' readonly='readonly'></div>\n"; |
574 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
608 | $show .= "<div class='inputbox'><input type='submit' value=' Удалить '></div></fieldset>\n"; |
575 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
609 | }
|
- | |
610 | $show .= "</form>"; |
- | |
611 | 576 | ||
612 | return $show; |
577 | return $show; |
613 | }
|
578 | }
|
614 | 579 | ||
615 | }
|
580 | }
|
616 | 581 | ||
617 | ?>
|
582 | ?>
|