Редакция 687 | Редакция 690 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | |||
3 | /** |
||
4 | * |
||
554 | alex-w | 5 | * Codename: ant-ng - generator of sources.list for apt-distributives |
304 | alex-w | 6 | * http://alex-w.org.ru/p/antng/ |
7 | * |
||
8 | * Copyright (c) 2009 Alexander Wolf |
||
9 | * Dual licensed under the MIT and GNU LGPL licenses. |
||
10 | * http://alex-w.org.ru/p/antng/license |
||
11 | * |
||
12 | */ |
||
13 | |||
14 | class Core { |
||
308 | alex-w | 15 | protected $db = NULL; |
16 | protected $prefix = NULL; |
||
313 | alex-w | 17 | protected $secure = NULL; |
359 | alex-w | 18 | protected $cookie = NULL; |
304 | alex-w | 19 | |
463 | alex-w | 20 | /** |
21 | * Конструктор класса Core - ядро генератора |
||
22 | * |
||
23 | * @author Alexander Wolf |
||
24 | * @category Core |
||
25 | * |
||
26 | * @param string $database |
||
27 | * @param string $prefix |
||
28 | * @param object $secure |
||
29 | * @param string $cookie |
||
30 | */ |
||
368 | alex-w | 31 | public function __construct($database, $prefix, $secure, $cookie) { |
308 | alex-w | 32 | $this->db = $database; |
33 | $this->prefix = $prefix; |
||
359 | alex-w | 34 | $this->secure = $secure; |
35 | $this->cookie = $cookie; |
||
307 | alex-w | 36 | } |
37 | |||
463 | alex-w | 38 | /** |
39 | * Получение данных о настройке |
||
40 | * |
||
41 | * @author Alexander Wolf |
||
42 | * @category Core |
||
43 | * |
||
44 | * @param string $attr |
||
45 | * @return array |
||
46 | */ |
||
368 | alex-w | 47 | public function getOption($attr) { |
308 | alex-w | 48 | $result = array(); |
315 | alex-w | 49 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
314 | alex-w | 50 | $rq =& $this->db->query($query); |
308 | alex-w | 51 | if ($rq->numRows()!=0) { |
52 | $rq->fetchInto($element); |
||
53 | $result["ERR"] = 0; |
||
54 | $result["OptValue"] = $element["optvalue"]; |
||
55 | } else { |
||
56 | $result["ERR"] = 1; |
||
57 | $result["ERRINFO"] = "Empty result"; |
||
58 | } |
||
59 | return $result; |
||
60 | } |
||
61 | |||
463 | alex-w | 62 | /** |
63 | * Установка данных о настройке |
||
64 | * |
||
65 | * @author Alexander Wolf |
||
66 | * @category Core |
||
67 | * |
||
68 | * @param string $attr |
||
69 | * @param string $value |
||
70 | * @return array |
||
71 | */ |
||
368 | alex-w | 72 | public function setOption($attr, $value) { |
359 | alex-w | 73 | $result = array(); |
74 | |||
75 | if ($attr != "passwd") { |
||
76 | $sValue = $this->secure->checkStr($value); |
||
77 | } else { |
||
78 | $sValue = $value; |
||
79 | } |
||
80 | |||
81 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
||
82 | $rq =& $this->db->query($query); |
||
83 | if (PEAR::isError($this->db)) { |
||
84 | $result["ERR"] = 1; |
||
85 | $result["ERRINFO"] = $this->db->getMessage(); |
||
86 | } else { |
||
87 | $result["ERR"] = 0; |
||
88 | } |
||
89 | |||
90 | return $result; |
||
91 | } |
||
92 | |||
463 | alex-w | 93 | /** |
94 | * Создание настройки |
||
95 | * |
||
96 | * @author Alexander Wolf |
||
97 | * @category Core |
||
98 | * |
||
99 | * @param string $attr |
||
100 | * @param string $value |
||
101 | * @return array |
||
102 | */ |
||
368 | alex-w | 103 | public function addOption($attr, $value) { |
359 | alex-w | 104 | $result = array(); |
105 | $sValue = $this->secure->checkStr($value); |
||
106 | |||
107 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
||
108 | $rq =& $this->db->query($query); |
||
109 | if (PEAR::isError($this->db)) { |
||
110 | $result["ERR"] = 1; |
||
111 | $result["ERRINFO"] = $this->db->getMessage(); |
||
112 | } else { |
||
113 | $result["ERR"] = 0; |
||
114 | } |
||
115 | |||
116 | return $result; |
||
117 | } |
||
463 | alex-w | 118 | |
119 | /** |
||
467 | alex-w | 120 | * Получение и отображение списка дистрибутвов |
463 | alex-w | 121 | * |
122 | * @author Alexander Wolf |
||
123 | * @category Core |
||
124 | * @deprecated may be deprecated XXX |
||
125 | * |
||
126 | * @param string $name |
||
127 | * @param string $heads |
||
128 | * @param string $info |
||
129 | * @param string $format |
||
130 | * @return string |
||
131 | */ |
||
393 | alex-w | 132 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
315 | alex-w | 133 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
317 | alex-w | 134 | $rq =& $this->db->query($query); |
315 | alex-w | 135 | switch ($format) { |
136 | case 'html': |
||
394 | alex-w | 137 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
390 | alex-w | 138 | $show .= "<option value=''>".$info."</option>\n"; |
315 | alex-w | 139 | while ($rq->fetchInto($element)) { |
140 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
||
141 | } |
||
317 | alex-w | 142 | $show .= "</select></fieldset>"; |
315 | alex-w | 143 | break; |
144 | case 'json': |
||
317 | alex-w | 145 | $show = '[{value:"",text:"'.$info.'"}'; |
315 | alex-w | 146 | while ($rq->fetchInto($element)) { |
147 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
||
148 | } |
||
149 | $show .= ']'; |
||
150 | break; |
||
504 | alex-w | 151 | case 'innerhtml': |
152 | $show = "<select id='".$name."' name='".$name."'>\n"; |
||
153 | while ($rq->fetchInto($element)) { |
||
154 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
||
155 | } |
||
156 | $show .= "</select>"; |
||
157 | break; |
||
506 | alex-w | 158 | case 'list': |
159 | $show = "<ul>"; |
||
160 | while ($rq->fetchInto($element)) { |
||
546 | alex-w | 161 | $show .= "<li>[<a href='".$heads."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n"; |
506 | alex-w | 162 | } |
163 | $show .= "</ul>"; |
||
164 | break; |
||
315 | alex-w | 165 | } |
166 | return $show; |
||
167 | } |
||
168 | |||
463 | alex-w | 169 | /** |
170 | * Получение названия дистрибутива |
||
171 | * |
||
172 | * @author Alexander Wolf |
||
173 | * @category Core |
||
174 | * |
||
175 | * @param integer $distID |
||
176 | * @return array |
||
177 | */ |
||
368 | alex-w | 178 | public function getDistName($distID) { |
315 | alex-w | 179 | $result = array(); |
180 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
||
181 | $rq =& $this->db->query($query); |
||
182 | if (PEAR::isError($this->db)) { |
||
183 | $result["ERR"] = 1; |
||
184 | $result["ERRINFO"] = $this->db->getMessage(); |
||
185 | } else { |
||
186 | $rq->fetchInto($element); |
||
187 | $result["ERR"] = 0; |
||
188 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
||
189 | } |
||
190 | |||
191 | return $result; |
||
192 | } |
||
193 | |||
463 | alex-w | 194 | /** |
195 | * Получение названия программы, ее версии и описания |
||
196 | * |
||
197 | * @author Alexander Wolf |
||
198 | * @category Core |
||
199 | * |
||
200 | * @param string $attr |
||
201 | * @return string |
||
202 | */ |
||
383 | alex-w | 203 | public function getEngineAttr($attr = 'codename') { |
204 | $cname = $this->getOption($attr); |
||
382 | alex-w | 205 | return $this->secure->checkStr($cname["OptValue"],1); |
381 | alex-w | 206 | } |
207 | |||
463 | alex-w | 208 | /** |
209 | * Получение и отображение списка версий дистрибутива |
||
210 | * |
||
211 | * @author Alexander Wolf |
||
212 | * @category Core |
||
213 | * |
||
214 | * @param string $name |
||
215 | * @param integer $distID |
||
216 | * @param string $format |
||
217 | * @return string |
||
218 | */ |
||
509 | alex-w | 219 | public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') { |
316 | alex-w | 220 | $distname = $this->getDistName($distID); |
509 | alex-w | 221 | if ($distID == 0) { |
222 | $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"; |
||
223 | } else { |
||
224 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
||
225 | } |
||
317 | alex-w | 226 | $rq =& $this->db->query($query); |
315 | alex-w | 227 | switch ($format) { |
228 | case 'html': |
||
394 | alex-w | 229 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
230 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
||
315 | alex-w | 231 | while ($rq->fetchInto($element)) { |
316 | alex-w | 232 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
315 | alex-w | 233 | } |
317 | alex-w | 234 | $show .= "</select></fieldset>"; |
315 | alex-w | 235 | break; |
236 | case 'json': |
||
317 | alex-w | 237 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
315 | alex-w | 238 | while ($rq->fetchInto($element)) { |
316 | alex-w | 239 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
315 | alex-w | 240 | } |
241 | $show .= ']'; |
||
242 | break; |
||
509 | alex-w | 243 | case 'list': |
244 | $show = "<ul>\n"; |
||
245 | while ($rq->fetchInto($element)) { |
||
545 | alex-w | 246 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." “<em>".$this->secure->checkStr($element["vname"],1)."</em>”</li>\n"; |
509 | alex-w | 247 | } |
248 | $show .= "</ul>"; |
||
249 | break; |
||
315 | alex-w | 250 | } |
251 | return $show; |
||
252 | } |
||
253 | |||
463 | alex-w | 254 | /** |
255 | * Получение и отображение списка секций основного (официального) репозитория |
||
256 | * |
||
257 | * @author Alexander Wolf |
||
258 | * @category Core |
||
259 | * |
||
260 | * @param integer $version |
||
261 | * @param string $format |
||
262 | * @return string |
||
263 | */ |
||
368 | alex-w | 264 | public function showBranchesList($version, $format = 'html') { |
317 | alex-w | 265 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
266 | $rq =& $this->db->query($query); |
||
267 | $rq->fetchInto($types); |
||
268 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
||
269 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
||
270 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
||
271 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
627 | alex-w | 272 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."' "; |
273 | $query .= "ORDER BY s.sect_id ASC"; |
||
317 | alex-w | 274 | $rq =& $this->db->query($query); |
275 | switch ($format) { |
||
276 | case 'html': |
||
277 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
||
278 | while ($rq->fetchInto($element)) { |
||
493 | alex-w | 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"; |
317 | alex-w | 280 | } |
281 | $show .= "</fieldset>\n"; |
||
282 | break; |
||
283 | case 'json': |
||
284 | //TODO Доделать JSON-вывод списка секций основного репозитория |
||
285 | break; |
||
286 | } |
||
318 | alex-w | 287 | |
288 | return $show; |
||
317 | alex-w | 289 | } |
290 | |||
463 | alex-w | 291 | /** |
292 | * Получение и отображение списка репозиториев |
||
293 | * |
||
294 | * @author Alexander Wolf |
||
295 | * @category Core |
||
296 | * |
||
297 | * @param integer $version |
||
298 | * @param integer $reptype |
||
299 | * @param string $format |
||
300 | * @return string |
||
301 | */ |
||
368 | alex-w | 302 | public function showRepList($version, $reptype, $format = 'html') { |
606 | alex-w | 303 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
304 | $rq =& $this->db->query($query); |
||
305 | $rq->fetchInto($types); |
||
317 | alex-w | 306 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
307 | $rq =& $this->db->query($query); |
||
308 | switch ($format) { |
||
309 | case 'html': |
||
672 | alex-w | 310 | if ($rq->numRows()>0) { |
311 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
||
312 | while ($rq->fetchInto($element)) { |
||
313 | $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"; |
||
314 | } |
||
315 | $show .= "</fieldset>\n"; |
||
317 | alex-w | 316 | } |
317 | break; |
||
318 | case 'json': |
||
319 | //TODO Доделать JSON-вывод списка репозиториев |
||
320 | break; |
||
321 | } |
||
318 | alex-w | 322 | |
323 | return $show; |
||
317 | alex-w | 324 | } |
325 | |||
463 | alex-w | 326 | /** |
327 | * Добавление поддержки нового apt-дистрибутива |
||
328 | * |
||
329 | * @author Alexander Wolf |
||
330 | * @category Core |
||
331 | * |
||
332 | * @param string $distname |
||
333 | * @param integer $disttype |
||
334 | * @param string $distua |
||
335 | * @param byte $distlogo |
||
336 | * @return array |
||
337 | */ |
||
514 | alex-w | 338 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
321 | alex-w | 339 | $result = array(); |
582 | alex-w | 340 | $sDName = $this->secure->checkStr($distname); |
321 | alex-w | 341 | $sDType = $this->secure->checkInt($disttype); |
582 | alex-w | 342 | $sDUAgt = $this->secure->checkStr($distua); |
514 | alex-w | 343 | $sDLogo = $this->secure->checkInt($distlogo); |
321 | alex-w | 344 | |
345 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
||
346 | $rq =& $this->db->query($query); |
||
347 | if (PEAR::isError($this->db)) { |
||
348 | $result["ERR"] = 1; |
||
349 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 350 | } else { |
321 | alex-w | 351 | $result["ERR"] = 0; |
352 | } |
||
353 | |||
354 | return $result; |
||
355 | } |
||
356 | |||
463 | alex-w | 357 | /** |
514 | alex-w | 358 | * Обновление информации о дистрибутиве |
359 | * |
||
360 | * @author Alexander Wolf |
||
361 | * @category Core |
||
362 | * |
||
363 | * @param integer $distID |
||
364 | * @param string $distname |
||
365 | * @param integer $disttype |
||
366 | * @param string $distua |
||
367 | * @param integer $distlogo |
||
368 | * @return array |
||
369 | */ |
||
538 | alex-w | 370 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
514 | alex-w | 371 | $result = array(); |
372 | $sDID = $this->secure->checkInt($distID); |
||
579 | alex-w | 373 | $sDName = $this->secure->checkStr($distname); |
514 | alex-w | 374 | $sDType = $this->secure->checkInt($disttype); |
579 | alex-w | 375 | $sDUAgt = $this->secure->checkStr($distua); |
514 | alex-w | 376 | $sDLogo = $this->secure->checkInt($distlogo); |
377 | |||
538 | alex-w | 378 | if ($sDLogo!=0) { |
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
||
380 | } else { |
||
381 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
||
382 | } |
||
514 | alex-w | 383 | $rq =& $this->db->query($query); |
384 | if (PEAR::isError($this->db)) { |
||
385 | $result["ERR"] = 1; |
||
386 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 387 | } else { |
514 | alex-w | 388 | $result["ERR"] = 0; |
389 | } |
||
390 | |||
391 | return $result; |
||
392 | } |
||
393 | |||
394 | /** |
||
395 | * Удаление информации о дистрибутиве |
||
396 | * |
||
397 | * @author Alexander Wolf |
||
398 | * @category Core |
||
399 | * |
||
400 | * @param integer $distID |
||
401 | * @return array |
||
402 | */ |
||
403 | public function dropDistribution($distID) { |
||
404 | $result = array(); |
||
405 | $sDID = $this->secure->checkInt($distID); |
||
406 | |||
407 | // Удаление дистрибутива |
||
408 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
||
409 | $rq =& $this->db->query($query); |
||
410 | if (PEAR::isError($this->db)) { |
||
411 | $result["ERR"] = 1; |
||
412 | $result["ERRINFO"] = $this->db->getMessage(); |
||
519 | alex-w | 413 | } else { |
514 | alex-w | 414 | $result["ERR"] = 0; |
415 | } |
||
416 | |||
417 | // Удаление версий дистрибутива |
||
418 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
||
419 | $rq =& $this->db->query($query); |
||
420 | if (PEAR::isError($this->db)) { |
||
421 | $result["ERR"] = 1; |
||
422 | $result["ERRINFO"] = $this->db->getMessage(); |
||
519 | alex-w | 423 | } else { |
514 | alex-w | 424 | $result["ERR"] = 0; |
425 | } |
||
426 | |||
427 | return $result; |
||
428 | } |
||
429 | |||
430 | /** |
||
463 | alex-w | 431 | * Добавление поддержки новой версии apt-дистрибутива |
432 | * |
||
433 | * @author Alexander Wolf |
||
434 | * @category Core |
||
435 | * |
||
436 | * @param integer $distID |
||
437 | * @param integer $version |
||
438 | * @param string $vname |
||
439 | * @param integer $vcodename |
||
440 | * @return array |
||
441 | */ |
||
368 | alex-w | 442 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
356 | alex-w | 443 | $result = array(); |
463 | alex-w | 444 | $sDistID = $this->secure->checkInt($distID); |
582 | alex-w | 445 | $sDVersion = $this->secure->checkStr($version); |
446 | $sDVName = $this->secure->checkStr($vname); |
||
447 | $sDVCName = $this->secure->checkStr($vcodename); |
||
356 | alex-w | 448 | |
449 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
||
450 | $rq =& $this->db->query($query); |
||
451 | if (PEAR::isError($this->db)) { |
||
452 | $result["ERR"] = 1; |
||
453 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 454 | } else { |
356 | alex-w | 455 | $result["ERR"] = 0; |
456 | } |
||
457 | |||
458 | return $result; |
||
459 | } |
||
358 | alex-w | 460 | |
463 | alex-w | 461 | /** |
514 | alex-w | 462 | * Редактирование информации о версии дистрибутива |
463 | * |
||
464 | * @author Alexander Wolf |
||
465 | * @category Core |
||
466 | * |
||
467 | * @param integer $versionID |
||
468 | * @param string $version |
||
469 | * @param string $vname |
||
470 | * @param string $vcodename |
||
471 | * @return array |
||
472 | */ |
||
473 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
||
474 | $result = array(); |
||
475 | $sVersID = $this->secure->checkInt($versionID); |
||
516 | alex-w | 476 | $sDVersion = $this->secure->checkStr($version,1); |
477 | $sDVName = $this->secure->checkStr($vname,1); |
||
478 | $sDVCName = $this->secure->checkStr($vcodename,1); |
||
514 | alex-w | 479 | |
480 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
||
481 | $rq =& $this->db->query($query); |
||
482 | if (PEAR::isError($this->db)) { |
||
483 | $result["ERR"] = 1; |
||
484 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 485 | } else { |
514 | alex-w | 486 | $result["ERR"] = 0; |
487 | } |
||
488 | |||
489 | return $result; |
||
490 | } |
||
491 | |||
492 | /** |
||
493 | * Удаление информации о версии дистрибутива |
||
494 | * |
||
495 | * @author Alexander Wolf |
||
496 | * @category Core |
||
497 | * |
||
498 | * @param integer $versionID |
||
499 | * @return array |
||
500 | */ |
||
501 | public function dropDistVersion($versionID) { |
||
502 | $result = array(); |
||
503 | $sVersID = $this->secure->checkInt($versionID); |
||
504 | |||
505 | // Удаление версии дистрибутива |
||
506 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
||
507 | $rq =& $this->db->query($query); |
||
508 | if (PEAR::isError($this->db)) { |
||
509 | $result["ERR"] = 1; |
||
510 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 511 | } else { |
514 | alex-w | 512 | $result["ERR"] = 0; |
513 | } |
||
514 | |||
515 | // Удаление репозиториев этой версии дистрибутива |
||
516 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
||
517 | $rq =& $this->db->query($query); |
||
518 | if (PEAR::isError($this->db)) { |
||
519 | $result["ERR"] = 1; |
||
520 | $result["ERRINFO"] = $this->db->getMessage(); |
||
517 | alex-w | 521 | } else { |
514 | alex-w | 522 | $result["ERR"] = 0; |
523 | } |
||
524 | |||
525 | return $result; |
||
526 | } |
||
527 | |||
528 | /** |
||
463 | alex-w | 529 | * Отображение типа дистрибутива |
530 | * |
||
531 | * @author Alexander Wolf |
||
532 | * @category Core |
||
533 | * |
||
534 | * @param string $name |
||
535 | * @param byte $type |
||
536 | * @return string |
||
537 | */ |
||
368 | alex-w | 538 | public function showDistTypeForm($name = "dtype",$type = 0) { |
329 | alex-w | 539 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
540 | $rq =& $this->db->query($query); |
||
541 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
542 | while ($rq->fetchInto($element)) { |
||
347 | alex-w | 543 | if ($element["type_id"] == $type) { |
544 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
||
329 | alex-w | 545 | } else { |
347 | alex-w | 546 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
329 | alex-w | 547 | } |
548 | } |
||
549 | $show .= "</select>"; |
||
550 | |||
551 | return $show; |
||
552 | } |
||
553 | |||
463 | alex-w | 554 | /** |
555 | * Отображение формы создания и редактирования apt-дистрибутива |
||
556 | * |
||
557 | * @author Alexander Wolf |
||
558 | * @category Core |
||
559 | * |
||
560 | * @param integer $distID |
||
561 | * @return string |
||
562 | */ |
||
511 | alex-w | 563 | public function showDistributionForm($distID = 0, $info = '') { |
329 | alex-w | 564 | $sDistID = $this->secure->checkInt($distID); |
511 | alex-w | 565 | $sInfo = $this->secure->checkStr($info, 1); |
566 | if ($sInfo == "") { |
||
567 | $sInfo = "Дистрибутив"; |
||
568 | } |
||
329 | alex-w | 569 | if ($sDistID != 0) { |
570 | // Режим редактирования |
||
571 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
||
572 | $rq =& $this->db->query($query); |
||
573 | $rq->fetchInto($element); |
||
574 | } |
||
575 | |||
576 | if ($element["distlogo"] == 1) { |
||
380 | alex-w | 577 | $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)."'>"; |
329 | alex-w | 578 | } else { |
380 | alex-w | 579 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
329 | alex-w | 580 | } |
581 | |||
511 | alex-w | 582 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
350 | alex-w | 583 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
584 | $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"; |
||
518 | alex-w | 585 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
348 | alex-w | 586 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
329 | alex-w | 587 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
350 | alex-w | 588 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
329 | alex-w | 589 | |
590 | return $show; |
||
591 | } |
||
592 | |||
628 | alex-w | 593 | /** |
594 | * Генератор sources.list |
||
595 | * |
||
596 | * @author Alexander Wolf |
||
597 | * @category Core |
||
598 | * @version 1.0 |
||
599 | * |
||
600 | * @param array $data |
||
601 | * @return string |
||
602 | */ |
||
668 | alex-w | 603 | public function showSourcesList($data) { |
646 | alex-w | 604 | // Извлекаем информацию о дистрибутиве и его версии |
605 | $query = "SELECT * FROM ".$this->prefix."distribution d "; |
||
649 | alex-w | 606 | $query .= "JOIN ".$this->prefix."version v ON v.dist_id=d.dist_id "; |
646 | alex-w | 607 | $query .= "JOIN ".$this->prefix."dtype t ON d.disttype=t.type_id "; |
648 | alex-w | 608 | $query .= "WHERE d.dist_id='".$data["dist_id"]."' AND v.version_id='".$data["version_id"]."'"; |
646 | alex-w | 609 | $rq =& $this->db->query($query); |
610 | $rq->fetchInto($dist); |
||
663 | alex-w | 611 | |
678 | alex-w | 612 | $show = "# Список репозиториев для ".$this->secure->checkStr($dist["distname"],1)." ".$this->secure->checkStr($dist["version"],1)." ".$this->secure->checkStr($dist["vname"],1)."\n"; |
613 | $show .= "# Этот sources.list сгенерирован при помощи ".$core->getEngineAttr('codename')." ".$core->getEngineAttr('version')."\n\n"; |
||
646 | alex-w | 614 | |
615 | // Извлекаем информацию о репозиториях и строим sources.list |
||
616 | if ($dist["type"]=="deb") { |
||
617 | // Базовый репозиторий |
||
618 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
619 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
620 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
651 | alex-w | 621 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
646 | alex-w | 622 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
623 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
624 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
650 | alex-w | 625 | $query .= "WHERE v.version_id='".$data["version_id"]."' AND r.rtype_id='1'"; |
646 | alex-w | 626 | $rq =& $this->db->query($query); |
675 | alex-w | 627 | if ($rq->numRows()>0) { |
628 | $rq->fetchInto($base); |
||
629 | // Формируем type proto://host/folder |
||
630 | $show .= "# ".$this->secure->checkStr($base["repinfo"],1)."\n"; |
||
631 | if ($base["repkey"]!="") { |
||
632 | $show .= "# Установка ключа: ".$this->secure->checkStr($base["repkey"],1)."\n"; |
||
633 | } |
||
634 | $show .= $this->secure->checkStr($dist["type"],1)." ".$this->secure->checkStr($base["proto"],1).$this->secure->checkStr($base["rhost"],1).$this->secure->checkStr($base["rfolder"],1); |
||
635 | $dvname = str_replace("{DIST}",$this->secure->checkStr($dist["vcodename"],1),$this->secure->checkStr($base["scheme"],1)); |
||
636 | // Формируем distname |
||
637 | $show .= " ".$dvname." "; |
||
638 | // Формируем sections |
||
639 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
640 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
641 | $query .= "WHERE r.rep_id='".$base["rep_id"]."' AND ("; |
||
642 | for($i=0;$i<count($data["section"]);$i++) { |
||
643 | $query .= "s.sect_id='".$data["section"][$i]."' "; |
||
644 | if ($i<count($data["section"])-1) { |
||
645 | $query .= " OR "; |
||
646 | } |
||
647 | } |
||
648 | $query .= ")"; |
||
649 | $rq =& $this->db->query($query); |
||
650 | while ($rq->fetchInto($sections)) { |
||
651 | $show .= $sections["secname"]." "; |
||
652 | } |
||
653 | $show .= "\n\n"; |
||
670 | alex-w | 654 | } |
655 | alex-w | 655 | |
676 | alex-w | 656 | if (count($data["repository"])>0) { |
657 | // Репозитории обновлений и третьих лиц |
||
658 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
659 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
660 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
661 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
||
662 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
||
663 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
664 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
665 | $query .= "WHERE r.rtype_id>'1' AND ("; |
||
666 | for($i=0;$i<count($data["repository"]);$i++) { |
||
667 | $query .= "r.rep_id='".$data["repository"][$i]."' "; |
||
668 | if ($i<count($data["repository"])-1) { |
||
669 | $query .= " OR "; |
||
670 | } |
||
656 | alex-w | 671 | } |
676 | alex-w | 672 | $query .= ") ORDER BY r.rtype_id ASC"; |
673 | $req =& $this->db->query($query); |
||
674 | |||
675 | alex-w | 675 | while ($req->fetchInto($updates)) { |
676 | // Формируем type proto://host/folder |
||
677 | $show .= "# ".$this->secure->checkStr($updates["repinfo"],1)."\n"; |
||
678 | if ($updates["repkey"]!="") { |
||
679 | $show .= "# Установка ключа: ".$this->secure->checkStr($updates["repkey"],1)."\n"; |
||
680 | } |
||
681 | $show .= $this->secure->checkStr($dist["type"],1)." ".$this->secure->checkStr($updates["proto"],1).$this->secure->checkStr($updates["rhost"],1).$this->secure->checkStr($updates["rfolder"],1); |
||
682 | $dvname = str_replace("{DIST}",$this->secure->checkStr($dist["vcodename"],1),$this->secure->checkStr($updates["scheme"],1)); |
||
683 | // Формируем distname |
||
684 | $show .= " ".$dvname." "; |
||
685 | // Формируем sections |
||
686 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
687 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
688 | $query .= "WHERE r.rep_id='".$updates["rep_id"]."'"; |
||
689 | $rq =& $this->db->query($query); |
||
690 | while ($rq->fetchInto($sections)) { |
||
691 | $show .= $sections["secname"]." "; |
||
692 | } |
||
693 | $show .= "\n\n"; |
||
670 | alex-w | 694 | } |
675 | alex-w | 695 | $show .= "\n"; |
655 | alex-w | 696 | } |
668 | alex-w | 697 | } else { |
698 | // Базовый репозиторий |
||
699 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
700 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
701 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
702 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
||
703 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
||
704 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
705 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
706 | $query .= "WHERE v.version_id='".$data["version_id"]."' AND r.rtype_id='1'"; |
||
707 | $rq =& $this->db->query($query); |
||
675 | alex-w | 708 | if ($rq->numRows()>0) { |
709 | $rq->fetchInto($base); |
||
710 | // Формируем type proto://host/folder |
||
711 | $show .= "# ".$this->secure->checkStr($base["repinfo"],1)."\n"; |
||
712 | $show .= $this->secure->checkStr($dist["type"],1)." "; |
||
713 | if ($base["sign_id"]!=0) { |
||
714 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$base["sign_id"]."'"; |
||
715 | $rq =& $this->db->query($query); |
||
716 | $rq->fetchInto($sign); |
||
717 | $show .= "[".$this->secure->checkStr($sign["sname"],1)."] "; |
||
718 | } |
||
719 | $show .= $this->secure->checkStr($base["proto"],1).$this->secure->checkStr($base["rhost"],1).$this->secure->checkStr($base["rfolder"],1)." "; |
||
720 | $show .= $this->secure->checkStr($base["scheme"],1)." "; |
||
646 | alex-w | 721 | |
675 | alex-w | 722 | // Формируем sections |
723 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
724 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
725 | $query .= "WHERE r.rep_id='".$base["rep_id"]."' AND ("; |
||
726 | for($i=0;$i<count($data["section"]);$i++) { |
||
727 | $query .= "s.sect_id='".$data["section"][$i]."' "; |
||
728 | if ($i<count($data["section"])-1) { |
||
729 | $query .= " OR "; |
||
730 | } |
||
731 | } |
||
732 | $query .= ")"; |
||
733 | $rq =& $this->db->query($query); |
||
734 | while ($rq->fetchInto($sections)) { |
||
735 | $show .= $sections["secname"]." "; |
||
736 | } |
||
737 | $show .= "\n\n"; |
||
668 | alex-w | 738 | } |
739 | |||
677 | alex-w | 740 | if (count($data["repository"])>0) { |
741 | // Репозитории обновлений и третьих лиц |
||
742 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
743 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
744 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
745 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
||
746 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
||
747 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
748 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
749 | $query .= "WHERE r.rtype_id>'1' AND ("; |
||
750 | for($i=0;$i<count($data["repository"]);$i++) { |
||
751 | $query .= "r.rep_id='".$data["repository"][$i]."' "; |
||
752 | if ($i<count($data["repository"])-1) { |
||
753 | $query .= " OR "; |
||
754 | } |
||
668 | alex-w | 755 | } |
677 | alex-w | 756 | $query .= ") ORDER BY r.rtype_id ASC"; |
757 | $req =& $this->db->query($query); |
||
758 | |||
675 | alex-w | 759 | while ($req->fetchInto($updates)) { |
760 | // Формируем type proto://host/folder |
||
761 | $show .= "# ".$this->secure->checkStr($updates["repinfo"],1)."\n"; |
||
762 | $show .= $this->secure->checkStr($dist["type"],1)." "; |
||
763 | if ($updates["sign_id"]!=0) { |
||
764 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$base["sign_id"]."'"; |
||
765 | $rqs =& $this->db->query($query); |
||
766 | $rqs->fetchInto($sign); |
||
767 | $show .= "[".$this->secure->checkStr($sign["sname"],1)."] "; |
||
768 | } |
||
769 | $show .= $this->secure->checkStr($updates["proto"],1).$this->secure->checkStr($updates["rhost"],1).$this->secure->checkStr($updates["rfolder"],1)." "; |
||
770 | $show .= $this->secure->checkStr($updates["scheme"],1)." "; |
||
771 | // Формируем sections |
||
772 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
773 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
774 | $query .= "WHERE r.rep_id='".$updates["rep_id"]."'"; |
||
775 | $rq =& $this->db->query($query); |
||
776 | while ($rq->fetchInto($sections)) { |
||
777 | $show .= $sections["secname"]." "; |
||
778 | } |
||
779 | $show .= "\n\n"; |
||
668 | alex-w | 780 | } |
675 | alex-w | 781 | $show .= "\n"; |
668 | alex-w | 782 | } |
646 | alex-w | 783 | } |
784 | |||
668 | alex-w | 785 | $HTTPHeader1 = "Content-length: ".strlen($show); |
786 | $HTTPHeader2 = "Content-disposition: attachment; filename=sources.list\n\n"; |
||
787 | |||
788 | header($HTTPHeader1); |
||
789 | header($HTTPHeader2); |
||
628 | alex-w | 790 | return $show; |
358 | alex-w | 791 | } |
522 | alex-w | 792 | |
463 | alex-w | 793 | /** |
522 | alex-w | 794 | * Показывает список секций |
795 | * |
||
796 | * @author Alexander Wolf |
||
797 | * @category Core |
||
798 | * |
||
799 | * @param string $name |
||
800 | * @param string $actor |
||
561 | alex-w | 801 | * @param string $format |
522 | alex-w | 802 | * @return string |
803 | */ |
||
560 | alex-w | 804 | public function showSectionsList($name, $actor, $format = 'html') { |
805 | switch($format) { |
||
806 | case 'html': |
||
561 | alex-w | 807 | $query = "SELECT * FROM ".$this->prefix."section"; |
808 | $rq =& $this->db->query($query); |
||
560 | alex-w | 809 | $show = "<ul>\n"; |
810 | while ($rq->fetchInto($element)) { |
||
811 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sect_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sect_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["secname"],1)."</li>\n"; |
||
812 | } |
||
813 | $show .= "</ul>"; |
||
814 | break; |
||
815 | case 'innerhtml': |
||
816 | $show = ""; |
||
561 | alex-w | 817 | $repID = $this->secure->checkInt($actor); |
818 | if ($repID==0) { |
||
819 | $query = "SELECT * FROM ".$this->prefix."section"; |
||
820 | $rq =& $this->db->query($query); |
||
821 | while ($rq->fetchInto($element)) { |
||
567 | alex-w | 822 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 823 | } |
824 | } else { |
||
825 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
||
826 | $rq =& $this->db->query($query); |
||
827 | while ($rq->fetchInto($element)) { |
||
567 | alex-w | 828 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 829 | } |
830 | $query = "SELECT s.* FROM ".$this->prefix."section s WHERE s.sect_id NOT IN (SELECT sect_id FROM ".$this->prefix."sect2rep WHERE rep_id='$repID')"; |
||
563 | alex-w | 831 | $rq =& $this->db->query($query); |
561 | alex-w | 832 | while ($rq->fetchInto($element)) { |
567 | alex-w | 833 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 834 | } |
835 | } |
||
836 | |||
560 | alex-w | 837 | break; |
522 | alex-w | 838 | } |
839 | |||
840 | return $show; |
||
841 | } |
||
842 | |||
523 | alex-w | 843 | /** |
844 | * Вывод формы редактирования/добавления секций |
||
845 | * |
||
846 | * @author Alexander Wolf |
||
847 | * @category Core |
||
848 | * |
||
849 | * @param integer $sectionID |
||
850 | * @param string $info |
||
851 | * @return string |
||
852 | */ |
||
853 | public function showSectionsForm($sectionID = 0, $info = "") { |
||
522 | alex-w | 854 | $sSectID = $this->secure->checkInt($sectionID); |
855 | $sInfo = $this->secure->checkStr($info, 1); |
||
856 | if ($sInfo == "") { |
||
857 | $sInfo = "Секция"; |
||
858 | } |
||
859 | if ($sSectID != 0) { |
||
860 | // Режим редактирования |
||
861 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
||
862 | $rq =& $this->db->query($query); |
||
863 | $rq->fetchInto($element); |
||
864 | } |
||
865 | |||
866 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
867 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
||
868 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
||
869 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
870 | |||
871 | return $show; |
||
872 | } |
||
873 | |||
874 | /** |
||
523 | alex-w | 875 | * Обновление информации о секции |
876 | * |
||
877 | * @author Alexander Wolf |
||
878 | * @category Core |
||
879 | * |
||
880 | * @param integer $sectionID |
||
881 | * @param string $sname |
||
882 | * @param string $sinfo |
||
883 | * @return array |
||
884 | */ |
||
885 | public function updateSection($sectionID, $sname, $sinfo = "") { |
||
886 | $result = array(); |
||
887 | $sSectID = $this->secure->checkInt($sectionID); |
||
579 | alex-w | 888 | $sSName = $this->secure->checkStr($sname); |
889 | $sSInfo = $this->secure->checkStr($sinfo); |
||
523 | alex-w | 890 | |
891 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
||
892 | $rq =& $this->db->query($query); |
||
893 | if (PEAR::isError($this->db)) { |
||
894 | $result["ERR"] = 1; |
||
895 | $result["ERRINFO"] = $this->db->getMessage(); |
||
896 | } else { |
||
897 | $result["ERR"] = 0; |
||
898 | } |
||
899 | |||
900 | return $result; |
||
901 | } |
||
902 | |||
903 | /** |
||
904 | * Удаление информации о секции |
||
905 | * |
||
906 | * @author Alexander Wolf |
||
907 | * @category Core |
||
908 | * |
||
909 | * @param integer $sectionID |
||
910 | * @return array |
||
911 | */ |
||
912 | public function dropSection($sectionID) { |
||
913 | $result = array(); |
||
914 | $sSectID = $this->secure->checkInt($sectionID); |
||
915 | |||
916 | // Удаление секции |
||
917 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
||
918 | $rq =& $this->db->query($query); |
||
919 | if (PEAR::isError($this->db)) { |
||
920 | $result["ERR"] = 1; |
||
921 | $result["ERRINFO"] = $this->db->getMessage(); |
||
922 | } else { |
||
923 | $result["ERR"] = 0; |
||
924 | } |
||
925 | |||
926 | return $result; |
||
927 | } |
||
928 | |||
929 | /** |
||
930 | * Добавление новой секции |
||
931 | * |
||
932 | * @author Alexander Wolf |
||
933 | * @category Core |
||
934 | * |
||
935 | * @param string $sname |
||
936 | * @param string $sinfo |
||
937 | * @return array |
||
938 | */ |
||
939 | public function addSection($sname, $sinfo = "") { |
||
940 | $result = array(); |
||
582 | alex-w | 941 | $sSName = $this->secure->checkStr($sname); |
942 | $sSInfo = $this->secure->checkStr($sinfo); |
||
523 | alex-w | 943 | |
944 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
||
945 | $rq =& $this->db->query($query); |
||
946 | if (PEAR::isError($this->db)) { |
||
947 | $result["ERR"] = 1; |
||
948 | $result["ERRINFO"] = $this->db->getMessage(); |
||
949 | } else { |
||
950 | $result["ERR"] = 0; |
||
951 | } |
||
952 | |||
953 | return $result; |
||
954 | } |
||
955 | |||
956 | /** |
||
568 | alex-w | 957 | * Вывод списка поддерживаемых архитектур |
958 | * |
||
959 | * @author Alexander Wolf |
||
960 | * @category Core |
||
961 | * |
||
962 | * @param string $name |
||
963 | * @param string $actor |
||
964 | * @param string $format |
||
965 | * @return string |
||
966 | */ |
||
967 | public function showArchList($name, $actor, $format = 'list') { |
||
968 | switch($format) { |
||
969 | case 'list': |
||
970 | $query = "SELECT * FROM ".$this->prefix."arch"; |
||
971 | $rq =& $this->db->query($query); |
||
972 | $show = "<ul>\n"; |
||
973 | while ($rq->fetchInto($element)) { |
||
974 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["arch_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["arch_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["arch"],1)."</li>\n"; |
||
975 | } |
||
976 | $show .= "</ul>"; |
||
977 | break; |
||
978 | case 'innerhtml': |
||
979 | $show = ""; |
||
980 | $repID = $this->secure->checkInt($actor); |
||
614 | alex-w | 981 | if ($repID==0) { |
568 | alex-w | 982 | $query = "SELECT * FROM ".$this->prefix."arch"; |
983 | $rq =& $this->db->query($query); |
||
984 | while ($rq->fetchInto($element)) { |
||
985 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
||
986 | } |
||
987 | } else { |
||
988 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
||
989 | $rq =& $this->db->query($query); |
||
990 | while ($rq->fetchInto($element)) { |
||
991 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
||
992 | } |
||
993 | $query = "SELECT a.* FROM ".$this->prefix."arch a WHERE a.arch_id NOT IN (SELECT arch_id FROM ".$this->prefix."arch2rep WHERE rep_id='$repID')"; |
||
994 | $rq =& $this->db->query($query); |
||
610 | alex-w | 995 | if ($rq->numRows()>0) { |
996 | while ($rq->fetchInto($element)) { |
||
997 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
||
998 | } |
||
568 | alex-w | 999 | } |
1000 | } |
||
1001 | break; |
||
1002 | } |
||
1003 | return $show; |
||
1004 | } |
||
1005 | |||
1006 | /** |
||
1007 | * Добавление новой архитектуры |
||
1008 | * |
||
1009 | * @author Alexander Wolf |
||
1010 | * @category Core |
||
1011 | * |
||
1012 | * @param string $arch |
||
1013 | * @return array |
||
1014 | */ |
||
1015 | public function addArch($arch) { |
||
1016 | $result = array(); |
||
582 | alex-w | 1017 | $sArch = $this->secure->checkStr($arch); |
568 | alex-w | 1018 | |
1019 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
||
1020 | $rq =& $this->db->query($query); |
||
1021 | if (PEAR::isError($this->db)) { |
||
1022 | $result["ERR"] = 1; |
||
1023 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1024 | } else { |
||
1025 | $result["ERR"] = 0; |
||
1026 | } |
||
1027 | |||
1028 | return $result; |
||
1029 | } |
||
1030 | |||
1031 | /** |
||
1032 | * Удаление информации об архитектуре |
||
1033 | * |
||
1034 | * @author Alexander Wolf |
||
1035 | * @category Core |
||
1036 | * |
||
1037 | * @param integer $archID |
||
1038 | * @return array |
||
1039 | */ |
||
1040 | public function dropArch($archID) { |
||
1041 | $result = array(); |
||
1042 | $sArchID = $this->secure->checkInt($archID); |
||
1043 | |||
1044 | // Удаление архитектуры |
||
1045 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
||
1046 | $rq =& $this->db->query($query); |
||
1047 | if (PEAR::isError($this->db)) { |
||
1048 | $result["ERR"] = 1; |
||
1049 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1050 | } else { |
||
1051 | $result["ERR"] = 0; |
||
1052 | } |
||
1053 | |||
1054 | // Удаление архитектуры из списка репозиториев |
||
1055 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
||
1056 | $rq =& $this->db->query($query); |
||
1057 | if (PEAR::isError($this->db)) { |
||
1058 | $result["ERR"] = 1; |
||
1059 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1060 | } else { |
||
1061 | $result["ERR"] = 0; |
||
1062 | } |
||
1063 | return $result; |
||
1064 | } |
||
1065 | |||
1066 | /** |
||
1067 | * Обновление информации об архитектуре |
||
1068 | * |
||
1069 | * @author Alexander Wolf |
||
1070 | * @category Core |
||
1071 | * |
||
1072 | * @param integer $archID |
||
1073 | * @param string $arch |
||
1074 | * @return array |
||
1075 | */ |
||
1076 | public function updateArch($archID, $arch) { |
||
1077 | $result = array(); |
||
1078 | $sArchID = $this->secure->checkInt($archID); |
||
579 | alex-w | 1079 | $sArch = $this->secure->checkStr($arch); |
568 | alex-w | 1080 | |
1081 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
||
1082 | $rq =& $this->db->query($query); |
||
1083 | if (PEAR::isError($this->db)) { |
||
1084 | $result["ERR"] = 1; |
||
1085 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1086 | } else { |
||
1087 | $result["ERR"] = 0; |
||
1088 | } |
||
1089 | |||
1090 | return $result; |
||
1091 | } |
||
1092 | |||
1093 | /** |
||
1094 | * Вывод формы редактирования/добавления архитектур |
||
1095 | * |
||
1096 | * @author Alexander Wolf |
||
1097 | * @category Core |
||
1098 | * |
||
1099 | * @param integer $archID |
||
1100 | * @param string $info |
||
1101 | * @return string |
||
1102 | */ |
||
1103 | public function showArchForm($archID = 0, $info = "") { |
||
1104 | $sArchID = $this->secure->checkInt($archID); |
||
1105 | $sInfo = $this->secure->checkStr($info, 1); |
||
1106 | if ($sInfo == "") { |
||
1107 | $sInfo = "Архитектура"; |
||
1108 | } |
||
1109 | if ($sArchID != 0) { |
||
1110 | // Режим редактирования |
||
1111 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
||
1112 | $rq =& $this->db->query($query); |
||
1113 | $rq->fetchInto($element); |
||
1114 | } |
||
1115 | |||
1116 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1117 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
||
1118 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1119 | |||
1120 | return $show; |
||
1121 | } |
||
1122 | |||
1123 | /** |
||
570 | alex-w | 1124 | * Вывод списка схем репозиториев |
1125 | * |
||
1126 | * @author Alexander Wolf |
||
1127 | * @category Core |
||
1128 | * |
||
1129 | * @param string $name |
||
1130 | * @param string $actor |
||
1131 | * @param string $format |
||
1132 | * @return string |
||
1133 | */ |
||
1134 | public function showSchemeList($name, $actor, $format = 'list') { |
||
1135 | switch($format) { |
||
1136 | case 'list': |
||
1137 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
||
1138 | $rq =& $this->db->query($query); |
||
1139 | $show = "<ul>\n"; |
||
1140 | while ($rq->fetchInto($element)) { |
||
1141 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["scheme_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["scheme_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["scheme"],1)."</li>\n"; |
||
1142 | } |
||
1143 | $show .= "</ul>"; |
||
1144 | break; |
||
1145 | case 'innerhtml': |
||
611 | alex-w | 1146 | $schemeID = $this->secure->checkInt($actor); |
570 | alex-w | 1147 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
1148 | $rq =& $this->db->query($query); |
||
1149 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1150 | while ($rq->fetchInto($element)) { |
||
611 | alex-w | 1151 | if ($element["scheme_id"]==$schemeID) { |
570 | alex-w | 1152 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
1153 | } else { |
||
611 | alex-w | 1154 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
570 | alex-w | 1155 | } |
1156 | } |
||
1157 | $show .= "</select>"; |
||
1158 | break; |
||
1159 | } |
||
1160 | return $show; |
||
1161 | } |
||
1162 | |||
1163 | /** |
||
1164 | * Добавление новой схемы репозитория |
||
1165 | * |
||
1166 | * @author Alexander Wolf |
||
1167 | * @category Core |
||
1168 | * |
||
1169 | * @param string $scheme |
||
1170 | * @return array |
||
1171 | */ |
||
1172 | public function addScheme($scheme) { |
||
1173 | $result = array(); |
||
582 | alex-w | 1174 | $sScheme = $this->secure->checkStr($scheme); |
570 | alex-w | 1175 | |
1176 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
||
1177 | $rq =& $this->db->query($query); |
||
1178 | if (PEAR::isError($this->db)) { |
||
1179 | $result["ERR"] = 1; |
||
1180 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1181 | } else { |
||
1182 | $result["ERR"] = 0; |
||
1183 | } |
||
1184 | |||
1185 | return $result; |
||
1186 | } |
||
1187 | |||
1188 | /** |
||
1189 | * Удаление информации о схеме репозитория |
||
1190 | * |
||
1191 | * @author Alexander Wolf |
||
1192 | * @category Core |
||
1193 | * |
||
1194 | * @param integer $schemeID |
||
1195 | * @return array |
||
1196 | */ |
||
1197 | public function dropScheme($schemeID) { |
||
1198 | $result = array(); |
||
1199 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
1200 | |||
1201 | // Удаление схемы |
||
1202 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
||
1203 | $rq =& $this->db->query($query); |
||
1204 | if (PEAR::isError($this->db)) { |
||
1205 | $result["ERR"] = 1; |
||
1206 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1207 | } else { |
||
1208 | $result["ERR"] = 0; |
||
1209 | } |
||
1210 | |||
1211 | return $result; |
||
1212 | } |
||
1213 | |||
1214 | /** |
||
1215 | * Обновление информации о схеме репозитория |
||
1216 | * |
||
1217 | * @author Alexander Wolf |
||
1218 | * @category Core |
||
1219 | * |
||
1220 | * @param integer $schemeID |
||
1221 | * @param string $info |
||
1222 | * @return array |
||
1223 | */ |
||
1224 | public function updateScheme($schemeID, $info) { |
||
1225 | $result = array(); |
||
1226 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
579 | alex-w | 1227 | $sScheme = $this->secure->checkStr($info); |
570 | alex-w | 1228 | |
1229 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
||
1230 | $rq =& $this->db->query($query); |
||
1231 | if (PEAR::isError($this->db)) { |
||
1232 | $result["ERR"] = 1; |
||
1233 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1234 | } else { |
||
1235 | $result["ERR"] = 0; |
||
1236 | } |
||
1237 | |||
1238 | return $result; |
||
1239 | } |
||
1240 | |||
1241 | /** |
||
1242 | * Вывод формы редактирования/добавления схем репозиториев |
||
1243 | * |
||
1244 | * @author Alexander Wolf |
||
1245 | * @category Core |
||
1246 | * |
||
1247 | * @param integer $schemeID |
||
1248 | * @param string $info |
||
1249 | * @return string |
||
1250 | */ |
||
1251 | public function showSchemeForm($schemeID = 0, $info = "") { |
||
1252 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
1253 | $sInfo = $this->secure->checkStr($info, 1); |
||
1254 | if ($sInfo == "") { |
||
1255 | $sInfo = "Схема репозитория"; |
||
1256 | } |
||
571 | alex-w | 1257 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
570 | alex-w | 1258 | if ($sSchemeID != 0) { |
1259 | // Режим редактирования |
||
1260 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
||
1261 | $rq =& $this->db->query($query); |
||
573 | alex-w | 1262 | $rq->fetchInto($element); |
1263 | } |
||
571 | alex-w | 1264 | |
573 | alex-w | 1265 | $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n"; |
570 | alex-w | 1266 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1267 | |||
1268 | return $show; |
||
1269 | } |
||
1270 | |||
1271 | /** |
||
574 | alex-w | 1272 | * Вывод списка протоколов |
1273 | * |
||
1274 | * @author Alexander Wolf |
||
1275 | * @category Core |
||
1276 | * |
||
1277 | * @param string $name |
||
1278 | * @param string $actor |
||
1279 | * @param string $format |
||
1280 | * @return string |
||
1281 | */ |
||
1282 | public function showProtoList($name, $actor, $format = 'list') { |
||
1283 | switch($format) { |
||
1284 | case 'list': |
||
1285 | $query = "SELECT * FROM ".$this->prefix."protos"; |
||
1286 | $rq =& $this->db->query($query); |
||
1287 | $show = "<ul>\n"; |
||
1288 | while ($rq->fetchInto($element)) { |
||
1289 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["proto_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["proto_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["proto"],1)."</li>\n"; |
||
1290 | } |
||
1291 | $show .= "</ul>"; |
||
1292 | break; |
||
1293 | case 'innerhtml': |
||
1294 | $protoID = $this->secure->checkInt($actor); |
||
1295 | $query = "SELECT * FROM ".$this->prefix."protos"; |
||
1296 | $rq =& $this->db->query($query); |
||
1297 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1298 | while ($rq->fetchInto($element)) { |
||
1299 | if ($element["proto_id"]==$protoID) { |
||
1300 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
||
1301 | } else { |
||
580 | alex-w | 1302 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
574 | alex-w | 1303 | } |
1304 | } |
||
1305 | $show .= "</select>"; |
||
1306 | break; |
||
1307 | } |
||
1308 | return $show; |
||
1309 | } |
||
1310 | |||
1311 | /** |
||
1312 | * Добавление нового протокола |
||
1313 | * |
||
1314 | * @author Alexander Wolf |
||
1315 | * @category Core |
||
1316 | * |
||
1317 | * @param string $proto |
||
1318 | * @return array |
||
1319 | */ |
||
1320 | public function addProto($proto) { |
||
1321 | $result = array(); |
||
582 | alex-w | 1322 | $sProto = $this->secure->checkStr($proto); |
574 | alex-w | 1323 | |
1324 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
||
1325 | $rq =& $this->db->query($query); |
||
1326 | if (PEAR::isError($this->db)) { |
||
1327 | $result["ERR"] = 1; |
||
1328 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1329 | } else { |
||
1330 | $result["ERR"] = 0; |
||
1331 | } |
||
1332 | |||
1333 | return $result; |
||
1334 | } |
||
1335 | |||
1336 | /** |
||
1337 | * Удаление информации о протоколе |
||
1338 | * |
||
1339 | * @author Alexander Wolf |
||
1340 | * @category Core |
||
1341 | * |
||
1342 | * @param integer $protoID |
||
1343 | * @return array |
||
1344 | */ |
||
1345 | public function dropProto($protoID) { |
||
1346 | $result = array(); |
||
1347 | $sProtoID = $this->secure->checkInt($protoID); |
||
1348 | |||
1349 | // Удаление протокола |
||
1350 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
||
1351 | $rq =& $this->db->query($query); |
||
1352 | if (PEAR::isError($this->db)) { |
||
1353 | $result["ERR"] = 1; |
||
1354 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1355 | } else { |
||
1356 | $result["ERR"] = 0; |
||
1357 | } |
||
1358 | |||
1359 | return $result; |
||
1360 | } |
||
1361 | |||
1362 | /** |
||
1363 | * Обновление информации о протоколе |
||
1364 | * |
||
1365 | * @author Alexander Wolf |
||
1366 | * @category Core |
||
1367 | * |
||
1368 | * @param integer $protoID |
||
1369 | * @param string $info |
||
1370 | * @return array |
||
1371 | */ |
||
1372 | public function updateProto($protoID, $info) { |
||
1373 | $result = array(); |
||
1374 | $sProtoID = $this->secure->checkInt($protoID); |
||
579 | alex-w | 1375 | $sProto = $this->secure->checkStr($info); |
574 | alex-w | 1376 | |
1377 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
||
1378 | $rq =& $this->db->query($query); |
||
1379 | if (PEAR::isError($this->db)) { |
||
1380 | $result["ERR"] = 1; |
||
1381 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1382 | } else { |
||
1383 | $result["ERR"] = 0; |
||
1384 | } |
||
1385 | |||
1386 | return $result; |
||
1387 | } |
||
1388 | |||
1389 | /** |
||
1390 | * Вывод формы редактирования/добавления протоколов |
||
1391 | * |
||
1392 | * @author Alexander Wolf |
||
1393 | * @category Core |
||
1394 | * |
||
1395 | * @param integer $protoID |
||
1396 | * @param string $info |
||
1397 | * @return string |
||
1398 | */ |
||
1399 | public function showProtoForm($protoID = 0, $info = "") { |
||
1400 | $sProtoID = $this->secure->checkInt($protoID); |
||
1401 | $sInfo = $this->secure->checkStr($info, 1); |
||
1402 | if ($sInfo == "") { |
||
1403 | $sInfo = "Протокол доступа"; |
||
1404 | } |
||
1405 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1406 | if ($sProtoID != 0) { |
||
1407 | // Режим редактирования |
||
1408 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
||
1409 | $rq =& $this->db->query($query); |
||
1410 | $rq->fetchInto($element); |
||
1411 | } |
||
1412 | |||
1413 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
||
1414 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1415 | |||
1416 | return $show; |
||
1417 | } |
||
1418 | |||
1419 | /** |
||
582 | alex-w | 1420 | * Вывод списка хостов |
1421 | * |
||
1422 | * @author Alexander Wolf |
||
1423 | * @category Core |
||
1424 | * |
||
1425 | * @param string $name |
||
1426 | * @param string $actor |
||
1427 | * @param string $format |
||
1428 | * @return string |
||
1429 | */ |
||
1430 | public function showHostsList($name, $actor, $format = 'list') { |
||
1431 | switch($format) { |
||
1432 | case 'list': |
||
1433 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
||
1434 | $rq =& $this->db->query($query); |
||
1435 | $show = "<ul>\n"; |
||
1436 | while ($rq->fetchInto($element)) { |
||
1437 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["rhost_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["rhost_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["rhost"],1)."</li>\n"; |
||
1438 | } |
||
1439 | $show .= "</ul>"; |
||
1440 | break; |
||
1441 | case 'innerhtml': |
||
1442 | $hostID = $this->secure->checkInt($actor); |
||
1443 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
||
1444 | $rq =& $this->db->query($query); |
||
1445 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1446 | while ($rq->fetchInto($element)) { |
||
1447 | if ($element["rhost_id"]==$hostID) { |
||
1448 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
||
1449 | } else { |
||
1450 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
||
1451 | } |
||
1452 | } |
||
1453 | $show .= "</select>"; |
||
1454 | break; |
||
1455 | } |
||
1456 | return $show; |
||
1457 | } |
||
1458 | |||
1459 | /** |
||
1460 | * Добавление нового хоста |
||
1461 | * |
||
1462 | * @author Alexander Wolf |
||
1463 | * @category Core |
||
1464 | * |
||
1465 | * @param string $host |
||
1466 | * @return array |
||
1467 | */ |
||
1468 | public function addHost($host) { |
||
1469 | $result = array(); |
||
1470 | $sHost = $this->secure->checkStr($host); |
||
1471 | |||
586 | alex-w | 1472 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
582 | alex-w | 1473 | $rq =& $this->db->query($query); |
1474 | if (PEAR::isError($this->db)) { |
||
1475 | $result["ERR"] = 1; |
||
1476 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1477 | } else { |
||
1478 | $result["ERR"] = 0; |
||
1479 | } |
||
1480 | |||
1481 | return $result; |
||
1482 | } |
||
1483 | |||
1484 | /** |
||
1485 | * Удаление информации о хосте |
||
1486 | * |
||
1487 | * @author Alexander Wolf |
||
1488 | * @category Core |
||
1489 | * |
||
1490 | * @param integer $hostID |
||
1491 | * @return array |
||
1492 | */ |
||
1493 | public function dropHost($hostID) { |
||
1494 | $result = array(); |
||
1495 | $sHostID = $this->secure->checkInt($hostID); |
||
1496 | |||
1497 | // Удаление хоста |
||
1498 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
||
1499 | $rq =& $this->db->query($query); |
||
1500 | if (PEAR::isError($this->db)) { |
||
1501 | $result["ERR"] = 1; |
||
1502 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1503 | } else { |
||
1504 | $result["ERR"] = 0; |
||
1505 | } |
||
1506 | |||
1507 | return $result; |
||
1508 | } |
||
1509 | |||
1510 | /** |
||
1511 | * Обновление информации о хосте |
||
1512 | * |
||
1513 | * @author Alexander Wolf |
||
1514 | * @category Core |
||
1515 | * |
||
1516 | * @param integer $hostID |
||
1517 | * @param string $info |
||
1518 | * @return array |
||
1519 | */ |
||
1520 | public function updateHost($hostID, $info) { |
||
1521 | $result = array(); |
||
1522 | $sHostID = $this->secure->checkInt($hostID); |
||
1523 | $sHost = $this->secure->checkStr($info); |
||
1524 | |||
1525 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
||
1526 | $rq =& $this->db->query($query); |
||
1527 | if (PEAR::isError($this->db)) { |
||
1528 | $result["ERR"] = 1; |
||
1529 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1530 | } else { |
||
1531 | $result["ERR"] = 0; |
||
1532 | } |
||
1533 | |||
1534 | return $result; |
||
1535 | } |
||
1536 | |||
1537 | /** |
||
1538 | * Вывод формы редактирования/добавления хостов |
||
1539 | * |
||
1540 | * @author Alexander Wolf |
||
1541 | * @category Core |
||
1542 | * |
||
1543 | * @param integer $hostID |
||
1544 | * @param string $info |
||
1545 | * @return string |
||
1546 | */ |
||
1547 | public function showHostForm($hostID = 0, $info = "") { |
||
1548 | $sHostID = $this->secure->checkInt($hostID); |
||
1549 | $sInfo = $this->secure->checkStr($info, 1); |
||
1550 | if ($sInfo == "") { |
||
1551 | $sInfo = "Хост репозитория"; |
||
1552 | } |
||
1553 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1554 | if ($sHostID != 0) { |
||
1555 | // Режим редактирования |
||
1556 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
||
1557 | $rq =& $this->db->query($query); |
||
1558 | $rq->fetchInto($element); |
||
1559 | } |
||
1560 | |||
1561 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
||
1562 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1563 | |||
1564 | return $show; |
||
1565 | } |
||
1566 | |||
1567 | /** |
||
589 | alex-w | 1568 | * Вывод списка корневых папок |
1569 | * |
||
1570 | * @author Alexander Wolf |
||
1571 | * @category Core |
||
1572 | * |
||
1573 | * @param string $name |
||
1574 | * @param string $actor |
||
1575 | * @param string $format |
||
1576 | * @return string |
||
1577 | */ |
||
1578 | public function showFoldersList($name, $actor, $format = 'list') { |
||
1579 | switch($format) { |
||
1580 | case 'list': |
||
1581 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
||
1582 | $rq =& $this->db->query($query); |
||
1583 | $show = "<ul>\n"; |
||
1584 | while ($rq->fetchInto($element)) { |
||
1585 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["rfolder_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["rfolder_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["rfolder"],1)."</li>\n"; |
||
1586 | } |
||
1587 | $show .= "</ul>"; |
||
1588 | break; |
||
1589 | case 'innerhtml': |
||
1590 | $folderID = $this->secure->checkInt($actor); |
||
1591 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
||
1592 | $rq =& $this->db->query($query); |
||
1593 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1594 | while ($rq->fetchInto($element)) { |
||
1595 | if ($element["rfolder_id"]==$folderID) { |
||
1596 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
||
1597 | } else { |
||
1598 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
||
1599 | } |
||
1600 | } |
||
1601 | $show .= "</select>"; |
||
1602 | break; |
||
1603 | } |
||
1604 | return $show; |
||
1605 | } |
||
1606 | |||
1607 | /** |
||
1608 | * Добавление нового корневого каталога |
||
1609 | * |
||
1610 | * @author Alexander Wolf |
||
1611 | * @category Core |
||
1612 | * |
||
1613 | * @param string $flder |
||
1614 | * @return array |
||
1615 | */ |
||
1616 | public function addFolder($folder) { |
||
1617 | $result = array(); |
||
1618 | $sFolder = $this->secure->checkStr($folder); |
||
1619 | |||
1620 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
||
1621 | $rq =& $this->db->query($query); |
||
1622 | if (PEAR::isError($this->db)) { |
||
1623 | $result["ERR"] = 1; |
||
1624 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1625 | } else { |
||
1626 | $result["ERR"] = 0; |
||
1627 | } |
||
1628 | |||
1629 | return $result; |
||
1630 | } |
||
1631 | |||
1632 | /** |
||
1633 | * Удаление информации о корневой папке |
||
1634 | * |
||
1635 | * @author Alexander Wolf |
||
1636 | * @category Core |
||
1637 | * |
||
1638 | * @param integer $folderID |
||
1639 | * @return array |
||
1640 | */ |
||
1641 | public function dropFolder($folderID) { |
||
1642 | $result = array(); |
||
1643 | $sFolderID = $this->secure->checkInt($folderID); |
||
1644 | |||
1645 | // Удаление корневой папки |
||
1646 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
||
1647 | $rq =& $this->db->query($query); |
||
1648 | if (PEAR::isError($this->db)) { |
||
1649 | $result["ERR"] = 1; |
||
1650 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1651 | } else { |
||
1652 | $result["ERR"] = 0; |
||
1653 | } |
||
1654 | |||
1655 | return $result; |
||
1656 | } |
||
1657 | |||
1658 | /** |
||
1659 | * Обновление информации о корневой папки |
||
1660 | * |
||
1661 | * @author Alexander Wolf |
||
1662 | * @category Core |
||
1663 | * |
||
1664 | * @param integer $folderID |
||
1665 | * @param string $info |
||
1666 | * @return array |
||
1667 | */ |
||
1668 | public function updateFolder($folderID, $info) { |
||
1669 | $result = array(); |
||
1670 | $sFolderID = $this->secure->checkInt($folderID); |
||
1671 | $sFolder = $this->secure->checkStr($info); |
||
1672 | |||
1673 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
||
1674 | $rq =& $this->db->query($query); |
||
1675 | if (PEAR::isError($this->db)) { |
||
1676 | $result["ERR"] = 1; |
||
1677 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1678 | } else { |
||
1679 | $result["ERR"] = 0; |
||
1680 | } |
||
1681 | |||
1682 | return $result; |
||
1683 | } |
||
1684 | |||
1685 | /** |
||
1686 | * Вывод формы редактирования/добавления корневых папок |
||
1687 | * |
||
1688 | * @author Alexander Wolf |
||
1689 | * @category Core |
||
1690 | * |
||
1691 | * @param integer $folderID |
||
1692 | * @param string $info |
||
1693 | * @return string |
||
1694 | */ |
||
1695 | public function showFolderForm($folderID = 0, $info = "") { |
||
1696 | $sFolderID = $this->secure->checkInt($folderID); |
||
1697 | $sInfo = $this->secure->checkStr($info, 1); |
||
1698 | if ($sInfo == "") { |
||
1699 | $sInfo = "Корневая папка"; |
||
1700 | } |
||
1701 | if ($sFolderID != 0) { |
||
1702 | // Режим редактирования |
||
1703 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
||
1704 | $rq =& $this->db->query($query); |
||
1705 | $rq->fetchInto($element); |
||
1706 | } |
||
1707 | |||
1708 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1709 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
||
1710 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1711 | |||
1712 | return $show; |
||
1713 | } |
||
1714 | |||
1715 | /** |
||
539 | alex-w | 1716 | * Показывает список подписей |
1717 | * |
||
1718 | * @author Alexander Wolf |
||
1719 | * @category Core |
||
1720 | * |
||
1721 | * @param string $name |
||
1722 | * @param string $actor |
||
596 | alex-w | 1723 | * @param string $format |
539 | alex-w | 1724 | * @return string |
1725 | */ |
||
594 | alex-w | 1726 | public function showSignsList($name, $actor, $format = 'list') { |
539 | alex-w | 1727 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1728 | $rq =& $this->db->query($query); |
||
594 | alex-w | 1729 | switch ($format) { |
1730 | case 'list': |
||
1731 | $show = "<ul>\n"; |
||
1732 | while ($rq->fetchInto($element)) { |
||
1733 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sign_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sign_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["sname"],1)."</li>\n"; |
||
1734 | } |
||
1735 | $show .= "</ul>"; |
||
1736 | break; |
||
1737 | case 'innerhtml': |
||
1738 | $signID = $this->secure->checkInt($actor); |
||
1739 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1740 | $show .= "<option value='0'>Подписи нет</option>\n"; |
||
1741 | while ($rq->fetchInto($element)) { |
||
1742 | if ($element["sign_id"]==$signID) { |
||
1743 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
||
1744 | } else { |
||
1745 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
||
1746 | } |
||
1747 | } |
||
1748 | $show .= "</select>\n"; |
||
1749 | break; |
||
539 | alex-w | 1750 | } |
1751 | |||
1752 | return $show; |
||
1753 | } |
||
1754 | |||
1755 | /** |
||
1756 | * Вывод формы редактирования/добавления подписей |
||
1757 | * |
||
1758 | * @author Alexander Wolf |
||
1759 | * @category Core |
||
1760 | * |
||
1761 | * @param integer $sectionID |
||
1762 | * @param string $info |
||
1763 | * @return string |
||
1764 | */ |
||
1765 | public function showSignsForm($signID = 0, $info = "") { |
||
1766 | $sSignID = $this->secure->checkInt($signID); |
||
1767 | $sInfo = $this->secure->checkStr($info, 1); |
||
1768 | if ($sInfo == "") { |
||
1769 | $sInfo = "Подписи"; |
||
1770 | } |
||
1771 | if ($sSignID != 0) { |
||
1772 | // Режим редактирования |
||
1773 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
||
1774 | $rq =& $this->db->query($query); |
||
1775 | $rq->fetchInto($element); |
||
1776 | } |
||
1777 | |||
1778 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1779 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
||
1780 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
||
1781 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1782 | |||
1783 | return $show; |
||
1784 | } |
||
1785 | |||
1786 | /** |
||
1787 | * Обновление информации о секции |
||
1788 | * |
||
1789 | * @author Alexander Wolf |
||
1790 | * @category Core |
||
1791 | * |
||
1792 | * @param integer $sectionID |
||
1793 | * @param string $sname |
||
1794 | * @param string $sinfo |
||
1795 | * @return array |
||
1796 | */ |
||
1797 | public function updateSign($signID, $sname, $sinfo = "") { |
||
1798 | $result = array(); |
||
1799 | $sSignID = $this->secure->checkInt($signID); |
||
579 | alex-w | 1800 | $sSName = $this->secure->checkStr($sname); |
1801 | $sSInfo = $this->secure->checkStr($sinfo); |
||
539 | alex-w | 1802 | |
1803 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
||
1804 | $rq =& $this->db->query($query); |
||
1805 | if (PEAR::isError($this->db)) { |
||
1806 | $result["ERR"] = 1; |
||
1807 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1808 | } else { |
||
1809 | $result["ERR"] = 0; |
||
1810 | } |
||
1811 | |||
1812 | return $result; |
||
1813 | } |
||
1814 | |||
1815 | /** |
||
1816 | * Удаление информации о подписи |
||
1817 | * |
||
1818 | * @author Alexander Wolf |
||
1819 | * @category Core |
||
1820 | * |
||
1821 | * @param integer $sectionID |
||
1822 | * @return array |
||
1823 | */ |
||
540 | alex-w | 1824 | public function dropSign($signID) { |
539 | alex-w | 1825 | $result = array(); |
1826 | $sSignID = $this->secure->checkInt($signID); |
||
1827 | |||
1828 | // Удаление подписи |
||
1829 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
||
1830 | $rq =& $this->db->query($query); |
||
1831 | if (PEAR::isError($this->db)) { |
||
1832 | $result["ERR"] = 1; |
||
1833 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1834 | } else { |
||
1835 | $result["ERR"] = 0; |
||
1836 | } |
||
1837 | |||
1838 | return $result; |
||
1839 | } |
||
1840 | |||
1841 | /** |
||
540 | alex-w | 1842 | * Добавление новой подписи |
539 | alex-w | 1843 | * |
1844 | * @author Alexander Wolf |
||
1845 | * @category Core |
||
1846 | * |
||
1847 | * @param string $sname |
||
1848 | * @param string $sinfo |
||
1849 | * @return array |
||
1850 | */ |
||
540 | alex-w | 1851 | public function addSign($sname, $sinfo = "") { |
539 | alex-w | 1852 | $result = array(); |
582 | alex-w | 1853 | $sSName = $this->secure->checkStr($sname); |
1854 | $sSInfo = $this->secure->checkStr($sinfo); |
||
539 | alex-w | 1855 | |
540 | alex-w | 1856 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
539 | alex-w | 1857 | $rq =& $this->db->query($query); |
1858 | if (PEAR::isError($this->db)) { |
||
1859 | $result["ERR"] = 1; |
||
1860 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1861 | } else { |
||
1862 | $result["ERR"] = 0; |
||
1863 | } |
||
1864 | |||
1865 | return $result; |
||
1866 | } |
||
540 | alex-w | 1867 | |
539 | alex-w | 1868 | /** |
463 | alex-w | 1869 | * Проверка пароля (из формы авторизации) |
1870 | * |
||
1871 | * @author Alexander Wolf |
||
1872 | * @category Core |
||
1873 | * |
||
1874 | * @param string $word |
||
1875 | * @return array |
||
1876 | */ |
||
368 | alex-w | 1877 | public function checkSign($word) { |
359 | alex-w | 1878 | $result = array(); |
1879 | |||
1880 | $sHash = $this->secure->encryptStr($word); |
||
1881 | $pwd = $this->getOption("passwd"); |
||
1882 | if ($sHash == $pwd["OptValue"]) { |
||
1883 | $result["ERR"] = 0; |
||
1884 | $result["Location"] = "manager.php"; |
||
1885 | setcookie($this->cookie, $sHash); |
||
1886 | } else { |
||
1887 | $result["ERR"] = 1; |
||
1888 | $result["ERRINFO"] = "Password not valid"; |
||
368 | alex-w | 1889 | $result["Location"] = "manager.php?error=1"; |
359 | alex-w | 1890 | } |
1891 | |||
1892 | return $result; |
||
358 | alex-w | 1893 | } |
357 | alex-w | 1894 | |
463 | alex-w | 1895 | /** |
1896 | * Проверка пароля (из cookies) |
||
1897 | * |
||
1898 | * @author Alexander Wolf |
||
1899 | * @category Core |
||
1900 | * |
||
1901 | * @param string $hash |
||
1902 | * @return array |
||
1903 | */ |
||
368 | alex-w | 1904 | public function checkCookieSign($hash) { |
359 | alex-w | 1905 | $result = array(); |
1906 | |||
1907 | $pwd = $this->getOption("passwd"); |
||
1908 | if ($hash == $pwd["OptValue"]) { |
||
1909 | $result["ERR"] = 0; |
||
1910 | } else { |
||
1911 | $result["ERR"] = 1; |
||
1912 | $result["ERRINFO"] = "Hash not valid"; |
||
368 | alex-w | 1913 | $result["Location"] = "manager.php"; |
359 | alex-w | 1914 | } |
1915 | |||
1916 | return $result; |
||
1917 | } |
||
1918 | |||
463 | alex-w | 1919 | /** |
1920 | * Форма ввода пароля |
||
1921 | * |
||
1922 | * @author Alexander Wolf |
||
1923 | * @category Core |
||
1924 | * |
||
1925 | * @return string |
||
1926 | */ |
||
368 | alex-w | 1927 | public function showSigninForm() { |
425 | alex-w | 1928 | $show = "<div id='regform'>"; |
1929 | $show .= "<form action='process.php' method='post'>\n"; |
||
368 | alex-w | 1930 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1931 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
||
427 | alex-w | 1932 | $show .= "<input type='password' name='word' value=''>\n"; |
368 | alex-w | 1933 | $show .= "<input type='submit' value=' Войти '>\n"; |
425 | alex-w | 1934 | $show .= "</fieldset>\n</form></div>\n"; |
368 | alex-w | 1935 | |
1936 | return $show; |
||
1937 | } |
||
1938 | |||
463 | alex-w | 1939 | /** |
1940 | * Обновление пароля |
||
1941 | * |
||
1942 | * @author Alexander Wolf |
||
1943 | * @category Core |
||
1944 | * |
||
1945 | * @param string $word1 |
||
1946 | * @param string $word2 |
||
1947 | * @return array |
||
1948 | */ |
||
368 | alex-w | 1949 | public function updatePassword($word1, $word2) { |
359 | alex-w | 1950 | $result = array(); |
1951 | |||
1952 | if ($word1 == $word2) { |
||
1953 | $sWord = $this->secure->encryptStr($word1); |
||
1954 | $r = $this->setOption("passwd", $sWord); |
||
1955 | $result = $r; |
||
1956 | } else { |
||
1957 | $result["ERR"] = 1; |
||
1958 | $result["ERRINFO"] = "Passwords is mismatch"; |
||
1959 | } |
||
1960 | |||
1961 | return $result; |
||
1962 | } |
||
1963 | |||
504 | alex-w | 1964 | /** |
509 | alex-w | 1965 | * Отображение формы создания и редактирования версии apt-дистрибутива |
504 | alex-w | 1966 | * |
1967 | * @author Alexander Wolf |
||
1968 | * @category Core |
||
1969 | * |
||
1970 | * @param string $name |
||
1971 | * @param string $actor |
||
1972 | * @param integer $versionID |
||
1973 | * @return string |
||
1974 | */ |
||
511 | alex-w | 1975 | public function showDistVersionsForm($versionID = 0, $info = '') { |
509 | alex-w | 1976 | $sVersionID = $this->secure->checkInt($versionID); |
511 | alex-w | 1977 | $sInfo = $this->secure->checkStr($info, 1); |
1978 | if ($sInfo == "") { |
||
1979 | $sInfo = "Версия дистрибутива"; |
||
1980 | } |
||
509 | alex-w | 1981 | if ($sVersionID != 0) { |
1982 | // Режим редактирования |
||
556 | alex-w | 1983 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'"; |
497 | alex-w | 1984 | $rq =& $this->db->query($query); |
1985 | $rq->fetchInto($element); |
||
509 | alex-w | 1986 | } |
1987 | |||
511 | alex-w | 1988 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
510 | alex-w | 1989 | if ($sVersionID != 0) { |
1990 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
||
1991 | } else { |
||
1992 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
||
1993 | } |
||
509 | alex-w | 1994 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1995 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
||
1996 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
||
1997 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
||
495 | alex-w | 1998 | |
504 | alex-w | 1999 | return $show; |
509 | alex-w | 2000 | } |
504 | alex-w | 2001 | |
520 | alex-w | 2002 | /** |
2003 | * Парсер схемы адреса репозитория |
||
2004 | * FIXME Возможно не потребуется |
||
2005 | * |
||
2006 | * @author Alexander Wolf |
||
2007 | * @category Core |
||
2008 | * |
||
2009 | * @param string $repstring |
||
2010 | * @return integer |
||
2011 | */ |
||
2012 | public function repositoryParser($repstring) { |
||
2013 | $tokens = array(); |
||
2014 | $sections = array(); |
||
2015 | $tokens = split(" ",$repstring); |
||
2016 | |||
2017 | if ($tokens[0] == "deb") { |
||
2018 | // debian/ubuntu репозиторий "type proto://host/folder distr sections" |
||
2019 | $url = parse_url($tokens[1]); |
||
2020 | $distr = $tokens[2]; |
||
2021 | |||
2022 | for($i=3;$i<count($tokens);$i++) { |
||
2023 | $sections[] = $tokens[$i]; |
||
2024 | } |
||
2025 | } else { |
||
2026 | // altlinux репозиторий "type [sign] proto://host/folder base repname" |
||
2027 | if (stripos($tokens[1],"]")!=0) { |
||
2028 | $sign = $tokens[1]; |
||
2029 | $url = parse_url($tokens[2]); |
||
2030 | $base = $tokens[3]; |
||
2031 | $repname = $tokens[4]; |
||
2032 | } else { |
||
2033 | $url = parse_url($tokens[1]); |
||
2034 | $base = $tokens[2]; |
||
2035 | $repname = $tokens[3]; |
||
2036 | } |
||
2037 | } |
||
2038 | |||
2039 | $proto = $url["scheme"]."://"; |
||
2040 | $addr = $url["host"]; |
||
2041 | if ($url["port"]!="") { |
||
2042 | $addr .= ":".$url["port"]; |
||
2043 | } |
||
2044 | $path = $url["path"]; |
||
2045 | |||
2046 | return 0; |
||
2047 | } |
||
2048 | |||
539 | alex-w | 2049 | /** |
2050 | * Выгрузка картинок логотипов дистрибутивов |
||
2051 | * |
||
2052 | * @author Alexander Wolf |
||
2053 | * @category Core |
||
2054 | * |
||
2055 | * @param string $path |
||
2056 | * @param string $dist |
||
2057 | * @param array $datafile |
||
2058 | * @return integer |
||
2059 | */ |
||
535 | alex-w | 2060 | public function uploadPicture($path, $dist, $datafile) { |
2061 | $folder = $path.$dist."-orig.png"; |
||
2062 | $folderN = $path.$dist.".png"; |
||
2063 | $folderEM = $path.$dist."-em.png"; |
||
2064 | |||
2065 | $distlogo = 0; |
||
2066 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
||
2067 | chmod($folder, 0644); |
||
2068 | list($width, $height) = GetImageSize($folder); |
||
2069 | $percent = 32/$height; |
||
2070 | $newwidth = $width * $percent; |
||
2071 | $newheight = $height * $percent; |
||
2072 | |||
2073 | $output = ImageCreateTrueColor($newwidth, $newheight); |
||
2074 | $source = ImageCreateFromPNG($folder); |
||
2075 | |||
2076 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
||
2077 | ImagePNG($output, $folderEM); |
||
2078 | |||
2079 | $percent = 15/$height; |
||
2080 | $newwidth = $width * $percent; |
||
2081 | $newheight = $height * $percent; |
||
2082 | |||
2083 | $output = ImageCreateTrueColor($newwidth, $newheight); |
||
2084 | |||
2085 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
||
2086 | ImagePNG($output, $folderN); |
||
2087 | |||
2088 | unlink($folder); |
||
2089 | $distlogo = 1; |
||
2090 | } |
||
2091 | return $distlogo; |
||
2092 | } |
||
547 | alex-w | 2093 | |
2094 | /** |
||
2095 | * Показ списка репозиториев |
||
2096 | * |
||
2097 | * @author Alexander Wolf |
||
2098 | * @category Core |
||
2099 | * |
||
2100 | * @param string $name |
||
2101 | * @param string $actor |
||
2102 | * @param string $format |
||
2103 | * @return string |
||
2104 | */ |
||
548 | alex-w | 2105 | public function showRepositoriesList($name, $actor, $format = 'list') { |
643 | alex-w | 2106 | $query = "SELECT r.*,rt.*,v.version_id,CONCAT(d.distname,' ',v.version,' “',v.vname,'”') AS fullname FROM ".$this->prefix."repository r "; |
548 | alex-w | 2107 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
629 | alex-w | 2108 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version "; |
641 | alex-w | 2109 | $query .= "JOIN ".$this->prefix."distribution d ON d.dist_id=v.dist_id "; |
629 | alex-w | 2110 | $query .= "ORDER BY v.version_id,r.rep_id ASC"; |
548 | alex-w | 2111 | $rq =& $this->db->query($query); |
639 | alex-w | 2112 | $show = "<ul><li class='nomarker'></li>"; |
630 | alex-w | 2113 | $splitter = 0; |
548 | alex-w | 2114 | while ($rq->fetchInto($element)) { |
630 | alex-w | 2115 | if ($splitter != $this->secure->checkInt($element["version_id"])) { |
2116 | $splitter = $this->secure->checkInt($element["version_id"]); |
||
645 | alex-w | 2117 | $show .= "</ul><ul><li class='nomarker'><strong>Репозитории для ".$this->secure->checkStr($element["fullname"],1)."</strong></li>"; |
630 | alex-w | 2118 | } |
634 | alex-w | 2119 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["rep_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["rep_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["repname"],1)." (<em>".$this->secure->checkStr($element["rtype"],1)."</em>)</li>\n"; |
548 | alex-w | 2120 | } |
2121 | $show .= "</ul>"; |
||
547 | alex-w | 2122 | return $show; |
2123 | } |
||
2124 | |||
2125 | /** |
||
558 | alex-w | 2126 | * Вывод списка типов репозиториев |
2127 | * |
||
2128 | * @author Alexander Wolf |
||
2129 | * @category Core |
||
2130 | * |
||
2131 | * @param integer $reptype |
||
2132 | * @param string $name |
||
2133 | * @return string |
||
2134 | */ |
||
2135 | public function showRepType($reptype = 0, $name = "") { |
||
2136 | $sRT = $this->secure->checkInt($reptype); |
||
2137 | $sNM = $this->secure->checkStr($name,1); |
||
559 | alex-w | 2138 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
558 | alex-w | 2139 | $rq =& $this->db->query($query); |
2140 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
||
2141 | while ($rq->fetchInto($element)) { |
||
2142 | if ($element["rtype_id"]==$sRT) { |
||
2143 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
||
2144 | } else { |
||
2145 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
||
2146 | } |
||
2147 | } |
||
2148 | $show .= "</select>"; |
||
2149 | |||
2150 | return $show; |
||
2151 | } |
||
2152 | |||
623 | alex-w | 2153 | /** |
2154 | * Вывод списка версий дистрибутивов |
||
2155 | * |
||
2156 | * @author Alexander Wolf |
||
2157 | * @category Core |
||
2158 | * |
||
2159 | * @param string $name |
||
2160 | * @param integer $versionID |
||
2161 | * @return string |
||
2162 | */ |
||
591 | alex-w | 2163 | public function showVDList($name, $versionID = 0) { |
592 | alex-w | 2164 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
591 | alex-w | 2165 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
2166 | $rq =& $this->db->query($query); |
||
2167 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
2168 | while ($rq->fetchInto($element)) { |
||
592 | alex-w | 2169 | if ($element["version_id"]==$versionID) { |
2170 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
||
2171 | } else { |
||
2172 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
||
2173 | } |
||
591 | alex-w | 2174 | } |
2175 | $show .= "</select>"; |
||
2176 | return $show; |
||
2177 | } |
||
2178 | |||
558 | alex-w | 2179 | /** |
547 | alex-w | 2180 | * Форма создания/редактирвоания репозиториев |
2181 | * |
||
2182 | * @author Alexander Wolf |
||
2183 | * @category Core |
||
2184 | * |
||
2185 | * @param integer $repID |
||
2186 | * @param string $info |
||
2187 | * @param string $reptype |
||
2188 | * @return string |
||
2189 | */ |
||
594 | alex-w | 2190 | public function showRepositoriesForm($repID = 0, $info = "") { |
556 | alex-w | 2191 | $sRepID = $this->secure->checkInt($repID); |
594 | alex-w | 2192 | $sInfo = $this->secure->checkStr($info, 1); |
556 | alex-w | 2193 | if ($sInfo == "") { |
2194 | $sInfo = "Репозиторий"; |
||
2195 | } |
||
2196 | if ($sRepID != 0) { |
||
2197 | // Режим редактирования |
||
591 | alex-w | 2198 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
556 | alex-w | 2199 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
2200 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
||
2201 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
||
2202 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
||
2203 | $rq =& $this->db->query($query); |
||
594 | alex-w | 2204 | $rq->fetchInto($element); |
556 | alex-w | 2205 | } |
2206 | |||
594 | alex-w | 2207 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
609 | alex-w | 2208 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
626 | alex-w | 2209 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value=\"".$this->secure->checkStr($element["repname"],1)."\"></div>\n"; |
2210 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value=\"".$this->secure->checkStr($element["repinfo"],1)."\"></div>\n"; |
||
2211 | $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value=\"".$this->secure->checkStr($element["repkey"],1)."\"></div>\n"; |
||
576 | alex-w | 2212 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
588 | alex-w | 2213 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
604 | alex-w | 2214 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
558 | alex-w | 2215 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
564 | alex-w | 2216 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
569 | alex-w | 2217 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
613 | alex-w | 2218 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
595 | alex-w | 2219 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
556 | alex-w | 2220 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
593 | alex-w | 2221 | |
547 | alex-w | 2222 | return $show; |
2223 | } |
||
598 | alex-w | 2224 | |
2225 | /** |
||
2226 | * Добавление нового репозитория |
||
2227 | * |
||
2228 | * @author Alexander Wolf |
||
2229 | * @category Core |
||
2230 | * |
||
2231 | * @param integer $verionID |
||
2232 | * @param string $rname |
||
2233 | * @param string $rinfo |
||
2234 | * @param string $rkey |
||
2235 | * @param integer $proto |
||
2236 | * @param integer $rhost |
||
2237 | * @param integer $rfolder |
||
2238 | * @param integer $rtype |
||
2239 | * @param array $sections |
||
2240 | * @param array $arch |
||
2241 | * @param integer $scheme |
||
2242 | * @param integer $sign |
||
2243 | * @return array |
||
2244 | */ |
||
612 | alex-w | 2245 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
598 | alex-w | 2246 | $result = array(); |
2247 | $sVersionID = $this->secure->checkInt($verionID); |
||
2248 | $sRName = $this->secure->checkStr($rname); |
||
2249 | $sRInfo = $this->secure->checkStr($rinfo); |
||
2250 | $sRKey = $this->secure->checkStr($rkey); |
||
2251 | $sProto = $this->secure->checkInt($proto); |
||
2252 | $sRHost = $this->secure->checkInt($rhost); |
||
2253 | $sRFolder = $this->secure->checkInt($rfolder); |
||
2254 | $sRType = $this->secure->checkInt($rtype); |
||
2255 | $sRScheme = $this->secure->checkInt($scheme); |
||
2256 | $sRSign = $this->secure->checkInt($sign); |
||
2257 | |||
602 | alex-w | 2258 | $query = "INSERT INTO ".$this->prefix."repository SET proto_id='".$sProto."', rhost_id='".$sRHost."', rfolder_id='".$sRFolder."', version='".$sVersionID."', rtype_id='".$sRType."', scheme_id='".$sRScheme."', sign_id='".$sRSign."', repname='".$sRName."', repinfo='".$sRInfo."', repkey='".$sRKey."'"; |
598 | alex-w | 2259 | $rq =& $this->db->query($query); |
2260 | |||
2261 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
||
2262 | $rq =& $this->db->query($query); |
||
2263 | $rq->fetchInto($repository); |
||
2264 | |||
2265 | for($i=0;$i<count($sections);$i++) { |
||
2266 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
||
2267 | $rq =& $this->db->query($query); |
||
2268 | } |
||
2269 | |||
2270 | for($i=0;$i<count($arch);$i++) { |
||
2271 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
||
2272 | $rq =& $this->db->query($query); |
||
2273 | } |
||
2274 | |||
2275 | if (PEAR::isError($this->db)) { |
||
2276 | $result["ERR"] = 1; |
||
2277 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2278 | } else { |
||
2279 | $result["ERR"] = 0; |
||
2280 | } |
||
2281 | |||
2282 | return $result; |
||
2283 | } |
||
618 | alex-w | 2284 | |
2285 | /** |
||
2286 | * Обновление информации о репозитории |
||
2287 | * |
||
2288 | * @author Alexander Wolf |
||
2289 | * @category Core |
||
2290 | * |
||
2291 | * @param integer $repID |
||
2292 | * @param integer $verionID |
||
2293 | * @param string $rname |
||
2294 | * @param string $rinfo |
||
2295 | * @param string $rkey |
||
2296 | * @param integer $proto |
||
2297 | * @param integer $rhost |
||
2298 | * @param integer $rfolder |
||
2299 | * @param integer $rtype |
||
2300 | * @param array $sections |
||
2301 | * @param array $arch |
||
2302 | * @param integer $scheme |
||
2303 | * @param integer $sign |
||
2304 | * @return array |
||
2305 | */ |
||
2306 | public function updateRepository($repID, $verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
||
2307 | $result = array(); |
||
2308 | $sRepID = $this->secure->checkInt($repID); |
||
2309 | $sVersionID = $this->secure->checkInt($verionID); |
||
2310 | $sRName = $this->secure->checkStr($rname); |
||
2311 | $sRInfo = $this->secure->checkStr($rinfo); |
||
2312 | $sRKey = $this->secure->checkStr($rkey); |
||
2313 | $sProto = $this->secure->checkInt($proto); |
||
2314 | $sRHost = $this->secure->checkInt($rhost); |
||
2315 | $sRFolder = $this->secure->checkInt($rfolder); |
||
2316 | $sRType = $this->secure->checkInt($rtype); |
||
2317 | $sRScheme = $this->secure->checkInt($scheme); |
||
2318 | $sRSign = $this->secure->checkInt($sign); |
||
2319 | |||
2320 | $query = "UPDATE ".$this->prefix."repository SET proto_id='".$sProto."', rhost_id='".$sRHost."', rfolder_id='".$sRFolder."', version='".$sVersionID."', rtype_id='".$sRType."', scheme_id='".$sRScheme."', sign_id='".$sRSign."', repname='".$sRName."', repinfo='".$sRInfo."', repkey='".$sRKey."' WHERE rep_id='".$sRepID."'"; |
||
2321 | $rq =& $this->db->query($query); |
||
2322 | |||
2323 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
||
2324 | $rq =& $this->db->query($query); |
||
2325 | for($i=0;$i<count($sections);$i++) { |
||
2326 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$sRepID."', sect_id='".$sections[$i]."'"; |
||
2327 | $rq =& $this->db->query($query); |
||
2328 | } |
||
2329 | |||
2330 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
||
2331 | $rq =& $this->db->query($query); |
||
2332 | for($i=0;$i<count($arch);$i++) { |
||
2333 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$sRepID."', arch_id='".$arch[$i]."'"; |
||
2334 | $rq =& $this->db->query($query); |
||
2335 | } |
||
2336 | |||
2337 | if (PEAR::isError($this->db)) { |
||
2338 | $result["ERR"] = 1; |
||
2339 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2340 | } else { |
||
2341 | $result["ERR"] = 0; |
||
2342 | } |
||
2343 | |||
2344 | return $result; |
||
2345 | } |
||
2346 | |||
2347 | /** |
||
2348 | * Удаление информации о репозитории |
||
2349 | * |
||
2350 | * @author Alexander Wolf |
||
2351 | * @category Core |
||
2352 | * |
||
2353 | * @param integer $repID |
||
2354 | * @return array |
||
2355 | */ |
||
2356 | public function dropRepository($repID) { |
||
2357 | $result = array(); |
||
2358 | $sRepID = $this->secure->checkInt($repID); |
||
2359 | |||
2360 | // Удаление репозитория |
||
2361 | $query = "DELETE FROM ".$this->prefix."repository WHERE rep_id='".$sRepID."'"; |
||
2362 | $rq =& $this->db->query($query); |
||
2363 | if (PEAR::isError($this->db)) { |
||
2364 | $result["ERR"] = 1; |
||
2365 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2366 | } else { |
||
2367 | $result["ERR"] = 0; |
||
2368 | } |
||
2369 | |||
2370 | // Удаление секций репозитория |
||
2371 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
||
2372 | $rq =& $this->db->query($query); |
||
2373 | if (PEAR::isError($this->db)) { |
||
2374 | $result["ERR"] = 1; |
||
2375 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2376 | } else { |
||
2377 | $result["ERR"] = 0; |
||
2378 | } |
||
2379 | |||
2380 | // Удаление архитектур репозитория |
||
2381 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
||
2382 | $rq =& $this->db->query($query); |
||
2383 | if (PEAR::isError($this->db)) { |
||
2384 | $result["ERR"] = 1; |
||
2385 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2386 | } else { |
||
2387 | $result["ERR"] = 0; |
||
2388 | } |
||
2389 | |||
2390 | return $result; |
||
2391 | } |
||
684 | alex-w | 2392 | |
685 | alex-w | 2393 | /** |
2394 | * Вывод списка настроек |
||
2395 | * |
||
2396 | * @author Alexander Wolf |
||
2397 | * @category Core |
||
2398 | * |
||
2399 | * @param string $name |
||
2400 | * @param string $actor |
||
2401 | * @param string $format |
||
2402 | * @return string |
||
2403 | */ |
||
684 | alex-w | 2404 | public function showSettingsList($name, $actor, $format = 'list') { |
2405 | $query = "SELECT * FROM ".$this->prefix."settings"; |
||
2406 | $rq =& $this->db->query($query); |
||
2407 | $show = "<ul>\n"; |
||
688 | alex-w | 2408 | $show .= "<li><a href='".$actor."?mode=".$name."&action=update-password' class='edit'>Изменить пароль доступа</a></li>\n"; |
684 | alex-w | 2409 | $show .= "</ul>"; |
685 | alex-w | 2410 | |
2411 | return $show; |
||
684 | alex-w | 2412 | } |
688 | alex-w | 2413 | |
2414 | /** |
||
2415 | * Форма обновления пароля |
||
2416 | * |
||
2417 | * @author Alexander Wolf |
||
2418 | * @category Core |
||
2419 | * |
||
2420 | * @return string |
||
2421 | */ |
||
2422 | public function showUpdatePasswordForm() { |
||
2423 | $show .= "<fieldset><legend>Обновление пароля доступа</legend>\n"; |
||
2424 | $show .= "<div class='inputbox'><label for='oword'>Текущий пароль:</label> <input type='password' name='oword' value=''></div>\n"; |
||
2425 | $show .= "<div class='inputbox'><label for='nword'>Новый пароль:</label> <input type='password' name='nword' value=''></div>\n"; |
||
2426 | $show .= "<div class='inputbox'><label for='again'>Повторно:</label> <input type='password' name='again' value=''></div>\n"; |
||
2427 | $show .= "<input type='submit' value=' Войти '>\n"; |
||
2428 | $show .= "</fieldset>\n\n"; |
||
2429 | |||
2430 | return $show; |
||
2431 | } |
||
560 | alex-w | 2432 | |
304 | alex-w | 2433 | } |
2434 | |||
356 | alex-w | 2435 | ?> |