Редакция 314 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 314 | Редакция 315 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | /**
|
3 | /**
|
4 | *
|
4 | *
|
5 | * Codename: ant-ng - generator of sources.list for Debian and
|
5 | * Codename: ant-ng - generator of sources.list for Debian and
|
6 | * distributives, based on Debian
|
6 | * distributives, based on Debian
|
7 | * http://alex-w.org.ru/p/antng/
|
7 | * http://alex-w.org.ru/p/antng/
|
8 | *
|
8 | *
|
9 | * Copyright (c) 2009 Alexander Wolf
|
9 | * Copyright (c) 2009 Alexander Wolf
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
11 | * http://alex-w.org.ru/p/antng/license
|
11 | * http://alex-w.org.ru/p/antng/license
|
12 | *
|
12 | *
|
13 | */
|
13 | */
|
14 | 14 | ||
15 | class Core { |
15 | class Core { |
16 | protected $db = NULL; |
16 | protected $db = NULL; |
17 | protected $prefix = NULL; |
17 | protected $prefix = NULL; |
18 | protected $secure = NULL; |
18 | protected $secure = NULL; |
19 | 19 | ||
20 | 20 | ||
21 | function __construct($database, $prefix, $secure) { |
21 | function __construct($database, $prefix, $secure) { |
22 | $this->db = $database; |
22 | $this->db = $database; |
23 | $this->prefix = $prefix; |
23 | $this->prefix = $prefix; |
24 | $this->secure = $secure; |
24 | $this->secure = $secure; |
25 | }
|
25 | }
|
26 | 26 | ||
- | 27 | // Получение данных о настройке
|
|
27 | function getOption($attr) { |
28 | function getOption($attr) { |
28 | $result = array(); |
29 | $result = array(); |
29 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkInt($attr)."'"; |
30 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
30 | $rq =& $this->db->query($query); |
31 | $rq =& $this->db->query($query); |
31 | if ($rq->numRows()!=0) { |
32 | if ($rq->numRows()!=0) { |
32 | $rq->fetchInto($element); |
33 | $rq->fetchInto($element); |
33 | $result["ERR"] = 0; |
34 | $result["ERR"] = 0; |
34 | $result["OptValue"] = $element["optvalue"]; |
35 | $result["OptValue"] = $element["optvalue"]; |
35 | } else { |
36 | } else { |
36 | $result["ERR"] = 1; |
37 | $result["ERR"] = 1; |
37 | $result["ERRINFO"] = "Empty result"; |
38 | $result["ERRINFO"] = "Empty result"; |
38 | }
|
39 | }
|
39 | return $result; |
40 | return $result; |
40 | }
|
41 | }
|
- | 42 | ||
- | 43 | // Получение и отображение списка дистрибутивов
|
|
- | 44 | function showDistributionList($name, $info = "", $format = 'html') { |
|
- | 45 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
|
- | 46 | switch ($format) { |
|
- | 47 | case 'html': |
|
- | 48 | $show = "<label for='".$name."'>".$info."</label> <select id='".$name."' name='".$name."'>\n"; |
|
- | 49 | $rq =& $this->db->query($query); |
|
- | 50 | while ($rq->fetchInto($element)) { |
|
- | 51 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
|
- | 52 | }
|
|
- | 53 | $show .= "</select>"; |
|
- | 54 | break; |
|
- | 55 | case 'json': |
|
- | 56 | $show = '[{value:"",text:"'.$info.'"}'; |
|
- | 57 | $rq =& $this->db->query($query); |
|
- | 58 | while ($rq->fetchInto($element)) { |
|
- | 59 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
|
- | 60 | }
|
|
- | 61 | $show .= ']'; |
|
- | 62 | break; |
|
- | 63 | }
|
|
- | 64 | return $show; |
|
- | 65 | }
|
|
- | 66 | ||
- | 67 | // Получение названия дистрибутива
|
|
- | 68 | function getDistName($distID) { |
|
- | 69 | $result = array(); |
|
- | 70 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
|
- | 71 | $rq =& $this->db->query($query); |
|
- | 72 | if (PEAR::isError($this->db)) { |
|
- | 73 | $result["ERR"] = 1; |
|
- | 74 | $result["ERRINFO"] = $this->db->getMessage(); |
|
- | 75 | } else { |
|
- | 76 | $rq->fetchInto($element); |
|
- | 77 | $result["ERR"] = 0; |
|
- | 78 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
|
- | 79 | }
|
|
- | 80 | ||
- | 81 | return $result; |
|
- | 82 | }
|
|
- | 83 | ||
- | 84 | // Получение и отображение списка версий дистрибутива
|
|
- | 85 | function showDistVersionsList($name, $distID, $format = 'html') { |
|
- | 86 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
|
- | 87 | switch ($format) { |
|
- | 88 | case 'html': |
|
- | 89 | $show = "<label for='".$name."'>".$info."</label> <select id='".$name."' name='".$name."'>\n"; |
|
- | 90 | $rq =& $this->db->query($query); |
|
- | 91 | while ($rq->fetchInto($element)) { |
|
- | 92 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
|
- | 93 | }
|
|
- | 94 | $show .= "</select>"; |
|
- | 95 | break; |
|
- | 96 | case 'json': |
|
- | 97 | $show = '[{value:"",text:"'.$info.'"}'; |
|
- | 98 | $rq =& $this->db->query($query); |
|
- | 99 | while ($rq->fetchInto($element)) { |
|
- | 100 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
|
- | 101 | }
|
|
- | 102 | $show .= ']'; |
|
- | 103 | break; |
|
- | 104 | }
|
|
- | 105 | return $show; |
|
- | 106 | }
|
|
41 | 107 | ||
42 | }
|
108 | }
|
43 | 109 | ||
44 | ?>
|
110 | ?>
|
45 | 111 |