Редакция 694 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | 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"; |
694 | alex-w | 613 | $show .= "# Этот sources.list сгенерирован при помощи ".$this->getEngineAttr('codename')." ".$this->getEngineAttr('version')."\n"; |
691 | alex-w | 614 | $show .= "# Адрес проекта: http://alex-w.org.ru/p/ant\n\n"; |
646 | alex-w | 615 | |
616 | // Извлекаем информацию о репозиториях и строим sources.list |
||
617 | if ($dist["type"]=="deb") { |
||
618 | // Базовый репозиторий |
||
619 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
620 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
621 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
651 | alex-w | 622 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
646 | alex-w | 623 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
624 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
625 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
650 | alex-w | 626 | $query .= "WHERE v.version_id='".$data["version_id"]."' AND r.rtype_id='1'"; |
646 | alex-w | 627 | $rq =& $this->db->query($query); |
675 | alex-w | 628 | if ($rq->numRows()>0) { |
629 | $rq->fetchInto($base); |
||
630 | // Формируем type proto://host/folder |
||
631 | $show .= "# ".$this->secure->checkStr($base["repinfo"],1)."\n"; |
||
632 | if ($base["repkey"]!="") { |
||
633 | $show .= "# Установка ключа: ".$this->secure->checkStr($base["repkey"],1)."\n"; |
||
634 | } |
||
635 | $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); |
||
636 | $dvname = str_replace("{DIST}",$this->secure->checkStr($dist["vcodename"],1),$this->secure->checkStr($base["scheme"],1)); |
||
637 | // Формируем distname |
||
638 | $show .= " ".$dvname." "; |
||
639 | // Формируем sections |
||
640 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
641 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
642 | $query .= "WHERE r.rep_id='".$base["rep_id"]."' AND ("; |
||
643 | for($i=0;$i<count($data["section"]);$i++) { |
||
644 | $query .= "s.sect_id='".$data["section"][$i]."' "; |
||
645 | if ($i<count($data["section"])-1) { |
||
646 | $query .= " OR "; |
||
647 | } |
||
648 | } |
||
649 | $query .= ")"; |
||
650 | $rq =& $this->db->query($query); |
||
651 | while ($rq->fetchInto($sections)) { |
||
652 | $show .= $sections["secname"]." "; |
||
653 | } |
||
654 | $show .= "\n\n"; |
||
670 | alex-w | 655 | } |
655 | alex-w | 656 | |
676 | alex-w | 657 | if (count($data["repository"])>0) { |
658 | // Репозитории обновлений и третьих лиц |
||
659 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
660 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
661 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
662 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
||
663 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
||
664 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
665 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
666 | $query .= "WHERE r.rtype_id>'1' AND ("; |
||
667 | for($i=0;$i<count($data["repository"]);$i++) { |
||
668 | $query .= "r.rep_id='".$data["repository"][$i]."' "; |
||
669 | if ($i<count($data["repository"])-1) { |
||
670 | $query .= " OR "; |
||
671 | } |
||
656 | alex-w | 672 | } |
676 | alex-w | 673 | $query .= ") ORDER BY r.rtype_id ASC"; |
674 | $req =& $this->db->query($query); |
||
675 | |||
675 | alex-w | 676 | while ($req->fetchInto($updates)) { |
677 | // Формируем type proto://host/folder |
||
678 | $show .= "# ".$this->secure->checkStr($updates["repinfo"],1)."\n"; |
||
679 | if ($updates["repkey"]!="") { |
||
680 | $show .= "# Установка ключа: ".$this->secure->checkStr($updates["repkey"],1)."\n"; |
||
681 | } |
||
682 | $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); |
||
683 | $dvname = str_replace("{DIST}",$this->secure->checkStr($dist["vcodename"],1),$this->secure->checkStr($updates["scheme"],1)); |
||
684 | // Формируем distname |
||
685 | $show .= " ".$dvname." "; |
||
686 | // Формируем sections |
||
687 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
688 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
689 | $query .= "WHERE r.rep_id='".$updates["rep_id"]."'"; |
||
690 | $rq =& $this->db->query($query); |
||
691 | while ($rq->fetchInto($sections)) { |
||
692 | $show .= $sections["secname"]." "; |
||
693 | } |
||
694 | $show .= "\n\n"; |
||
670 | alex-w | 695 | } |
675 | alex-w | 696 | $show .= "\n"; |
655 | alex-w | 697 | } |
668 | alex-w | 698 | } else { |
699 | // Базовый репозиторий |
||
700 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
701 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
702 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
703 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
||
704 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
||
705 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
706 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
707 | $query .= "WHERE v.version_id='".$data["version_id"]."' AND r.rtype_id='1'"; |
||
708 | $rq =& $this->db->query($query); |
||
675 | alex-w | 709 | if ($rq->numRows()>0) { |
710 | $rq->fetchInto($base); |
||
711 | // Формируем type proto://host/folder |
||
712 | $show .= "# ".$this->secure->checkStr($base["repinfo"],1)."\n"; |
||
713 | $show .= $this->secure->checkStr($dist["type"],1)." "; |
||
714 | if ($base["sign_id"]!=0) { |
||
715 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$base["sign_id"]."'"; |
||
716 | $rq =& $this->db->query($query); |
||
717 | $rq->fetchInto($sign); |
||
718 | $show .= "[".$this->secure->checkStr($sign["sname"],1)."] "; |
||
719 | } |
||
720 | $show .= $this->secure->checkStr($base["proto"],1).$this->secure->checkStr($base["rhost"],1).$this->secure->checkStr($base["rfolder"],1)." "; |
||
721 | $show .= $this->secure->checkStr($base["scheme"],1)." "; |
||
646 | alex-w | 722 | |
675 | alex-w | 723 | // Формируем sections |
724 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
725 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
726 | $query .= "WHERE r.rep_id='".$base["rep_id"]."' AND ("; |
||
727 | for($i=0;$i<count($data["section"]);$i++) { |
||
728 | $query .= "s.sect_id='".$data["section"][$i]."' "; |
||
729 | if ($i<count($data["section"])-1) { |
||
730 | $query .= " OR "; |
||
731 | } |
||
732 | } |
||
733 | $query .= ")"; |
||
734 | $rq =& $this->db->query($query); |
||
735 | while ($rq->fetchInto($sections)) { |
||
736 | $show .= $sections["secname"]." "; |
||
737 | } |
||
738 | $show .= "\n\n"; |
||
668 | alex-w | 739 | } |
740 | |||
677 | alex-w | 741 | if (count($data["repository"])>0) { |
742 | // Репозитории обновлений и третьих лиц |
||
743 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
||
744 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
||
745 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
||
746 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id "; |
||
747 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
||
748 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
||
749 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
||
750 | $query .= "WHERE r.rtype_id>'1' AND ("; |
||
751 | for($i=0;$i<count($data["repository"]);$i++) { |
||
752 | $query .= "r.rep_id='".$data["repository"][$i]."' "; |
||
753 | if ($i<count($data["repository"])-1) { |
||
754 | $query .= " OR "; |
||
755 | } |
||
668 | alex-w | 756 | } |
677 | alex-w | 757 | $query .= ") ORDER BY r.rtype_id ASC"; |
758 | $req =& $this->db->query($query); |
||
759 | |||
675 | alex-w | 760 | while ($req->fetchInto($updates)) { |
761 | // Формируем type proto://host/folder |
||
762 | $show .= "# ".$this->secure->checkStr($updates["repinfo"],1)."\n"; |
||
763 | $show .= $this->secure->checkStr($dist["type"],1)." "; |
||
764 | if ($updates["sign_id"]!=0) { |
||
765 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$base["sign_id"]."'"; |
||
766 | $rqs =& $this->db->query($query); |
||
767 | $rqs->fetchInto($sign); |
||
768 | $show .= "[".$this->secure->checkStr($sign["sname"],1)."] "; |
||
769 | } |
||
770 | $show .= $this->secure->checkStr($updates["proto"],1).$this->secure->checkStr($updates["rhost"],1).$this->secure->checkStr($updates["rfolder"],1)." "; |
||
771 | $show .= $this->secure->checkStr($updates["scheme"],1)." "; |
||
772 | // Формируем sections |
||
773 | $query = "SELECT * FROM ".$this->prefix."section s "; |
||
774 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
||
775 | $query .= "WHERE r.rep_id='".$updates["rep_id"]."'"; |
||
776 | $rq =& $this->db->query($query); |
||
777 | while ($rq->fetchInto($sections)) { |
||
778 | $show .= $sections["secname"]." "; |
||
779 | } |
||
780 | $show .= "\n\n"; |
||
668 | alex-w | 781 | } |
675 | alex-w | 782 | $show .= "\n"; |
668 | alex-w | 783 | } |
646 | alex-w | 784 | } |
785 | |||
668 | alex-w | 786 | $HTTPHeader1 = "Content-length: ".strlen($show); |
787 | $HTTPHeader2 = "Content-disposition: attachment; filename=sources.list\n\n"; |
||
788 | |||
789 | header($HTTPHeader1); |
||
790 | header($HTTPHeader2); |
||
628 | alex-w | 791 | return $show; |
358 | alex-w | 792 | } |
522 | alex-w | 793 | |
463 | alex-w | 794 | /** |
522 | alex-w | 795 | * Показывает список секций |
796 | * |
||
797 | * @author Alexander Wolf |
||
798 | * @category Core |
||
799 | * |
||
800 | * @param string $name |
||
801 | * @param string $actor |
||
561 | alex-w | 802 | * @param string $format |
522 | alex-w | 803 | * @return string |
804 | */ |
||
560 | alex-w | 805 | public function showSectionsList($name, $actor, $format = 'html') { |
806 | switch($format) { |
||
807 | case 'html': |
||
561 | alex-w | 808 | $query = "SELECT * FROM ".$this->prefix."section"; |
809 | $rq =& $this->db->query($query); |
||
560 | alex-w | 810 | $show = "<ul>\n"; |
811 | while ($rq->fetchInto($element)) { |
||
812 | $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"; |
||
813 | } |
||
814 | $show .= "</ul>"; |
||
815 | break; |
||
816 | case 'innerhtml': |
||
817 | $show = ""; |
||
561 | alex-w | 818 | $repID = $this->secure->checkInt($actor); |
819 | if ($repID==0) { |
||
820 | $query = "SELECT * FROM ".$this->prefix."section"; |
||
821 | $rq =& $this->db->query($query); |
||
822 | while ($rq->fetchInto($element)) { |
||
567 | alex-w | 823 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 824 | } |
825 | } else { |
||
826 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
||
827 | $rq =& $this->db->query($query); |
||
828 | while ($rq->fetchInto($element)) { |
||
567 | alex-w | 829 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 830 | } |
831 | $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 | 832 | $rq =& $this->db->query($query); |
561 | alex-w | 833 | while ($rq->fetchInto($element)) { |
567 | alex-w | 834 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 835 | } |
836 | } |
||
837 | |||
560 | alex-w | 838 | break; |
522 | alex-w | 839 | } |
840 | |||
841 | return $show; |
||
842 | } |
||
843 | |||
523 | alex-w | 844 | /** |
845 | * Вывод формы редактирования/добавления секций |
||
846 | * |
||
847 | * @author Alexander Wolf |
||
848 | * @category Core |
||
849 | * |
||
850 | * @param integer $sectionID |
||
851 | * @param string $info |
||
852 | * @return string |
||
853 | */ |
||
854 | public function showSectionsForm($sectionID = 0, $info = "") { |
||
522 | alex-w | 855 | $sSectID = $this->secure->checkInt($sectionID); |
856 | $sInfo = $this->secure->checkStr($info, 1); |
||
857 | if ($sInfo == "") { |
||
858 | $sInfo = "Секция"; |
||
859 | } |
||
860 | if ($sSectID != 0) { |
||
861 | // Режим редактирования |
||
862 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
||
863 | $rq =& $this->db->query($query); |
||
864 | $rq->fetchInto($element); |
||
865 | } |
||
866 | |||
867 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
868 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
||
869 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
||
870 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
871 | |||
872 | return $show; |
||
873 | } |
||
874 | |||
875 | /** |
||
523 | alex-w | 876 | * Обновление информации о секции |
877 | * |
||
878 | * @author Alexander Wolf |
||
879 | * @category Core |
||
880 | * |
||
881 | * @param integer $sectionID |
||
882 | * @param string $sname |
||
883 | * @param string $sinfo |
||
884 | * @return array |
||
885 | */ |
||
886 | public function updateSection($sectionID, $sname, $sinfo = "") { |
||
887 | $result = array(); |
||
888 | $sSectID = $this->secure->checkInt($sectionID); |
||
579 | alex-w | 889 | $sSName = $this->secure->checkStr($sname); |
890 | $sSInfo = $this->secure->checkStr($sinfo); |
||
523 | alex-w | 891 | |
892 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
||
893 | $rq =& $this->db->query($query); |
||
894 | if (PEAR::isError($this->db)) { |
||
895 | $result["ERR"] = 1; |
||
896 | $result["ERRINFO"] = $this->db->getMessage(); |
||
897 | } else { |
||
898 | $result["ERR"] = 0; |
||
899 | } |
||
900 | |||
901 | return $result; |
||
902 | } |
||
903 | |||
904 | /** |
||
905 | * Удаление информации о секции |
||
906 | * |
||
907 | * @author Alexander Wolf |
||
908 | * @category Core |
||
909 | * |
||
910 | * @param integer $sectionID |
||
911 | * @return array |
||
912 | */ |
||
913 | public function dropSection($sectionID) { |
||
914 | $result = array(); |
||
915 | $sSectID = $this->secure->checkInt($sectionID); |
||
916 | |||
917 | // Удаление секции |
||
918 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
||
919 | $rq =& $this->db->query($query); |
||
920 | if (PEAR::isError($this->db)) { |
||
921 | $result["ERR"] = 1; |
||
922 | $result["ERRINFO"] = $this->db->getMessage(); |
||
923 | } else { |
||
924 | $result["ERR"] = 0; |
||
925 | } |
||
926 | |||
927 | return $result; |
||
928 | } |
||
929 | |||
930 | /** |
||
931 | * Добавление новой секции |
||
932 | * |
||
933 | * @author Alexander Wolf |
||
934 | * @category Core |
||
935 | * |
||
936 | * @param string $sname |
||
937 | * @param string $sinfo |
||
938 | * @return array |
||
939 | */ |
||
940 | public function addSection($sname, $sinfo = "") { |
||
941 | $result = array(); |
||
582 | alex-w | 942 | $sSName = $this->secure->checkStr($sname); |
943 | $sSInfo = $this->secure->checkStr($sinfo); |
||
523 | alex-w | 944 | |
945 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
||
946 | $rq =& $this->db->query($query); |
||
947 | if (PEAR::isError($this->db)) { |
||
948 | $result["ERR"] = 1; |
||
949 | $result["ERRINFO"] = $this->db->getMessage(); |
||
950 | } else { |
||
951 | $result["ERR"] = 0; |
||
952 | } |
||
953 | |||
954 | return $result; |
||
955 | } |
||
956 | |||
957 | /** |
||
568 | alex-w | 958 | * Вывод списка поддерживаемых архитектур |
959 | * |
||
960 | * @author Alexander Wolf |
||
961 | * @category Core |
||
962 | * |
||
963 | * @param string $name |
||
964 | * @param string $actor |
||
965 | * @param string $format |
||
966 | * @return string |
||
967 | */ |
||
968 | public function showArchList($name, $actor, $format = 'list') { |
||
969 | switch($format) { |
||
970 | case 'list': |
||
971 | $query = "SELECT * FROM ".$this->prefix."arch"; |
||
972 | $rq =& $this->db->query($query); |
||
973 | $show = "<ul>\n"; |
||
974 | while ($rq->fetchInto($element)) { |
||
975 | $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"; |
||
976 | } |
||
977 | $show .= "</ul>"; |
||
978 | break; |
||
979 | case 'innerhtml': |
||
980 | $show = ""; |
||
981 | $repID = $this->secure->checkInt($actor); |
||
614 | alex-w | 982 | if ($repID==0) { |
568 | alex-w | 983 | $query = "SELECT * FROM ".$this->prefix."arch"; |
984 | $rq =& $this->db->query($query); |
||
985 | while ($rq->fetchInto($element)) { |
||
986 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
||
987 | } |
||
988 | } else { |
||
989 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
||
990 | $rq =& $this->db->query($query); |
||
991 | while ($rq->fetchInto($element)) { |
||
992 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
||
993 | } |
||
994 | $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')"; |
||
995 | $rq =& $this->db->query($query); |
||
610 | alex-w | 996 | if ($rq->numRows()>0) { |
997 | while ($rq->fetchInto($element)) { |
||
998 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
||
999 | } |
||
568 | alex-w | 1000 | } |
1001 | } |
||
1002 | break; |
||
1003 | } |
||
1004 | return $show; |
||
1005 | } |
||
1006 | |||
1007 | /** |
||
1008 | * Добавление новой архитектуры |
||
1009 | * |
||
1010 | * @author Alexander Wolf |
||
1011 | * @category Core |
||
1012 | * |
||
1013 | * @param string $arch |
||
1014 | * @return array |
||
1015 | */ |
||
1016 | public function addArch($arch) { |
||
1017 | $result = array(); |
||
582 | alex-w | 1018 | $sArch = $this->secure->checkStr($arch); |
568 | alex-w | 1019 | |
1020 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
||
1021 | $rq =& $this->db->query($query); |
||
1022 | if (PEAR::isError($this->db)) { |
||
1023 | $result["ERR"] = 1; |
||
1024 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1025 | } else { |
||
1026 | $result["ERR"] = 0; |
||
1027 | } |
||
1028 | |||
1029 | return $result; |
||
1030 | } |
||
1031 | |||
1032 | /** |
||
1033 | * Удаление информации об архитектуре |
||
1034 | * |
||
1035 | * @author Alexander Wolf |
||
1036 | * @category Core |
||
1037 | * |
||
1038 | * @param integer $archID |
||
1039 | * @return array |
||
1040 | */ |
||
1041 | public function dropArch($archID) { |
||
1042 | $result = array(); |
||
1043 | $sArchID = $this->secure->checkInt($archID); |
||
1044 | |||
1045 | // Удаление архитектуры |
||
1046 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
||
1047 | $rq =& $this->db->query($query); |
||
1048 | if (PEAR::isError($this->db)) { |
||
1049 | $result["ERR"] = 1; |
||
1050 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1051 | } else { |
||
1052 | $result["ERR"] = 0; |
||
1053 | } |
||
1054 | |||
1055 | // Удаление архитектуры из списка репозиториев |
||
1056 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
||
1057 | $rq =& $this->db->query($query); |
||
1058 | if (PEAR::isError($this->db)) { |
||
1059 | $result["ERR"] = 1; |
||
1060 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1061 | } else { |
||
1062 | $result["ERR"] = 0; |
||
1063 | } |
||
1064 | return $result; |
||
1065 | } |
||
1066 | |||
1067 | /** |
||
1068 | * Обновление информации об архитектуре |
||
1069 | * |
||
1070 | * @author Alexander Wolf |
||
1071 | * @category Core |
||
1072 | * |
||
1073 | * @param integer $archID |
||
1074 | * @param string $arch |
||
1075 | * @return array |
||
1076 | */ |
||
1077 | public function updateArch($archID, $arch) { |
||
1078 | $result = array(); |
||
1079 | $sArchID = $this->secure->checkInt($archID); |
||
579 | alex-w | 1080 | $sArch = $this->secure->checkStr($arch); |
568 | alex-w | 1081 | |
1082 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
||
1083 | $rq =& $this->db->query($query); |
||
1084 | if (PEAR::isError($this->db)) { |
||
1085 | $result["ERR"] = 1; |
||
1086 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1087 | } else { |
||
1088 | $result["ERR"] = 0; |
||
1089 | } |
||
1090 | |||
1091 | return $result; |
||
1092 | } |
||
1093 | |||
1094 | /** |
||
1095 | * Вывод формы редактирования/добавления архитектур |
||
1096 | * |
||
1097 | * @author Alexander Wolf |
||
1098 | * @category Core |
||
1099 | * |
||
1100 | * @param integer $archID |
||
1101 | * @param string $info |
||
1102 | * @return string |
||
1103 | */ |
||
1104 | public function showArchForm($archID = 0, $info = "") { |
||
1105 | $sArchID = $this->secure->checkInt($archID); |
||
1106 | $sInfo = $this->secure->checkStr($info, 1); |
||
1107 | if ($sInfo == "") { |
||
1108 | $sInfo = "Архитектура"; |
||
1109 | } |
||
1110 | if ($sArchID != 0) { |
||
1111 | // Режим редактирования |
||
1112 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
||
1113 | $rq =& $this->db->query($query); |
||
1114 | $rq->fetchInto($element); |
||
1115 | } |
||
1116 | |||
1117 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1118 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
||
1119 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1120 | |||
1121 | return $show; |
||
1122 | } |
||
1123 | |||
1124 | /** |
||
570 | alex-w | 1125 | * Вывод списка схем репозиториев |
1126 | * |
||
1127 | * @author Alexander Wolf |
||
1128 | * @category Core |
||
1129 | * |
||
1130 | * @param string $name |
||
1131 | * @param string $actor |
||
1132 | * @param string $format |
||
1133 | * @return string |
||
1134 | */ |
||
1135 | public function showSchemeList($name, $actor, $format = 'list') { |
||
1136 | switch($format) { |
||
1137 | case 'list': |
||
1138 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
||
1139 | $rq =& $this->db->query($query); |
||
1140 | $show = "<ul>\n"; |
||
1141 | while ($rq->fetchInto($element)) { |
||
1142 | $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"; |
||
1143 | } |
||
1144 | $show .= "</ul>"; |
||
1145 | break; |
||
1146 | case 'innerhtml': |
||
611 | alex-w | 1147 | $schemeID = $this->secure->checkInt($actor); |
570 | alex-w | 1148 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
1149 | $rq =& $this->db->query($query); |
||
1150 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1151 | while ($rq->fetchInto($element)) { |
||
611 | alex-w | 1152 | if ($element["scheme_id"]==$schemeID) { |
570 | alex-w | 1153 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
1154 | } else { |
||
611 | alex-w | 1155 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
570 | alex-w | 1156 | } |
1157 | } |
||
1158 | $show .= "</select>"; |
||
1159 | break; |
||
1160 | } |
||
1161 | return $show; |
||
1162 | } |
||
1163 | |||
1164 | /** |
||
1165 | * Добавление новой схемы репозитория |
||
1166 | * |
||
1167 | * @author Alexander Wolf |
||
1168 | * @category Core |
||
1169 | * |
||
1170 | * @param string $scheme |
||
1171 | * @return array |
||
1172 | */ |
||
1173 | public function addScheme($scheme) { |
||
1174 | $result = array(); |
||
582 | alex-w | 1175 | $sScheme = $this->secure->checkStr($scheme); |
570 | alex-w | 1176 | |
1177 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
||
1178 | $rq =& $this->db->query($query); |
||
1179 | if (PEAR::isError($this->db)) { |
||
1180 | $result["ERR"] = 1; |
||
1181 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1182 | } else { |
||
1183 | $result["ERR"] = 0; |
||
1184 | } |
||
1185 | |||
1186 | return $result; |
||
1187 | } |
||
1188 | |||
1189 | /** |
||
1190 | * Удаление информации о схеме репозитория |
||
1191 | * |
||
1192 | * @author Alexander Wolf |
||
1193 | * @category Core |
||
1194 | * |
||
1195 | * @param integer $schemeID |
||
1196 | * @return array |
||
1197 | */ |
||
1198 | public function dropScheme($schemeID) { |
||
1199 | $result = array(); |
||
1200 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
1201 | |||
1202 | // Удаление схемы |
||
1203 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
||
1204 | $rq =& $this->db->query($query); |
||
1205 | if (PEAR::isError($this->db)) { |
||
1206 | $result["ERR"] = 1; |
||
1207 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1208 | } else { |
||
1209 | $result["ERR"] = 0; |
||
1210 | } |
||
1211 | |||
1212 | return $result; |
||
1213 | } |
||
1214 | |||
1215 | /** |
||
1216 | * Обновление информации о схеме репозитория |
||
1217 | * |
||
1218 | * @author Alexander Wolf |
||
1219 | * @category Core |
||
1220 | * |
||
1221 | * @param integer $schemeID |
||
1222 | * @param string $info |
||
1223 | * @return array |
||
1224 | */ |
||
1225 | public function updateScheme($schemeID, $info) { |
||
1226 | $result = array(); |
||
1227 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
579 | alex-w | 1228 | $sScheme = $this->secure->checkStr($info); |
570 | alex-w | 1229 | |
1230 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
||
1231 | $rq =& $this->db->query($query); |
||
1232 | if (PEAR::isError($this->db)) { |
||
1233 | $result["ERR"] = 1; |
||
1234 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1235 | } else { |
||
1236 | $result["ERR"] = 0; |
||
1237 | } |
||
1238 | |||
1239 | return $result; |
||
1240 | } |
||
1241 | |||
1242 | /** |
||
1243 | * Вывод формы редактирования/добавления схем репозиториев |
||
1244 | * |
||
1245 | * @author Alexander Wolf |
||
1246 | * @category Core |
||
1247 | * |
||
1248 | * @param integer $schemeID |
||
1249 | * @param string $info |
||
1250 | * @return string |
||
1251 | */ |
||
1252 | public function showSchemeForm($schemeID = 0, $info = "") { |
||
1253 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
1254 | $sInfo = $this->secure->checkStr($info, 1); |
||
1255 | if ($sInfo == "") { |
||
1256 | $sInfo = "Схема репозитория"; |
||
1257 | } |
||
571 | alex-w | 1258 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
570 | alex-w | 1259 | if ($sSchemeID != 0) { |
1260 | // Режим редактирования |
||
1261 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
||
1262 | $rq =& $this->db->query($query); |
||
573 | alex-w | 1263 | $rq->fetchInto($element); |
1264 | } |
||
571 | alex-w | 1265 | |
573 | alex-w | 1266 | $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 | 1267 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1268 | |||
1269 | return $show; |
||
1270 | } |
||
1271 | |||
1272 | /** |
||
574 | alex-w | 1273 | * Вывод списка протоколов |
1274 | * |
||
1275 | * @author Alexander Wolf |
||
1276 | * @category Core |
||
1277 | * |
||
1278 | * @param string $name |
||
1279 | * @param string $actor |
||
1280 | * @param string $format |
||
1281 | * @return string |
||
1282 | */ |
||
1283 | public function showProtoList($name, $actor, $format = 'list') { |
||
1284 | switch($format) { |
||
1285 | case 'list': |
||
1286 | $query = "SELECT * FROM ".$this->prefix."protos"; |
||
1287 | $rq =& $this->db->query($query); |
||
1288 | $show = "<ul>\n"; |
||
1289 | while ($rq->fetchInto($element)) { |
||
1290 | $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"; |
||
1291 | } |
||
1292 | $show .= "</ul>"; |
||
1293 | break; |
||
1294 | case 'innerhtml': |
||
1295 | $protoID = $this->secure->checkInt($actor); |
||
1296 | $query = "SELECT * FROM ".$this->prefix."protos"; |
||
1297 | $rq =& $this->db->query($query); |
||
1298 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1299 | while ($rq->fetchInto($element)) { |
||
1300 | if ($element["proto_id"]==$protoID) { |
||
1301 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
||
1302 | } else { |
||
580 | alex-w | 1303 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
574 | alex-w | 1304 | } |
1305 | } |
||
1306 | $show .= "</select>"; |
||
1307 | break; |
||
1308 | } |
||
1309 | return $show; |
||
1310 | } |
||
1311 | |||
1312 | /** |
||
1313 | * Добавление нового протокола |
||
1314 | * |
||
1315 | * @author Alexander Wolf |
||
1316 | * @category Core |
||
1317 | * |
||
1318 | * @param string $proto |
||
1319 | * @return array |
||
1320 | */ |
||
1321 | public function addProto($proto) { |
||
1322 | $result = array(); |
||
582 | alex-w | 1323 | $sProto = $this->secure->checkStr($proto); |
574 | alex-w | 1324 | |
1325 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
||
1326 | $rq =& $this->db->query($query); |
||
1327 | if (PEAR::isError($this->db)) { |
||
1328 | $result["ERR"] = 1; |
||
1329 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1330 | } else { |
||
1331 | $result["ERR"] = 0; |
||
1332 | } |
||
1333 | |||
1334 | return $result; |
||
1335 | } |
||
1336 | |||
1337 | /** |
||
1338 | * Удаление информации о протоколе |
||
1339 | * |
||
1340 | * @author Alexander Wolf |
||
1341 | * @category Core |
||
1342 | * |
||
1343 | * @param integer $protoID |
||
1344 | * @return array |
||
1345 | */ |
||
1346 | public function dropProto($protoID) { |
||
1347 | $result = array(); |
||
1348 | $sProtoID = $this->secure->checkInt($protoID); |
||
1349 | |||
1350 | // Удаление протокола |
||
1351 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
||
1352 | $rq =& $this->db->query($query); |
||
1353 | if (PEAR::isError($this->db)) { |
||
1354 | $result["ERR"] = 1; |
||
1355 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1356 | } else { |
||
1357 | $result["ERR"] = 0; |
||
1358 | } |
||
1359 | |||
1360 | return $result; |
||
1361 | } |
||
1362 | |||
1363 | /** |
||
1364 | * Обновление информации о протоколе |
||
1365 | * |
||
1366 | * @author Alexander Wolf |
||
1367 | * @category Core |
||
1368 | * |
||
1369 | * @param integer $protoID |
||
1370 | * @param string $info |
||
1371 | * @return array |
||
1372 | */ |
||
1373 | public function updateProto($protoID, $info) { |
||
1374 | $result = array(); |
||
1375 | $sProtoID = $this->secure->checkInt($protoID); |
||
579 | alex-w | 1376 | $sProto = $this->secure->checkStr($info); |
574 | alex-w | 1377 | |
1378 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
||
1379 | $rq =& $this->db->query($query); |
||
1380 | if (PEAR::isError($this->db)) { |
||
1381 | $result["ERR"] = 1; |
||
1382 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1383 | } else { |
||
1384 | $result["ERR"] = 0; |
||
1385 | } |
||
1386 | |||
1387 | return $result; |
||
1388 | } |
||
1389 | |||
1390 | /** |
||
1391 | * Вывод формы редактирования/добавления протоколов |
||
1392 | * |
||
1393 | * @author Alexander Wolf |
||
1394 | * @category Core |
||
1395 | * |
||
1396 | * @param integer $protoID |
||
1397 | * @param string $info |
||
1398 | * @return string |
||
1399 | */ |
||
1400 | public function showProtoForm($protoID = 0, $info = "") { |
||
1401 | $sProtoID = $this->secure->checkInt($protoID); |
||
1402 | $sInfo = $this->secure->checkStr($info, 1); |
||
1403 | if ($sInfo == "") { |
||
1404 | $sInfo = "Протокол доступа"; |
||
1405 | } |
||
1406 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1407 | if ($sProtoID != 0) { |
||
1408 | // Режим редактирования |
||
1409 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
||
1410 | $rq =& $this->db->query($query); |
||
1411 | $rq->fetchInto($element); |
||
1412 | } |
||
1413 | |||
1414 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
||
1415 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1416 | |||
1417 | return $show; |
||
1418 | } |
||
1419 | |||
1420 | /** |
||
582 | alex-w | 1421 | * Вывод списка хостов |
1422 | * |
||
1423 | * @author Alexander Wolf |
||
1424 | * @category Core |
||
1425 | * |
||
1426 | * @param string $name |
||
1427 | * @param string $actor |
||
1428 | * @param string $format |
||
1429 | * @return string |
||
1430 | */ |
||
1431 | public function showHostsList($name, $actor, $format = 'list') { |
||
1432 | switch($format) { |
||
1433 | case 'list': |
||
1434 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
||
1435 | $rq =& $this->db->query($query); |
||
1436 | $show = "<ul>\n"; |
||
1437 | while ($rq->fetchInto($element)) { |
||
1438 | $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"; |
||
1439 | } |
||
1440 | $show .= "</ul>"; |
||
1441 | break; |
||
1442 | case 'innerhtml': |
||
1443 | $hostID = $this->secure->checkInt($actor); |
||
1444 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
||
1445 | $rq =& $this->db->query($query); |
||
1446 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1447 | while ($rq->fetchInto($element)) { |
||
1448 | if ($element["rhost_id"]==$hostID) { |
||
1449 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
||
1450 | } else { |
||
1451 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
||
1452 | } |
||
1453 | } |
||
1454 | $show .= "</select>"; |
||
1455 | break; |
||
1456 | } |
||
1457 | return $show; |
||
1458 | } |
||
1459 | |||
1460 | /** |
||
1461 | * Добавление нового хоста |
||
1462 | * |
||
1463 | * @author Alexander Wolf |
||
1464 | * @category Core |
||
1465 | * |
||
1466 | * @param string $host |
||
1467 | * @return array |
||
1468 | */ |
||
1469 | public function addHost($host) { |
||
1470 | $result = array(); |
||
1471 | $sHost = $this->secure->checkStr($host); |
||
1472 | |||
586 | alex-w | 1473 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
582 | alex-w | 1474 | $rq =& $this->db->query($query); |
1475 | if (PEAR::isError($this->db)) { |
||
1476 | $result["ERR"] = 1; |
||
1477 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1478 | } else { |
||
1479 | $result["ERR"] = 0; |
||
1480 | } |
||
1481 | |||
1482 | return $result; |
||
1483 | } |
||
1484 | |||
1485 | /** |
||
1486 | * Удаление информации о хосте |
||
1487 | * |
||
1488 | * @author Alexander Wolf |
||
1489 | * @category Core |
||
1490 | * |
||
1491 | * @param integer $hostID |
||
1492 | * @return array |
||
1493 | */ |
||
1494 | public function dropHost($hostID) { |
||
1495 | $result = array(); |
||
1496 | $sHostID = $this->secure->checkInt($hostID); |
||
1497 | |||
1498 | // Удаление хоста |
||
1499 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
||
1500 | $rq =& $this->db->query($query); |
||
1501 | if (PEAR::isError($this->db)) { |
||
1502 | $result["ERR"] = 1; |
||
1503 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1504 | } else { |
||
1505 | $result["ERR"] = 0; |
||
1506 | } |
||
1507 | |||
1508 | return $result; |
||
1509 | } |
||
1510 | |||
1511 | /** |
||
1512 | * Обновление информации о хосте |
||
1513 | * |
||
1514 | * @author Alexander Wolf |
||
1515 | * @category Core |
||
1516 | * |
||
1517 | * @param integer $hostID |
||
1518 | * @param string $info |
||
1519 | * @return array |
||
1520 | */ |
||
1521 | public function updateHost($hostID, $info) { |
||
1522 | $result = array(); |
||
1523 | $sHostID = $this->secure->checkInt($hostID); |
||
1524 | $sHost = $this->secure->checkStr($info); |
||
1525 | |||
1526 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
||
1527 | $rq =& $this->db->query($query); |
||
1528 | if (PEAR::isError($this->db)) { |
||
1529 | $result["ERR"] = 1; |
||
1530 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1531 | } else { |
||
1532 | $result["ERR"] = 0; |
||
1533 | } |
||
1534 | |||
1535 | return $result; |
||
1536 | } |
||
1537 | |||
1538 | /** |
||
1539 | * Вывод формы редактирования/добавления хостов |
||
1540 | * |
||
1541 | * @author Alexander Wolf |
||
1542 | * @category Core |
||
1543 | * |
||
1544 | * @param integer $hostID |
||
1545 | * @param string $info |
||
1546 | * @return string |
||
1547 | */ |
||
1548 | public function showHostForm($hostID = 0, $info = "") { |
||
1549 | $sHostID = $this->secure->checkInt($hostID); |
||
1550 | $sInfo = $this->secure->checkStr($info, 1); |
||
1551 | if ($sInfo == "") { |
||
1552 | $sInfo = "Хост репозитория"; |
||
1553 | } |
||
1554 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1555 | if ($sHostID != 0) { |
||
1556 | // Режим редактирования |
||
1557 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
||
1558 | $rq =& $this->db->query($query); |
||
1559 | $rq->fetchInto($element); |
||
1560 | } |
||
1561 | |||
1562 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
||
1563 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1564 | |||
1565 | return $show; |
||
1566 | } |
||
1567 | |||
1568 | /** |
||
589 | alex-w | 1569 | * Вывод списка корневых папок |
1570 | * |
||
1571 | * @author Alexander Wolf |
||
1572 | * @category Core |
||
1573 | * |
||
1574 | * @param string $name |
||
1575 | * @param string $actor |
||
1576 | * @param string $format |
||
1577 | * @return string |
||
1578 | */ |
||
1579 | public function showFoldersList($name, $actor, $format = 'list') { |
||
1580 | switch($format) { |
||
1581 | case 'list': |
||
1582 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
||
1583 | $rq =& $this->db->query($query); |
||
1584 | $show = "<ul>\n"; |
||
1585 | while ($rq->fetchInto($element)) { |
||
1586 | $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"; |
||
1587 | } |
||
1588 | $show .= "</ul>"; |
||
1589 | break; |
||
1590 | case 'innerhtml': |
||
1591 | $folderID = $this->secure->checkInt($actor); |
||
1592 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
||
1593 | $rq =& $this->db->query($query); |
||
1594 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1595 | while ($rq->fetchInto($element)) { |
||
1596 | if ($element["rfolder_id"]==$folderID) { |
||
1597 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
||
1598 | } else { |
||
1599 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
||
1600 | } |
||
1601 | } |
||
1602 | $show .= "</select>"; |
||
1603 | break; |
||
1604 | } |
||
1605 | return $show; |
||
1606 | } |
||
1607 | |||
1608 | /** |
||
1609 | * Добавление нового корневого каталога |
||
1610 | * |
||
1611 | * @author Alexander Wolf |
||
1612 | * @category Core |
||
1613 | * |
||
1614 | * @param string $flder |
||
1615 | * @return array |
||
1616 | */ |
||
1617 | public function addFolder($folder) { |
||
1618 | $result = array(); |
||
1619 | $sFolder = $this->secure->checkStr($folder); |
||
1620 | |||
1621 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
||
1622 | $rq =& $this->db->query($query); |
||
1623 | if (PEAR::isError($this->db)) { |
||
1624 | $result["ERR"] = 1; |
||
1625 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1626 | } else { |
||
1627 | $result["ERR"] = 0; |
||
1628 | } |
||
1629 | |||
1630 | return $result; |
||
1631 | } |
||
1632 | |||
1633 | /** |
||
1634 | * Удаление информации о корневой папке |
||
1635 | * |
||
1636 | * @author Alexander Wolf |
||
1637 | * @category Core |
||
1638 | * |
||
1639 | * @param integer $folderID |
||
1640 | * @return array |
||
1641 | */ |
||
1642 | public function dropFolder($folderID) { |
||
1643 | $result = array(); |
||
1644 | $sFolderID = $this->secure->checkInt($folderID); |
||
1645 | |||
1646 | // Удаление корневой папки |
||
1647 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
||
1648 | $rq =& $this->db->query($query); |
||
1649 | if (PEAR::isError($this->db)) { |
||
1650 | $result["ERR"] = 1; |
||
1651 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1652 | } else { |
||
1653 | $result["ERR"] = 0; |
||
1654 | } |
||
1655 | |||
1656 | return $result; |
||
1657 | } |
||
1658 | |||
1659 | /** |
||
1660 | * Обновление информации о корневой папки |
||
1661 | * |
||
1662 | * @author Alexander Wolf |
||
1663 | * @category Core |
||
1664 | * |
||
1665 | * @param integer $folderID |
||
1666 | * @param string $info |
||
1667 | * @return array |
||
1668 | */ |
||
1669 | public function updateFolder($folderID, $info) { |
||
1670 | $result = array(); |
||
1671 | $sFolderID = $this->secure->checkInt($folderID); |
||
1672 | $sFolder = $this->secure->checkStr($info); |
||
1673 | |||
1674 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
||
1675 | $rq =& $this->db->query($query); |
||
1676 | if (PEAR::isError($this->db)) { |
||
1677 | $result["ERR"] = 1; |
||
1678 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1679 | } else { |
||
1680 | $result["ERR"] = 0; |
||
1681 | } |
||
1682 | |||
1683 | return $result; |
||
1684 | } |
||
1685 | |||
1686 | /** |
||
1687 | * Вывод формы редактирования/добавления корневых папок |
||
1688 | * |
||
1689 | * @author Alexander Wolf |
||
1690 | * @category Core |
||
1691 | * |
||
1692 | * @param integer $folderID |
||
1693 | * @param string $info |
||
1694 | * @return string |
||
1695 | */ |
||
1696 | public function showFolderForm($folderID = 0, $info = "") { |
||
1697 | $sFolderID = $this->secure->checkInt($folderID); |
||
1698 | $sInfo = $this->secure->checkStr($info, 1); |
||
1699 | if ($sInfo == "") { |
||
1700 | $sInfo = "Корневая папка"; |
||
1701 | } |
||
1702 | if ($sFolderID != 0) { |
||
1703 | // Режим редактирования |
||
1704 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
||
1705 | $rq =& $this->db->query($query); |
||
1706 | $rq->fetchInto($element); |
||
1707 | } |
||
1708 | |||
1709 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1710 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
||
1711 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1712 | |||
1713 | return $show; |
||
1714 | } |
||
1715 | |||
1716 | /** |
||
539 | alex-w | 1717 | * Показывает список подписей |
1718 | * |
||
1719 | * @author Alexander Wolf |
||
1720 | * @category Core |
||
1721 | * |
||
1722 | * @param string $name |
||
1723 | * @param string $actor |
||
596 | alex-w | 1724 | * @param string $format |
539 | alex-w | 1725 | * @return string |
1726 | */ |
||
594 | alex-w | 1727 | public function showSignsList($name, $actor, $format = 'list') { |
539 | alex-w | 1728 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1729 | $rq =& $this->db->query($query); |
||
594 | alex-w | 1730 | switch ($format) { |
1731 | case 'list': |
||
1732 | $show = "<ul>\n"; |
||
1733 | while ($rq->fetchInto($element)) { |
||
1734 | $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"; |
||
1735 | } |
||
1736 | $show .= "</ul>"; |
||
1737 | break; |
||
1738 | case 'innerhtml': |
||
1739 | $signID = $this->secure->checkInt($actor); |
||
1740 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1741 | $show .= "<option value='0'>Подписи нет</option>\n"; |
||
1742 | while ($rq->fetchInto($element)) { |
||
1743 | if ($element["sign_id"]==$signID) { |
||
1744 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
||
1745 | } else { |
||
1746 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
||
1747 | } |
||
1748 | } |
||
1749 | $show .= "</select>\n"; |
||
1750 | break; |
||
539 | alex-w | 1751 | } |
1752 | |||
1753 | return $show; |
||
1754 | } |
||
1755 | |||
1756 | /** |
||
1757 | * Вывод формы редактирования/добавления подписей |
||
1758 | * |
||
1759 | * @author Alexander Wolf |
||
1760 | * @category Core |
||
1761 | * |
||
1762 | * @param integer $sectionID |
||
1763 | * @param string $info |
||
1764 | * @return string |
||
1765 | */ |
||
1766 | public function showSignsForm($signID = 0, $info = "") { |
||
1767 | $sSignID = $this->secure->checkInt($signID); |
||
1768 | $sInfo = $this->secure->checkStr($info, 1); |
||
1769 | if ($sInfo == "") { |
||
1770 | $sInfo = "Подписи"; |
||
1771 | } |
||
1772 | if ($sSignID != 0) { |
||
1773 | // Режим редактирования |
||
1774 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
||
1775 | $rq =& $this->db->query($query); |
||
1776 | $rq->fetchInto($element); |
||
1777 | } |
||
1778 | |||
1779 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1780 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
||
1781 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
||
1782 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1783 | |||
1784 | return $show; |
||
1785 | } |
||
1786 | |||
1787 | /** |
||
1788 | * Обновление информации о секции |
||
1789 | * |
||
1790 | * @author Alexander Wolf |
||
1791 | * @category Core |
||
1792 | * |
||
1793 | * @param integer $sectionID |
||
1794 | * @param string $sname |
||
1795 | * @param string $sinfo |
||
1796 | * @return array |
||
1797 | */ |
||
1798 | public function updateSign($signID, $sname, $sinfo = "") { |
||
1799 | $result = array(); |
||
1800 | $sSignID = $this->secure->checkInt($signID); |
||
579 | alex-w | 1801 | $sSName = $this->secure->checkStr($sname); |
1802 | $sSInfo = $this->secure->checkStr($sinfo); |
||
539 | alex-w | 1803 | |
1804 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
||
1805 | $rq =& $this->db->query($query); |
||
1806 | if (PEAR::isError($this->db)) { |
||
1807 | $result["ERR"] = 1; |
||
1808 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1809 | } else { |
||
1810 | $result["ERR"] = 0; |
||
1811 | } |
||
1812 | |||
1813 | return $result; |
||
1814 | } |
||
1815 | |||
1816 | /** |
||
1817 | * Удаление информации о подписи |
||
1818 | * |
||
1819 | * @author Alexander Wolf |
||
1820 | * @category Core |
||
1821 | * |
||
1822 | * @param integer $sectionID |
||
1823 | * @return array |
||
1824 | */ |
||
540 | alex-w | 1825 | public function dropSign($signID) { |
539 | alex-w | 1826 | $result = array(); |
1827 | $sSignID = $this->secure->checkInt($signID); |
||
1828 | |||
1829 | // Удаление подписи |
||
1830 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
||
1831 | $rq =& $this->db->query($query); |
||
1832 | if (PEAR::isError($this->db)) { |
||
1833 | $result["ERR"] = 1; |
||
1834 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1835 | } else { |
||
1836 | $result["ERR"] = 0; |
||
1837 | } |
||
1838 | |||
1839 | return $result; |
||
1840 | } |
||
1841 | |||
1842 | /** |
||
540 | alex-w | 1843 | * Добавление новой подписи |
539 | alex-w | 1844 | * |
1845 | * @author Alexander Wolf |
||
1846 | * @category Core |
||
1847 | * |
||
1848 | * @param string $sname |
||
1849 | * @param string $sinfo |
||
1850 | * @return array |
||
1851 | */ |
||
540 | alex-w | 1852 | public function addSign($sname, $sinfo = "") { |
539 | alex-w | 1853 | $result = array(); |
582 | alex-w | 1854 | $sSName = $this->secure->checkStr($sname); |
1855 | $sSInfo = $this->secure->checkStr($sinfo); |
||
539 | alex-w | 1856 | |
540 | alex-w | 1857 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
539 | alex-w | 1858 | $rq =& $this->db->query($query); |
1859 | if (PEAR::isError($this->db)) { |
||
1860 | $result["ERR"] = 1; |
||
1861 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1862 | } else { |
||
1863 | $result["ERR"] = 0; |
||
1864 | } |
||
1865 | |||
1866 | return $result; |
||
1867 | } |
||
540 | alex-w | 1868 | |
539 | alex-w | 1869 | /** |
463 | alex-w | 1870 | * Проверка пароля (из формы авторизации) |
1871 | * |
||
1872 | * @author Alexander Wolf |
||
1873 | * @category Core |
||
1874 | * |
||
1875 | * @param string $word |
||
1876 | * @return array |
||
1877 | */ |
||
368 | alex-w | 1878 | public function checkSign($word) { |
359 | alex-w | 1879 | $result = array(); |
1880 | |||
1881 | $sHash = $this->secure->encryptStr($word); |
||
1882 | $pwd = $this->getOption("passwd"); |
||
1883 | if ($sHash == $pwd["OptValue"]) { |
||
1884 | $result["ERR"] = 0; |
||
1885 | $result["Location"] = "manager.php"; |
||
1886 | setcookie($this->cookie, $sHash); |
||
1887 | } else { |
||
1888 | $result["ERR"] = 1; |
||
1889 | $result["ERRINFO"] = "Password not valid"; |
||
368 | alex-w | 1890 | $result["Location"] = "manager.php?error=1"; |
359 | alex-w | 1891 | } |
1892 | |||
1893 | return $result; |
||
358 | alex-w | 1894 | } |
357 | alex-w | 1895 | |
463 | alex-w | 1896 | /** |
1897 | * Проверка пароля (из cookies) |
||
1898 | * |
||
1899 | * @author Alexander Wolf |
||
1900 | * @category Core |
||
1901 | * |
||
1902 | * @param string $hash |
||
1903 | * @return array |
||
1904 | */ |
||
368 | alex-w | 1905 | public function checkCookieSign($hash) { |
359 | alex-w | 1906 | $result = array(); |
1907 | |||
1908 | $pwd = $this->getOption("passwd"); |
||
1909 | if ($hash == $pwd["OptValue"]) { |
||
1910 | $result["ERR"] = 0; |
||
1911 | } else { |
||
1912 | $result["ERR"] = 1; |
||
1913 | $result["ERRINFO"] = "Hash not valid"; |
||
368 | alex-w | 1914 | $result["Location"] = "manager.php"; |
359 | alex-w | 1915 | } |
1916 | |||
1917 | return $result; |
||
1918 | } |
||
1919 | |||
463 | alex-w | 1920 | /** |
1921 | * Форма ввода пароля |
||
1922 | * |
||
1923 | * @author Alexander Wolf |
||
1924 | * @category Core |
||
1925 | * |
||
1926 | * @return string |
||
1927 | */ |
||
368 | alex-w | 1928 | public function showSigninForm() { |
425 | alex-w | 1929 | $show = "<div id='regform'>"; |
1930 | $show .= "<form action='process.php' method='post'>\n"; |
||
368 | alex-w | 1931 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1932 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
||
427 | alex-w | 1933 | $show .= "<input type='password' name='word' value=''>\n"; |
368 | alex-w | 1934 | $show .= "<input type='submit' value=' Войти '>\n"; |
425 | alex-w | 1935 | $show .= "</fieldset>\n</form></div>\n"; |
368 | alex-w | 1936 | |
1937 | return $show; |
||
1938 | } |
||
1939 | |||
463 | alex-w | 1940 | /** |
1941 | * Обновление пароля |
||
1942 | * |
||
1943 | * @author Alexander Wolf |
||
1944 | * @category Core |
||
1945 | * |
||
1946 | * @param string $word1 |
||
1947 | * @param string $word2 |
||
1948 | * @return array |
||
1949 | */ |
||
368 | alex-w | 1950 | public function updatePassword($word1, $word2) { |
359 | alex-w | 1951 | $result = array(); |
1952 | |||
1953 | if ($word1 == $word2) { |
||
1954 | $sWord = $this->secure->encryptStr($word1); |
||
1955 | $r = $this->setOption("passwd", $sWord); |
||
1956 | $result = $r; |
||
1957 | } else { |
||
1958 | $result["ERR"] = 1; |
||
1959 | $result["ERRINFO"] = "Passwords is mismatch"; |
||
1960 | } |
||
1961 | |||
1962 | return $result; |
||
1963 | } |
||
1964 | |||
504 | alex-w | 1965 | /** |
509 | alex-w | 1966 | * Отображение формы создания и редактирования версии apt-дистрибутива |
504 | alex-w | 1967 | * |
1968 | * @author Alexander Wolf |
||
1969 | * @category Core |
||
1970 | * |
||
1971 | * @param string $name |
||
1972 | * @param string $actor |
||
1973 | * @param integer $versionID |
||
1974 | * @return string |
||
1975 | */ |
||
511 | alex-w | 1976 | public function showDistVersionsForm($versionID = 0, $info = '') { |
509 | alex-w | 1977 | $sVersionID = $this->secure->checkInt($versionID); |
511 | alex-w | 1978 | $sInfo = $this->secure->checkStr($info, 1); |
1979 | if ($sInfo == "") { |
||
1980 | $sInfo = "Версия дистрибутива"; |
||
1981 | } |
||
509 | alex-w | 1982 | if ($sVersionID != 0) { |
1983 | // Режим редактирования |
||
556 | alex-w | 1984 | $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 | 1985 | $rq =& $this->db->query($query); |
1986 | $rq->fetchInto($element); |
||
509 | alex-w | 1987 | } |
1988 | |||
511 | alex-w | 1989 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
510 | alex-w | 1990 | if ($sVersionID != 0) { |
1991 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
||
1992 | } else { |
||
1993 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
||
1994 | } |
||
509 | alex-w | 1995 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1996 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
||
1997 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
||
1998 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
||
495 | alex-w | 1999 | |
504 | alex-w | 2000 | return $show; |
509 | alex-w | 2001 | } |
504 | alex-w | 2002 | |
520 | alex-w | 2003 | /** |
2004 | * Парсер схемы адреса репозитория |
||
2005 | * FIXME Возможно не потребуется |
||
2006 | * |
||
2007 | * @author Alexander Wolf |
||
2008 | * @category Core |
||
2009 | * |
||
2010 | * @param string $repstring |
||
2011 | * @return integer |
||
2012 | */ |
||
2013 | public function repositoryParser($repstring) { |
||
2014 | $tokens = array(); |
||
2015 | $sections = array(); |
||
2016 | $tokens = split(" ",$repstring); |
||
2017 | |||
2018 | if ($tokens[0] == "deb") { |
||
2019 | // debian/ubuntu репозиторий "type proto://host/folder distr sections" |
||
2020 | $url = parse_url($tokens[1]); |
||
2021 | $distr = $tokens[2]; |
||
2022 | |||
2023 | for($i=3;$i<count($tokens);$i++) { |
||
2024 | $sections[] = $tokens[$i]; |
||
2025 | } |
||
2026 | } else { |
||
2027 | // altlinux репозиторий "type [sign] proto://host/folder base repname" |
||
2028 | if (stripos($tokens[1],"]")!=0) { |
||
2029 | $sign = $tokens[1]; |
||
2030 | $url = parse_url($tokens[2]); |
||
2031 | $base = $tokens[3]; |
||
2032 | $repname = $tokens[4]; |
||
2033 | } else { |
||
2034 | $url = parse_url($tokens[1]); |
||
2035 | $base = $tokens[2]; |
||
2036 | $repname = $tokens[3]; |
||
2037 | } |
||
2038 | } |
||
2039 | |||
2040 | $proto = $url["scheme"]."://"; |
||
2041 | $addr = $url["host"]; |
||
2042 | if ($url["port"]!="") { |
||
2043 | $addr .= ":".$url["port"]; |
||
2044 | } |
||
2045 | $path = $url["path"]; |
||
2046 | |||
2047 | return 0; |
||
2048 | } |
||
2049 | |||
539 | alex-w | 2050 | /** |
2051 | * Выгрузка картинок логотипов дистрибутивов |
||
2052 | * |
||
2053 | * @author Alexander Wolf |
||
2054 | * @category Core |
||
2055 | * |
||
2056 | * @param string $path |
||
2057 | * @param string $dist |
||
2058 | * @param array $datafile |
||
2059 | * @return integer |
||
2060 | */ |
||
535 | alex-w | 2061 | public function uploadPicture($path, $dist, $datafile) { |
2062 | $folder = $path.$dist."-orig.png"; |
||
2063 | $folderN = $path.$dist.".png"; |
||
2064 | $folderEM = $path.$dist."-em.png"; |
||
2065 | |||
2066 | $distlogo = 0; |
||
2067 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
||
2068 | chmod($folder, 0644); |
||
2069 | list($width, $height) = GetImageSize($folder); |
||
2070 | $percent = 32/$height; |
||
2071 | $newwidth = $width * $percent; |
||
2072 | $newheight = $height * $percent; |
||
2073 | |||
2074 | $output = ImageCreateTrueColor($newwidth, $newheight); |
||
2075 | $source = ImageCreateFromPNG($folder); |
||
2076 | |||
2077 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
||
2078 | ImagePNG($output, $folderEM); |
||
2079 | |||
2080 | $percent = 15/$height; |
||
2081 | $newwidth = $width * $percent; |
||
2082 | $newheight = $height * $percent; |
||
2083 | |||
2084 | $output = ImageCreateTrueColor($newwidth, $newheight); |
||
2085 | |||
2086 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
||
2087 | ImagePNG($output, $folderN); |
||
2088 | |||
2089 | unlink($folder); |
||
2090 | $distlogo = 1; |
||
2091 | } |
||
2092 | return $distlogo; |
||
2093 | } |
||
547 | alex-w | 2094 | |
2095 | /** |
||
2096 | * Показ списка репозиториев |
||
2097 | * |
||
2098 | * @author Alexander Wolf |
||
2099 | * @category Core |
||
2100 | * |
||
2101 | * @param string $name |
||
2102 | * @param string $actor |
||
2103 | * @param string $format |
||
2104 | * @return string |
||
2105 | */ |
||
548 | alex-w | 2106 | public function showRepositoriesList($name, $actor, $format = 'list') { |
643 | alex-w | 2107 | $query = "SELECT r.*,rt.*,v.version_id,CONCAT(d.distname,' ',v.version,' “',v.vname,'”') AS fullname FROM ".$this->prefix."repository r "; |
548 | alex-w | 2108 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
629 | alex-w | 2109 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version "; |
641 | alex-w | 2110 | $query .= "JOIN ".$this->prefix."distribution d ON d.dist_id=v.dist_id "; |
695 | alex-w | 2111 | $query .= "ORDER BY v.version_id,rt.rtype_id,r.rep_id ASC"; |
548 | alex-w | 2112 | $rq =& $this->db->query($query); |
639 | alex-w | 2113 | $show = "<ul><li class='nomarker'></li>"; |
630 | alex-w | 2114 | $splitter = 0; |
548 | alex-w | 2115 | while ($rq->fetchInto($element)) { |
630 | alex-w | 2116 | if ($splitter != $this->secure->checkInt($element["version_id"])) { |
2117 | $splitter = $this->secure->checkInt($element["version_id"]); |
||
645 | alex-w | 2118 | $show .= "</ul><ul><li class='nomarker'><strong>Репозитории для ".$this->secure->checkStr($element["fullname"],1)."</strong></li>"; |
630 | alex-w | 2119 | } |
634 | alex-w | 2120 | $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 | 2121 | } |
2122 | $show .= "</ul>"; |
||
547 | alex-w | 2123 | return $show; |
2124 | } |
||
2125 | |||
2126 | /** |
||
558 | alex-w | 2127 | * Вывод списка типов репозиториев |
2128 | * |
||
2129 | * @author Alexander Wolf |
||
2130 | * @category Core |
||
2131 | * |
||
2132 | * @param integer $reptype |
||
2133 | * @param string $name |
||
2134 | * @return string |
||
2135 | */ |
||
2136 | public function showRepType($reptype = 0, $name = "") { |
||
2137 | $sRT = $this->secure->checkInt($reptype); |
||
2138 | $sNM = $this->secure->checkStr($name,1); |
||
559 | alex-w | 2139 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
558 | alex-w | 2140 | $rq =& $this->db->query($query); |
2141 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
||
2142 | while ($rq->fetchInto($element)) { |
||
2143 | if ($element["rtype_id"]==$sRT) { |
||
2144 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
||
2145 | } else { |
||
2146 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
||
2147 | } |
||
2148 | } |
||
2149 | $show .= "</select>"; |
||
2150 | |||
2151 | return $show; |
||
2152 | } |
||
2153 | |||
623 | alex-w | 2154 | /** |
2155 | * Вывод списка версий дистрибутивов |
||
2156 | * |
||
2157 | * @author Alexander Wolf |
||
2158 | * @category Core |
||
2159 | * |
||
2160 | * @param string $name |
||
2161 | * @param integer $versionID |
||
2162 | * @return string |
||
2163 | */ |
||
591 | alex-w | 2164 | public function showVDList($name, $versionID = 0) { |
592 | alex-w | 2165 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
591 | alex-w | 2166 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
2167 | $rq =& $this->db->query($query); |
||
2168 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
2169 | while ($rq->fetchInto($element)) { |
||
592 | alex-w | 2170 | if ($element["version_id"]==$versionID) { |
2171 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
||
2172 | } else { |
||
2173 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
||
2174 | } |
||
591 | alex-w | 2175 | } |
2176 | $show .= "</select>"; |
||
2177 | return $show; |
||
2178 | } |
||
2179 | |||
558 | alex-w | 2180 | /** |
547 | alex-w | 2181 | * Форма создания/редактирвоания репозиториев |
2182 | * |
||
2183 | * @author Alexander Wolf |
||
2184 | * @category Core |
||
2185 | * |
||
2186 | * @param integer $repID |
||
2187 | * @param string $info |
||
2188 | * @param string $reptype |
||
2189 | * @return string |
||
2190 | */ |
||
594 | alex-w | 2191 | public function showRepositoriesForm($repID = 0, $info = "") { |
556 | alex-w | 2192 | $sRepID = $this->secure->checkInt($repID); |
594 | alex-w | 2193 | $sInfo = $this->secure->checkStr($info, 1); |
556 | alex-w | 2194 | if ($sInfo == "") { |
2195 | $sInfo = "Репозиторий"; |
||
2196 | } |
||
2197 | if ($sRepID != 0) { |
||
2198 | // Режим редактирования |
||
591 | alex-w | 2199 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
556 | alex-w | 2200 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
2201 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
||
2202 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
||
2203 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
||
2204 | $rq =& $this->db->query($query); |
||
594 | alex-w | 2205 | $rq->fetchInto($element); |
556 | alex-w | 2206 | } |
2207 | |||
594 | alex-w | 2208 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
609 | alex-w | 2209 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
626 | alex-w | 2210 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value=\"".$this->secure->checkStr($element["repname"],1)."\"></div>\n"; |
2211 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value=\"".$this->secure->checkStr($element["repinfo"],1)."\"></div>\n"; |
||
2212 | $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 | 2213 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
588 | alex-w | 2214 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
604 | alex-w | 2215 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
558 | alex-w | 2216 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
564 | alex-w | 2217 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
569 | alex-w | 2218 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
613 | alex-w | 2219 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
595 | alex-w | 2220 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
556 | alex-w | 2221 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
593 | alex-w | 2222 | |
547 | alex-w | 2223 | return $show; |
2224 | } |
||
598 | alex-w | 2225 | |
2226 | /** |
||
2227 | * Добавление нового репозитория |
||
2228 | * |
||
2229 | * @author Alexander Wolf |
||
2230 | * @category Core |
||
2231 | * |
||
2232 | * @param integer $verionID |
||
2233 | * @param string $rname |
||
2234 | * @param string $rinfo |
||
2235 | * @param string $rkey |
||
2236 | * @param integer $proto |
||
2237 | * @param integer $rhost |
||
2238 | * @param integer $rfolder |
||
2239 | * @param integer $rtype |
||
2240 | * @param array $sections |
||
2241 | * @param array $arch |
||
2242 | * @param integer $scheme |
||
2243 | * @param integer $sign |
||
2244 | * @return array |
||
2245 | */ |
||
612 | alex-w | 2246 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
598 | alex-w | 2247 | $result = array(); |
2248 | $sVersionID = $this->secure->checkInt($verionID); |
||
2249 | $sRName = $this->secure->checkStr($rname); |
||
2250 | $sRInfo = $this->secure->checkStr($rinfo); |
||
2251 | $sRKey = $this->secure->checkStr($rkey); |
||
2252 | $sProto = $this->secure->checkInt($proto); |
||
2253 | $sRHost = $this->secure->checkInt($rhost); |
||
2254 | $sRFolder = $this->secure->checkInt($rfolder); |
||
2255 | $sRType = $this->secure->checkInt($rtype); |
||
2256 | $sRScheme = $this->secure->checkInt($scheme); |
||
2257 | $sRSign = $this->secure->checkInt($sign); |
||
2258 | |||
602 | alex-w | 2259 | $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 | 2260 | $rq =& $this->db->query($query); |
2261 | |||
2262 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
||
2263 | $rq =& $this->db->query($query); |
||
2264 | $rq->fetchInto($repository); |
||
2265 | |||
2266 | for($i=0;$i<count($sections);$i++) { |
||
2267 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
||
2268 | $rq =& $this->db->query($query); |
||
2269 | } |
||
2270 | |||
2271 | for($i=0;$i<count($arch);$i++) { |
||
2272 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
||
2273 | $rq =& $this->db->query($query); |
||
2274 | } |
||
2275 | |||
2276 | if (PEAR::isError($this->db)) { |
||
2277 | $result["ERR"] = 1; |
||
2278 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2279 | } else { |
||
2280 | $result["ERR"] = 0; |
||
2281 | } |
||
2282 | |||
2283 | return $result; |
||
2284 | } |
||
618 | alex-w | 2285 | |
2286 | /** |
||
2287 | * Обновление информации о репозитории |
||
2288 | * |
||
2289 | * @author Alexander Wolf |
||
2290 | * @category Core |
||
2291 | * |
||
2292 | * @param integer $repID |
||
2293 | * @param integer $verionID |
||
2294 | * @param string $rname |
||
2295 | * @param string $rinfo |
||
2296 | * @param string $rkey |
||
2297 | * @param integer $proto |
||
2298 | * @param integer $rhost |
||
2299 | * @param integer $rfolder |
||
2300 | * @param integer $rtype |
||
2301 | * @param array $sections |
||
2302 | * @param array $arch |
||
2303 | * @param integer $scheme |
||
2304 | * @param integer $sign |
||
2305 | * @return array |
||
2306 | */ |
||
2307 | public function updateRepository($repID, $verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
||
2308 | $result = array(); |
||
2309 | $sRepID = $this->secure->checkInt($repID); |
||
2310 | $sVersionID = $this->secure->checkInt($verionID); |
||
2311 | $sRName = $this->secure->checkStr($rname); |
||
2312 | $sRInfo = $this->secure->checkStr($rinfo); |
||
2313 | $sRKey = $this->secure->checkStr($rkey); |
||
2314 | $sProto = $this->secure->checkInt($proto); |
||
2315 | $sRHost = $this->secure->checkInt($rhost); |
||
2316 | $sRFolder = $this->secure->checkInt($rfolder); |
||
2317 | $sRType = $this->secure->checkInt($rtype); |
||
2318 | $sRScheme = $this->secure->checkInt($scheme); |
||
2319 | $sRSign = $this->secure->checkInt($sign); |
||
2320 | |||
2321 | $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."'"; |
||
2322 | $rq =& $this->db->query($query); |
||
2323 | |||
2324 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
||
2325 | $rq =& $this->db->query($query); |
||
2326 | for($i=0;$i<count($sections);$i++) { |
||
2327 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$sRepID."', sect_id='".$sections[$i]."'"; |
||
2328 | $rq =& $this->db->query($query); |
||
2329 | } |
||
2330 | |||
2331 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
||
2332 | $rq =& $this->db->query($query); |
||
2333 | for($i=0;$i<count($arch);$i++) { |
||
2334 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$sRepID."', arch_id='".$arch[$i]."'"; |
||
2335 | $rq =& $this->db->query($query); |
||
2336 | } |
||
2337 | |||
2338 | if (PEAR::isError($this->db)) { |
||
2339 | $result["ERR"] = 1; |
||
2340 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2341 | } else { |
||
2342 | $result["ERR"] = 0; |
||
2343 | } |
||
2344 | |||
2345 | return $result; |
||
2346 | } |
||
2347 | |||
2348 | /** |
||
2349 | * Удаление информации о репозитории |
||
2350 | * |
||
2351 | * @author Alexander Wolf |
||
2352 | * @category Core |
||
2353 | * |
||
2354 | * @param integer $repID |
||
2355 | * @return array |
||
2356 | */ |
||
2357 | public function dropRepository($repID) { |
||
2358 | $result = array(); |
||
2359 | $sRepID = $this->secure->checkInt($repID); |
||
2360 | |||
2361 | // Удаление репозитория |
||
2362 | $query = "DELETE FROM ".$this->prefix."repository WHERE rep_id='".$sRepID."'"; |
||
2363 | $rq =& $this->db->query($query); |
||
2364 | if (PEAR::isError($this->db)) { |
||
2365 | $result["ERR"] = 1; |
||
2366 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2367 | } else { |
||
2368 | $result["ERR"] = 0; |
||
2369 | } |
||
2370 | |||
2371 | // Удаление секций репозитория |
||
2372 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
||
2373 | $rq =& $this->db->query($query); |
||
2374 | if (PEAR::isError($this->db)) { |
||
2375 | $result["ERR"] = 1; |
||
2376 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2377 | } else { |
||
2378 | $result["ERR"] = 0; |
||
2379 | } |
||
2380 | |||
2381 | // Удаление архитектур репозитория |
||
2382 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
||
2383 | $rq =& $this->db->query($query); |
||
2384 | if (PEAR::isError($this->db)) { |
||
2385 | $result["ERR"] = 1; |
||
2386 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2387 | } else { |
||
2388 | $result["ERR"] = 0; |
||
2389 | } |
||
2390 | |||
2391 | return $result; |
||
2392 | } |
||
684 | alex-w | 2393 | |
685 | alex-w | 2394 | /** |
2395 | * Вывод списка настроек |
||
2396 | * |
||
2397 | * @author Alexander Wolf |
||
2398 | * @category Core |
||
2399 | * |
||
2400 | * @param string $name |
||
2401 | * @param string $actor |
||
2402 | * @param string $format |
||
2403 | * @return string |
||
2404 | */ |
||
684 | alex-w | 2405 | public function showSettingsList($name, $actor, $format = 'list') { |
2406 | $query = "SELECT * FROM ".$this->prefix."settings"; |
||
2407 | $rq =& $this->db->query($query); |
||
2408 | $show = "<ul>\n"; |
||
688 | alex-w | 2409 | $show .= "<li><a href='".$actor."?mode=".$name."&action=update-password' class='edit'>Изменить пароль доступа</a></li>\n"; |
684 | alex-w | 2410 | $show .= "</ul>"; |
685 | alex-w | 2411 | |
2412 | return $show; |
||
684 | alex-w | 2413 | } |
688 | alex-w | 2414 | |
2415 | /** |
||
2416 | * Форма обновления пароля |
||
2417 | * |
||
2418 | * @author Alexander Wolf |
||
2419 | * @category Core |
||
2420 | * |
||
2421 | * @return string |
||
2422 | */ |
||
2423 | public function showUpdatePasswordForm() { |
||
2424 | $show .= "<fieldset><legend>Обновление пароля доступа</legend>\n"; |
||
2425 | $show .= "<div class='inputbox'><label for='oword'>Текущий пароль:</label> <input type='password' name='oword' value=''></div>\n"; |
||
2426 | $show .= "<div class='inputbox'><label for='nword'>Новый пароль:</label> <input type='password' name='nword' value=''></div>\n"; |
||
2427 | $show .= "<div class='inputbox'><label for='again'>Повторно:</label> <input type='password' name='again' value=''></div>\n"; |
||
2428 | $show .= "<input type='submit' value=' Войти '>\n"; |
||
2429 | $show .= "</fieldset>\n\n"; |
||
2430 | |||
2431 | return $show; |
||
2432 | } |
||
560 | alex-w | 2433 | |
304 | alex-w | 2434 | } |
2435 | |||
356 | alex-w | 2436 | ?> |