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