Редакция 406 | Редакция 425 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 406 | Редакция 423 | ||
---|---|---|---|
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 | protected $cookie = NULL; |
19 | protected $cookie = NULL; |
20 | 20 | ||
21 | public function __construct($database, $prefix, $secure, $cookie) { |
21 | public function __construct($database, $prefix, $secure, $cookie) { |
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 | $this->cookie = $cookie; |
25 | $this->cookie = $cookie; |
26 | }
|
26 | }
|
27 | 27 | ||
28 | // Получение данных о настройке
|
28 | // Получение данных о настройке
|
29 | public function getOption($attr) { |
29 | public function getOption($attr) { |
30 | $result = array(); |
30 | $result = array(); |
31 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
31 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
32 | $rq =& $this->db->query($query); |
32 | $rq =& $this->db->query($query); |
33 | if ($rq->numRows()!=0) { |
33 | if ($rq->numRows()!=0) { |
34 | $rq->fetchInto($element); |
34 | $rq->fetchInto($element); |
35 | $result["ERR"] = 0; |
35 | $result["ERR"] = 0; |
36 | $result["OptValue"] = $element["optvalue"]; |
36 | $result["OptValue"] = $element["optvalue"]; |
37 | } else { |
37 | } else { |
38 | $result["ERR"] = 1; |
38 | $result["ERR"] = 1; |
39 | $result["ERRINFO"] = "Empty result"; |
39 | $result["ERRINFO"] = "Empty result"; |
40 | }
|
40 | }
|
41 | return $result; |
41 | return $result; |
42 | }
|
42 | }
|
43 | 43 | ||
44 | // Установка данных о настройке
|
44 | // Установка данных о настройке
|
45 | public function setOption($attr, $value) { |
45 | public function setOption($attr, $value) { |
46 | $result = array(); |
46 | $result = array(); |
47 | 47 | ||
48 | if ($attr != "passwd") { |
48 | if ($attr != "passwd") { |
49 | $sValue = $this->secure->checkStr($value); |
49 | $sValue = $this->secure->checkStr($value); |
50 | } else { |
50 | } else { |
51 | $sValue = $value; |
51 | $sValue = $value; |
52 | }
|
52 | }
|
53 | 53 | ||
54 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
54 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
55 | $rq =& $this->db->query($query); |
55 | $rq =& $this->db->query($query); |
56 | if (PEAR::isError($this->db)) { |
56 | if (PEAR::isError($this->db)) { |
57 | $result["ERR"] = 1; |
57 | $result["ERR"] = 1; |
58 | $result["ERRINFO"] = $this->db->getMessage(); |
58 | $result["ERRINFO"] = $this->db->getMessage(); |
59 | } else { |
59 | } else { |
60 | $result["ERR"] = 0; |
60 | $result["ERR"] = 0; |
61 | }
|
61 | }
|
62 | 62 | ||
63 | return $result; |
63 | return $result; |
64 | }
|
64 | }
|
65 | 65 | ||
66 | // Создание настройки
|
66 | // Создание настройки
|
67 | public function addOption($attr, $value) { |
67 | public function addOption($attr, $value) { |
68 | $result = array(); |
68 | $result = array(); |
69 | $sValue = $this->secure->checkStr($value); |
69 | $sValue = $this->secure->checkStr($value); |
70 | 70 | ||
71 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
71 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
72 | $rq =& $this->db->query($query); |
72 | $rq =& $this->db->query($query); |
73 | if (PEAR::isError($this->db)) { |
73 | if (PEAR::isError($this->db)) { |
74 | $result["ERR"] = 1; |
74 | $result["ERR"] = 1; |
75 | $result["ERRINFO"] = $this->db->getMessage(); |
75 | $result["ERRINFO"] = $this->db->getMessage(); |
76 | } else { |
76 | } else { |
77 | $result["ERR"] = 0; |
77 | $result["ERR"] = 0; |
78 | }
|
78 | }
|
79 | 79 | ||
80 | return $result; |
80 | return $result; |
81 | }
|
81 | }
|
82 | 82 | ||
83 | // Получение и отображение списка дистрибутивов
|
83 | // Получение и отображение списка дистрибутивов
|
- | 84 | // XXX deprecated ?
|
|
84 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
85 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
85 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
86 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
86 | $rq =& $this->db->query($query); |
87 | $rq =& $this->db->query($query); |
87 | switch ($format) { |
88 | switch ($format) { |
88 | case 'html': |
89 | case 'html': |
89 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
90 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
90 | $show .= "<option value=''>".$info."</option>\n"; |
91 | $show .= "<option value=''>".$info."</option>\n"; |
91 | while ($rq->fetchInto($element)) { |
92 | while ($rq->fetchInto($element)) { |
92 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
93 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
93 | }
|
94 | }
|
94 | $show .= "</select></fieldset>"; |
95 | $show .= "</select></fieldset>"; |
95 | break; |
96 | break; |
96 | case 'json': |
97 | case 'json': |
97 | $show = '[{value:"",text:"'.$info.'"}'; |
98 | $show = '[{value:"",text:"'.$info.'"}'; |
98 | while ($rq->fetchInto($element)) { |
99 | while ($rq->fetchInto($element)) { |
99 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
100 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
100 | }
|
101 | }
|
101 | $show .= ']'; |
102 | $show .= ']'; |
102 | break; |
103 | break; |
103 | }
|
104 | }
|
104 | return $show; |
105 | return $show; |
105 | }
|
106 | }
|
106 | 107 | ||
107 | // Получение названия дистрибутива
|
108 | // Получение названия дистрибутива
|
108 | public function getDistName($distID) { |
109 | public function getDistName($distID) { |
109 | $result = array(); |
110 | $result = array(); |
110 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
111 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
111 | $rq =& $this->db->query($query); |
112 | $rq =& $this->db->query($query); |
112 | if (PEAR::isError($this->db)) { |
113 | if (PEAR::isError($this->db)) { |
113 | $result["ERR"] = 1; |
114 | $result["ERR"] = 1; |
114 | $result["ERRINFO"] = $this->db->getMessage(); |
115 | $result["ERRINFO"] = $this->db->getMessage(); |
115 | } else { |
116 | } else { |
116 | $rq->fetchInto($element); |
117 | $rq->fetchInto($element); |
117 | $result["ERR"] = 0; |
118 | $result["ERR"] = 0; |
118 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
119 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
119 | }
|
120 | }
|
120 | 121 | ||
121 | return $result; |
122 | return $result; |
122 | }
|
123 | }
|
123 | 124 | ||
124 | // Получение названия программы, ее версии и описания
|
125 | // Получение названия программы, ее версии и описания
|
125 | public function getEngineAttr($attr = 'codename') { |
126 | public function getEngineAttr($attr = 'codename') { |
126 | $cname = $this->getOption($attr); |
127 | $cname = $this->getOption($attr); |
127 | return $this->secure->checkStr($cname["OptValue"],1); |
128 | return $this->secure->checkStr($cname["OptValue"],1); |
128 | }
|
129 | }
|
129 | 130 | ||
130 | // Получение и отображение списка версий дистрибутива
|
131 | // Получение и отображение списка версий дистрибутива
|
131 | public function showDistVersionsList($name, $distID, $format = 'html') { |
132 | public function showDistVersionsList($name, $distID, $format = 'html') { |
132 | $distname = $this->getDistName($distID); |
133 | $distname = $this->getDistName($distID); |
133 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
134 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
134 | $rq =& $this->db->query($query); |
135 | $rq =& $this->db->query($query); |
135 | switch ($format) { |
136 | switch ($format) { |
136 | case 'html': |
137 | case 'html': |
137 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
138 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
138 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
139 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
139 | while ($rq->fetchInto($element)) { |
140 | while ($rq->fetchInto($element)) { |
140 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
141 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
141 | }
|
142 | }
|
142 | $show .= "</select></fieldset>"; |
143 | $show .= "</select></fieldset>"; |
143 | break; |
144 | break; |
144 | case 'json': |
145 | case 'json': |
145 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
146 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
146 | while ($rq->fetchInto($element)) { |
147 | while ($rq->fetchInto($element)) { |
147 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
148 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
148 | }
|
149 | }
|
149 | $show .= ']'; |
150 | $show .= ']'; |
150 | break; |
151 | break; |
151 | }
|
152 | }
|
152 | return $show; |
153 | return $show; |
153 | }
|
154 | }
|
154 | 155 | ||
155 | // Получение и отображение списка секций основного (официального) репозитория
|
156 | // Получение и отображение списка секций основного (официального) репозитория
|
156 | public function showBranchesList($version, $format = 'html') { |
157 | public function showBranchesList($version, $format = 'html') { |
157 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
158 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
158 | $rq =& $this->db->query($query); |
159 | $rq =& $this->db->query($query); |
159 | $rq->fetchInto($types); |
160 | $rq->fetchInto($types); |
160 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
161 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
161 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
162 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
162 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
163 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
163 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
164 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
164 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
165 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
165 | $rq =& $this->db->query($query); |
166 | $rq =& $this->db->query($query); |
166 | switch ($format) { |
167 | switch ($format) { |
167 | case 'html': |
168 | case 'html': |
168 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
169 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
169 | while ($rq->fetchInto($element)) { |
170 | while ($rq->fetchInto($element)) { |
170 | $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." — ".$this->secure->checkStr($element["secinfo"],1)."</div>\n"; |
171 | $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." — ".$this->secure->checkStr($element["secinfo"],1)."</div>\n"; |
171 | }
|
172 | }
|
172 | $show .= "</fieldset>\n"; |
173 | $show .= "</fieldset>\n"; |
173 | break; |
174 | break; |
174 | case 'json': |
175 | case 'json': |
175 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
176 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
176 | break; |
177 | break; |
177 | }
|
178 | }
|
178 | 179 | ||
179 | return $show; |
180 | return $show; |
180 | }
|
181 | }
|
181 | 182 | ||
182 | // Получение и отображение списка репозиториев
|
183 | // Получение и отображение списка репозиториев
|
183 | public function showRepList($version, $reptype, $format = 'html') { |
184 | public function showRepList($version, $reptype, $format = 'html') { |
184 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
185 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
185 | $rq =& $this->db->query($query); |
186 | $rq =& $this->db->query($query); |
186 | $rq->fetchInto($types); |
187 | $rq->fetchInto($types); |
187 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
188 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
188 | $rq =& $this->db->query($query); |
189 | $rq =& $this->db->query($query); |
189 | switch ($format) { |
190 | switch ($format) { |
190 | case 'html': |
191 | case 'html': |
191 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
192 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
192 | while ($rq->fetchInto($types)) { |
193 | while ($rq->fetchInto($types)) { |
193 | $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"; |
194 | $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"; |
194 | }
|
195 | }
|
195 | $show .= "</fieldset>\n"; |
196 | $show .= "</fieldset>\n"; |
196 | break; |
197 | break; |
197 | case 'json': |
198 | case 'json': |
198 | //TODO Доделать JSON-вывод списка репозиториев
|
199 | //TODO Доделать JSON-вывод списка репозиториев
|
199 | break; |
200 | break; |
200 | }
|
201 | }
|
201 | 202 | ||
202 | return $show; |
203 | return $show; |
203 | }
|
204 | }
|
204 | 205 | ||
205 | // Добавление поддержки нового apt-дистрибутива
|
206 | // Добавление поддержки нового apt-дистрибутива
|
206 | public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) { |
207 | public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) { |
207 | $result = array(); |
208 | $result = array(); |
208 | $sDName = $this->secure->checkStr($distname); |
209 | $sDName = $this->secure->checkStr($distname); |
209 | $sDType = $this->secure->checkInt($disttype); |
210 | $sDType = $this->secure->checkInt($disttype); |
210 | $sDUAgt = $this->secure->checkStr($distua); |
211 | $sDUAgt = $this->secure->checkStr($distua); |
211 | $sDLogo = $this->secure->checkInt($distname); |
212 | $sDLogo = $this->secure->checkInt($distname); |
212 | 213 | ||
213 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
214 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
214 | $rq =& $this->db->query($query); |
215 | $rq =& $this->db->query($query); |
215 | if (PEAR::isError($this->db)) { |
216 | if (PEAR::isError($this->db)) { |
216 | $result["ERR"] = 1; |
217 | $result["ERR"] = 1; |
217 | $result["ERRINFO"] = $this->db->getMessage(); |
218 | $result["ERRINFO"] = $this->db->getMessage(); |
218 | } else { |
219 | } else { |
219 | $rq->fetchInto($element); |
220 | $rq->fetchInto($element); |
220 | $result["ERR"] = 0; |
221 | $result["ERR"] = 0; |
221 | }
|
222 | }
|
222 | 223 | ||
223 | return $result; |
224 | return $result; |
224 | }
|
225 | }
|
225 | 226 | ||
226 | // Добавление поддержки новой версии apt-дистрибутива
|
227 | // Добавление поддержки новой версии apt-дистрибутива
|
227 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
228 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
228 | $result = array(); |
229 | $result = array(); |
229 | $sDistID = $this->secure->checkStr($distID); |
230 | $sDistID = $this->secure->checkStr($distID); |
230 | $sDVersion = $this->secure->checkStr($version); |
231 | $sDVersion = $this->secure->checkStr($version); |
231 | $sDVName = $this->secure->checkStr($vname); |
232 | $sDVName = $this->secure->checkStr($vname); |
232 | $sDVCName = $this->secure->checkInt($vcodename); |
233 | $sDVCName = $this->secure->checkInt($vcodename); |
233 | 234 | ||
234 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
235 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
235 | $rq =& $this->db->query($query); |
236 | $rq =& $this->db->query($query); |
236 | if (PEAR::isError($this->db)) { |
237 | if (PEAR::isError($this->db)) { |
237 | $result["ERR"] = 1; |
238 | $result["ERR"] = 1; |
238 | $result["ERRINFO"] = $this->db->getMessage(); |
239 | $result["ERRINFO"] = $this->db->getMessage(); |
239 | } else { |
240 | } else { |
240 | $rq->fetchInto($element); |
241 | $rq->fetchInto($element); |
241 | $result["ERR"] = 0; |
242 | $result["ERR"] = 0; |
242 | }
|
243 | }
|
243 | 244 | ||
244 | return $result; |
245 | return $result; |
245 | }
|
246 | }
|
246 | 247 | ||
247 | // Отображение типа дистрибутива
|
248 | // Отображение типа дистрибутива
|
248 | public function showDistTypeForm($name = "dtype",$type = 0) { |
249 | public function showDistTypeForm($name = "dtype",$type = 0) { |
249 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
250 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
250 | $rq =& $this->db->query($query); |
251 | $rq =& $this->db->query($query); |
251 | $show = "<select name='".$name."' id='".$name."'>\n"; |
252 | $show = "<select name='".$name."' id='".$name."'>\n"; |
252 | while ($rq->fetchInto($element)) { |
253 | while ($rq->fetchInto($element)) { |
253 | if ($element["type_id"] == $type) { |
254 | if ($element["type_id"] == $type) { |
254 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
255 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
255 | } else { |
256 | } else { |
256 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
257 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
257 | }
|
258 | }
|
258 | }
|
259 | }
|
259 | $show .= "</select>"; |
260 | $show .= "</select>"; |
260 | 261 | ||
261 | return $show; |
262 | return $show; |
262 | }
|
263 | }
|
263 | 264 | ||
264 | // Отображение формы создания и редактирования apt-дистрибутива
|
265 | // Отображение формы создания и редактирования apt-дистрибутива
|
265 | public function showDistributionForm($distID = 0) { |
266 | public function showDistributionForm($distID = 0) { |
266 | $sDistID = $this->secure->checkInt($distID); |
267 | $sDistID = $this->secure->checkInt($distID); |
267 | if ($sDistID != 0) { |
268 | if ($sDistID != 0) { |
268 | // Режим редактирования
|
269 | // Режим редактирования
|
269 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
270 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
270 | $rq =& $this->db->query($query); |
271 | $rq =& $this->db->query($query); |
271 | $rq->fetchInto($element); |
272 | $rq->fetchInto($element); |
272 | }
|
273 | }
|
273 | 274 | ||
274 | if ($element["distlogo"] == 1) { |
275 | if ($element["distlogo"] == 1) { |
275 | $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)."'>"; |
276 | $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)."'>"; |
276 | } else { |
277 | } else { |
277 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
278 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
278 | }
|
279 | }
|
279 | 280 | ||
280 | $show = "<fieldset><legend>Дистрибутив</legend>\n"; |
281 | $show = "<fieldset><legend>Дистрибутив</legend>\n"; |
281 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
282 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
282 | $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"; |
283 | $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"; |
283 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n"; |
284 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n"; |
284 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
285 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
285 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
286 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
286 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
287 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
287 | 288 | ||
288 | return $show; |
289 | return $show; |
289 | }
|
290 | }
|
290 | 291 | ||
291 | // sourses.list
|
292 | // sourses.list
|
292 | public function showSourcesList($requestID) { |
293 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
293 | //TODO Написать генератор sources.list
|
294 | //TODO Написать генератор sources.list
|
294 | list($distID,$versID,$repsIDs) = split(":",$requestID); |
- | |
295 | $reps = array(); |
- | |
296 | $reps = split("-",$repsIDs); |
- | |
297 | }
|
295 | }
|
298 | 296 | ||
299 | // Проверка пароля (из формы авторизации)
|
297 | // Проверка пароля (из формы авторизации)
|
300 | public function checkSign($word) { |
298 | public function checkSign($word) { |
301 | $result = array(); |
299 | $result = array(); |
302 | 300 | ||
303 | $sHash = $this->secure->encryptStr($word); |
301 | $sHash = $this->secure->encryptStr($word); |
304 | $pwd = $this->getOption("passwd"); |
302 | $pwd = $this->getOption("passwd"); |
305 | if ($sHash == $pwd["OptValue"]) { |
303 | if ($sHash == $pwd["OptValue"]) { |
306 | $result["ERR"] = 0; |
304 | $result["ERR"] = 0; |
307 | $result["Location"] = "manager.php"; |
305 | $result["Location"] = "manager.php"; |
308 | setcookie($this->cookie, $sHash); |
306 | setcookie($this->cookie, $sHash); |
309 | } else { |
307 | } else { |
310 | $result["ERR"] = 1; |
308 | $result["ERR"] = 1; |
311 | $result["ERRINFO"] = "Password not valid"; |
309 | $result["ERRINFO"] = "Password not valid"; |
312 | $result["Location"] = "manager.php?error=1"; |
310 | $result["Location"] = "manager.php?error=1"; |
313 | }
|
311 | }
|
314 | 312 | ||
315 | return $result; |
313 | return $result; |
316 | }
|
314 | }
|
317 | 315 | ||
318 | // Проверка пароля (из cookies)
|
316 | // Проверка пароля (из cookies)
|
319 | public function checkCookieSign($hash) { |
317 | public function checkCookieSign($hash) { |
320 | $result = array(); |
318 | $result = array(); |
321 | 319 | ||
322 | $pwd = $this->getOption("passwd"); |
320 | $pwd = $this->getOption("passwd"); |
323 | if ($hash == $pwd["OptValue"]) { |
321 | if ($hash == $pwd["OptValue"]) { |
324 | $result["ERR"] = 0; |
322 | $result["ERR"] = 0; |
325 | } else { |
323 | } else { |
326 | $result["ERR"] = 1; |
324 | $result["ERR"] = 1; |
327 | $result["ERRINFO"] = "Hash not valid"; |
325 | $result["ERRINFO"] = "Hash not valid"; |
328 | $result["Location"] = "manager.php"; |
326 | $result["Location"] = "manager.php"; |
329 | }
|
327 | }
|
330 | 328 | ||
331 | return $result; |
329 | return $result; |
332 | }
|
330 | }
|
333 | 331 | ||
334 | // Форма ввода пароля
|
332 | // Форма ввода пароля
|
335 | public function showSigninForm() { |
333 | public function showSigninForm() { |
336 | $show = "<form action='process.php' method='post'>\n"; |
334 | $show = "<form action='process.php' method='post'>\n"; |
337 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
335 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
338 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
336 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
339 | $show .= "<input type='text' name='word' value=''>\n<br />"; |
337 | $show .= "<input type='text' name='word' value=''>\n<br />"; |
340 | $show .= "<input type='submit' value=' Войти '>\n"; |
338 | $show .= "<input type='submit' value=' Войти '>\n"; |
341 | $show .= "</fieldset>\n</form>\n"; |
339 | $show .= "</fieldset>\n</form>\n"; |
342 | 340 | ||
343 | return $show; |
341 | return $show; |
344 | }
|
342 | }
|
345 | 343 | ||
346 | // Обновление пароля
|
344 | // Обновление пароля
|
347 | public function updatePassword($word1, $word2) { |
345 | public function updatePassword($word1, $word2) { |
348 | $result = array(); |
346 | $result = array(); |
349 | 347 | ||
350 | if ($word1 == $word2) { |
348 | if ($word1 == $word2) { |
351 | $sWord = $this->secure->encryptStr($word1); |
349 | $sWord = $this->secure->encryptStr($word1); |
352 | $r = $this->setOption("passwd", $sWord); |
350 | $r = $this->setOption("passwd", $sWord); |
353 | $result = $r; |
351 | $result = $r; |
354 | } else { |
352 | } else { |
355 | $result["ERR"] = 1; |
353 | $result["ERR"] = 1; |
356 | $result["ERRINFO"] = "Passwords is mismatch"; |
354 | $result["ERRINFO"] = "Passwords is mismatch"; |
357 | }
|
355 | }
|
358 | 356 | ||
359 | return $result; |
357 | return $result; |
360 | }
|
358 | }
|
361 | 359 | ||
362 | 360 | ||
363 | }
|
361 | }
|
364 | 362 | ||
365 | ?>
|
363 | ?>
|