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