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