Редакция 547 | Редакция 549 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 547 | Редакция 548 | ||
---|---|---|---|
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"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</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"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</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"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</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"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</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 = '', $distlogo = 0) { |
336 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
337 | $result = array(); |
337 | $result = array(); |
338 | $sDName = $this->secure->checkStr($distname,1); |
338 | $sDName = $this->secure->checkStr($distname,1); |
339 | $sDType = $this->secure->checkInt($disttype); |
339 | $sDType = $this->secure->checkInt($disttype); |
340 | $sDUAgt = $this->secure->checkStr($distua,1); |
340 | $sDUAgt = $this->secure->checkStr($distua,1); |
341 | $sDLogo = $this->secure->checkInt($distlogo); |
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 | $result["ERR"] = 0; |
349 | $result["ERR"] = 0; |
350 | }
|
350 | }
|
351 | 351 | ||
352 | return $result; |
352 | return $result; |
353 | }
|
353 | }
|
354 | 354 | ||
355 | /**
|
355 | /**
|
356 | * Обновление информации о дистрибутиве
|
356 | * Обновление информации о дистрибутиве
|
357 | *
|
357 | *
|
358 | * @author Alexander Wolf
|
358 | * @author Alexander Wolf
|
359 | * @category Core
|
359 | * @category Core
|
360 | *
|
360 | *
|
361 | * @param integer $distID
|
361 | * @param integer $distID
|
362 | * @param string $distname
|
362 | * @param string $distname
|
363 | * @param integer $disttype
|
363 | * @param integer $disttype
|
364 | * @param string $distua
|
364 | * @param string $distua
|
365 | * @param integer $distlogo
|
365 | * @param integer $distlogo
|
366 | * @return array
|
366 | * @return array
|
367 | */
|
367 | */
|
368 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
368 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
369 | $result = array(); |
369 | $result = array(); |
370 | $sDID = $this->secure->checkInt($distID); |
370 | $sDID = $this->secure->checkInt($distID); |
371 | $sDName = $this->secure->checkStr($distname,1); |
371 | $sDName = $this->secure->checkStr($distname,1); |
372 | $sDType = $this->secure->checkInt($disttype); |
372 | $sDType = $this->secure->checkInt($disttype); |
373 | $sDUAgt = $this->secure->checkStr($distua,1); |
373 | $sDUAgt = $this->secure->checkStr($distua,1); |
374 | $sDLogo = $this->secure->checkInt($distlogo); |
374 | $sDLogo = $this->secure->checkInt($distlogo); |
375 | 375 | ||
376 | if ($sDLogo!=0) { |
376 | if ($sDLogo!=0) { |
377 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
377 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
378 | } else { |
378 | } else { |
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
380 | }
|
380 | }
|
381 | $rq =& $this->db->query($query); |
381 | $rq =& $this->db->query($query); |
382 | if (PEAR::isError($this->db)) { |
382 | if (PEAR::isError($this->db)) { |
383 | $result["ERR"] = 1; |
383 | $result["ERR"] = 1; |
384 | $result["ERRINFO"] = $this->db->getMessage(); |
384 | $result["ERRINFO"] = $this->db->getMessage(); |
385 | } else { |
385 | } else { |
386 | $result["ERR"] = 0; |
386 | $result["ERR"] = 0; |
387 | }
|
387 | }
|
388 | 388 | ||
389 | return $result; |
389 | return $result; |
390 | }
|
390 | }
|
391 | 391 | ||
392 | /**
|
392 | /**
|
393 | * Удаление информации о дистрибутиве
|
393 | * Удаление информации о дистрибутиве
|
394 | *
|
394 | *
|
395 | * @author Alexander Wolf
|
395 | * @author Alexander Wolf
|
396 | * @category Core
|
396 | * @category Core
|
397 | *
|
397 | *
|
398 | * @param integer $distID
|
398 | * @param integer $distID
|
399 | * @return array
|
399 | * @return array
|
400 | */
|
400 | */
|
401 | public function dropDistribution($distID) { |
401 | public function dropDistribution($distID) { |
402 | $result = array(); |
402 | $result = array(); |
403 | $sDID = $this->secure->checkInt($distID); |
403 | $sDID = $this->secure->checkInt($distID); |
404 | 404 | ||
405 | // Удаление дистрибутива
|
405 | // Удаление дистрибутива
|
406 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
406 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
407 | $rq =& $this->db->query($query); |
407 | $rq =& $this->db->query($query); |
408 | if (PEAR::isError($this->db)) { |
408 | if (PEAR::isError($this->db)) { |
409 | $result["ERR"] = 1; |
409 | $result["ERR"] = 1; |
410 | $result["ERRINFO"] = $this->db->getMessage(); |
410 | $result["ERRINFO"] = $this->db->getMessage(); |
411 | } else { |
411 | } else { |
412 | $result["ERR"] = 0; |
412 | $result["ERR"] = 0; |
413 | }
|
413 | }
|
414 | 414 | ||
415 | // Удаление версий дистрибутива
|
415 | // Удаление версий дистрибутива
|
416 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
416 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
417 | $rq =& $this->db->query($query); |
417 | $rq =& $this->db->query($query); |
418 | if (PEAR::isError($this->db)) { |
418 | if (PEAR::isError($this->db)) { |
419 | $result["ERR"] = 1; |
419 | $result["ERR"] = 1; |
420 | $result["ERRINFO"] = $this->db->getMessage(); |
420 | $result["ERRINFO"] = $this->db->getMessage(); |
421 | } else { |
421 | } else { |
422 | $result["ERR"] = 0; |
422 | $result["ERR"] = 0; |
423 | }
|
423 | }
|
424 | 424 | ||
425 | return $result; |
425 | return $result; |
426 | }
|
426 | }
|
427 | 427 | ||
428 | /**
|
428 | /**
|
429 | * Добавление поддержки новой версии apt-дистрибутива
|
429 | * Добавление поддержки новой версии apt-дистрибутива
|
430 | *
|
430 | *
|
431 | * @author Alexander Wolf
|
431 | * @author Alexander Wolf
|
432 | * @category Core
|
432 | * @category Core
|
433 | *
|
433 | *
|
434 | * @param integer $distID
|
434 | * @param integer $distID
|
435 | * @param integer $version
|
435 | * @param integer $version
|
436 | * @param string $vname
|
436 | * @param string $vname
|
437 | * @param integer $vcodename
|
437 | * @param integer $vcodename
|
438 | * @return array
|
438 | * @return array
|
439 | */
|
439 | */
|
440 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
440 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
441 | $result = array(); |
441 | $result = array(); |
442 | $sDistID = $this->secure->checkInt($distID); |
442 | $sDistID = $this->secure->checkInt($distID); |
443 | $sDVersion = $this->secure->checkStr($version,1); |
443 | $sDVersion = $this->secure->checkStr($version,1); |
444 | $sDVName = $this->secure->checkStr($vname,1); |
444 | $sDVName = $this->secure->checkStr($vname,1); |
445 | $sDVCName = $this->secure->checkStr($vcodename,1); |
445 | $sDVCName = $this->secure->checkStr($vcodename,1); |
446 | 446 | ||
447 | $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."'"; |
448 | $rq =& $this->db->query($query); |
448 | $rq =& $this->db->query($query); |
449 | if (PEAR::isError($this->db)) { |
449 | if (PEAR::isError($this->db)) { |
450 | $result["ERR"] = 1; |
450 | $result["ERR"] = 1; |
451 | $result["ERRINFO"] = $this->db->getMessage(); |
451 | $result["ERRINFO"] = $this->db->getMessage(); |
452 | } else { |
452 | } else { |
453 | $result["ERR"] = 0; |
453 | $result["ERR"] = 0; |
454 | }
|
454 | }
|
455 | 455 | ||
456 | return $result; |
456 | return $result; |
457 | }
|
457 | }
|
458 | 458 | ||
459 | /**
|
459 | /**
|
460 | * Редактирование информации о версии дистрибутива
|
460 | * Редактирование информации о версии дистрибутива
|
461 | *
|
461 | *
|
462 | * @author Alexander Wolf
|
462 | * @author Alexander Wolf
|
463 | * @category Core
|
463 | * @category Core
|
464 | *
|
464 | *
|
465 | * @param integer $versionID
|
465 | * @param integer $versionID
|
466 | * @param string $version
|
466 | * @param string $version
|
467 | * @param string $vname
|
467 | * @param string $vname
|
468 | * @param string $vcodename
|
468 | * @param string $vcodename
|
469 | * @return array
|
469 | * @return array
|
470 | */
|
470 | */
|
471 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
471 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
472 | $result = array(); |
472 | $result = array(); |
473 | $sVersID = $this->secure->checkInt($versionID); |
473 | $sVersID = $this->secure->checkInt($versionID); |
474 | $sDVersion = $this->secure->checkStr($version,1); |
474 | $sDVersion = $this->secure->checkStr($version,1); |
475 | $sDVName = $this->secure->checkStr($vname,1); |
475 | $sDVName = $this->secure->checkStr($vname,1); |
476 | $sDVCName = $this->secure->checkStr($vcodename,1); |
476 | $sDVCName = $this->secure->checkStr($vcodename,1); |
477 | 477 | ||
478 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
478 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
479 | $rq =& $this->db->query($query); |
479 | $rq =& $this->db->query($query); |
480 | if (PEAR::isError($this->db)) { |
480 | if (PEAR::isError($this->db)) { |
481 | $result["ERR"] = 1; |
481 | $result["ERR"] = 1; |
482 | $result["ERRINFO"] = $this->db->getMessage(); |
482 | $result["ERRINFO"] = $this->db->getMessage(); |
483 | } else { |
483 | } else { |
484 | $result["ERR"] = 0; |
484 | $result["ERR"] = 0; |
485 | }
|
485 | }
|
486 | 486 | ||
487 | return $result; |
487 | return $result; |
488 | }
|
488 | }
|
489 | 489 | ||
490 | /**
|
490 | /**
|
491 | * Удаление информации о версии дистрибутива
|
491 | * Удаление информации о версии дистрибутива
|
492 | *
|
492 | *
|
493 | * @author Alexander Wolf
|
493 | * @author Alexander Wolf
|
494 | * @category Core
|
494 | * @category Core
|
495 | *
|
495 | *
|
496 | * @param integer $versionID
|
496 | * @param integer $versionID
|
497 | * @return array
|
497 | * @return array
|
498 | */
|
498 | */
|
499 | public function dropDistVersion($versionID) { |
499 | public function dropDistVersion($versionID) { |
500 | $result = array(); |
500 | $result = array(); |
501 | $sVersID = $this->secure->checkInt($versionID); |
501 | $sVersID = $this->secure->checkInt($versionID); |
502 | 502 | ||
503 | // Удаление версии дистрибутива
|
503 | // Удаление версии дистрибутива
|
504 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
504 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
505 | $rq =& $this->db->query($query); |
505 | $rq =& $this->db->query($query); |
506 | if (PEAR::isError($this->db)) { |
506 | if (PEAR::isError($this->db)) { |
507 | $result["ERR"] = 1; |
507 | $result["ERR"] = 1; |
508 | $result["ERRINFO"] = $this->db->getMessage(); |
508 | $result["ERRINFO"] = $this->db->getMessage(); |
509 | } else { |
509 | } else { |
510 | $result["ERR"] = 0; |
510 | $result["ERR"] = 0; |
511 | }
|
511 | }
|
512 | 512 | ||
513 | // Удаление репозиториев этой версии дистрибутива
|
513 | // Удаление репозиториев этой версии дистрибутива
|
514 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
514 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
515 | $rq =& $this->db->query($query); |
515 | $rq =& $this->db->query($query); |
516 | if (PEAR::isError($this->db)) { |
516 | if (PEAR::isError($this->db)) { |
517 | $result["ERR"] = 1; |
517 | $result["ERR"] = 1; |
518 | $result["ERRINFO"] = $this->db->getMessage(); |
518 | $result["ERRINFO"] = $this->db->getMessage(); |
519 | } else { |
519 | } else { |
520 | $result["ERR"] = 0; |
520 | $result["ERR"] = 0; |
521 | }
|
521 | }
|
522 | 522 | ||
523 | return $result; |
523 | return $result; |
524 | }
|
524 | }
|
525 | 525 | ||
526 | /**
|
526 | /**
|
527 | * Отображение типа дистрибутива
|
527 | * Отображение типа дистрибутива
|
528 | *
|
528 | *
|
529 | * @author Alexander Wolf
|
529 | * @author Alexander Wolf
|
530 | * @category Core
|
530 | * @category Core
|
531 | *
|
531 | *
|
532 | * @param string $name
|
532 | * @param string $name
|
533 | * @param byte $type
|
533 | * @param byte $type
|
534 | * @return string
|
534 | * @return string
|
535 | */
|
535 | */
|
536 | public function showDistTypeForm($name = "dtype",$type = 0) { |
536 | public function showDistTypeForm($name = "dtype",$type = 0) { |
537 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
537 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
538 | $rq =& $this->db->query($query); |
538 | $rq =& $this->db->query($query); |
539 | $show = "<select name='".$name."' id='".$name."'>\n"; |
539 | $show = "<select name='".$name."' id='".$name."'>\n"; |
540 | while ($rq->fetchInto($element)) { |
540 | while ($rq->fetchInto($element)) { |
541 | if ($element["type_id"] == $type) { |
541 | if ($element["type_id"] == $type) { |
542 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
542 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
543 | } else { |
543 | } else { |
544 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
544 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
545 | }
|
545 | }
|
546 | }
|
546 | }
|
547 | $show .= "</select>"; |
547 | $show .= "</select>"; |
548 | 548 | ||
549 | return $show; |
549 | return $show; |
550 | }
|
550 | }
|
551 | 551 | ||
552 | /**
|
552 | /**
|
553 | * Отображение формы создания и редактирования apt-дистрибутива
|
553 | * Отображение формы создания и редактирования apt-дистрибутива
|
554 | *
|
554 | *
|
555 | * @author Alexander Wolf
|
555 | * @author Alexander Wolf
|
556 | * @category Core
|
556 | * @category Core
|
557 | *
|
557 | *
|
558 | * @param integer $distID
|
558 | * @param integer $distID
|
559 | * @return string
|
559 | * @return string
|
560 | */
|
560 | */
|
561 | public function showDistributionForm($distID = 0, $info = '') { |
561 | public function showDistributionForm($distID = 0, $info = '') { |
562 | $sDistID = $this->secure->checkInt($distID); |
562 | $sDistID = $this->secure->checkInt($distID); |
563 | $sInfo = $this->secure->checkStr($info, 1); |
563 | $sInfo = $this->secure->checkStr($info, 1); |
564 | if ($sInfo == "") { |
564 | if ($sInfo == "") { |
565 | $sInfo = "Дистрибутив"; |
565 | $sInfo = "Дистрибутив"; |
566 | }
|
566 | }
|
567 | if ($sDistID != 0) { |
567 | if ($sDistID != 0) { |
568 | // Режим редактирования
|
568 | // Режим редактирования
|
569 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
569 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
570 | $rq =& $this->db->query($query); |
570 | $rq =& $this->db->query($query); |
571 | $rq->fetchInto($element); |
571 | $rq->fetchInto($element); |
572 | }
|
572 | }
|
573 | 573 | ||
574 | if ($element["distlogo"] == 1) { |
574 | if ($element["distlogo"] == 1) { |
575 | $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)."'>"; |
575 | $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)."'>"; |
576 | } else { |
576 | } else { |
577 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
577 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
578 | }
|
578 | }
|
579 | 579 | ||
580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
581 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
581 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
582 | $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"; |
582 | $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"; |
583 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
583 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
584 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
584 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
585 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
585 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
586 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
586 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
587 | 587 | ||
588 | return $show; |
588 | return $show; |
589 | }
|
589 | }
|
590 | 590 | ||
591 | // sourses.list
|
591 | // sourses.list
|
592 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
592 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
593 | //TODO Написать генератор sources.list
|
593 | //TODO Написать генератор sources.list
|
594 | }
|
594 | }
|
595 | 595 | ||
596 | /**
|
596 | /**
|
597 | * Показывает список секций
|
597 | * Показывает список секций
|
598 | *
|
598 | *
|
599 | * @author Alexander Wolf
|
599 | * @author Alexander Wolf
|
600 | * @category Core
|
600 | * @category Core
|
601 | *
|
601 | *
|
602 | * @param string $name
|
602 | * @param string $name
|
603 | * @param string $actor
|
603 | * @param string $actor
|
604 | * @return string
|
604 | * @return string
|
605 | */
|
605 | */
|
606 | public function showSectionsList($name, $actor) { |
606 | public function showSectionsList($name, $actor) { |
607 | $query = "SELECT * FROM ".$this->prefix."section"; |
607 | $query = "SELECT * FROM ".$this->prefix."section"; |
608 | $rq =& $this->db->query($query); |
608 | $rq =& $this->db->query($query); |
609 | $show = "<ul>\n"; |
609 | $show = "<ul>\n"; |
610 | while ($rq->fetchInto($element)) { |
610 | while ($rq->fetchInto($element)) { |
611 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sect_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sect_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["secname"],1)."</li>\n"; |
611 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sect_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sect_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["secname"],1)."</li>\n"; |
612 | }
|
612 | }
|
613 | $show .= "</ul>"; |
613 | $show .= "</ul>"; |
614 | 614 | ||
615 | return $show; |
615 | return $show; |
616 | }
|
616 | }
|
617 | 617 | ||
618 | /**
|
618 | /**
|
619 | * Вывод формы редактирования/добавления секций
|
619 | * Вывод формы редактирования/добавления секций
|
620 | *
|
620 | *
|
621 | * @author Alexander Wolf
|
621 | * @author Alexander Wolf
|
622 | * @category Core
|
622 | * @category Core
|
623 | *
|
623 | *
|
624 | * @param integer $sectionID
|
624 | * @param integer $sectionID
|
625 | * @param string $info
|
625 | * @param string $info
|
626 | * @return string
|
626 | * @return string
|
627 | */
|
627 | */
|
628 | public function showSectionsForm($sectionID = 0, $info = "") { |
628 | public function showSectionsForm($sectionID = 0, $info = "") { |
629 | $sSectID = $this->secure->checkInt($sectionID); |
629 | $sSectID = $this->secure->checkInt($sectionID); |
630 | $sInfo = $this->secure->checkStr($info, 1); |
630 | $sInfo = $this->secure->checkStr($info, 1); |
631 | if ($sInfo == "") { |
631 | if ($sInfo == "") { |
632 | $sInfo = "Секция"; |
632 | $sInfo = "Секция"; |
633 | }
|
633 | }
|
634 | if ($sSectID != 0) { |
634 | if ($sSectID != 0) { |
635 | // Режим редактирования
|
635 | // Режим редактирования
|
636 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
636 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
637 | $rq =& $this->db->query($query); |
637 | $rq =& $this->db->query($query); |
638 | $rq->fetchInto($element); |
638 | $rq->fetchInto($element); |
639 | }
|
639 | }
|
640 | 640 | ||
641 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
641 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
642 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
642 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
643 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
643 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
644 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
644 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
645 | 645 | ||
646 | return $show; |
646 | return $show; |
647 | }
|
647 | }
|
648 | 648 | ||
649 | /**
|
649 | /**
|
650 | * Обновление информации о секции
|
650 | * Обновление информации о секции
|
651 | *
|
651 | *
|
652 | * @author Alexander Wolf
|
652 | * @author Alexander Wolf
|
653 | * @category Core
|
653 | * @category Core
|
654 | *
|
654 | *
|
655 | * @param integer $sectionID
|
655 | * @param integer $sectionID
|
656 | * @param string $sname
|
656 | * @param string $sname
|
657 | * @param string $sinfo
|
657 | * @param string $sinfo
|
658 | * @return array
|
658 | * @return array
|
659 | */
|
659 | */
|
660 | public function updateSection($sectionID, $sname, $sinfo = "") { |
660 | public function updateSection($sectionID, $sname, $sinfo = "") { |
661 | $result = array(); |
661 | $result = array(); |
662 | $sSectID = $this->secure->checkInt($sectionID); |
662 | $sSectID = $this->secure->checkInt($sectionID); |
663 | $sSName = $this->secure->checkStr($sname,1); |
663 | $sSName = $this->secure->checkStr($sname,1); |
664 | $sSInfo = $this->secure->checkStr($sinfo,1); |
664 | $sSInfo = $this->secure->checkStr($sinfo,1); |
665 | 665 | ||
666 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
666 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
667 | $rq =& $this->db->query($query); |
667 | $rq =& $this->db->query($query); |
668 | if (PEAR::isError($this->db)) { |
668 | if (PEAR::isError($this->db)) { |
669 | $result["ERR"] = 1; |
669 | $result["ERR"] = 1; |
670 | $result["ERRINFO"] = $this->db->getMessage(); |
670 | $result["ERRINFO"] = $this->db->getMessage(); |
671 | } else { |
671 | } else { |
672 | $result["ERR"] = 0; |
672 | $result["ERR"] = 0; |
673 | }
|
673 | }
|
674 | 674 | ||
675 | return $result; |
675 | return $result; |
676 | }
|
676 | }
|
677 | 677 | ||
678 | /**
|
678 | /**
|
679 | * Удаление информации о секции
|
679 | * Удаление информации о секции
|
680 | *
|
680 | *
|
681 | * @author Alexander Wolf
|
681 | * @author Alexander Wolf
|
682 | * @category Core
|
682 | * @category Core
|
683 | *
|
683 | *
|
684 | * @param integer $sectionID
|
684 | * @param integer $sectionID
|
685 | * @return array
|
685 | * @return array
|
686 | */
|
686 | */
|
687 | public function dropSection($sectionID) { |
687 | public function dropSection($sectionID) { |
688 | $result = array(); |
688 | $result = array(); |
689 | $sSectID = $this->secure->checkInt($sectionID); |
689 | $sSectID = $this->secure->checkInt($sectionID); |
690 | 690 | ||
691 | // Удаление секции
|
691 | // Удаление секции
|
692 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
692 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
693 | $rq =& $this->db->query($query); |
693 | $rq =& $this->db->query($query); |
694 | if (PEAR::isError($this->db)) { |
694 | if (PEAR::isError($this->db)) { |
695 | $result["ERR"] = 1; |
695 | $result["ERR"] = 1; |
696 | $result["ERRINFO"] = $this->db->getMessage(); |
696 | $result["ERRINFO"] = $this->db->getMessage(); |
697 | } else { |
697 | } else { |
698 | $result["ERR"] = 0; |
698 | $result["ERR"] = 0; |
699 | }
|
699 | }
|
700 | 700 | ||
701 | return $result; |
701 | return $result; |
702 | }
|
702 | }
|
703 | 703 | ||
704 | /**
|
704 | /**
|
705 | * Добавление новой секции
|
705 | * Добавление новой секции
|
706 | *
|
706 | *
|
707 | * @author Alexander Wolf
|
707 | * @author Alexander Wolf
|
708 | * @category Core
|
708 | * @category Core
|
709 | *
|
709 | *
|
710 | * @param string $sname
|
710 | * @param string $sname
|
711 | * @param string $sinfo
|
711 | * @param string $sinfo
|
712 | * @return array
|
712 | * @return array
|
713 | */
|
713 | */
|
714 | public function addSection($sname, $sinfo = "") { |
714 | public function addSection($sname, $sinfo = "") { |
715 | $result = array(); |
715 | $result = array(); |
716 | $sSName = $this->secure->checkStr($sname,1); |
716 | $sSName = $this->secure->checkStr($sname,1); |
717 | $sSInfo = $this->secure->checkStr($sinfo,1); |
717 | $sSInfo = $this->secure->checkStr($sinfo,1); |
718 | 718 | ||
719 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
719 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
720 | $rq =& $this->db->query($query); |
720 | $rq =& $this->db->query($query); |
721 | if (PEAR::isError($this->db)) { |
721 | if (PEAR::isError($this->db)) { |
722 | $result["ERR"] = 1; |
722 | $result["ERR"] = 1; |
723 | $result["ERRINFO"] = $this->db->getMessage(); |
723 | $result["ERRINFO"] = $this->db->getMessage(); |
724 | } else { |
724 | } else { |
725 | $result["ERR"] = 0; |
725 | $result["ERR"] = 0; |
726 | }
|
726 | }
|
727 | 727 | ||
728 | return $result; |
728 | return $result; |
729 | }
|
729 | }
|
730 | 730 | ||
731 | /**
|
731 | /**
|
732 | * Показывает список подписей
|
732 | * Показывает список подписей
|
733 | *
|
733 | *
|
734 | * @author Alexander Wolf
|
734 | * @author Alexander Wolf
|
735 | * @category Core
|
735 | * @category Core
|
736 | *
|
736 | *
|
737 | * @param string $name
|
737 | * @param string $name
|
738 | * @param string $actor
|
738 | * @param string $actor
|
739 | * @return string
|
739 | * @return string
|
740 | */
|
740 | */
|
741 | public function showSignsList($name, $actor) { |
741 | public function showSignsList($name, $actor) { |
742 | $query = "SELECT * FROM ".$this->prefix."signs"; |
742 | $query = "SELECT * FROM ".$this->prefix."signs"; |
743 | $rq =& $this->db->query($query); |
743 | $rq =& $this->db->query($query); |
744 | $show = "<ul>\n"; |
744 | $show = "<ul>\n"; |
745 | while ($rq->fetchInto($element)) { |
745 | while ($rq->fetchInto($element)) { |
746 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sign_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sign_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["sname"],1)."</li>\n"; |
746 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sign_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sign_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["sname"],1)."</li>\n"; |
747 | }
|
747 | }
|
748 | $show .= "</ul>"; |
748 | $show .= "</ul>"; |
749 | 749 | ||
750 | return $show; |
750 | return $show; |
751 | }
|
751 | }
|
752 | 752 | ||
753 | /**
|
753 | /**
|
754 | * Вывод формы редактирования/добавления подписей
|
754 | * Вывод формы редактирования/добавления подписей
|
755 | *
|
755 | *
|
756 | * @author Alexander Wolf
|
756 | * @author Alexander Wolf
|
757 | * @category Core
|
757 | * @category Core
|
758 | *
|
758 | *
|
759 | * @param integer $sectionID
|
759 | * @param integer $sectionID
|
760 | * @param string $info
|
760 | * @param string $info
|
761 | * @return string
|
761 | * @return string
|
762 | */
|
762 | */
|
763 | public function showSignsForm($signID = 0, $info = "") { |
763 | public function showSignsForm($signID = 0, $info = "") { |
764 | $sSignID = $this->secure->checkInt($signID); |
764 | $sSignID = $this->secure->checkInt($signID); |
765 | $sInfo = $this->secure->checkStr($info, 1); |
765 | $sInfo = $this->secure->checkStr($info, 1); |
766 | if ($sInfo == "") { |
766 | if ($sInfo == "") { |
767 | $sInfo = "Подписи"; |
767 | $sInfo = "Подписи"; |
768 | }
|
768 | }
|
769 | if ($sSignID != 0) { |
769 | if ($sSignID != 0) { |
770 | // Режим редактирования
|
770 | // Режим редактирования
|
771 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
771 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
772 | $rq =& $this->db->query($query); |
772 | $rq =& $this->db->query($query); |
773 | $rq->fetchInto($element); |
773 | $rq->fetchInto($element); |
774 | }
|
774 | }
|
775 | 775 | ||
776 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
776 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
777 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
777 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
778 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
778 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
779 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
779 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
780 | 780 | ||
781 | return $show; |
781 | return $show; |
782 | }
|
782 | }
|
783 | 783 | ||
784 | /**
|
784 | /**
|
785 | * Обновление информации о секции
|
785 | * Обновление информации о секции
|
786 | *
|
786 | *
|
787 | * @author Alexander Wolf
|
787 | * @author Alexander Wolf
|
788 | * @category Core
|
788 | * @category Core
|
789 | *
|
789 | *
|
790 | * @param integer $sectionID
|
790 | * @param integer $sectionID
|
791 | * @param string $sname
|
791 | * @param string $sname
|
792 | * @param string $sinfo
|
792 | * @param string $sinfo
|
793 | * @return array
|
793 | * @return array
|
794 | */
|
794 | */
|
795 | public function updateSign($signID, $sname, $sinfo = "") { |
795 | public function updateSign($signID, $sname, $sinfo = "") { |
796 | $result = array(); |
796 | $result = array(); |
797 | $sSignID = $this->secure->checkInt($signID); |
797 | $sSignID = $this->secure->checkInt($signID); |
798 | $sSName = $this->secure->checkStr($sname,1); |
798 | $sSName = $this->secure->checkStr($sname,1); |
799 | $sSInfo = $this->secure->checkStr($sinfo,1); |
799 | $sSInfo = $this->secure->checkStr($sinfo,1); |
800 | 800 | ||
801 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
801 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
802 | $rq =& $this->db->query($query); |
802 | $rq =& $this->db->query($query); |
803 | if (PEAR::isError($this->db)) { |
803 | if (PEAR::isError($this->db)) { |
804 | $result["ERR"] = 1; |
804 | $result["ERR"] = 1; |
805 | $result["ERRINFO"] = $this->db->getMessage(); |
805 | $result["ERRINFO"] = $this->db->getMessage(); |
806 | } else { |
806 | } else { |
807 | $result["ERR"] = 0; |
807 | $result["ERR"] = 0; |
808 | }
|
808 | }
|
809 | 809 | ||
810 | return $result; |
810 | return $result; |
811 | }
|
811 | }
|
812 | 812 | ||
813 | /**
|
813 | /**
|
814 | * Удаление информации о подписи
|
814 | * Удаление информации о подписи
|
815 | *
|
815 | *
|
816 | * @author Alexander Wolf
|
816 | * @author Alexander Wolf
|
817 | * @category Core
|
817 | * @category Core
|
818 | *
|
818 | *
|
819 | * @param integer $sectionID
|
819 | * @param integer $sectionID
|
820 | * @return array
|
820 | * @return array
|
821 | */
|
821 | */
|
822 | public function dropSign($signID) { |
822 | public function dropSign($signID) { |
823 | $result = array(); |
823 | $result = array(); |
824 | $sSignID = $this->secure->checkInt($signID); |
824 | $sSignID = $this->secure->checkInt($signID); |
825 | 825 | ||
826 | // Удаление подписи
|
826 | // Удаление подписи
|
827 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
827 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
828 | $rq =& $this->db->query($query); |
828 | $rq =& $this->db->query($query); |
829 | if (PEAR::isError($this->db)) { |
829 | if (PEAR::isError($this->db)) { |
830 | $result["ERR"] = 1; |
830 | $result["ERR"] = 1; |
831 | $result["ERRINFO"] = $this->db->getMessage(); |
831 | $result["ERRINFO"] = $this->db->getMessage(); |
832 | } else { |
832 | } else { |
833 | $result["ERR"] = 0; |
833 | $result["ERR"] = 0; |
834 | }
|
834 | }
|
835 | 835 | ||
836 | return $result; |
836 | return $result; |
837 | }
|
837 | }
|
838 | 838 | ||
839 | /**
|
839 | /**
|
840 | * Добавление новой подписи
|
840 | * Добавление новой подписи
|
841 | *
|
841 | *
|
842 | * @author Alexander Wolf
|
842 | * @author Alexander Wolf
|
843 | * @category Core
|
843 | * @category Core
|
844 | *
|
844 | *
|
845 | * @param string $sname
|
845 | * @param string $sname
|
846 | * @param string $sinfo
|
846 | * @param string $sinfo
|
847 | * @return array
|
847 | * @return array
|
848 | */
|
848 | */
|
849 | public function addSign($sname, $sinfo = "") { |
849 | public function addSign($sname, $sinfo = "") { |
850 | $result = array(); |
850 | $result = array(); |
851 | $sSName = $this->secure->checkStr($sname,1); |
851 | $sSName = $this->secure->checkStr($sname,1); |
852 | $sSInfo = $this->secure->checkStr($sinfo,1); |
852 | $sSInfo = $this->secure->checkStr($sinfo,1); |
853 | 853 | ||
854 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
854 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
855 | $rq =& $this->db->query($query); |
855 | $rq =& $this->db->query($query); |
856 | if (PEAR::isError($this->db)) { |
856 | if (PEAR::isError($this->db)) { |
857 | $result["ERR"] = 1; |
857 | $result["ERR"] = 1; |
858 | $result["ERRINFO"] = $this->db->getMessage(); |
858 | $result["ERRINFO"] = $this->db->getMessage(); |
859 | } else { |
859 | } else { |
860 | $result["ERR"] = 0; |
860 | $result["ERR"] = 0; |
861 | }
|
861 | }
|
862 | 862 | ||
863 | return $result; |
863 | return $result; |
864 | }
|
864 | }
|
865 | 865 | ||
866 | /**
|
866 | /**
|
867 | * Проверка пароля (из формы авторизации)
|
867 | * Проверка пароля (из формы авторизации)
|
868 | *
|
868 | *
|
869 | * @author Alexander Wolf
|
869 | * @author Alexander Wolf
|
870 | * @category Core
|
870 | * @category Core
|
871 | *
|
871 | *
|
872 | * @param string $word
|
872 | * @param string $word
|
873 | * @return array
|
873 | * @return array
|
874 | */
|
874 | */
|
875 | public function checkSign($word) { |
875 | public function checkSign($word) { |
876 | $result = array(); |
876 | $result = array(); |
877 | 877 | ||
878 | $sHash = $this->secure->encryptStr($word); |
878 | $sHash = $this->secure->encryptStr($word); |
879 | $pwd = $this->getOption("passwd"); |
879 | $pwd = $this->getOption("passwd"); |
880 | if ($sHash == $pwd["OptValue"]) { |
880 | if ($sHash == $pwd["OptValue"]) { |
881 | $result["ERR"] = 0; |
881 | $result["ERR"] = 0; |
882 | $result["Location"] = "manager.php"; |
882 | $result["Location"] = "manager.php"; |
883 | setcookie($this->cookie, $sHash); |
883 | setcookie($this->cookie, $sHash); |
884 | } else { |
884 | } else { |
885 | $result["ERR"] = 1; |
885 | $result["ERR"] = 1; |
886 | $result["ERRINFO"] = "Password not valid"; |
886 | $result["ERRINFO"] = "Password not valid"; |
887 | $result["Location"] = "manager.php?error=1"; |
887 | $result["Location"] = "manager.php?error=1"; |
888 | }
|
888 | }
|
889 | 889 | ||
890 | return $result; |
890 | return $result; |
891 | }
|
891 | }
|
892 | 892 | ||
893 | /**
|
893 | /**
|
894 | * Проверка пароля (из cookies)
|
894 | * Проверка пароля (из cookies)
|
895 | *
|
895 | *
|
896 | * @author Alexander Wolf
|
896 | * @author Alexander Wolf
|
897 | * @category Core
|
897 | * @category Core
|
898 | *
|
898 | *
|
899 | * @param string $hash
|
899 | * @param string $hash
|
900 | * @return array
|
900 | * @return array
|
901 | */
|
901 | */
|
902 | public function checkCookieSign($hash) { |
902 | public function checkCookieSign($hash) { |
903 | $result = array(); |
903 | $result = array(); |
904 | 904 | ||
905 | $pwd = $this->getOption("passwd"); |
905 | $pwd = $this->getOption("passwd"); |
906 | if ($hash == $pwd["OptValue"]) { |
906 | if ($hash == $pwd["OptValue"]) { |
907 | $result["ERR"] = 0; |
907 | $result["ERR"] = 0; |
908 | } else { |
908 | } else { |
909 | $result["ERR"] = 1; |
909 | $result["ERR"] = 1; |
910 | $result["ERRINFO"] = "Hash not valid"; |
910 | $result["ERRINFO"] = "Hash not valid"; |
911 | $result["Location"] = "manager.php"; |
911 | $result["Location"] = "manager.php"; |
912 | }
|
912 | }
|
913 | 913 | ||
914 | return $result; |
914 | return $result; |
915 | }
|
915 | }
|
916 | 916 | ||
917 | /**
|
917 | /**
|
918 | * Форма ввода пароля
|
918 | * Форма ввода пароля
|
919 | *
|
919 | *
|
920 | * @author Alexander Wolf
|
920 | * @author Alexander Wolf
|
921 | * @category Core
|
921 | * @category Core
|
922 | *
|
922 | *
|
923 | * @return string
|
923 | * @return string
|
924 | */
|
924 | */
|
925 | public function showSigninForm() { |
925 | public function showSigninForm() { |
926 | $show = "<div id='regform'>"; |
926 | $show = "<div id='regform'>"; |
927 | $show .= "<form action='process.php' method='post'>\n"; |
927 | $show .= "<form action='process.php' method='post'>\n"; |
928 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
928 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
929 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
929 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
930 | $show .= "<input type='password' name='word' value=''>\n"; |
930 | $show .= "<input type='password' name='word' value=''>\n"; |
931 | $show .= "<input type='submit' value=' Войти '>\n"; |
931 | $show .= "<input type='submit' value=' Войти '>\n"; |
932 | $show .= "</fieldset>\n</form></div>\n"; |
932 | $show .= "</fieldset>\n</form></div>\n"; |
933 | 933 | ||
934 | return $show; |
934 | return $show; |
935 | }
|
935 | }
|
936 | 936 | ||
937 | /**
|
937 | /**
|
938 | * Обновление пароля
|
938 | * Обновление пароля
|
939 | *
|
939 | *
|
940 | * @author Alexander Wolf
|
940 | * @author Alexander Wolf
|
941 | * @category Core
|
941 | * @category Core
|
942 | *
|
942 | *
|
943 | * @param string $word1
|
943 | * @param string $word1
|
944 | * @param string $word2
|
944 | * @param string $word2
|
945 | * @return array
|
945 | * @return array
|
946 | */
|
946 | */
|
947 | public function updatePassword($word1, $word2) { |
947 | public function updatePassword($word1, $word2) { |
948 | $result = array(); |
948 | $result = array(); |
949 | 949 | ||
950 | if ($word1 == $word2) { |
950 | if ($word1 == $word2) { |
951 | $sWord = $this->secure->encryptStr($word1); |
951 | $sWord = $this->secure->encryptStr($word1); |
952 | $r = $this->setOption("passwd", $sWord); |
952 | $r = $this->setOption("passwd", $sWord); |
953 | $result = $r; |
953 | $result = $r; |
954 | } else { |
954 | } else { |
955 | $result["ERR"] = 1; |
955 | $result["ERR"] = 1; |
956 | $result["ERRINFO"] = "Passwords is mismatch"; |
956 | $result["ERRINFO"] = "Passwords is mismatch"; |
957 | }
|
957 | }
|
958 | 958 | ||
959 | return $result; |
959 | return $result; |
960 | }
|
960 | }
|
961 | 961 | ||
962 | /**
|
962 | /**
|
963 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
963 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
964 | *
|
964 | *
|
965 | * @author Alexander Wolf
|
965 | * @author Alexander Wolf
|
966 | * @category Core
|
966 | * @category Core
|
967 | *
|
967 | *
|
968 | * @param string $name
|
968 | * @param string $name
|
969 | * @param string $actor
|
969 | * @param string $actor
|
970 | * @param integer $versionID
|
970 | * @param integer $versionID
|
971 | * @return string
|
971 | * @return string
|
972 | */
|
972 | */
|
973 | public function showDistVersionsForm($versionID = 0, $info = '') { |
973 | public function showDistVersionsForm($versionID = 0, $info = '') { |
974 | $sVersionID = $this->secure->checkInt($versionID); |
974 | $sVersionID = $this->secure->checkInt($versionID); |
975 | $sInfo = $this->secure->checkStr($info, 1); |
975 | $sInfo = $this->secure->checkStr($info, 1); |
976 | if ($sInfo == "") { |
976 | if ($sInfo == "") { |
977 | $sInfo = "Версия дистрибутива"; |
977 | $sInfo = "Версия дистрибутива"; |
978 | }
|
978 | }
|
979 | if ($sVersionID != 0) { |
979 | if ($sVersionID != 0) { |
980 | // Режим редактирования
|
980 | // Режим редактирования
|
981 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$versionID."'"; |
981 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$versionID."'"; |
982 | $rq =& $this->db->query($query); |
982 | $rq =& $this->db->query($query); |
983 | $rq->fetchInto($element); |
983 | $rq->fetchInto($element); |
984 | }
|
984 | }
|
985 | 985 | ||
986 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
986 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
987 | if ($sVersionID != 0) { |
987 | if ($sVersionID != 0) { |
988 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
988 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
989 | } else { |
989 | } else { |
990 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
990 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
991 | }
|
991 | }
|
992 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
992 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
993 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
993 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
994 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
994 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
995 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
995 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
996 | 996 | ||
997 | return $show; |
997 | return $show; |
998 | }
|
998 | }
|
999 | 999 | ||
1000 | /**
|
1000 | /**
|
1001 | * Парсер схемы адреса репозитория
|
1001 | * Парсер схемы адреса репозитория
|
1002 | * FIXME Возможно не потребуется
|
1002 | * FIXME Возможно не потребуется
|
1003 | *
|
1003 | *
|
1004 | * @author Alexander Wolf
|
1004 | * @author Alexander Wolf
|
1005 | * @category Core
|
1005 | * @category Core
|
1006 | *
|
1006 | *
|
1007 | * @param string $repstring
|
1007 | * @param string $repstring
|
1008 | * @return integer
|
1008 | * @return integer
|
1009 | */
|
1009 | */
|
1010 | public function repositoryParser($repstring) { |
1010 | public function repositoryParser($repstring) { |
1011 | $tokens = array(); |
1011 | $tokens = array(); |
1012 | $sections = array(); |
1012 | $sections = array(); |
1013 | $tokens = split(" ",$repstring); |
1013 | $tokens = split(" ",$repstring); |
1014 | 1014 | ||
1015 | if ($tokens[0] == "deb") { |
1015 | if ($tokens[0] == "deb") { |
1016 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1016 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1017 | $url = parse_url($tokens[1]); |
1017 | $url = parse_url($tokens[1]); |
1018 | $distr = $tokens[2]; |
1018 | $distr = $tokens[2]; |
1019 | 1019 | ||
1020 | for($i=3;$i<count($tokens);$i++) { |
1020 | for($i=3;$i<count($tokens);$i++) { |
1021 | $sections[] = $tokens[$i]; |
1021 | $sections[] = $tokens[$i]; |
1022 | }
|
1022 | }
|
1023 | } else { |
1023 | } else { |
1024 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1024 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1025 | if (stripos($tokens[1],"]")!=0) { |
1025 | if (stripos($tokens[1],"]")!=0) { |
1026 | $sign = $tokens[1]; |
1026 | $sign = $tokens[1]; |
1027 | $url = parse_url($tokens[2]); |
1027 | $url = parse_url($tokens[2]); |
1028 | $base = $tokens[3]; |
1028 | $base = $tokens[3]; |
1029 | $repname = $tokens[4]; |
1029 | $repname = $tokens[4]; |
1030 | } else { |
1030 | } else { |
1031 | $url = parse_url($tokens[1]); |
1031 | $url = parse_url($tokens[1]); |
1032 | $base = $tokens[2]; |
1032 | $base = $tokens[2]; |
1033 | $repname = $tokens[3]; |
1033 | $repname = $tokens[3]; |
1034 | }
|
1034 | }
|
1035 | }
|
1035 | }
|
1036 | 1036 | ||
1037 | $proto = $url["scheme"]."://"; |
1037 | $proto = $url["scheme"]."://"; |
1038 | $addr = $url["host"]; |
1038 | $addr = $url["host"]; |
1039 | if ($url["port"]!="") { |
1039 | if ($url["port"]!="") { |
1040 | $addr .= ":".$url["port"]; |
1040 | $addr .= ":".$url["port"]; |
1041 | }
|
1041 | }
|
1042 | $path = $url["path"]; |
1042 | $path = $url["path"]; |
1043 | 1043 | ||
1044 | return 0; |
1044 | return 0; |
1045 | }
|
1045 | }
|
1046 | 1046 | ||
1047 | /**
|
1047 | /**
|
1048 | * Выгрузка картинок логотипов дистрибутивов
|
1048 | * Выгрузка картинок логотипов дистрибутивов
|
1049 | *
|
1049 | *
|
1050 | * @author Alexander Wolf
|
1050 | * @author Alexander Wolf
|
1051 | * @category Core
|
1051 | * @category Core
|
1052 | *
|
1052 | *
|
1053 | * @param string $path
|
1053 | * @param string $path
|
1054 | * @param string $dist
|
1054 | * @param string $dist
|
1055 | * @param array $datafile
|
1055 | * @param array $datafile
|
1056 | * @return integer
|
1056 | * @return integer
|
1057 | */
|
1057 | */
|
1058 | public function uploadPicture($path, $dist, $datafile) { |
1058 | public function uploadPicture($path, $dist, $datafile) { |
1059 | $folder = $path.$dist."-orig.png"; |
1059 | $folder = $path.$dist."-orig.png"; |
1060 | $folderN = $path.$dist.".png"; |
1060 | $folderN = $path.$dist.".png"; |
1061 | $folderEM = $path.$dist."-em.png"; |
1061 | $folderEM = $path.$dist."-em.png"; |
1062 | 1062 | ||
1063 | $distlogo = 0; |
1063 | $distlogo = 0; |
1064 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1064 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1065 | chmod($folder, 0644); |
1065 | chmod($folder, 0644); |
1066 | list($width, $height) = GetImageSize($folder); |
1066 | list($width, $height) = GetImageSize($folder); |
1067 | $percent = 32/$height; |
1067 | $percent = 32/$height; |
1068 | $newwidth = $width * $percent; |
1068 | $newwidth = $width * $percent; |
1069 | $newheight = $height * $percent; |
1069 | $newheight = $height * $percent; |
1070 | 1070 | ||
1071 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1071 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1072 | $source = ImageCreateFromPNG($folder); |
1072 | $source = ImageCreateFromPNG($folder); |
1073 | 1073 | ||
1074 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1074 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1075 | ImagePNG($output, $folderEM); |
1075 | ImagePNG($output, $folderEM); |
1076 | 1076 | ||
1077 | $percent = 15/$height; |
1077 | $percent = 15/$height; |
1078 | $newwidth = $width * $percent; |
1078 | $newwidth = $width * $percent; |
1079 | $newheight = $height * $percent; |
1079 | $newheight = $height * $percent; |
1080 | 1080 | ||
1081 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1081 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1082 | 1082 | ||
1083 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1083 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1084 | ImagePNG($output, $folderN); |
1084 | ImagePNG($output, $folderN); |
1085 | 1085 | ||
1086 | unlink($folder); |
1086 | unlink($folder); |
1087 | $distlogo = 1; |
1087 | $distlogo = 1; |
1088 | }
|
1088 | }
|
1089 | return $distlogo; |
1089 | return $distlogo; |
1090 | }
|
1090 | }
|
1091 | 1091 | ||
1092 | /**
|
1092 | /**
|
1093 | * Показ списка репозиториев
|
1093 | * Показ списка репозиториев
|
1094 | *
|
1094 | *
|
1095 | * @author Alexander Wolf
|
1095 | * @author Alexander Wolf
|
1096 | * @category Core
|
1096 | * @category Core
|
1097 | *
|
1097 | *
|
1098 | * @param string $name
|
1098 | * @param string $name
|
1099 | * @param string $actor
|
1099 | * @param string $actor
|
1100 | * @param string $format
|
1100 | * @param string $format
|
1101 | * @return string
|
1101 | * @return string
|
1102 | */
|
1102 | */
|
- | 1103 | public function showRepositoriesList($name, $actor, $format = 'list') { |
|
- | 1104 | $query = "SELECT * FROM ".$this->prefix."repositories r "; |
|
- | 1105 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
|
- | 1106 | $rq =& $this->db->query($query); |
|
- | 1107 | $show = "<ul>"; |
|
- | 1108 | while ($rq->fetchInto($element)) { |
|
1103 | public function showRepositoriesList($name, $actor, $format = 'html') { |
1109 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["rep_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["rep_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["repname"],1)." (".$this->secure->checkStr($element["rtype"],1).")</li>\n"; |
- | 1110 | }
|
|
- | 1111 | $show .= "</ul>"; |
|
1104 | return $show; |
1112 | return $show; |
1105 | }
|
1113 | }
|
1106 | 1114 | ||
1107 | /**
|
1115 | /**
|
1108 | * Форма создания/редактирвоания репозиториев
|
1116 | * Форма создания/редактирвоания репозиториев
|
1109 | *
|
1117 | *
|
1110 | * @author Alexander Wolf
|
1118 | * @author Alexander Wolf
|
1111 | * @category Core
|
1119 | * @category Core
|
1112 | *
|
1120 | *
|
1113 | * @param integer $repID
|
1121 | * @param integer $repID
|
1114 | * @param string $info
|
1122 | * @param string $info
|
1115 | * @param string $reptype
|
1123 | * @param string $reptype
|
1116 | * @return string
|
1124 | * @return string
|
1117 | */
|
1125 | */
|
1118 | public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") { |
1126 | public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") { |
1119 | return $show; |
1127 | return $show; |
1120 | }
|
1128 | }
|
1121 | }
|
1129 | }
|
1122 | 1130 | ||
1123 | ?>
|
1131 | ?>
|