Редакция 643 | Редакция 645 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | 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': |
||
607 | alex-w | 310 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
311 | while ($rq->fetchInto($element)) { |
||
320 | alex-w | 312 | $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." — ".$this->secure->checkStr($element["repinfo"],1)."</div>\n"; |
317 | alex-w | 313 | } |
314 | $show .= "</fieldset>\n"; |
||
315 | break; |
||
316 | case 'json': |
||
317 | //TODO Доделать JSON-вывод списка репозиториев |
||
318 | break; |
||
319 | } |
||
318 | alex-w | 320 | |
321 | return $show; |
||
317 | alex-w | 322 | } |
323 | |||
463 | alex-w | 324 | /** |
325 | * Добавление поддержки нового apt-дистрибутива |
||
326 | * |
||
327 | * @author Alexander Wolf |
||
328 | * @category Core |
||
329 | * |
||
330 | * @param string $distname |
||
331 | * @param integer $disttype |
||
332 | * @param string $distua |
||
333 | * @param byte $distlogo |
||
334 | * @return array |
||
335 | */ |
||
514 | alex-w | 336 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
321 | alex-w | 337 | $result = array(); |
582 | alex-w | 338 | $sDName = $this->secure->checkStr($distname); |
321 | alex-w | 339 | $sDType = $this->secure->checkInt($disttype); |
582 | alex-w | 340 | $sDUAgt = $this->secure->checkStr($distua); |
514 | alex-w | 341 | $sDLogo = $this->secure->checkInt($distlogo); |
321 | alex-w | 342 | |
343 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
||
344 | $rq =& $this->db->query($query); |
||
345 | if (PEAR::isError($this->db)) { |
||
346 | $result["ERR"] = 1; |
||
347 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 348 | } else { |
321 | alex-w | 349 | $result["ERR"] = 0; |
350 | } |
||
351 | |||
352 | return $result; |
||
353 | } |
||
354 | |||
463 | alex-w | 355 | /** |
514 | alex-w | 356 | * Обновление информации о дистрибутиве |
357 | * |
||
358 | * @author Alexander Wolf |
||
359 | * @category Core |
||
360 | * |
||
361 | * @param integer $distID |
||
362 | * @param string $distname |
||
363 | * @param integer $disttype |
||
364 | * @param string $distua |
||
365 | * @param integer $distlogo |
||
366 | * @return array |
||
367 | */ |
||
538 | alex-w | 368 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
514 | alex-w | 369 | $result = array(); |
370 | $sDID = $this->secure->checkInt($distID); |
||
579 | alex-w | 371 | $sDName = $this->secure->checkStr($distname); |
514 | alex-w | 372 | $sDType = $this->secure->checkInt($disttype); |
579 | alex-w | 373 | $sDUAgt = $this->secure->checkStr($distua); |
514 | alex-w | 374 | $sDLogo = $this->secure->checkInt($distlogo); |
375 | |||
538 | alex-w | 376 | if ($sDLogo!=0) { |
377 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
||
378 | } else { |
||
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
||
380 | } |
||
514 | alex-w | 381 | $rq =& $this->db->query($query); |
382 | if (PEAR::isError($this->db)) { |
||
383 | $result["ERR"] = 1; |
||
384 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 385 | } else { |
514 | alex-w | 386 | $result["ERR"] = 0; |
387 | } |
||
388 | |||
389 | return $result; |
||
390 | } |
||
391 | |||
392 | /** |
||
393 | * Удаление информации о дистрибутиве |
||
394 | * |
||
395 | * @author Alexander Wolf |
||
396 | * @category Core |
||
397 | * |
||
398 | * @param integer $distID |
||
399 | * @return array |
||
400 | */ |
||
401 | public function dropDistribution($distID) { |
||
402 | $result = array(); |
||
403 | $sDID = $this->secure->checkInt($distID); |
||
404 | |||
405 | // Удаление дистрибутива |
||
406 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
||
407 | $rq =& $this->db->query($query); |
||
408 | if (PEAR::isError($this->db)) { |
||
409 | $result["ERR"] = 1; |
||
410 | $result["ERRINFO"] = $this->db->getMessage(); |
||
519 | alex-w | 411 | } else { |
514 | alex-w | 412 | $result["ERR"] = 0; |
413 | } |
||
414 | |||
415 | // Удаление версий дистрибутива |
||
416 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
||
417 | $rq =& $this->db->query($query); |
||
418 | if (PEAR::isError($this->db)) { |
||
419 | $result["ERR"] = 1; |
||
420 | $result["ERRINFO"] = $this->db->getMessage(); |
||
519 | alex-w | 421 | } else { |
514 | alex-w | 422 | $result["ERR"] = 0; |
423 | } |
||
424 | |||
425 | return $result; |
||
426 | } |
||
427 | |||
428 | /** |
||
463 | alex-w | 429 | * Добавление поддержки новой версии apt-дистрибутива |
430 | * |
||
431 | * @author Alexander Wolf |
||
432 | * @category Core |
||
433 | * |
||
434 | * @param integer $distID |
||
435 | * @param integer $version |
||
436 | * @param string $vname |
||
437 | * @param integer $vcodename |
||
438 | * @return array |
||
439 | */ |
||
368 | alex-w | 440 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
356 | alex-w | 441 | $result = array(); |
463 | alex-w | 442 | $sDistID = $this->secure->checkInt($distID); |
582 | alex-w | 443 | $sDVersion = $this->secure->checkStr($version); |
444 | $sDVName = $this->secure->checkStr($vname); |
||
445 | $sDVCName = $this->secure->checkStr($vcodename); |
||
356 | alex-w | 446 | |
447 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
||
448 | $rq =& $this->db->query($query); |
||
449 | if (PEAR::isError($this->db)) { |
||
450 | $result["ERR"] = 1; |
||
451 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 452 | } else { |
356 | alex-w | 453 | $result["ERR"] = 0; |
454 | } |
||
455 | |||
456 | return $result; |
||
457 | } |
||
358 | alex-w | 458 | |
463 | alex-w | 459 | /** |
514 | alex-w | 460 | * Редактирование информации о версии дистрибутива |
461 | * |
||
462 | * @author Alexander Wolf |
||
463 | * @category Core |
||
464 | * |
||
465 | * @param integer $versionID |
||
466 | * @param string $version |
||
467 | * @param string $vname |
||
468 | * @param string $vcodename |
||
469 | * @return array |
||
470 | */ |
||
471 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
||
472 | $result = array(); |
||
473 | $sVersID = $this->secure->checkInt($versionID); |
||
516 | alex-w | 474 | $sDVersion = $this->secure->checkStr($version,1); |
475 | $sDVName = $this->secure->checkStr($vname,1); |
||
476 | $sDVCName = $this->secure->checkStr($vcodename,1); |
||
514 | alex-w | 477 | |
478 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
||
479 | $rq =& $this->db->query($query); |
||
480 | if (PEAR::isError($this->db)) { |
||
481 | $result["ERR"] = 1; |
||
482 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 483 | } else { |
514 | alex-w | 484 | $result["ERR"] = 0; |
485 | } |
||
486 | |||
487 | return $result; |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * Удаление информации о версии дистрибутива |
||
492 | * |
||
493 | * @author Alexander Wolf |
||
494 | * @category Core |
||
495 | * |
||
496 | * @param integer $versionID |
||
497 | * @return array |
||
498 | */ |
||
499 | public function dropDistVersion($versionID) { |
||
500 | $result = array(); |
||
501 | $sVersID = $this->secure->checkInt($versionID); |
||
502 | |||
503 | // Удаление версии дистрибутива |
||
504 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
||
505 | $rq =& $this->db->query($query); |
||
506 | if (PEAR::isError($this->db)) { |
||
507 | $result["ERR"] = 1; |
||
508 | $result["ERRINFO"] = $this->db->getMessage(); |
||
515 | alex-w | 509 | } else { |
514 | alex-w | 510 | $result["ERR"] = 0; |
511 | } |
||
512 | |||
513 | // Удаление репозиториев этой версии дистрибутива |
||
514 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
||
515 | $rq =& $this->db->query($query); |
||
516 | if (PEAR::isError($this->db)) { |
||
517 | $result["ERR"] = 1; |
||
518 | $result["ERRINFO"] = $this->db->getMessage(); |
||
517 | alex-w | 519 | } else { |
514 | alex-w | 520 | $result["ERR"] = 0; |
521 | } |
||
522 | |||
523 | return $result; |
||
524 | } |
||
525 | |||
526 | /** |
||
463 | alex-w | 527 | * Отображение типа дистрибутива |
528 | * |
||
529 | * @author Alexander Wolf |
||
530 | * @category Core |
||
531 | * |
||
532 | * @param string $name |
||
533 | * @param byte $type |
||
534 | * @return string |
||
535 | */ |
||
368 | alex-w | 536 | public function showDistTypeForm($name = "dtype",$type = 0) { |
329 | alex-w | 537 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
538 | $rq =& $this->db->query($query); |
||
539 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
540 | while ($rq->fetchInto($element)) { |
||
347 | alex-w | 541 | if ($element["type_id"] == $type) { |
542 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
||
329 | alex-w | 543 | } else { |
347 | alex-w | 544 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
329 | alex-w | 545 | } |
546 | } |
||
547 | $show .= "</select>"; |
||
548 | |||
549 | return $show; |
||
550 | } |
||
551 | |||
463 | alex-w | 552 | /** |
553 | * Отображение формы создания и редактирования apt-дистрибутива |
||
554 | * |
||
555 | * @author Alexander Wolf |
||
556 | * @category Core |
||
557 | * |
||
558 | * @param integer $distID |
||
559 | * @return string |
||
560 | */ |
||
511 | alex-w | 561 | public function showDistributionForm($distID = 0, $info = '') { |
329 | alex-w | 562 | $sDistID = $this->secure->checkInt($distID); |
511 | alex-w | 563 | $sInfo = $this->secure->checkStr($info, 1); |
564 | if ($sInfo == "") { |
||
565 | $sInfo = "Дистрибутив"; |
||
566 | } |
||
329 | alex-w | 567 | if ($sDistID != 0) { |
568 | // Режим редактирования |
||
569 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
||
570 | $rq =& $this->db->query($query); |
||
571 | $rq->fetchInto($element); |
||
572 | } |
||
573 | |||
574 | if ($element["distlogo"] == 1) { |
||
380 | alex-w | 575 | $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 | 576 | } else { |
380 | alex-w | 577 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
329 | alex-w | 578 | } |
579 | |||
511 | alex-w | 580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
350 | alex-w | 581 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
582 | $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 | 583 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
348 | alex-w | 584 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
329 | alex-w | 585 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
350 | alex-w | 586 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
329 | alex-w | 587 | |
588 | return $show; |
||
589 | } |
||
590 | |||
628 | alex-w | 591 | /** |
592 | * Генератор sources.list |
||
593 | * |
||
594 | * @author Alexander Wolf |
||
595 | * @category Core |
||
596 | * @version 1.0 |
||
597 | * |
||
598 | * @param array $data |
||
599 | * @return string |
||
600 | */ |
||
601 | public function showSourcesList($data) { |
||
602 | //TODO Написать генератор sources.list |
||
603 | |||
604 | return $show; |
||
358 | alex-w | 605 | } |
522 | alex-w | 606 | |
463 | alex-w | 607 | /** |
522 | alex-w | 608 | * Показывает список секций |
609 | * |
||
610 | * @author Alexander Wolf |
||
611 | * @category Core |
||
612 | * |
||
613 | * @param string $name |
||
614 | * @param string $actor |
||
561 | alex-w | 615 | * @param string $format |
522 | alex-w | 616 | * @return string |
617 | */ |
||
560 | alex-w | 618 | public function showSectionsList($name, $actor, $format = 'html') { |
619 | switch($format) { |
||
620 | case 'html': |
||
561 | alex-w | 621 | $query = "SELECT * FROM ".$this->prefix."section"; |
622 | $rq =& $this->db->query($query); |
||
560 | alex-w | 623 | $show = "<ul>\n"; |
624 | while ($rq->fetchInto($element)) { |
||
625 | $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"; |
||
626 | } |
||
627 | $show .= "</ul>"; |
||
628 | break; |
||
629 | case 'innerhtml': |
||
630 | $show = ""; |
||
561 | alex-w | 631 | $repID = $this->secure->checkInt($actor); |
632 | if ($repID==0) { |
||
633 | $query = "SELECT * FROM ".$this->prefix."section"; |
||
634 | $rq =& $this->db->query($query); |
||
635 | while ($rq->fetchInto($element)) { |
||
567 | alex-w | 636 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 637 | } |
638 | } else { |
||
639 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
||
640 | $rq =& $this->db->query($query); |
||
641 | while ($rq->fetchInto($element)) { |
||
567 | alex-w | 642 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 643 | } |
644 | $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 | 645 | $rq =& $this->db->query($query); |
561 | alex-w | 646 | while ($rq->fetchInto($element)) { |
567 | alex-w | 647 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
561 | alex-w | 648 | } |
649 | } |
||
650 | |||
560 | alex-w | 651 | break; |
522 | alex-w | 652 | } |
653 | |||
654 | return $show; |
||
655 | } |
||
656 | |||
523 | alex-w | 657 | /** |
658 | * Вывод формы редактирования/добавления секций |
||
659 | * |
||
660 | * @author Alexander Wolf |
||
661 | * @category Core |
||
662 | * |
||
663 | * @param integer $sectionID |
||
664 | * @param string $info |
||
665 | * @return string |
||
666 | */ |
||
667 | public function showSectionsForm($sectionID = 0, $info = "") { |
||
522 | alex-w | 668 | $sSectID = $this->secure->checkInt($sectionID); |
669 | $sInfo = $this->secure->checkStr($info, 1); |
||
670 | if ($sInfo == "") { |
||
671 | $sInfo = "Секция"; |
||
672 | } |
||
673 | if ($sSectID != 0) { |
||
674 | // Режим редактирования |
||
675 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
||
676 | $rq =& $this->db->query($query); |
||
677 | $rq->fetchInto($element); |
||
678 | } |
||
679 | |||
680 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
681 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
||
682 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
||
683 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
684 | |||
685 | return $show; |
||
686 | } |
||
687 | |||
688 | /** |
||
523 | alex-w | 689 | * Обновление информации о секции |
690 | * |
||
691 | * @author Alexander Wolf |
||
692 | * @category Core |
||
693 | * |
||
694 | * @param integer $sectionID |
||
695 | * @param string $sname |
||
696 | * @param string $sinfo |
||
697 | * @return array |
||
698 | */ |
||
699 | public function updateSection($sectionID, $sname, $sinfo = "") { |
||
700 | $result = array(); |
||
701 | $sSectID = $this->secure->checkInt($sectionID); |
||
579 | alex-w | 702 | $sSName = $this->secure->checkStr($sname); |
703 | $sSInfo = $this->secure->checkStr($sinfo); |
||
523 | alex-w | 704 | |
705 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
||
706 | $rq =& $this->db->query($query); |
||
707 | if (PEAR::isError($this->db)) { |
||
708 | $result["ERR"] = 1; |
||
709 | $result["ERRINFO"] = $this->db->getMessage(); |
||
710 | } else { |
||
711 | $result["ERR"] = 0; |
||
712 | } |
||
713 | |||
714 | return $result; |
||
715 | } |
||
716 | |||
717 | /** |
||
718 | * Удаление информации о секции |
||
719 | * |
||
720 | * @author Alexander Wolf |
||
721 | * @category Core |
||
722 | * |
||
723 | * @param integer $sectionID |
||
724 | * @return array |
||
725 | */ |
||
726 | public function dropSection($sectionID) { |
||
727 | $result = array(); |
||
728 | $sSectID = $this->secure->checkInt($sectionID); |
||
729 | |||
730 | // Удаление секции |
||
731 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
||
732 | $rq =& $this->db->query($query); |
||
733 | if (PEAR::isError($this->db)) { |
||
734 | $result["ERR"] = 1; |
||
735 | $result["ERRINFO"] = $this->db->getMessage(); |
||
736 | } else { |
||
737 | $result["ERR"] = 0; |
||
738 | } |
||
739 | |||
740 | return $result; |
||
741 | } |
||
742 | |||
743 | /** |
||
744 | * Добавление новой секции |
||
745 | * |
||
746 | * @author Alexander Wolf |
||
747 | * @category Core |
||
748 | * |
||
749 | * @param string $sname |
||
750 | * @param string $sinfo |
||
751 | * @return array |
||
752 | */ |
||
753 | public function addSection($sname, $sinfo = "") { |
||
754 | $result = array(); |
||
582 | alex-w | 755 | $sSName = $this->secure->checkStr($sname); |
756 | $sSInfo = $this->secure->checkStr($sinfo); |
||
523 | alex-w | 757 | |
758 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
||
759 | $rq =& $this->db->query($query); |
||
760 | if (PEAR::isError($this->db)) { |
||
761 | $result["ERR"] = 1; |
||
762 | $result["ERRINFO"] = $this->db->getMessage(); |
||
763 | } else { |
||
764 | $result["ERR"] = 0; |
||
765 | } |
||
766 | |||
767 | return $result; |
||
768 | } |
||
769 | |||
770 | /** |
||
568 | alex-w | 771 | * Вывод списка поддерживаемых архитектур |
772 | * |
||
773 | * @author Alexander Wolf |
||
774 | * @category Core |
||
775 | * |
||
776 | * @param string $name |
||
777 | * @param string $actor |
||
778 | * @param string $format |
||
779 | * @return string |
||
780 | */ |
||
781 | public function showArchList($name, $actor, $format = 'list') { |
||
782 | switch($format) { |
||
783 | case 'list': |
||
784 | $query = "SELECT * FROM ".$this->prefix."arch"; |
||
785 | $rq =& $this->db->query($query); |
||
786 | $show = "<ul>\n"; |
||
787 | while ($rq->fetchInto($element)) { |
||
788 | $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"; |
||
789 | } |
||
790 | $show .= "</ul>"; |
||
791 | break; |
||
792 | case 'innerhtml': |
||
793 | $show = ""; |
||
794 | $repID = $this->secure->checkInt($actor); |
||
614 | alex-w | 795 | if ($repID==0) { |
568 | alex-w | 796 | $query = "SELECT * FROM ".$this->prefix."arch"; |
797 | $rq =& $this->db->query($query); |
||
798 | while ($rq->fetchInto($element)) { |
||
799 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
||
800 | } |
||
801 | } else { |
||
802 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
||
803 | $rq =& $this->db->query($query); |
||
804 | while ($rq->fetchInto($element)) { |
||
805 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
||
806 | } |
||
807 | $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')"; |
||
808 | $rq =& $this->db->query($query); |
||
610 | alex-w | 809 | if ($rq->numRows()>0) { |
810 | while ($rq->fetchInto($element)) { |
||
811 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
||
812 | } |
||
568 | alex-w | 813 | } |
814 | } |
||
815 | break; |
||
816 | } |
||
817 | return $show; |
||
818 | } |
||
819 | |||
820 | /** |
||
821 | * Добавление новой архитектуры |
||
822 | * |
||
823 | * @author Alexander Wolf |
||
824 | * @category Core |
||
825 | * |
||
826 | * @param string $arch |
||
827 | * @return array |
||
828 | */ |
||
829 | public function addArch($arch) { |
||
830 | $result = array(); |
||
582 | alex-w | 831 | $sArch = $this->secure->checkStr($arch); |
568 | alex-w | 832 | |
833 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
||
834 | $rq =& $this->db->query($query); |
||
835 | if (PEAR::isError($this->db)) { |
||
836 | $result["ERR"] = 1; |
||
837 | $result["ERRINFO"] = $this->db->getMessage(); |
||
838 | } else { |
||
839 | $result["ERR"] = 0; |
||
840 | } |
||
841 | |||
842 | return $result; |
||
843 | } |
||
844 | |||
845 | /** |
||
846 | * Удаление информации об архитектуре |
||
847 | * |
||
848 | * @author Alexander Wolf |
||
849 | * @category Core |
||
850 | * |
||
851 | * @param integer $archID |
||
852 | * @return array |
||
853 | */ |
||
854 | public function dropArch($archID) { |
||
855 | $result = array(); |
||
856 | $sArchID = $this->secure->checkInt($archID); |
||
857 | |||
858 | // Удаление архитектуры |
||
859 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
||
860 | $rq =& $this->db->query($query); |
||
861 | if (PEAR::isError($this->db)) { |
||
862 | $result["ERR"] = 1; |
||
863 | $result["ERRINFO"] = $this->db->getMessage(); |
||
864 | } else { |
||
865 | $result["ERR"] = 0; |
||
866 | } |
||
867 | |||
868 | // Удаление архитектуры из списка репозиториев |
||
869 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
||
870 | $rq =& $this->db->query($query); |
||
871 | if (PEAR::isError($this->db)) { |
||
872 | $result["ERR"] = 1; |
||
873 | $result["ERRINFO"] = $this->db->getMessage(); |
||
874 | } else { |
||
875 | $result["ERR"] = 0; |
||
876 | } |
||
877 | return $result; |
||
878 | } |
||
879 | |||
880 | /** |
||
881 | * Обновление информации об архитектуре |
||
882 | * |
||
883 | * @author Alexander Wolf |
||
884 | * @category Core |
||
885 | * |
||
886 | * @param integer $archID |
||
887 | * @param string $arch |
||
888 | * @return array |
||
889 | */ |
||
890 | public function updateArch($archID, $arch) { |
||
891 | $result = array(); |
||
892 | $sArchID = $this->secure->checkInt($archID); |
||
579 | alex-w | 893 | $sArch = $this->secure->checkStr($arch); |
568 | alex-w | 894 | |
895 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
||
896 | $rq =& $this->db->query($query); |
||
897 | if (PEAR::isError($this->db)) { |
||
898 | $result["ERR"] = 1; |
||
899 | $result["ERRINFO"] = $this->db->getMessage(); |
||
900 | } else { |
||
901 | $result["ERR"] = 0; |
||
902 | } |
||
903 | |||
904 | return $result; |
||
905 | } |
||
906 | |||
907 | /** |
||
908 | * Вывод формы редактирования/добавления архитектур |
||
909 | * |
||
910 | * @author Alexander Wolf |
||
911 | * @category Core |
||
912 | * |
||
913 | * @param integer $archID |
||
914 | * @param string $info |
||
915 | * @return string |
||
916 | */ |
||
917 | public function showArchForm($archID = 0, $info = "") { |
||
918 | $sArchID = $this->secure->checkInt($archID); |
||
919 | $sInfo = $this->secure->checkStr($info, 1); |
||
920 | if ($sInfo == "") { |
||
921 | $sInfo = "Архитектура"; |
||
922 | } |
||
923 | if ($sArchID != 0) { |
||
924 | // Режим редактирования |
||
925 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
||
926 | $rq =& $this->db->query($query); |
||
927 | $rq->fetchInto($element); |
||
928 | } |
||
929 | |||
930 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
931 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
||
932 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
933 | |||
934 | return $show; |
||
935 | } |
||
936 | |||
937 | /** |
||
570 | alex-w | 938 | * Вывод списка схем репозиториев |
939 | * |
||
940 | * @author Alexander Wolf |
||
941 | * @category Core |
||
942 | * |
||
943 | * @param string $name |
||
944 | * @param string $actor |
||
945 | * @param string $format |
||
946 | * @return string |
||
947 | */ |
||
948 | public function showSchemeList($name, $actor, $format = 'list') { |
||
949 | switch($format) { |
||
950 | case 'list': |
||
951 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
||
952 | $rq =& $this->db->query($query); |
||
953 | $show = "<ul>\n"; |
||
954 | while ($rq->fetchInto($element)) { |
||
955 | $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"; |
||
956 | } |
||
957 | $show .= "</ul>"; |
||
958 | break; |
||
959 | case 'innerhtml': |
||
611 | alex-w | 960 | $schemeID = $this->secure->checkInt($actor); |
570 | alex-w | 961 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
962 | $rq =& $this->db->query($query); |
||
963 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
964 | while ($rq->fetchInto($element)) { |
||
611 | alex-w | 965 | if ($element["scheme_id"]==$schemeID) { |
570 | alex-w | 966 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
967 | } else { |
||
611 | alex-w | 968 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
570 | alex-w | 969 | } |
970 | } |
||
971 | $show .= "</select>"; |
||
972 | break; |
||
973 | } |
||
974 | return $show; |
||
975 | } |
||
976 | |||
977 | /** |
||
978 | * Добавление новой схемы репозитория |
||
979 | * |
||
980 | * @author Alexander Wolf |
||
981 | * @category Core |
||
982 | * |
||
983 | * @param string $scheme |
||
984 | * @return array |
||
985 | */ |
||
986 | public function addScheme($scheme) { |
||
987 | $result = array(); |
||
582 | alex-w | 988 | $sScheme = $this->secure->checkStr($scheme); |
570 | alex-w | 989 | |
990 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
||
991 | $rq =& $this->db->query($query); |
||
992 | if (PEAR::isError($this->db)) { |
||
993 | $result["ERR"] = 1; |
||
994 | $result["ERRINFO"] = $this->db->getMessage(); |
||
995 | } else { |
||
996 | $result["ERR"] = 0; |
||
997 | } |
||
998 | |||
999 | return $result; |
||
1000 | } |
||
1001 | |||
1002 | /** |
||
1003 | * Удаление информации о схеме репозитория |
||
1004 | * |
||
1005 | * @author Alexander Wolf |
||
1006 | * @category Core |
||
1007 | * |
||
1008 | * @param integer $schemeID |
||
1009 | * @return array |
||
1010 | */ |
||
1011 | public function dropScheme($schemeID) { |
||
1012 | $result = array(); |
||
1013 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
1014 | |||
1015 | // Удаление схемы |
||
1016 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
||
1017 | $rq =& $this->db->query($query); |
||
1018 | if (PEAR::isError($this->db)) { |
||
1019 | $result["ERR"] = 1; |
||
1020 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1021 | } else { |
||
1022 | $result["ERR"] = 0; |
||
1023 | } |
||
1024 | |||
1025 | return $result; |
||
1026 | } |
||
1027 | |||
1028 | /** |
||
1029 | * Обновление информации о схеме репозитория |
||
1030 | * |
||
1031 | * @author Alexander Wolf |
||
1032 | * @category Core |
||
1033 | * |
||
1034 | * @param integer $schemeID |
||
1035 | * @param string $info |
||
1036 | * @return array |
||
1037 | */ |
||
1038 | public function updateScheme($schemeID, $info) { |
||
1039 | $result = array(); |
||
1040 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
579 | alex-w | 1041 | $sScheme = $this->secure->checkStr($info); |
570 | alex-w | 1042 | |
1043 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
||
1044 | $rq =& $this->db->query($query); |
||
1045 | if (PEAR::isError($this->db)) { |
||
1046 | $result["ERR"] = 1; |
||
1047 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1048 | } else { |
||
1049 | $result["ERR"] = 0; |
||
1050 | } |
||
1051 | |||
1052 | return $result; |
||
1053 | } |
||
1054 | |||
1055 | /** |
||
1056 | * Вывод формы редактирования/добавления схем репозиториев |
||
1057 | * |
||
1058 | * @author Alexander Wolf |
||
1059 | * @category Core |
||
1060 | * |
||
1061 | * @param integer $schemeID |
||
1062 | * @param string $info |
||
1063 | * @return string |
||
1064 | */ |
||
1065 | public function showSchemeForm($schemeID = 0, $info = "") { |
||
1066 | $sSchemeID = $this->secure->checkInt($schemeID); |
||
1067 | $sInfo = $this->secure->checkStr($info, 1); |
||
1068 | if ($sInfo == "") { |
||
1069 | $sInfo = "Схема репозитория"; |
||
1070 | } |
||
571 | alex-w | 1071 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
570 | alex-w | 1072 | if ($sSchemeID != 0) { |
1073 | // Режим редактирования |
||
1074 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
||
1075 | $rq =& $this->db->query($query); |
||
573 | alex-w | 1076 | $rq->fetchInto($element); |
1077 | } |
||
571 | alex-w | 1078 | |
573 | alex-w | 1079 | $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 | 1080 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1081 | |||
1082 | return $show; |
||
1083 | } |
||
1084 | |||
1085 | /** |
||
574 | alex-w | 1086 | * Вывод списка протоколов |
1087 | * |
||
1088 | * @author Alexander Wolf |
||
1089 | * @category Core |
||
1090 | * |
||
1091 | * @param string $name |
||
1092 | * @param string $actor |
||
1093 | * @param string $format |
||
1094 | * @return string |
||
1095 | */ |
||
1096 | public function showProtoList($name, $actor, $format = 'list') { |
||
1097 | switch($format) { |
||
1098 | case 'list': |
||
1099 | $query = "SELECT * FROM ".$this->prefix."protos"; |
||
1100 | $rq =& $this->db->query($query); |
||
1101 | $show = "<ul>\n"; |
||
1102 | while ($rq->fetchInto($element)) { |
||
1103 | $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"; |
||
1104 | } |
||
1105 | $show .= "</ul>"; |
||
1106 | break; |
||
1107 | case 'innerhtml': |
||
1108 | $protoID = $this->secure->checkInt($actor); |
||
1109 | $query = "SELECT * FROM ".$this->prefix."protos"; |
||
1110 | $rq =& $this->db->query($query); |
||
1111 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1112 | while ($rq->fetchInto($element)) { |
||
1113 | if ($element["proto_id"]==$protoID) { |
||
1114 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
||
1115 | } else { |
||
580 | alex-w | 1116 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
574 | alex-w | 1117 | } |
1118 | } |
||
1119 | $show .= "</select>"; |
||
1120 | break; |
||
1121 | } |
||
1122 | return $show; |
||
1123 | } |
||
1124 | |||
1125 | /** |
||
1126 | * Добавление нового протокола |
||
1127 | * |
||
1128 | * @author Alexander Wolf |
||
1129 | * @category Core |
||
1130 | * |
||
1131 | * @param string $proto |
||
1132 | * @return array |
||
1133 | */ |
||
1134 | public function addProto($proto) { |
||
1135 | $result = array(); |
||
582 | alex-w | 1136 | $sProto = $this->secure->checkStr($proto); |
574 | alex-w | 1137 | |
1138 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
||
1139 | $rq =& $this->db->query($query); |
||
1140 | if (PEAR::isError($this->db)) { |
||
1141 | $result["ERR"] = 1; |
||
1142 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1143 | } else { |
||
1144 | $result["ERR"] = 0; |
||
1145 | } |
||
1146 | |||
1147 | return $result; |
||
1148 | } |
||
1149 | |||
1150 | /** |
||
1151 | * Удаление информации о протоколе |
||
1152 | * |
||
1153 | * @author Alexander Wolf |
||
1154 | * @category Core |
||
1155 | * |
||
1156 | * @param integer $protoID |
||
1157 | * @return array |
||
1158 | */ |
||
1159 | public function dropProto($protoID) { |
||
1160 | $result = array(); |
||
1161 | $sProtoID = $this->secure->checkInt($protoID); |
||
1162 | |||
1163 | // Удаление протокола |
||
1164 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
||
1165 | $rq =& $this->db->query($query); |
||
1166 | if (PEAR::isError($this->db)) { |
||
1167 | $result["ERR"] = 1; |
||
1168 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1169 | } else { |
||
1170 | $result["ERR"] = 0; |
||
1171 | } |
||
1172 | |||
1173 | return $result; |
||
1174 | } |
||
1175 | |||
1176 | /** |
||
1177 | * Обновление информации о протоколе |
||
1178 | * |
||
1179 | * @author Alexander Wolf |
||
1180 | * @category Core |
||
1181 | * |
||
1182 | * @param integer $protoID |
||
1183 | * @param string $info |
||
1184 | * @return array |
||
1185 | */ |
||
1186 | public function updateProto($protoID, $info) { |
||
1187 | $result = array(); |
||
1188 | $sProtoID = $this->secure->checkInt($protoID); |
||
579 | alex-w | 1189 | $sProto = $this->secure->checkStr($info); |
574 | alex-w | 1190 | |
1191 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
||
1192 | $rq =& $this->db->query($query); |
||
1193 | if (PEAR::isError($this->db)) { |
||
1194 | $result["ERR"] = 1; |
||
1195 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1196 | } else { |
||
1197 | $result["ERR"] = 0; |
||
1198 | } |
||
1199 | |||
1200 | return $result; |
||
1201 | } |
||
1202 | |||
1203 | /** |
||
1204 | * Вывод формы редактирования/добавления протоколов |
||
1205 | * |
||
1206 | * @author Alexander Wolf |
||
1207 | * @category Core |
||
1208 | * |
||
1209 | * @param integer $protoID |
||
1210 | * @param string $info |
||
1211 | * @return string |
||
1212 | */ |
||
1213 | public function showProtoForm($protoID = 0, $info = "") { |
||
1214 | $sProtoID = $this->secure->checkInt($protoID); |
||
1215 | $sInfo = $this->secure->checkStr($info, 1); |
||
1216 | if ($sInfo == "") { |
||
1217 | $sInfo = "Протокол доступа"; |
||
1218 | } |
||
1219 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1220 | if ($sProtoID != 0) { |
||
1221 | // Режим редактирования |
||
1222 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
||
1223 | $rq =& $this->db->query($query); |
||
1224 | $rq->fetchInto($element); |
||
1225 | } |
||
1226 | |||
1227 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
||
1228 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1229 | |||
1230 | return $show; |
||
1231 | } |
||
1232 | |||
1233 | /** |
||
582 | alex-w | 1234 | * Вывод списка хостов |
1235 | * |
||
1236 | * @author Alexander Wolf |
||
1237 | * @category Core |
||
1238 | * |
||
1239 | * @param string $name |
||
1240 | * @param string $actor |
||
1241 | * @param string $format |
||
1242 | * @return string |
||
1243 | */ |
||
1244 | public function showHostsList($name, $actor, $format = 'list') { |
||
1245 | switch($format) { |
||
1246 | case 'list': |
||
1247 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
||
1248 | $rq =& $this->db->query($query); |
||
1249 | $show = "<ul>\n"; |
||
1250 | while ($rq->fetchInto($element)) { |
||
1251 | $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"; |
||
1252 | } |
||
1253 | $show .= "</ul>"; |
||
1254 | break; |
||
1255 | case 'innerhtml': |
||
1256 | $hostID = $this->secure->checkInt($actor); |
||
1257 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
||
1258 | $rq =& $this->db->query($query); |
||
1259 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1260 | while ($rq->fetchInto($element)) { |
||
1261 | if ($element["rhost_id"]==$hostID) { |
||
1262 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
||
1263 | } else { |
||
1264 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
||
1265 | } |
||
1266 | } |
||
1267 | $show .= "</select>"; |
||
1268 | break; |
||
1269 | } |
||
1270 | return $show; |
||
1271 | } |
||
1272 | |||
1273 | /** |
||
1274 | * Добавление нового хоста |
||
1275 | * |
||
1276 | * @author Alexander Wolf |
||
1277 | * @category Core |
||
1278 | * |
||
1279 | * @param string $host |
||
1280 | * @return array |
||
1281 | */ |
||
1282 | public function addHost($host) { |
||
1283 | $result = array(); |
||
1284 | $sHost = $this->secure->checkStr($host); |
||
1285 | |||
586 | alex-w | 1286 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
582 | alex-w | 1287 | $rq =& $this->db->query($query); |
1288 | if (PEAR::isError($this->db)) { |
||
1289 | $result["ERR"] = 1; |
||
1290 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1291 | } else { |
||
1292 | $result["ERR"] = 0; |
||
1293 | } |
||
1294 | |||
1295 | return $result; |
||
1296 | } |
||
1297 | |||
1298 | /** |
||
1299 | * Удаление информации о хосте |
||
1300 | * |
||
1301 | * @author Alexander Wolf |
||
1302 | * @category Core |
||
1303 | * |
||
1304 | * @param integer $hostID |
||
1305 | * @return array |
||
1306 | */ |
||
1307 | public function dropHost($hostID) { |
||
1308 | $result = array(); |
||
1309 | $sHostID = $this->secure->checkInt($hostID); |
||
1310 | |||
1311 | // Удаление хоста |
||
1312 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
||
1313 | $rq =& $this->db->query($query); |
||
1314 | if (PEAR::isError($this->db)) { |
||
1315 | $result["ERR"] = 1; |
||
1316 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1317 | } else { |
||
1318 | $result["ERR"] = 0; |
||
1319 | } |
||
1320 | |||
1321 | return $result; |
||
1322 | } |
||
1323 | |||
1324 | /** |
||
1325 | * Обновление информации о хосте |
||
1326 | * |
||
1327 | * @author Alexander Wolf |
||
1328 | * @category Core |
||
1329 | * |
||
1330 | * @param integer $hostID |
||
1331 | * @param string $info |
||
1332 | * @return array |
||
1333 | */ |
||
1334 | public function updateHost($hostID, $info) { |
||
1335 | $result = array(); |
||
1336 | $sHostID = $this->secure->checkInt($hostID); |
||
1337 | $sHost = $this->secure->checkStr($info); |
||
1338 | |||
1339 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
||
1340 | $rq =& $this->db->query($query); |
||
1341 | if (PEAR::isError($this->db)) { |
||
1342 | $result["ERR"] = 1; |
||
1343 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1344 | } else { |
||
1345 | $result["ERR"] = 0; |
||
1346 | } |
||
1347 | |||
1348 | return $result; |
||
1349 | } |
||
1350 | |||
1351 | /** |
||
1352 | * Вывод формы редактирования/добавления хостов |
||
1353 | * |
||
1354 | * @author Alexander Wolf |
||
1355 | * @category Core |
||
1356 | * |
||
1357 | * @param integer $hostID |
||
1358 | * @param string $info |
||
1359 | * @return string |
||
1360 | */ |
||
1361 | public function showHostForm($hostID = 0, $info = "") { |
||
1362 | $sHostID = $this->secure->checkInt($hostID); |
||
1363 | $sInfo = $this->secure->checkStr($info, 1); |
||
1364 | if ($sInfo == "") { |
||
1365 | $sInfo = "Хост репозитория"; |
||
1366 | } |
||
1367 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1368 | if ($sHostID != 0) { |
||
1369 | // Режим редактирования |
||
1370 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
||
1371 | $rq =& $this->db->query($query); |
||
1372 | $rq->fetchInto($element); |
||
1373 | } |
||
1374 | |||
1375 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
||
1376 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1377 | |||
1378 | return $show; |
||
1379 | } |
||
1380 | |||
1381 | /** |
||
589 | alex-w | 1382 | * Вывод списка корневых папок |
1383 | * |
||
1384 | * @author Alexander Wolf |
||
1385 | * @category Core |
||
1386 | * |
||
1387 | * @param string $name |
||
1388 | * @param string $actor |
||
1389 | * @param string $format |
||
1390 | * @return string |
||
1391 | */ |
||
1392 | public function showFoldersList($name, $actor, $format = 'list') { |
||
1393 | switch($format) { |
||
1394 | case 'list': |
||
1395 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
||
1396 | $rq =& $this->db->query($query); |
||
1397 | $show = "<ul>\n"; |
||
1398 | while ($rq->fetchInto($element)) { |
||
1399 | $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"; |
||
1400 | } |
||
1401 | $show .= "</ul>"; |
||
1402 | break; |
||
1403 | case 'innerhtml': |
||
1404 | $folderID = $this->secure->checkInt($actor); |
||
1405 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
||
1406 | $rq =& $this->db->query($query); |
||
1407 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1408 | while ($rq->fetchInto($element)) { |
||
1409 | if ($element["rfolder_id"]==$folderID) { |
||
1410 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
||
1411 | } else { |
||
1412 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
||
1413 | } |
||
1414 | } |
||
1415 | $show .= "</select>"; |
||
1416 | break; |
||
1417 | } |
||
1418 | return $show; |
||
1419 | } |
||
1420 | |||
1421 | /** |
||
1422 | * Добавление нового корневого каталога |
||
1423 | * |
||
1424 | * @author Alexander Wolf |
||
1425 | * @category Core |
||
1426 | * |
||
1427 | * @param string $flder |
||
1428 | * @return array |
||
1429 | */ |
||
1430 | public function addFolder($folder) { |
||
1431 | $result = array(); |
||
1432 | $sFolder = $this->secure->checkStr($folder); |
||
1433 | |||
1434 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
||
1435 | $rq =& $this->db->query($query); |
||
1436 | if (PEAR::isError($this->db)) { |
||
1437 | $result["ERR"] = 1; |
||
1438 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1439 | } else { |
||
1440 | $result["ERR"] = 0; |
||
1441 | } |
||
1442 | |||
1443 | return $result; |
||
1444 | } |
||
1445 | |||
1446 | /** |
||
1447 | * Удаление информации о корневой папке |
||
1448 | * |
||
1449 | * @author Alexander Wolf |
||
1450 | * @category Core |
||
1451 | * |
||
1452 | * @param integer $folderID |
||
1453 | * @return array |
||
1454 | */ |
||
1455 | public function dropFolder($folderID) { |
||
1456 | $result = array(); |
||
1457 | $sFolderID = $this->secure->checkInt($folderID); |
||
1458 | |||
1459 | // Удаление корневой папки |
||
1460 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
||
1461 | $rq =& $this->db->query($query); |
||
1462 | if (PEAR::isError($this->db)) { |
||
1463 | $result["ERR"] = 1; |
||
1464 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1465 | } else { |
||
1466 | $result["ERR"] = 0; |
||
1467 | } |
||
1468 | |||
1469 | return $result; |
||
1470 | } |
||
1471 | |||
1472 | /** |
||
1473 | * Обновление информации о корневой папки |
||
1474 | * |
||
1475 | * @author Alexander Wolf |
||
1476 | * @category Core |
||
1477 | * |
||
1478 | * @param integer $folderID |
||
1479 | * @param string $info |
||
1480 | * @return array |
||
1481 | */ |
||
1482 | public function updateFolder($folderID, $info) { |
||
1483 | $result = array(); |
||
1484 | $sFolderID = $this->secure->checkInt($folderID); |
||
1485 | $sFolder = $this->secure->checkStr($info); |
||
1486 | |||
1487 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
||
1488 | $rq =& $this->db->query($query); |
||
1489 | if (PEAR::isError($this->db)) { |
||
1490 | $result["ERR"] = 1; |
||
1491 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1492 | } else { |
||
1493 | $result["ERR"] = 0; |
||
1494 | } |
||
1495 | |||
1496 | return $result; |
||
1497 | } |
||
1498 | |||
1499 | /** |
||
1500 | * Вывод формы редактирования/добавления корневых папок |
||
1501 | * |
||
1502 | * @author Alexander Wolf |
||
1503 | * @category Core |
||
1504 | * |
||
1505 | * @param integer $folderID |
||
1506 | * @param string $info |
||
1507 | * @return string |
||
1508 | */ |
||
1509 | public function showFolderForm($folderID = 0, $info = "") { |
||
1510 | $sFolderID = $this->secure->checkInt($folderID); |
||
1511 | $sInfo = $this->secure->checkStr($info, 1); |
||
1512 | if ($sInfo == "") { |
||
1513 | $sInfo = "Корневая папка"; |
||
1514 | } |
||
1515 | if ($sFolderID != 0) { |
||
1516 | // Режим редактирования |
||
1517 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
||
1518 | $rq =& $this->db->query($query); |
||
1519 | $rq->fetchInto($element); |
||
1520 | } |
||
1521 | |||
1522 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1523 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
||
1524 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1525 | |||
1526 | return $show; |
||
1527 | } |
||
1528 | |||
1529 | /** |
||
539 | alex-w | 1530 | * Показывает список подписей |
1531 | * |
||
1532 | * @author Alexander Wolf |
||
1533 | * @category Core |
||
1534 | * |
||
1535 | * @param string $name |
||
1536 | * @param string $actor |
||
596 | alex-w | 1537 | * @param string $format |
539 | alex-w | 1538 | * @return string |
1539 | */ |
||
594 | alex-w | 1540 | public function showSignsList($name, $actor, $format = 'list') { |
539 | alex-w | 1541 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1542 | $rq =& $this->db->query($query); |
||
594 | alex-w | 1543 | switch ($format) { |
1544 | case 'list': |
||
1545 | $show = "<ul>\n"; |
||
1546 | while ($rq->fetchInto($element)) { |
||
1547 | $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"; |
||
1548 | } |
||
1549 | $show .= "</ul>"; |
||
1550 | break; |
||
1551 | case 'innerhtml': |
||
1552 | $signID = $this->secure->checkInt($actor); |
||
1553 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1554 | $show .= "<option value='0'>Подписи нет</option>\n"; |
||
1555 | while ($rq->fetchInto($element)) { |
||
1556 | if ($element["sign_id"]==$signID) { |
||
1557 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
||
1558 | } else { |
||
1559 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
||
1560 | } |
||
1561 | } |
||
1562 | $show .= "</select>\n"; |
||
1563 | break; |
||
539 | alex-w | 1564 | } |
1565 | |||
1566 | return $show; |
||
1567 | } |
||
1568 | |||
1569 | /** |
||
1570 | * Вывод формы редактирования/добавления подписей |
||
1571 | * |
||
1572 | * @author Alexander Wolf |
||
1573 | * @category Core |
||
1574 | * |
||
1575 | * @param integer $sectionID |
||
1576 | * @param string $info |
||
1577 | * @return string |
||
1578 | */ |
||
1579 | public function showSignsForm($signID = 0, $info = "") { |
||
1580 | $sSignID = $this->secure->checkInt($signID); |
||
1581 | $sInfo = $this->secure->checkStr($info, 1); |
||
1582 | if ($sInfo == "") { |
||
1583 | $sInfo = "Подписи"; |
||
1584 | } |
||
1585 | if ($sSignID != 0) { |
||
1586 | // Режим редактирования |
||
1587 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
||
1588 | $rq =& $this->db->query($query); |
||
1589 | $rq->fetchInto($element); |
||
1590 | } |
||
1591 | |||
1592 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
||
1593 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
||
1594 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
||
1595 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
||
1596 | |||
1597 | return $show; |
||
1598 | } |
||
1599 | |||
1600 | /** |
||
1601 | * Обновление информации о секции |
||
1602 | * |
||
1603 | * @author Alexander Wolf |
||
1604 | * @category Core |
||
1605 | * |
||
1606 | * @param integer $sectionID |
||
1607 | * @param string $sname |
||
1608 | * @param string $sinfo |
||
1609 | * @return array |
||
1610 | */ |
||
1611 | public function updateSign($signID, $sname, $sinfo = "") { |
||
1612 | $result = array(); |
||
1613 | $sSignID = $this->secure->checkInt($signID); |
||
579 | alex-w | 1614 | $sSName = $this->secure->checkStr($sname); |
1615 | $sSInfo = $this->secure->checkStr($sinfo); |
||
539 | alex-w | 1616 | |
1617 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
||
1618 | $rq =& $this->db->query($query); |
||
1619 | if (PEAR::isError($this->db)) { |
||
1620 | $result["ERR"] = 1; |
||
1621 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1622 | } else { |
||
1623 | $result["ERR"] = 0; |
||
1624 | } |
||
1625 | |||
1626 | return $result; |
||
1627 | } |
||
1628 | |||
1629 | /** |
||
1630 | * Удаление информации о подписи |
||
1631 | * |
||
1632 | * @author Alexander Wolf |
||
1633 | * @category Core |
||
1634 | * |
||
1635 | * @param integer $sectionID |
||
1636 | * @return array |
||
1637 | */ |
||
540 | alex-w | 1638 | public function dropSign($signID) { |
539 | alex-w | 1639 | $result = array(); |
1640 | $sSignID = $this->secure->checkInt($signID); |
||
1641 | |||
1642 | // Удаление подписи |
||
1643 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
||
1644 | $rq =& $this->db->query($query); |
||
1645 | if (PEAR::isError($this->db)) { |
||
1646 | $result["ERR"] = 1; |
||
1647 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1648 | } else { |
||
1649 | $result["ERR"] = 0; |
||
1650 | } |
||
1651 | |||
1652 | return $result; |
||
1653 | } |
||
1654 | |||
1655 | /** |
||
540 | alex-w | 1656 | * Добавление новой подписи |
539 | alex-w | 1657 | * |
1658 | * @author Alexander Wolf |
||
1659 | * @category Core |
||
1660 | * |
||
1661 | * @param string $sname |
||
1662 | * @param string $sinfo |
||
1663 | * @return array |
||
1664 | */ |
||
540 | alex-w | 1665 | public function addSign($sname, $sinfo = "") { |
539 | alex-w | 1666 | $result = array(); |
582 | alex-w | 1667 | $sSName = $this->secure->checkStr($sname); |
1668 | $sSInfo = $this->secure->checkStr($sinfo); |
||
539 | alex-w | 1669 | |
540 | alex-w | 1670 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
539 | alex-w | 1671 | $rq =& $this->db->query($query); |
1672 | if (PEAR::isError($this->db)) { |
||
1673 | $result["ERR"] = 1; |
||
1674 | $result["ERRINFO"] = $this->db->getMessage(); |
||
1675 | } else { |
||
1676 | $result["ERR"] = 0; |
||
1677 | } |
||
1678 | |||
1679 | return $result; |
||
1680 | } |
||
540 | alex-w | 1681 | |
539 | alex-w | 1682 | /** |
463 | alex-w | 1683 | * Проверка пароля (из формы авторизации) |
1684 | * |
||
1685 | * @author Alexander Wolf |
||
1686 | * @category Core |
||
1687 | * |
||
1688 | * @param string $word |
||
1689 | * @return array |
||
1690 | */ |
||
368 | alex-w | 1691 | public function checkSign($word) { |
359 | alex-w | 1692 | $result = array(); |
1693 | |||
1694 | $sHash = $this->secure->encryptStr($word); |
||
1695 | $pwd = $this->getOption("passwd"); |
||
1696 | if ($sHash == $pwd["OptValue"]) { |
||
1697 | $result["ERR"] = 0; |
||
1698 | $result["Location"] = "manager.php"; |
||
1699 | setcookie($this->cookie, $sHash); |
||
1700 | } else { |
||
1701 | $result["ERR"] = 1; |
||
1702 | $result["ERRINFO"] = "Password not valid"; |
||
368 | alex-w | 1703 | $result["Location"] = "manager.php?error=1"; |
359 | alex-w | 1704 | } |
1705 | |||
1706 | return $result; |
||
358 | alex-w | 1707 | } |
357 | alex-w | 1708 | |
463 | alex-w | 1709 | /** |
1710 | * Проверка пароля (из cookies) |
||
1711 | * |
||
1712 | * @author Alexander Wolf |
||
1713 | * @category Core |
||
1714 | * |
||
1715 | * @param string $hash |
||
1716 | * @return array |
||
1717 | */ |
||
368 | alex-w | 1718 | public function checkCookieSign($hash) { |
359 | alex-w | 1719 | $result = array(); |
1720 | |||
1721 | $pwd = $this->getOption("passwd"); |
||
1722 | if ($hash == $pwd["OptValue"]) { |
||
1723 | $result["ERR"] = 0; |
||
1724 | } else { |
||
1725 | $result["ERR"] = 1; |
||
1726 | $result["ERRINFO"] = "Hash not valid"; |
||
368 | alex-w | 1727 | $result["Location"] = "manager.php"; |
359 | alex-w | 1728 | } |
1729 | |||
1730 | return $result; |
||
1731 | } |
||
1732 | |||
463 | alex-w | 1733 | /** |
1734 | * Форма ввода пароля |
||
1735 | * |
||
1736 | * @author Alexander Wolf |
||
1737 | * @category Core |
||
1738 | * |
||
1739 | * @return string |
||
1740 | */ |
||
368 | alex-w | 1741 | public function showSigninForm() { |
425 | alex-w | 1742 | $show = "<div id='regform'>"; |
1743 | $show .= "<form action='process.php' method='post'>\n"; |
||
368 | alex-w | 1744 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1745 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
||
427 | alex-w | 1746 | $show .= "<input type='password' name='word' value=''>\n"; |
368 | alex-w | 1747 | $show .= "<input type='submit' value=' Войти '>\n"; |
425 | alex-w | 1748 | $show .= "</fieldset>\n</form></div>\n"; |
368 | alex-w | 1749 | |
1750 | return $show; |
||
1751 | } |
||
1752 | |||
463 | alex-w | 1753 | /** |
1754 | * Обновление пароля |
||
1755 | * |
||
1756 | * @author Alexander Wolf |
||
1757 | * @category Core |
||
1758 | * |
||
1759 | * @param string $word1 |
||
1760 | * @param string $word2 |
||
1761 | * @return array |
||
1762 | */ |
||
368 | alex-w | 1763 | public function updatePassword($word1, $word2) { |
359 | alex-w | 1764 | $result = array(); |
1765 | |||
1766 | if ($word1 == $word2) { |
||
1767 | $sWord = $this->secure->encryptStr($word1); |
||
1768 | $r = $this->setOption("passwd", $sWord); |
||
1769 | $result = $r; |
||
1770 | } else { |
||
1771 | $result["ERR"] = 1; |
||
1772 | $result["ERRINFO"] = "Passwords is mismatch"; |
||
1773 | } |
||
1774 | |||
1775 | return $result; |
||
1776 | } |
||
1777 | |||
504 | alex-w | 1778 | /** |
509 | alex-w | 1779 | * Отображение формы создания и редактирования версии apt-дистрибутива |
504 | alex-w | 1780 | * |
1781 | * @author Alexander Wolf |
||
1782 | * @category Core |
||
1783 | * |
||
1784 | * @param string $name |
||
1785 | * @param string $actor |
||
1786 | * @param integer $versionID |
||
1787 | * @return string |
||
1788 | */ |
||
511 | alex-w | 1789 | public function showDistVersionsForm($versionID = 0, $info = '') { |
509 | alex-w | 1790 | $sVersionID = $this->secure->checkInt($versionID); |
511 | alex-w | 1791 | $sInfo = $this->secure->checkStr($info, 1); |
1792 | if ($sInfo == "") { |
||
1793 | $sInfo = "Версия дистрибутива"; |
||
1794 | } |
||
509 | alex-w | 1795 | if ($sVersionID != 0) { |
1796 | // Режим редактирования |
||
556 | alex-w | 1797 | $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 | 1798 | $rq =& $this->db->query($query); |
1799 | $rq->fetchInto($element); |
||
509 | alex-w | 1800 | } |
1801 | |||
511 | alex-w | 1802 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
510 | alex-w | 1803 | if ($sVersionID != 0) { |
1804 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
||
1805 | } else { |
||
1806 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
||
1807 | } |
||
509 | alex-w | 1808 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1809 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
||
1810 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
||
1811 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
||
495 | alex-w | 1812 | |
504 | alex-w | 1813 | return $show; |
509 | alex-w | 1814 | } |
504 | alex-w | 1815 | |
520 | alex-w | 1816 | /** |
1817 | * Парсер схемы адреса репозитория |
||
1818 | * FIXME Возможно не потребуется |
||
1819 | * |
||
1820 | * @author Alexander Wolf |
||
1821 | * @category Core |
||
1822 | * |
||
1823 | * @param string $repstring |
||
1824 | * @return integer |
||
1825 | */ |
||
1826 | public function repositoryParser($repstring) { |
||
1827 | $tokens = array(); |
||
1828 | $sections = array(); |
||
1829 | $tokens = split(" ",$repstring); |
||
1830 | |||
1831 | if ($tokens[0] == "deb") { |
||
1832 | // debian/ubuntu репозиторий "type proto://host/folder distr sections" |
||
1833 | $url = parse_url($tokens[1]); |
||
1834 | $distr = $tokens[2]; |
||
1835 | |||
1836 | for($i=3;$i<count($tokens);$i++) { |
||
1837 | $sections[] = $tokens[$i]; |
||
1838 | } |
||
1839 | } else { |
||
1840 | // altlinux репозиторий "type [sign] proto://host/folder base repname" |
||
1841 | if (stripos($tokens[1],"]")!=0) { |
||
1842 | $sign = $tokens[1]; |
||
1843 | $url = parse_url($tokens[2]); |
||
1844 | $base = $tokens[3]; |
||
1845 | $repname = $tokens[4]; |
||
1846 | } else { |
||
1847 | $url = parse_url($tokens[1]); |
||
1848 | $base = $tokens[2]; |
||
1849 | $repname = $tokens[3]; |
||
1850 | } |
||
1851 | } |
||
1852 | |||
1853 | $proto = $url["scheme"]."://"; |
||
1854 | $addr = $url["host"]; |
||
1855 | if ($url["port"]!="") { |
||
1856 | $addr .= ":".$url["port"]; |
||
1857 | } |
||
1858 | $path = $url["path"]; |
||
1859 | |||
1860 | return 0; |
||
1861 | } |
||
1862 | |||
539 | alex-w | 1863 | /** |
1864 | * Выгрузка картинок логотипов дистрибутивов |
||
1865 | * |
||
1866 | * @author Alexander Wolf |
||
1867 | * @category Core |
||
1868 | * |
||
1869 | * @param string $path |
||
1870 | * @param string $dist |
||
1871 | * @param array $datafile |
||
1872 | * @return integer |
||
1873 | */ |
||
535 | alex-w | 1874 | public function uploadPicture($path, $dist, $datafile) { |
1875 | $folder = $path.$dist."-orig.png"; |
||
1876 | $folderN = $path.$dist.".png"; |
||
1877 | $folderEM = $path.$dist."-em.png"; |
||
1878 | |||
1879 | $distlogo = 0; |
||
1880 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
||
1881 | chmod($folder, 0644); |
||
1882 | list($width, $height) = GetImageSize($folder); |
||
1883 | $percent = 32/$height; |
||
1884 | $newwidth = $width * $percent; |
||
1885 | $newheight = $height * $percent; |
||
1886 | |||
1887 | $output = ImageCreateTrueColor($newwidth, $newheight); |
||
1888 | $source = ImageCreateFromPNG($folder); |
||
1889 | |||
1890 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
||
1891 | ImagePNG($output, $folderEM); |
||
1892 | |||
1893 | $percent = 15/$height; |
||
1894 | $newwidth = $width * $percent; |
||
1895 | $newheight = $height * $percent; |
||
1896 | |||
1897 | $output = ImageCreateTrueColor($newwidth, $newheight); |
||
1898 | |||
1899 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
||
1900 | ImagePNG($output, $folderN); |
||
1901 | |||
1902 | unlink($folder); |
||
1903 | $distlogo = 1; |
||
1904 | } |
||
1905 | return $distlogo; |
||
1906 | } |
||
547 | alex-w | 1907 | |
1908 | /** |
||
1909 | * Показ списка репозиториев |
||
1910 | * |
||
1911 | * @author Alexander Wolf |
||
1912 | * @category Core |
||
1913 | * |
||
1914 | * @param string $name |
||
1915 | * @param string $actor |
||
1916 | * @param string $format |
||
1917 | * @return string |
||
1918 | */ |
||
548 | alex-w | 1919 | public function showRepositoriesList($name, $actor, $format = 'list') { |
643 | alex-w | 1920 | $query = "SELECT r.*,rt.*,v.version_id,CONCAT(d.distname,' ',v.version,' “',v.vname,'”') AS fullname FROM ".$this->prefix."repository r "; |
548 | alex-w | 1921 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
629 | alex-w | 1922 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version "; |
641 | alex-w | 1923 | $query .= "JOIN ".$this->prefix."distribution d ON d.dist_id=v.dist_id "; |
629 | alex-w | 1924 | $query .= "ORDER BY v.version_id,r.rep_id ASC"; |
548 | alex-w | 1925 | $rq =& $this->db->query($query); |
639 | alex-w | 1926 | $show = "<ul><li class='nomarker'></li>"; |
630 | alex-w | 1927 | $splitter = 0; |
548 | alex-w | 1928 | while ($rq->fetchInto($element)) { |
630 | alex-w | 1929 | if ($splitter != $this->secure->checkInt($element["version_id"])) { |
1930 | $splitter = $this->secure->checkInt($element["version_id"]); |
||
644 | alex-w | 1931 | $show .= "</ul><ul><li class='nomarker'>Репозитории для <strong>".$this->secure->checkStr($element["fullname"],1)."</strong></li>"; |
630 | alex-w | 1932 | } |
634 | alex-w | 1933 | $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 | 1934 | } |
1935 | $show .= "</ul>"; |
||
547 | alex-w | 1936 | return $show; |
1937 | } |
||
1938 | |||
1939 | /** |
||
558 | alex-w | 1940 | * Вывод списка типов репозиториев |
1941 | * |
||
1942 | * @author Alexander Wolf |
||
1943 | * @category Core |
||
1944 | * |
||
1945 | * @param integer $reptype |
||
1946 | * @param string $name |
||
1947 | * @return string |
||
1948 | */ |
||
1949 | public function showRepType($reptype = 0, $name = "") { |
||
1950 | $sRT = $this->secure->checkInt($reptype); |
||
1951 | $sNM = $this->secure->checkStr($name,1); |
||
559 | alex-w | 1952 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
558 | alex-w | 1953 | $rq =& $this->db->query($query); |
1954 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
||
1955 | while ($rq->fetchInto($element)) { |
||
1956 | if ($element["rtype_id"]==$sRT) { |
||
1957 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
||
1958 | } else { |
||
1959 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
||
1960 | } |
||
1961 | } |
||
1962 | $show .= "</select>"; |
||
1963 | |||
1964 | return $show; |
||
1965 | } |
||
1966 | |||
623 | alex-w | 1967 | /** |
1968 | * Вывод списка версий дистрибутивов |
||
1969 | * |
||
1970 | * @author Alexander Wolf |
||
1971 | * @category Core |
||
1972 | * |
||
1973 | * @param string $name |
||
1974 | * @param integer $versionID |
||
1975 | * @return string |
||
1976 | */ |
||
591 | alex-w | 1977 | public function showVDList($name, $versionID = 0) { |
592 | alex-w | 1978 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
591 | alex-w | 1979 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
1980 | $rq =& $this->db->query($query); |
||
1981 | $show = "<select name='".$name."' id='".$name."'>\n"; |
||
1982 | while ($rq->fetchInto($element)) { |
||
592 | alex-w | 1983 | if ($element["version_id"]==$versionID) { |
1984 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
||
1985 | } else { |
||
1986 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
||
1987 | } |
||
591 | alex-w | 1988 | } |
1989 | $show .= "</select>"; |
||
1990 | return $show; |
||
1991 | } |
||
1992 | |||
558 | alex-w | 1993 | /** |
547 | alex-w | 1994 | * Форма создания/редактирвоания репозиториев |
1995 | * |
||
1996 | * @author Alexander Wolf |
||
1997 | * @category Core |
||
1998 | * |
||
1999 | * @param integer $repID |
||
2000 | * @param string $info |
||
2001 | * @param string $reptype |
||
2002 | * @return string |
||
2003 | */ |
||
594 | alex-w | 2004 | public function showRepositoriesForm($repID = 0, $info = "") { |
556 | alex-w | 2005 | $sRepID = $this->secure->checkInt($repID); |
594 | alex-w | 2006 | $sInfo = $this->secure->checkStr($info, 1); |
556 | alex-w | 2007 | if ($sInfo == "") { |
2008 | $sInfo = "Репозиторий"; |
||
2009 | } |
||
2010 | if ($sRepID != 0) { |
||
2011 | // Режим редактирования |
||
591 | alex-w | 2012 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
556 | alex-w | 2013 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
2014 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
||
2015 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
||
2016 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
||
2017 | $rq =& $this->db->query($query); |
||
594 | alex-w | 2018 | $rq->fetchInto($element); |
556 | alex-w | 2019 | } |
2020 | |||
594 | alex-w | 2021 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
609 | alex-w | 2022 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
626 | alex-w | 2023 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value=\"".$this->secure->checkStr($element["repname"],1)."\"></div>\n"; |
2024 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value=\"".$this->secure->checkStr($element["repinfo"],1)."\"></div>\n"; |
||
2025 | $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 | 2026 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
588 | alex-w | 2027 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
604 | alex-w | 2028 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
558 | alex-w | 2029 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
564 | alex-w | 2030 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
569 | alex-w | 2031 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
613 | alex-w | 2032 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
595 | alex-w | 2033 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
556 | alex-w | 2034 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
593 | alex-w | 2035 | |
547 | alex-w | 2036 | return $show; |
2037 | } |
||
598 | alex-w | 2038 | |
2039 | /** |
||
2040 | * Добавление нового репозитория |
||
2041 | * |
||
2042 | * @author Alexander Wolf |
||
2043 | * @category Core |
||
2044 | * |
||
2045 | * @param integer $verionID |
||
2046 | * @param string $rname |
||
2047 | * @param string $rinfo |
||
2048 | * @param string $rkey |
||
2049 | * @param integer $proto |
||
2050 | * @param integer $rhost |
||
2051 | * @param integer $rfolder |
||
2052 | * @param integer $rtype |
||
2053 | * @param array $sections |
||
2054 | * @param array $arch |
||
2055 | * @param integer $scheme |
||
2056 | * @param integer $sign |
||
2057 | * @return array |
||
2058 | */ |
||
612 | alex-w | 2059 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
598 | alex-w | 2060 | $result = array(); |
2061 | $sVersionID = $this->secure->checkInt($verionID); |
||
2062 | $sRName = $this->secure->checkStr($rname); |
||
2063 | $sRInfo = $this->secure->checkStr($rinfo); |
||
2064 | $sRKey = $this->secure->checkStr($rkey); |
||
2065 | $sProto = $this->secure->checkInt($proto); |
||
2066 | $sRHost = $this->secure->checkInt($rhost); |
||
2067 | $sRFolder = $this->secure->checkInt($rfolder); |
||
2068 | $sRType = $this->secure->checkInt($rtype); |
||
2069 | $sRScheme = $this->secure->checkInt($scheme); |
||
2070 | $sRSign = $this->secure->checkInt($sign); |
||
2071 | |||
602 | alex-w | 2072 | $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 | 2073 | $rq =& $this->db->query($query); |
2074 | |||
2075 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
||
2076 | $rq =& $this->db->query($query); |
||
2077 | $rq->fetchInto($repository); |
||
2078 | |||
2079 | for($i=0;$i<count($sections);$i++) { |
||
2080 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
||
2081 | $rq =& $this->db->query($query); |
||
2082 | } |
||
2083 | |||
2084 | for($i=0;$i<count($arch);$i++) { |
||
2085 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
||
2086 | $rq =& $this->db->query($query); |
||
2087 | } |
||
2088 | |||
2089 | if (PEAR::isError($this->db)) { |
||
2090 | $result["ERR"] = 1; |
||
2091 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2092 | } else { |
||
2093 | $result["ERR"] = 0; |
||
2094 | } |
||
2095 | |||
2096 | return $result; |
||
2097 | } |
||
618 | alex-w | 2098 | |
2099 | /** |
||
2100 | * Обновление информации о репозитории |
||
2101 | * |
||
2102 | * @author Alexander Wolf |
||
2103 | * @category Core |
||
2104 | * |
||
2105 | * @param integer $repID |
||
2106 | * @param integer $verionID |
||
2107 | * @param string $rname |
||
2108 | * @param string $rinfo |
||
2109 | * @param string $rkey |
||
2110 | * @param integer $proto |
||
2111 | * @param integer $rhost |
||
2112 | * @param integer $rfolder |
||
2113 | * @param integer $rtype |
||
2114 | * @param array $sections |
||
2115 | * @param array $arch |
||
2116 | * @param integer $scheme |
||
2117 | * @param integer $sign |
||
2118 | * @return array |
||
2119 | */ |
||
2120 | public function updateRepository($repID, $verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
||
2121 | $result = array(); |
||
2122 | $sRepID = $this->secure->checkInt($repID); |
||
2123 | $sVersionID = $this->secure->checkInt($verionID); |
||
2124 | $sRName = $this->secure->checkStr($rname); |
||
2125 | $sRInfo = $this->secure->checkStr($rinfo); |
||
2126 | $sRKey = $this->secure->checkStr($rkey); |
||
2127 | $sProto = $this->secure->checkInt($proto); |
||
2128 | $sRHost = $this->secure->checkInt($rhost); |
||
2129 | $sRFolder = $this->secure->checkInt($rfolder); |
||
2130 | $sRType = $this->secure->checkInt($rtype); |
||
2131 | $sRScheme = $this->secure->checkInt($scheme); |
||
2132 | $sRSign = $this->secure->checkInt($sign); |
||
2133 | |||
2134 | $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."'"; |
||
2135 | $rq =& $this->db->query($query); |
||
2136 | |||
2137 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
||
2138 | $rq =& $this->db->query($query); |
||
2139 | for($i=0;$i<count($sections);$i++) { |
||
2140 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$sRepID."', sect_id='".$sections[$i]."'"; |
||
2141 | $rq =& $this->db->query($query); |
||
2142 | } |
||
2143 | |||
2144 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
||
2145 | $rq =& $this->db->query($query); |
||
2146 | for($i=0;$i<count($arch);$i++) { |
||
2147 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$sRepID."', arch_id='".$arch[$i]."'"; |
||
2148 | $rq =& $this->db->query($query); |
||
2149 | } |
||
2150 | |||
2151 | if (PEAR::isError($this->db)) { |
||
2152 | $result["ERR"] = 1; |
||
2153 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2154 | } else { |
||
2155 | $result["ERR"] = 0; |
||
2156 | } |
||
2157 | |||
2158 | return $result; |
||
2159 | } |
||
2160 | |||
2161 | /** |
||
2162 | * Удаление информации о репозитории |
||
2163 | * |
||
2164 | * @author Alexander Wolf |
||
2165 | * @category Core |
||
2166 | * |
||
2167 | * @param integer $repID |
||
2168 | * @return array |
||
2169 | */ |
||
2170 | public function dropRepository($repID) { |
||
2171 | $result = array(); |
||
2172 | $sRepID = $this->secure->checkInt($repID); |
||
2173 | |||
2174 | // Удаление репозитория |
||
2175 | $query = "DELETE FROM ".$this->prefix."repository WHERE rep_id='".$sRepID."'"; |
||
2176 | $rq =& $this->db->query($query); |
||
2177 | if (PEAR::isError($this->db)) { |
||
2178 | $result["ERR"] = 1; |
||
2179 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2180 | } else { |
||
2181 | $result["ERR"] = 0; |
||
2182 | } |
||
2183 | |||
2184 | // Удаление секций репозитория |
||
2185 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
||
2186 | $rq =& $this->db->query($query); |
||
2187 | if (PEAR::isError($this->db)) { |
||
2188 | $result["ERR"] = 1; |
||
2189 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2190 | } else { |
||
2191 | $result["ERR"] = 0; |
||
2192 | } |
||
2193 | |||
2194 | // Удаление архитектур репозитория |
||
2195 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
||
2196 | $rq =& $this->db->query($query); |
||
2197 | if (PEAR::isError($this->db)) { |
||
2198 | $result["ERR"] = 1; |
||
2199 | $result["ERRINFO"] = $this->db->getMessage(); |
||
2200 | } else { |
||
2201 | $result["ERR"] = 0; |
||
2202 | } |
||
2203 | |||
2204 | return $result; |
||
2205 | } |
||
560 | alex-w | 2206 | |
304 | alex-w | 2207 | } |
2208 | |||
356 | alex-w | 2209 | ?> |