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