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