Редакция 549 | Редакция 556 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 549 | Редакция 554 | ||
---|---|---|---|
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 apt-distributives
|
6 | * distributives, based on Debian
|
- | |
7 | * http://alex-w.org.ru/p/antng/
|
6 | * http://alex-w.org.ru/p/antng/
|
8 | *
|
7 | *
|
9 | * Copyright (c) 2009 Alexander Wolf
|
8 | * Copyright (c) 2009 Alexander Wolf
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
9 | * Dual licensed under the MIT and GNU LGPL licenses.
|
11 | * http://alex-w.org.ru/p/antng/license
|
10 | * http://alex-w.org.ru/p/antng/license
|
12 | *
|
11 | *
|
13 | */
|
12 | */
|
14 | 13 | ||
15 | class Core { |
14 | class Core { |
16 | protected $db = NULL; |
15 | protected $db = NULL; |
17 | protected $prefix = NULL; |
16 | protected $prefix = NULL; |
18 | protected $secure = NULL; |
17 | protected $secure = NULL; |
19 | protected $cookie = NULL; |
18 | protected $cookie = NULL; |
20 | 19 | ||
21 | /**
|
20 | /**
|
22 | * Конструктор класса Core - ядро генератора
|
21 | * Конструктор класса Core - ядро генератора
|
23 | *
|
22 | *
|
24 | * @author Alexander Wolf
|
23 | * @author Alexander Wolf
|
25 | * @category Core
|
24 | * @category Core
|
26 | *
|
25 | *
|
27 | * @param string $database
|
26 | * @param string $database
|
28 | * @param string $prefix
|
27 | * @param string $prefix
|
29 | * @param object $secure
|
28 | * @param object $secure
|
30 | * @param string $cookie
|
29 | * @param string $cookie
|
31 | */
|
30 | */
|
32 | public function __construct($database, $prefix, $secure, $cookie) { |
31 | public function __construct($database, $prefix, $secure, $cookie) { |
33 | $this->db = $database; |
32 | $this->db = $database; |
34 | $this->prefix = $prefix; |
33 | $this->prefix = $prefix; |
35 | $this->secure = $secure; |
34 | $this->secure = $secure; |
36 | $this->cookie = $cookie; |
35 | $this->cookie = $cookie; |
37 | }
|
36 | }
|
38 | 37 | ||
39 | /**
|
38 | /**
|
40 | * Получение данных о настройке
|
39 | * Получение данных о настройке
|
41 | *
|
40 | *
|
42 | * @author Alexander Wolf
|
41 | * @author Alexander Wolf
|
43 | * @category Core
|
42 | * @category Core
|
44 | *
|
43 | *
|
45 | * @param string $attr
|
44 | * @param string $attr
|
46 | * @return array
|
45 | * @return array
|
47 | */
|
46 | */
|
48 | public function getOption($attr) { |
47 | public function getOption($attr) { |
49 | $result = array(); |
48 | $result = array(); |
50 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
49 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
51 | $rq =& $this->db->query($query); |
50 | $rq =& $this->db->query($query); |
52 | if ($rq->numRows()!=0) { |
51 | if ($rq->numRows()!=0) { |
53 | $rq->fetchInto($element); |
52 | $rq->fetchInto($element); |
54 | $result["ERR"] = 0; |
53 | $result["ERR"] = 0; |
55 | $result["OptValue"] = $element["optvalue"]; |
54 | $result["OptValue"] = $element["optvalue"]; |
56 | } else { |
55 | } else { |
57 | $result["ERR"] = 1; |
56 | $result["ERR"] = 1; |
58 | $result["ERRINFO"] = "Empty result"; |
57 | $result["ERRINFO"] = "Empty result"; |
59 | }
|
58 | }
|
60 | return $result; |
59 | return $result; |
61 | }
|
60 | }
|
62 | 61 | ||
63 | /**
|
62 | /**
|
64 | * Установка данных о настройке
|
63 | * Установка данных о настройке
|
65 | *
|
64 | *
|
66 | * @author Alexander Wolf
|
65 | * @author Alexander Wolf
|
67 | * @category Core
|
66 | * @category Core
|
68 | *
|
67 | *
|
69 | * @param string $attr
|
68 | * @param string $attr
|
70 | * @param string $value
|
69 | * @param string $value
|
71 | * @return array
|
70 | * @return array
|
72 | */
|
71 | */
|
73 | public function setOption($attr, $value) { |
72 | public function setOption($attr, $value) { |
74 | $result = array(); |
73 | $result = array(); |
75 | 74 | ||
76 | if ($attr != "passwd") { |
75 | if ($attr != "passwd") { |
77 | $sValue = $this->secure->checkStr($value); |
76 | $sValue = $this->secure->checkStr($value); |
78 | } else { |
77 | } else { |
79 | $sValue = $value; |
78 | $sValue = $value; |
80 | }
|
79 | }
|
81 | 80 | ||
82 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
81 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
83 | $rq =& $this->db->query($query); |
82 | $rq =& $this->db->query($query); |
84 | if (PEAR::isError($this->db)) { |
83 | if (PEAR::isError($this->db)) { |
85 | $result["ERR"] = 1; |
84 | $result["ERR"] = 1; |
86 | $result["ERRINFO"] = $this->db->getMessage(); |
85 | $result["ERRINFO"] = $this->db->getMessage(); |
87 | } else { |
86 | } else { |
88 | $result["ERR"] = 0; |
87 | $result["ERR"] = 0; |
89 | }
|
88 | }
|
90 | 89 | ||
91 | return $result; |
90 | return $result; |
92 | }
|
91 | }
|
93 | 92 | ||
94 | /**
|
93 | /**
|
95 | * Создание настройки
|
94 | * Создание настройки
|
96 | *
|
95 | *
|
97 | * @author Alexander Wolf
|
96 | * @author Alexander Wolf
|
98 | * @category Core
|
97 | * @category Core
|
99 | *
|
98 | *
|
100 | * @param string $attr
|
99 | * @param string $attr
|
101 | * @param string $value
|
100 | * @param string $value
|
102 | * @return array
|
101 | * @return array
|
103 | */
|
102 | */
|
104 | public function addOption($attr, $value) { |
103 | public function addOption($attr, $value) { |
105 | $result = array(); |
104 | $result = array(); |
106 | $sValue = $this->secure->checkStr($value); |
105 | $sValue = $this->secure->checkStr($value); |
107 | 106 | ||
108 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
107 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
109 | $rq =& $this->db->query($query); |
108 | $rq =& $this->db->query($query); |
110 | if (PEAR::isError($this->db)) { |
109 | if (PEAR::isError($this->db)) { |
111 | $result["ERR"] = 1; |
110 | $result["ERR"] = 1; |
112 | $result["ERRINFO"] = $this->db->getMessage(); |
111 | $result["ERRINFO"] = $this->db->getMessage(); |
113 | } else { |
112 | } else { |
114 | $result["ERR"] = 0; |
113 | $result["ERR"] = 0; |
115 | }
|
114 | }
|
116 | 115 | ||
117 | return $result; |
116 | return $result; |
118 | }
|
117 | }
|
119 | 118 | ||
120 | /**
|
119 | /**
|
121 | * Получение и отображение списка дистрибутвов
|
120 | * Получение и отображение списка дистрибутвов
|
122 | *
|
121 | *
|
123 | * @author Alexander Wolf
|
122 | * @author Alexander Wolf
|
124 | * @category Core
|
123 | * @category Core
|
125 | * @deprecated may be deprecated XXX
|
124 | * @deprecated may be deprecated XXX
|
126 | *
|
125 | *
|
127 | * @param string $name
|
126 | * @param string $name
|
128 | * @param string $heads
|
127 | * @param string $heads
|
129 | * @param string $info
|
128 | * @param string $info
|
130 | * @param string $format
|
129 | * @param string $format
|
131 | * @return string
|
130 | * @return string
|
132 | */
|
131 | */
|
133 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
132 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
134 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
133 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
135 | $rq =& $this->db->query($query); |
134 | $rq =& $this->db->query($query); |
136 | switch ($format) { |
135 | switch ($format) { |
137 | case 'html': |
136 | case 'html': |
138 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
137 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
139 | $show .= "<option value=''>".$info."</option>\n"; |
138 | $show .= "<option value=''>".$info."</option>\n"; |
140 | while ($rq->fetchInto($element)) { |
139 | while ($rq->fetchInto($element)) { |
141 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
140 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
142 | }
|
141 | }
|
143 | $show .= "</select></fieldset>"; |
142 | $show .= "</select></fieldset>"; |
144 | break; |
143 | break; |
145 | case 'json': |
144 | case 'json': |
146 | $show = '[{value:"",text:"'.$info.'"}'; |
145 | $show = '[{value:"",text:"'.$info.'"}'; |
147 | while ($rq->fetchInto($element)) { |
146 | while ($rq->fetchInto($element)) { |
148 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
147 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
149 | }
|
148 | }
|
150 | $show .= ']'; |
149 | $show .= ']'; |
151 | break; |
150 | break; |
152 | case 'innerhtml': |
151 | case 'innerhtml': |
153 | $show = "<select id='".$name."' name='".$name."'>\n"; |
152 | $show = "<select id='".$name."' name='".$name."'>\n"; |
154 | while ($rq->fetchInto($element)) { |
153 | while ($rq->fetchInto($element)) { |
155 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
154 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
156 | }
|
155 | }
|
157 | $show .= "</select>"; |
156 | $show .= "</select>"; |
158 | break; |
157 | break; |
159 | case 'list': |
158 | case 'list': |
160 | $show = "<ul>"; |
159 | $show = "<ul>"; |
161 | while ($rq->fetchInto($element)) { |
160 | 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"; |
161 | $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 | }
|
162 | }
|
164 | $show .= "</ul>"; |
163 | $show .= "</ul>"; |
165 | break; |
164 | break; |
166 | }
|
165 | }
|
167 | return $show; |
166 | return $show; |
168 | }
|
167 | }
|
169 | 168 | ||
170 | /**
|
169 | /**
|
171 | * Получение названия дистрибутива
|
170 | * Получение названия дистрибутива
|
172 | *
|
171 | *
|
173 | * @author Alexander Wolf
|
172 | * @author Alexander Wolf
|
174 | * @category Core
|
173 | * @category Core
|
175 | *
|
174 | *
|
176 | * @param integer $distID
|
175 | * @param integer $distID
|
177 | * @return array
|
176 | * @return array
|
178 | */
|
177 | */
|
179 | public function getDistName($distID) { |
178 | public function getDistName($distID) { |
180 | $result = array(); |
179 | $result = array(); |
181 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
180 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
182 | $rq =& $this->db->query($query); |
181 | $rq =& $this->db->query($query); |
183 | if (PEAR::isError($this->db)) { |
182 | if (PEAR::isError($this->db)) { |
184 | $result["ERR"] = 1; |
183 | $result["ERR"] = 1; |
185 | $result["ERRINFO"] = $this->db->getMessage(); |
184 | $result["ERRINFO"] = $this->db->getMessage(); |
186 | } else { |
185 | } else { |
187 | $rq->fetchInto($element); |
186 | $rq->fetchInto($element); |
188 | $result["ERR"] = 0; |
187 | $result["ERR"] = 0; |
189 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
188 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
190 | }
|
189 | }
|
191 | 190 | ||
192 | return $result; |
191 | return $result; |
193 | }
|
192 | }
|
194 | 193 | ||
195 | /**
|
194 | /**
|
196 | * Получение названия программы, ее версии и описания
|
195 | * Получение названия программы, ее версии и описания
|
197 | *
|
196 | *
|
198 | * @author Alexander Wolf
|
197 | * @author Alexander Wolf
|
199 | * @category Core
|
198 | * @category Core
|
200 | *
|
199 | *
|
201 | * @param string $attr
|
200 | * @param string $attr
|
202 | * @return string
|
201 | * @return string
|
203 | */
|
202 | */
|
204 | public function getEngineAttr($attr = 'codename') { |
203 | public function getEngineAttr($attr = 'codename') { |
205 | $cname = $this->getOption($attr); |
204 | $cname = $this->getOption($attr); |
206 | return $this->secure->checkStr($cname["OptValue"],1); |
205 | return $this->secure->checkStr($cname["OptValue"],1); |
207 | }
|
206 | }
|
208 | 207 | ||
209 | /**
|
208 | /**
|
210 | * Получение и отображение списка версий дистрибутива
|
209 | * Получение и отображение списка версий дистрибутива
|
211 | *
|
210 | *
|
212 | * @author Alexander Wolf
|
211 | * @author Alexander Wolf
|
213 | * @category Core
|
212 | * @category Core
|
214 | *
|
213 | *
|
215 | * @param string $name
|
214 | * @param string $name
|
216 | * @param integer $distID
|
215 | * @param integer $distID
|
217 | * @param string $format
|
216 | * @param string $format
|
218 | * @return string
|
217 | * @return string
|
219 | */
|
218 | */
|
220 | public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') { |
219 | public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') { |
221 | $distname = $this->getDistName($distID); |
220 | $distname = $this->getDistName($distID); |
222 | if ($distID == 0) { |
221 | 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"; |
222 | $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 { |
223 | } else { |
225 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
224 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
226 | }
|
225 | }
|
227 | $rq =& $this->db->query($query); |
226 | $rq =& $this->db->query($query); |
228 | switch ($format) { |
227 | switch ($format) { |
229 | case 'html': |
228 | case 'html': |
230 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
229 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
231 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
230 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
232 | while ($rq->fetchInto($element)) { |
231 | 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"; |
232 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
234 | }
|
233 | }
|
235 | $show .= "</select></fieldset>"; |
234 | $show .= "</select></fieldset>"; |
236 | break; |
235 | break; |
237 | case 'json': |
236 | case 'json': |
238 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
237 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
239 | while ($rq->fetchInto($element)) { |
238 | 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).'"}'; |
239 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
241 | }
|
240 | }
|
242 | $show .= ']'; |
241 | $show .= ']'; |
243 | break; |
242 | break; |
244 | case 'list': |
243 | case 'list': |
245 | $show = "<ul>\n"; |
244 | $show = "<ul>\n"; |
246 | while ($rq->fetchInto($element)) { |
245 | 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"; |
246 | $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 | }
|
247 | }
|
249 | $show .= "</ul>"; |
248 | $show .= "</ul>"; |
250 | break; |
249 | break; |
251 | }
|
250 | }
|
252 | return $show; |
251 | return $show; |
253 | }
|
252 | }
|
254 | 253 | ||
255 | /**
|
254 | /**
|
256 | * Получение и отображение списка секций основного (официального) репозитория
|
255 | * Получение и отображение списка секций основного (официального) репозитория
|
257 | *
|
256 | *
|
258 | * @author Alexander Wolf
|
257 | * @author Alexander Wolf
|
259 | * @category Core
|
258 | * @category Core
|
260 | *
|
259 | *
|
261 | * @param integer $version
|
260 | * @param integer $version
|
262 | * @param string $format
|
261 | * @param string $format
|
263 | * @return string
|
262 | * @return string
|
264 | */
|
263 | */
|
265 | public function showBranchesList($version, $format = 'html') { |
264 | public function showBranchesList($version, $format = 'html') { |
266 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
265 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
267 | $rq =& $this->db->query($query); |
266 | $rq =& $this->db->query($query); |
268 | $rq->fetchInto($types); |
267 | $rq->fetchInto($types); |
269 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
268 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
270 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
269 | $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 "; |
270 | $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 "; |
271 | $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)."'"; |
272 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
274 | $rq =& $this->db->query($query); |
273 | $rq =& $this->db->query($query); |
275 | switch ($format) { |
274 | switch ($format) { |
276 | case 'html': |
275 | case 'html': |
277 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
276 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
278 | while ($rq->fetchInto($element)) { |
277 | 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"; |
278 | $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 | }
|
279 | }
|
281 | $show .= "</fieldset>\n"; |
280 | $show .= "</fieldset>\n"; |
282 | break; |
281 | break; |
283 | case 'json': |
282 | case 'json': |
284 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
283 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
285 | break; |
284 | break; |
286 | }
|
285 | }
|
287 | 286 | ||
288 | return $show; |
287 | return $show; |
289 | }
|
288 | }
|
290 | 289 | ||
291 | /**
|
290 | /**
|
292 | * Получение и отображение списка репозиториев
|
291 | * Получение и отображение списка репозиториев
|
293 | *
|
292 | *
|
294 | * @author Alexander Wolf
|
293 | * @author Alexander Wolf
|
295 | * @category Core
|
294 | * @category Core
|
296 | *
|
295 | *
|
297 | * @param integer $version
|
296 | * @param integer $version
|
298 | * @param integer $reptype
|
297 | * @param integer $reptype
|
299 | * @param string $format
|
298 | * @param string $format
|
300 | * @return string
|
299 | * @return string
|
301 | */
|
300 | */
|
302 | public function showRepList($version, $reptype, $format = 'html') { |
301 | public function showRepList($version, $reptype, $format = 'html') { |
303 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
302 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
304 | $rq =& $this->db->query($query); |
303 | $rq =& $this->db->query($query); |
305 | $rq->fetchInto($types); |
304 | $rq->fetchInto($types); |
306 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
305 | $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); |
306 | $rq =& $this->db->query($query); |
308 | switch ($format) { |
307 | switch ($format) { |
309 | case 'html': |
308 | case 'html': |
310 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
309 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
311 | while ($rq->fetchInto($types)) { |
310 | 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"; |
311 | $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 | }
|
312 | }
|
314 | $show .= "</fieldset>\n"; |
313 | $show .= "</fieldset>\n"; |
315 | break; |
314 | break; |
316 | case 'json': |
315 | case 'json': |
317 | //TODO Доделать JSON-вывод списка репозиториев
|
316 | //TODO Доделать JSON-вывод списка репозиториев
|
318 | break; |
317 | break; |
319 | }
|
318 | }
|
320 | 319 | ||
321 | return $show; |
320 | return $show; |
322 | }
|
321 | }
|
323 | 322 | ||
324 | /**
|
323 | /**
|
325 | * Добавление поддержки нового apt-дистрибутива
|
324 | * Добавление поддержки нового apt-дистрибутива
|
326 | *
|
325 | *
|
327 | * @author Alexander Wolf
|
326 | * @author Alexander Wolf
|
328 | * @category Core
|
327 | * @category Core
|
329 | *
|
328 | *
|
330 | * @param string $distname
|
329 | * @param string $distname
|
331 | * @param integer $disttype
|
330 | * @param integer $disttype
|
332 | * @param string $distua
|
331 | * @param string $distua
|
333 | * @param byte $distlogo
|
332 | * @param byte $distlogo
|
334 | * @return array
|
333 | * @return array
|
335 | */
|
334 | */
|
336 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
335 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
337 | $result = array(); |
336 | $result = array(); |
338 | $sDName = $this->secure->checkStr($distname,1); |
337 | $sDName = $this->secure->checkStr($distname,1); |
339 | $sDType = $this->secure->checkInt($disttype); |
338 | $sDType = $this->secure->checkInt($disttype); |
340 | $sDUAgt = $this->secure->checkStr($distua,1); |
339 | $sDUAgt = $this->secure->checkStr($distua,1); |
341 | $sDLogo = $this->secure->checkInt($distlogo); |
340 | $sDLogo = $this->secure->checkInt($distlogo); |
342 | 341 | ||
343 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
342 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
344 | $rq =& $this->db->query($query); |
343 | $rq =& $this->db->query($query); |
345 | if (PEAR::isError($this->db)) { |
344 | if (PEAR::isError($this->db)) { |
346 | $result["ERR"] = 1; |
345 | $result["ERR"] = 1; |
347 | $result["ERRINFO"] = $this->db->getMessage(); |
346 | $result["ERRINFO"] = $this->db->getMessage(); |
348 | } else { |
347 | } else { |
349 | $result["ERR"] = 0; |
348 | $result["ERR"] = 0; |
350 | }
|
349 | }
|
351 | 350 | ||
352 | return $result; |
351 | return $result; |
353 | }
|
352 | }
|
354 | 353 | ||
355 | /**
|
354 | /**
|
356 | * Обновление информации о дистрибутиве
|
355 | * Обновление информации о дистрибутиве
|
357 | *
|
356 | *
|
358 | * @author Alexander Wolf
|
357 | * @author Alexander Wolf
|
359 | * @category Core
|
358 | * @category Core
|
360 | *
|
359 | *
|
361 | * @param integer $distID
|
360 | * @param integer $distID
|
362 | * @param string $distname
|
361 | * @param string $distname
|
363 | * @param integer $disttype
|
362 | * @param integer $disttype
|
364 | * @param string $distua
|
363 | * @param string $distua
|
365 | * @param integer $distlogo
|
364 | * @param integer $distlogo
|
366 | * @return array
|
365 | * @return array
|
367 | */
|
366 | */
|
368 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
367 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
369 | $result = array(); |
368 | $result = array(); |
370 | $sDID = $this->secure->checkInt($distID); |
369 | $sDID = $this->secure->checkInt($distID); |
371 | $sDName = $this->secure->checkStr($distname,1); |
370 | $sDName = $this->secure->checkStr($distname,1); |
372 | $sDType = $this->secure->checkInt($disttype); |
371 | $sDType = $this->secure->checkInt($disttype); |
373 | $sDUAgt = $this->secure->checkStr($distua,1); |
372 | $sDUAgt = $this->secure->checkStr($distua,1); |
374 | $sDLogo = $this->secure->checkInt($distlogo); |
373 | $sDLogo = $this->secure->checkInt($distlogo); |
375 | 374 | ||
376 | if ($sDLogo!=0) { |
375 | if ($sDLogo!=0) { |
377 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
376 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
378 | } else { |
377 | } else { |
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
378 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
380 | }
|
379 | }
|
381 | $rq =& $this->db->query($query); |
380 | $rq =& $this->db->query($query); |
382 | if (PEAR::isError($this->db)) { |
381 | if (PEAR::isError($this->db)) { |
383 | $result["ERR"] = 1; |
382 | $result["ERR"] = 1; |
384 | $result["ERRINFO"] = $this->db->getMessage(); |
383 | $result["ERRINFO"] = $this->db->getMessage(); |
385 | } else { |
384 | } else { |
386 | $result["ERR"] = 0; |
385 | $result["ERR"] = 0; |
387 | }
|
386 | }
|
388 | 387 | ||
389 | return $result; |
388 | return $result; |
390 | }
|
389 | }
|
391 | 390 | ||
392 | /**
|
391 | /**
|
393 | * Удаление информации о дистрибутиве
|
392 | * Удаление информации о дистрибутиве
|
394 | *
|
393 | *
|
395 | * @author Alexander Wolf
|
394 | * @author Alexander Wolf
|
396 | * @category Core
|
395 | * @category Core
|
397 | *
|
396 | *
|
398 | * @param integer $distID
|
397 | * @param integer $distID
|
399 | * @return array
|
398 | * @return array
|
400 | */
|
399 | */
|
401 | public function dropDistribution($distID) { |
400 | public function dropDistribution($distID) { |
402 | $result = array(); |
401 | $result = array(); |
403 | $sDID = $this->secure->checkInt($distID); |
402 | $sDID = $this->secure->checkInt($distID); |
404 | 403 | ||
405 | // Удаление дистрибутива
|
404 | // Удаление дистрибутива
|
406 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
405 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
407 | $rq =& $this->db->query($query); |
406 | $rq =& $this->db->query($query); |
408 | if (PEAR::isError($this->db)) { |
407 | if (PEAR::isError($this->db)) { |
409 | $result["ERR"] = 1; |
408 | $result["ERR"] = 1; |
410 | $result["ERRINFO"] = $this->db->getMessage(); |
409 | $result["ERRINFO"] = $this->db->getMessage(); |
411 | } else { |
410 | } else { |
412 | $result["ERR"] = 0; |
411 | $result["ERR"] = 0; |
413 | }
|
412 | }
|
414 | 413 | ||
415 | // Удаление версий дистрибутива
|
414 | // Удаление версий дистрибутива
|
416 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
415 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
417 | $rq =& $this->db->query($query); |
416 | $rq =& $this->db->query($query); |
418 | if (PEAR::isError($this->db)) { |
417 | if (PEAR::isError($this->db)) { |
419 | $result["ERR"] = 1; |
418 | $result["ERR"] = 1; |
420 | $result["ERRINFO"] = $this->db->getMessage(); |
419 | $result["ERRINFO"] = $this->db->getMessage(); |
421 | } else { |
420 | } else { |
422 | $result["ERR"] = 0; |
421 | $result["ERR"] = 0; |
423 | }
|
422 | }
|
424 | 423 | ||
425 | return $result; |
424 | return $result; |
426 | }
|
425 | }
|
427 | 426 | ||
428 | /**
|
427 | /**
|
429 | * Добавление поддержки новой версии apt-дистрибутива
|
428 | * Добавление поддержки новой версии apt-дистрибутива
|
430 | *
|
429 | *
|
431 | * @author Alexander Wolf
|
430 | * @author Alexander Wolf
|
432 | * @category Core
|
431 | * @category Core
|
433 | *
|
432 | *
|
434 | * @param integer $distID
|
433 | * @param integer $distID
|
435 | * @param integer $version
|
434 | * @param integer $version
|
436 | * @param string $vname
|
435 | * @param string $vname
|
437 | * @param integer $vcodename
|
436 | * @param integer $vcodename
|
438 | * @return array
|
437 | * @return array
|
439 | */
|
438 | */
|
440 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
439 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
441 | $result = array(); |
440 | $result = array(); |
442 | $sDistID = $this->secure->checkInt($distID); |
441 | $sDistID = $this->secure->checkInt($distID); |
443 | $sDVersion = $this->secure->checkStr($version,1); |
442 | $sDVersion = $this->secure->checkStr($version,1); |
444 | $sDVName = $this->secure->checkStr($vname,1); |
443 | $sDVName = $this->secure->checkStr($vname,1); |
445 | $sDVCName = $this->secure->checkStr($vcodename,1); |
444 | $sDVCName = $this->secure->checkStr($vcodename,1); |
446 | 445 | ||
447 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
446 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
448 | $rq =& $this->db->query($query); |
447 | $rq =& $this->db->query($query); |
449 | if (PEAR::isError($this->db)) { |
448 | if (PEAR::isError($this->db)) { |
450 | $result["ERR"] = 1; |
449 | $result["ERR"] = 1; |
451 | $result["ERRINFO"] = $this->db->getMessage(); |
450 | $result["ERRINFO"] = $this->db->getMessage(); |
452 | } else { |
451 | } else { |
453 | $result["ERR"] = 0; |
452 | $result["ERR"] = 0; |
454 | }
|
453 | }
|
455 | 454 | ||
456 | return $result; |
455 | return $result; |
457 | }
|
456 | }
|
458 | 457 | ||
459 | /**
|
458 | /**
|
460 | * Редактирование информации о версии дистрибутива
|
459 | * Редактирование информации о версии дистрибутива
|
461 | *
|
460 | *
|
462 | * @author Alexander Wolf
|
461 | * @author Alexander Wolf
|
463 | * @category Core
|
462 | * @category Core
|
464 | *
|
463 | *
|
465 | * @param integer $versionID
|
464 | * @param integer $versionID
|
466 | * @param string $version
|
465 | * @param string $version
|
467 | * @param string $vname
|
466 | * @param string $vname
|
468 | * @param string $vcodename
|
467 | * @param string $vcodename
|
469 | * @return array
|
468 | * @return array
|
470 | */
|
469 | */
|
471 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
470 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
472 | $result = array(); |
471 | $result = array(); |
473 | $sVersID = $this->secure->checkInt($versionID); |
472 | $sVersID = $this->secure->checkInt($versionID); |
474 | $sDVersion = $this->secure->checkStr($version,1); |
473 | $sDVersion = $this->secure->checkStr($version,1); |
475 | $sDVName = $this->secure->checkStr($vname,1); |
474 | $sDVName = $this->secure->checkStr($vname,1); |
476 | $sDVCName = $this->secure->checkStr($vcodename,1); |
475 | $sDVCName = $this->secure->checkStr($vcodename,1); |
477 | 476 | ||
478 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
477 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
479 | $rq =& $this->db->query($query); |
478 | $rq =& $this->db->query($query); |
480 | if (PEAR::isError($this->db)) { |
479 | if (PEAR::isError($this->db)) { |
481 | $result["ERR"] = 1; |
480 | $result["ERR"] = 1; |
482 | $result["ERRINFO"] = $this->db->getMessage(); |
481 | $result["ERRINFO"] = $this->db->getMessage(); |
483 | } else { |
482 | } else { |
484 | $result["ERR"] = 0; |
483 | $result["ERR"] = 0; |
485 | }
|
484 | }
|
486 | 485 | ||
487 | return $result; |
486 | return $result; |
488 | }
|
487 | }
|
489 | 488 | ||
490 | /**
|
489 | /**
|
491 | * Удаление информации о версии дистрибутива
|
490 | * Удаление информации о версии дистрибутива
|
492 | *
|
491 | *
|
493 | * @author Alexander Wolf
|
492 | * @author Alexander Wolf
|
494 | * @category Core
|
493 | * @category Core
|
495 | *
|
494 | *
|
496 | * @param integer $versionID
|
495 | * @param integer $versionID
|
497 | * @return array
|
496 | * @return array
|
498 | */
|
497 | */
|
499 | public function dropDistVersion($versionID) { |
498 | public function dropDistVersion($versionID) { |
500 | $result = array(); |
499 | $result = array(); |
501 | $sVersID = $this->secure->checkInt($versionID); |
500 | $sVersID = $this->secure->checkInt($versionID); |
502 | 501 | ||
503 | // Удаление версии дистрибутива
|
502 | // Удаление версии дистрибутива
|
504 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
503 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
505 | $rq =& $this->db->query($query); |
504 | $rq =& $this->db->query($query); |
506 | if (PEAR::isError($this->db)) { |
505 | if (PEAR::isError($this->db)) { |
507 | $result["ERR"] = 1; |
506 | $result["ERR"] = 1; |
508 | $result["ERRINFO"] = $this->db->getMessage(); |
507 | $result["ERRINFO"] = $this->db->getMessage(); |
509 | } else { |
508 | } else { |
510 | $result["ERR"] = 0; |
509 | $result["ERR"] = 0; |
511 | }
|
510 | }
|
512 | 511 | ||
513 | // Удаление репозиториев этой версии дистрибутива
|
512 | // Удаление репозиториев этой версии дистрибутива
|
514 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
513 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
515 | $rq =& $this->db->query($query); |
514 | $rq =& $this->db->query($query); |
516 | if (PEAR::isError($this->db)) { |
515 | if (PEAR::isError($this->db)) { |
517 | $result["ERR"] = 1; |
516 | $result["ERR"] = 1; |
518 | $result["ERRINFO"] = $this->db->getMessage(); |
517 | $result["ERRINFO"] = $this->db->getMessage(); |
519 | } else { |
518 | } else { |
520 | $result["ERR"] = 0; |
519 | $result["ERR"] = 0; |
521 | }
|
520 | }
|
522 | 521 | ||
523 | return $result; |
522 | return $result; |
524 | }
|
523 | }
|
525 | 524 | ||
526 | /**
|
525 | /**
|
527 | * Отображение типа дистрибутива
|
526 | * Отображение типа дистрибутива
|
528 | *
|
527 | *
|
529 | * @author Alexander Wolf
|
528 | * @author Alexander Wolf
|
530 | * @category Core
|
529 | * @category Core
|
531 | *
|
530 | *
|
532 | * @param string $name
|
531 | * @param string $name
|
533 | * @param byte $type
|
532 | * @param byte $type
|
534 | * @return string
|
533 | * @return string
|
535 | */
|
534 | */
|
536 | public function showDistTypeForm($name = "dtype",$type = 0) { |
535 | public function showDistTypeForm($name = "dtype",$type = 0) { |
537 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
536 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
538 | $rq =& $this->db->query($query); |
537 | $rq =& $this->db->query($query); |
539 | $show = "<select name='".$name."' id='".$name."'>\n"; |
538 | $show = "<select name='".$name."' id='".$name."'>\n"; |
540 | while ($rq->fetchInto($element)) { |
539 | while ($rq->fetchInto($element)) { |
541 | if ($element["type_id"] == $type) { |
540 | if ($element["type_id"] == $type) { |
542 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
541 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
543 | } else { |
542 | } else { |
544 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
543 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
545 | }
|
544 | }
|
546 | }
|
545 | }
|
547 | $show .= "</select>"; |
546 | $show .= "</select>"; |
548 | 547 | ||
549 | return $show; |
548 | return $show; |
550 | }
|
549 | }
|
551 | 550 | ||
552 | /**
|
551 | /**
|
553 | * Отображение формы создания и редактирования apt-дистрибутива
|
552 | * Отображение формы создания и редактирования apt-дистрибутива
|
554 | *
|
553 | *
|
555 | * @author Alexander Wolf
|
554 | * @author Alexander Wolf
|
556 | * @category Core
|
555 | * @category Core
|
557 | *
|
556 | *
|
558 | * @param integer $distID
|
557 | * @param integer $distID
|
559 | * @return string
|
558 | * @return string
|
560 | */
|
559 | */
|
561 | public function showDistributionForm($distID = 0, $info = '') { |
560 | public function showDistributionForm($distID = 0, $info = '') { |
562 | $sDistID = $this->secure->checkInt($distID); |
561 | $sDistID = $this->secure->checkInt($distID); |
563 | $sInfo = $this->secure->checkStr($info, 1); |
562 | $sInfo = $this->secure->checkStr($info, 1); |
564 | if ($sInfo == "") { |
563 | if ($sInfo == "") { |
565 | $sInfo = "Дистрибутив"; |
564 | $sInfo = "Дистрибутив"; |
566 | }
|
565 | }
|
567 | if ($sDistID != 0) { |
566 | if ($sDistID != 0) { |
568 | // Режим редактирования
|
567 | // Режим редактирования
|
569 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
568 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
570 | $rq =& $this->db->query($query); |
569 | $rq =& $this->db->query($query); |
571 | $rq->fetchInto($element); |
570 | $rq->fetchInto($element); |
572 | }
|
571 | }
|
573 | 572 | ||
574 | if ($element["distlogo"] == 1) { |
573 | 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)."'>"; |
574 | $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 { |
575 | } else { |
577 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
576 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
578 | }
|
577 | }
|
579 | 578 | ||
580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
579 | $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"; |
580 | $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"; |
581 | $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"; |
582 | $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"; |
583 | $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"; |
584 | $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"; |
585 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
587 | 586 | ||
588 | return $show; |
587 | return $show; |
589 | }
|
588 | }
|
590 | 589 | ||
591 | // sourses.list
|
590 | // sourses.list
|
592 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
591 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
593 | //TODO Написать генератор sources.list
|
592 | //TODO Написать генератор sources.list
|
594 | }
|
593 | }
|
595 | 594 | ||
596 | /**
|
595 | /**
|
597 | * Показывает список секций
|
596 | * Показывает список секций
|
598 | *
|
597 | *
|
599 | * @author Alexander Wolf
|
598 | * @author Alexander Wolf
|
600 | * @category Core
|
599 | * @category Core
|
601 | *
|
600 | *
|
602 | * @param string $name
|
601 | * @param string $name
|
603 | * @param string $actor
|
602 | * @param string $actor
|
604 | * @return string
|
603 | * @return string
|
605 | */
|
604 | */
|
606 | public function showSectionsList($name, $actor) { |
605 | public function showSectionsList($name, $actor) { |
607 | $query = "SELECT * FROM ".$this->prefix."section"; |
606 | $query = "SELECT * FROM ".$this->prefix."section"; |
608 | $rq =& $this->db->query($query); |
607 | $rq =& $this->db->query($query); |
609 | $show = "<ul>\n"; |
608 | $show = "<ul>\n"; |
610 | while ($rq->fetchInto($element)) { |
609 | 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"; |
610 | $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 | }
|
611 | }
|
613 | $show .= "</ul>"; |
612 | $show .= "</ul>"; |
614 | 613 | ||
615 | return $show; |
614 | return $show; |
616 | }
|
615 | }
|
617 | 616 | ||
618 | /**
|
617 | /**
|
619 | * Вывод формы редактирования/добавления секций
|
618 | * Вывод формы редактирования/добавления секций
|
620 | *
|
619 | *
|
621 | * @author Alexander Wolf
|
620 | * @author Alexander Wolf
|
622 | * @category Core
|
621 | * @category Core
|
623 | *
|
622 | *
|
624 | * @param integer $sectionID
|
623 | * @param integer $sectionID
|
625 | * @param string $info
|
624 | * @param string $info
|
626 | * @return string
|
625 | * @return string
|
627 | */
|
626 | */
|
628 | public function showSectionsForm($sectionID = 0, $info = "") { |
627 | public function showSectionsForm($sectionID = 0, $info = "") { |
629 | $sSectID = $this->secure->checkInt($sectionID); |
628 | $sSectID = $this->secure->checkInt($sectionID); |
630 | $sInfo = $this->secure->checkStr($info, 1); |
629 | $sInfo = $this->secure->checkStr($info, 1); |
631 | if ($sInfo == "") { |
630 | if ($sInfo == "") { |
632 | $sInfo = "Секция"; |
631 | $sInfo = "Секция"; |
633 | }
|
632 | }
|
634 | if ($sSectID != 0) { |
633 | if ($sSectID != 0) { |
635 | // Режим редактирования
|
634 | // Режим редактирования
|
636 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
635 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
637 | $rq =& $this->db->query($query); |
636 | $rq =& $this->db->query($query); |
638 | $rq->fetchInto($element); |
637 | $rq->fetchInto($element); |
639 | }
|
638 | }
|
640 | 639 | ||
641 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
640 | $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"; |
641 | $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"; |
642 | $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"; |
643 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
645 | 644 | ||
646 | return $show; |
645 | return $show; |
647 | }
|
646 | }
|
648 | 647 | ||
649 | /**
|
648 | /**
|
650 | * Обновление информации о секции
|
649 | * Обновление информации о секции
|
651 | *
|
650 | *
|
652 | * @author Alexander Wolf
|
651 | * @author Alexander Wolf
|
653 | * @category Core
|
652 | * @category Core
|
654 | *
|
653 | *
|
655 | * @param integer $sectionID
|
654 | * @param integer $sectionID
|
656 | * @param string $sname
|
655 | * @param string $sname
|
657 | * @param string $sinfo
|
656 | * @param string $sinfo
|
658 | * @return array
|
657 | * @return array
|
659 | */
|
658 | */
|
660 | public function updateSection($sectionID, $sname, $sinfo = "") { |
659 | public function updateSection($sectionID, $sname, $sinfo = "") { |
661 | $result = array(); |
660 | $result = array(); |
662 | $sSectID = $this->secure->checkInt($sectionID); |
661 | $sSectID = $this->secure->checkInt($sectionID); |
663 | $sSName = $this->secure->checkStr($sname,1); |
662 | $sSName = $this->secure->checkStr($sname,1); |
664 | $sSInfo = $this->secure->checkStr($sinfo,1); |
663 | $sSInfo = $this->secure->checkStr($sinfo,1); |
665 | 664 | ||
666 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
665 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
667 | $rq =& $this->db->query($query); |
666 | $rq =& $this->db->query($query); |
668 | if (PEAR::isError($this->db)) { |
667 | if (PEAR::isError($this->db)) { |
669 | $result["ERR"] = 1; |
668 | $result["ERR"] = 1; |
670 | $result["ERRINFO"] = $this->db->getMessage(); |
669 | $result["ERRINFO"] = $this->db->getMessage(); |
671 | } else { |
670 | } else { |
672 | $result["ERR"] = 0; |
671 | $result["ERR"] = 0; |
673 | }
|
672 | }
|
674 | 673 | ||
675 | return $result; |
674 | return $result; |
676 | }
|
675 | }
|
677 | 676 | ||
678 | /**
|
677 | /**
|
679 | * Удаление информации о секции
|
678 | * Удаление информации о секции
|
680 | *
|
679 | *
|
681 | * @author Alexander Wolf
|
680 | * @author Alexander Wolf
|
682 | * @category Core
|
681 | * @category Core
|
683 | *
|
682 | *
|
684 | * @param integer $sectionID
|
683 | * @param integer $sectionID
|
685 | * @return array
|
684 | * @return array
|
686 | */
|
685 | */
|
687 | public function dropSection($sectionID) { |
686 | public function dropSection($sectionID) { |
688 | $result = array(); |
687 | $result = array(); |
689 | $sSectID = $this->secure->checkInt($sectionID); |
688 | $sSectID = $this->secure->checkInt($sectionID); |
690 | 689 | ||
691 | // Удаление секции
|
690 | // Удаление секции
|
692 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
691 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
693 | $rq =& $this->db->query($query); |
692 | $rq =& $this->db->query($query); |
694 | if (PEAR::isError($this->db)) { |
693 | if (PEAR::isError($this->db)) { |
695 | $result["ERR"] = 1; |
694 | $result["ERR"] = 1; |
696 | $result["ERRINFO"] = $this->db->getMessage(); |
695 | $result["ERRINFO"] = $this->db->getMessage(); |
697 | } else { |
696 | } else { |
698 | $result["ERR"] = 0; |
697 | $result["ERR"] = 0; |
699 | }
|
698 | }
|
700 | 699 | ||
701 | return $result; |
700 | return $result; |
702 | }
|
701 | }
|
703 | 702 | ||
704 | /**
|
703 | /**
|
705 | * Добавление новой секции
|
704 | * Добавление новой секции
|
706 | *
|
705 | *
|
707 | * @author Alexander Wolf
|
706 | * @author Alexander Wolf
|
708 | * @category Core
|
707 | * @category Core
|
709 | *
|
708 | *
|
710 | * @param string $sname
|
709 | * @param string $sname
|
711 | * @param string $sinfo
|
710 | * @param string $sinfo
|
712 | * @return array
|
711 | * @return array
|
713 | */
|
712 | */
|
714 | public function addSection($sname, $sinfo = "") { |
713 | public function addSection($sname, $sinfo = "") { |
715 | $result = array(); |
714 | $result = array(); |
716 | $sSName = $this->secure->checkStr($sname,1); |
715 | $sSName = $this->secure->checkStr($sname,1); |
717 | $sSInfo = $this->secure->checkStr($sinfo,1); |
716 | $sSInfo = $this->secure->checkStr($sinfo,1); |
718 | 717 | ||
719 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
718 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
720 | $rq =& $this->db->query($query); |
719 | $rq =& $this->db->query($query); |
721 | if (PEAR::isError($this->db)) { |
720 | if (PEAR::isError($this->db)) { |
722 | $result["ERR"] = 1; |
721 | $result["ERR"] = 1; |
723 | $result["ERRINFO"] = $this->db->getMessage(); |
722 | $result["ERRINFO"] = $this->db->getMessage(); |
724 | } else { |
723 | } else { |
725 | $result["ERR"] = 0; |
724 | $result["ERR"] = 0; |
726 | }
|
725 | }
|
727 | 726 | ||
728 | return $result; |
727 | return $result; |
729 | }
|
728 | }
|
730 | 729 | ||
731 | /**
|
730 | /**
|
732 | * Показывает список подписей
|
731 | * Показывает список подписей
|
733 | *
|
732 | *
|
734 | * @author Alexander Wolf
|
733 | * @author Alexander Wolf
|
735 | * @category Core
|
734 | * @category Core
|
736 | *
|
735 | *
|
737 | * @param string $name
|
736 | * @param string $name
|
738 | * @param string $actor
|
737 | * @param string $actor
|
739 | * @return string
|
738 | * @return string
|
740 | */
|
739 | */
|
741 | public function showSignsList($name, $actor) { |
740 | public function showSignsList($name, $actor) { |
742 | $query = "SELECT * FROM ".$this->prefix."signs"; |
741 | $query = "SELECT * FROM ".$this->prefix."signs"; |
743 | $rq =& $this->db->query($query); |
742 | $rq =& $this->db->query($query); |
744 | $show = "<ul>\n"; |
743 | $show = "<ul>\n"; |
745 | while ($rq->fetchInto($element)) { |
744 | 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"; |
745 | $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 | }
|
746 | }
|
748 | $show .= "</ul>"; |
747 | $show .= "</ul>"; |
749 | 748 | ||
750 | return $show; |
749 | return $show; |
751 | }
|
750 | }
|
752 | 751 | ||
753 | /**
|
752 | /**
|
754 | * Вывод формы редактирования/добавления подписей
|
753 | * Вывод формы редактирования/добавления подписей
|
755 | *
|
754 | *
|
756 | * @author Alexander Wolf
|
755 | * @author Alexander Wolf
|
757 | * @category Core
|
756 | * @category Core
|
758 | *
|
757 | *
|
759 | * @param integer $sectionID
|
758 | * @param integer $sectionID
|
760 | * @param string $info
|
759 | * @param string $info
|
761 | * @return string
|
760 | * @return string
|
762 | */
|
761 | */
|
763 | public function showSignsForm($signID = 0, $info = "") { |
762 | public function showSignsForm($signID = 0, $info = "") { |
764 | $sSignID = $this->secure->checkInt($signID); |
763 | $sSignID = $this->secure->checkInt($signID); |
765 | $sInfo = $this->secure->checkStr($info, 1); |
764 | $sInfo = $this->secure->checkStr($info, 1); |
766 | if ($sInfo == "") { |
765 | if ($sInfo == "") { |
767 | $sInfo = "Подписи"; |
766 | $sInfo = "Подписи"; |
768 | }
|
767 | }
|
769 | if ($sSignID != 0) { |
768 | if ($sSignID != 0) { |
770 | // Режим редактирования
|
769 | // Режим редактирования
|
771 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
770 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
772 | $rq =& $this->db->query($query); |
771 | $rq =& $this->db->query($query); |
773 | $rq->fetchInto($element); |
772 | $rq->fetchInto($element); |
774 | }
|
773 | }
|
775 | 774 | ||
776 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
775 | $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"; |
776 | $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"; |
777 | $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"; |
778 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
780 | 779 | ||
781 | return $show; |
780 | return $show; |
782 | }
|
781 | }
|
783 | 782 | ||
784 | /**
|
783 | /**
|
785 | * Обновление информации о секции
|
784 | * Обновление информации о секции
|
786 | *
|
785 | *
|
787 | * @author Alexander Wolf
|
786 | * @author Alexander Wolf
|
788 | * @category Core
|
787 | * @category Core
|
789 | *
|
788 | *
|
790 | * @param integer $sectionID
|
789 | * @param integer $sectionID
|
791 | * @param string $sname
|
790 | * @param string $sname
|
792 | * @param string $sinfo
|
791 | * @param string $sinfo
|
793 | * @return array
|
792 | * @return array
|
794 | */
|
793 | */
|
795 | public function updateSign($signID, $sname, $sinfo = "") { |
794 | public function updateSign($signID, $sname, $sinfo = "") { |
796 | $result = array(); |
795 | $result = array(); |
797 | $sSignID = $this->secure->checkInt($signID); |
796 | $sSignID = $this->secure->checkInt($signID); |
798 | $sSName = $this->secure->checkStr($sname,1); |
797 | $sSName = $this->secure->checkStr($sname,1); |
799 | $sSInfo = $this->secure->checkStr($sinfo,1); |
798 | $sSInfo = $this->secure->checkStr($sinfo,1); |
800 | 799 | ||
801 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
800 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
802 | $rq =& $this->db->query($query); |
801 | $rq =& $this->db->query($query); |
803 | if (PEAR::isError($this->db)) { |
802 | if (PEAR::isError($this->db)) { |
804 | $result["ERR"] = 1; |
803 | $result["ERR"] = 1; |
805 | $result["ERRINFO"] = $this->db->getMessage(); |
804 | $result["ERRINFO"] = $this->db->getMessage(); |
806 | } else { |
805 | } else { |
807 | $result["ERR"] = 0; |
806 | $result["ERR"] = 0; |
808 | }
|
807 | }
|
809 | 808 | ||
810 | return $result; |
809 | return $result; |
811 | }
|
810 | }
|
812 | 811 | ||
813 | /**
|
812 | /**
|
814 | * Удаление информации о подписи
|
813 | * Удаление информации о подписи
|
815 | *
|
814 | *
|
816 | * @author Alexander Wolf
|
815 | * @author Alexander Wolf
|
817 | * @category Core
|
816 | * @category Core
|
818 | *
|
817 | *
|
819 | * @param integer $sectionID
|
818 | * @param integer $sectionID
|
820 | * @return array
|
819 | * @return array
|
821 | */
|
820 | */
|
822 | public function dropSign($signID) { |
821 | public function dropSign($signID) { |
823 | $result = array(); |
822 | $result = array(); |
824 | $sSignID = $this->secure->checkInt($signID); |
823 | $sSignID = $this->secure->checkInt($signID); |
825 | 824 | ||
826 | // Удаление подписи
|
825 | // Удаление подписи
|
827 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
826 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
828 | $rq =& $this->db->query($query); |
827 | $rq =& $this->db->query($query); |
829 | if (PEAR::isError($this->db)) { |
828 | if (PEAR::isError($this->db)) { |
830 | $result["ERR"] = 1; |
829 | $result["ERR"] = 1; |
831 | $result["ERRINFO"] = $this->db->getMessage(); |
830 | $result["ERRINFO"] = $this->db->getMessage(); |
832 | } else { |
831 | } else { |
833 | $result["ERR"] = 0; |
832 | $result["ERR"] = 0; |
834 | }
|
833 | }
|
835 | 834 | ||
836 | return $result; |
835 | return $result; |
837 | }
|
836 | }
|
838 | 837 | ||
839 | /**
|
838 | /**
|
840 | * Добавление новой подписи
|
839 | * Добавление новой подписи
|
841 | *
|
840 | *
|
842 | * @author Alexander Wolf
|
841 | * @author Alexander Wolf
|
843 | * @category Core
|
842 | * @category Core
|
844 | *
|
843 | *
|
845 | * @param string $sname
|
844 | * @param string $sname
|
846 | * @param string $sinfo
|
845 | * @param string $sinfo
|
847 | * @return array
|
846 | * @return array
|
848 | */
|
847 | */
|
849 | public function addSign($sname, $sinfo = "") { |
848 | public function addSign($sname, $sinfo = "") { |
850 | $result = array(); |
849 | $result = array(); |
851 | $sSName = $this->secure->checkStr($sname,1); |
850 | $sSName = $this->secure->checkStr($sname,1); |
852 | $sSInfo = $this->secure->checkStr($sinfo,1); |
851 | $sSInfo = $this->secure->checkStr($sinfo,1); |
853 | 852 | ||
854 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
853 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
855 | $rq =& $this->db->query($query); |
854 | $rq =& $this->db->query($query); |
856 | if (PEAR::isError($this->db)) { |
855 | if (PEAR::isError($this->db)) { |
857 | $result["ERR"] = 1; |
856 | $result["ERR"] = 1; |
858 | $result["ERRINFO"] = $this->db->getMessage(); |
857 | $result["ERRINFO"] = $this->db->getMessage(); |
859 | } else { |
858 | } else { |
860 | $result["ERR"] = 0; |
859 | $result["ERR"] = 0; |
861 | }
|
860 | }
|
862 | 861 | ||
863 | return $result; |
862 | return $result; |
864 | }
|
863 | }
|
865 | 864 | ||
866 | /**
|
865 | /**
|
867 | * Проверка пароля (из формы авторизации)
|
866 | * Проверка пароля (из формы авторизации)
|
868 | *
|
867 | *
|
869 | * @author Alexander Wolf
|
868 | * @author Alexander Wolf
|
870 | * @category Core
|
869 | * @category Core
|
871 | *
|
870 | *
|
872 | * @param string $word
|
871 | * @param string $word
|
873 | * @return array
|
872 | * @return array
|
874 | */
|
873 | */
|
875 | public function checkSign($word) { |
874 | public function checkSign($word) { |
876 | $result = array(); |
875 | $result = array(); |
877 | 876 | ||
878 | $sHash = $this->secure->encryptStr($word); |
877 | $sHash = $this->secure->encryptStr($word); |
879 | $pwd = $this->getOption("passwd"); |
878 | $pwd = $this->getOption("passwd"); |
880 | if ($sHash == $pwd["OptValue"]) { |
879 | if ($sHash == $pwd["OptValue"]) { |
881 | $result["ERR"] = 0; |
880 | $result["ERR"] = 0; |
882 | $result["Location"] = "manager.php"; |
881 | $result["Location"] = "manager.php"; |
883 | setcookie($this->cookie, $sHash); |
882 | setcookie($this->cookie, $sHash); |
884 | } else { |
883 | } else { |
885 | $result["ERR"] = 1; |
884 | $result["ERR"] = 1; |
886 | $result["ERRINFO"] = "Password not valid"; |
885 | $result["ERRINFO"] = "Password not valid"; |
887 | $result["Location"] = "manager.php?error=1"; |
886 | $result["Location"] = "manager.php?error=1"; |
888 | }
|
887 | }
|
889 | 888 | ||
890 | return $result; |
889 | return $result; |
891 | }
|
890 | }
|
892 | 891 | ||
893 | /**
|
892 | /**
|
894 | * Проверка пароля (из cookies)
|
893 | * Проверка пароля (из cookies)
|
895 | *
|
894 | *
|
896 | * @author Alexander Wolf
|
895 | * @author Alexander Wolf
|
897 | * @category Core
|
896 | * @category Core
|
898 | *
|
897 | *
|
899 | * @param string $hash
|
898 | * @param string $hash
|
900 | * @return array
|
899 | * @return array
|
901 | */
|
900 | */
|
902 | public function checkCookieSign($hash) { |
901 | public function checkCookieSign($hash) { |
903 | $result = array(); |
902 | $result = array(); |
904 | 903 | ||
905 | $pwd = $this->getOption("passwd"); |
904 | $pwd = $this->getOption("passwd"); |
906 | if ($hash == $pwd["OptValue"]) { |
905 | if ($hash == $pwd["OptValue"]) { |
907 | $result["ERR"] = 0; |
906 | $result["ERR"] = 0; |
908 | } else { |
907 | } else { |
909 | $result["ERR"] = 1; |
908 | $result["ERR"] = 1; |
910 | $result["ERRINFO"] = "Hash not valid"; |
909 | $result["ERRINFO"] = "Hash not valid"; |
911 | $result["Location"] = "manager.php"; |
910 | $result["Location"] = "manager.php"; |
912 | }
|
911 | }
|
913 | 912 | ||
914 | return $result; |
913 | return $result; |
915 | }
|
914 | }
|
916 | 915 | ||
917 | /**
|
916 | /**
|
918 | * Форма ввода пароля
|
917 | * Форма ввода пароля
|
919 | *
|
918 | *
|
920 | * @author Alexander Wolf
|
919 | * @author Alexander Wolf
|
921 | * @category Core
|
920 | * @category Core
|
922 | *
|
921 | *
|
923 | * @return string
|
922 | * @return string
|
924 | */
|
923 | */
|
925 | public function showSigninForm() { |
924 | public function showSigninForm() { |
926 | $show = "<div id='regform'>"; |
925 | $show = "<div id='regform'>"; |
927 | $show .= "<form action='process.php' method='post'>\n"; |
926 | $show .= "<form action='process.php' method='post'>\n"; |
928 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
927 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
929 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
928 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
930 | $show .= "<input type='password' name='word' value=''>\n"; |
929 | $show .= "<input type='password' name='word' value=''>\n"; |
931 | $show .= "<input type='submit' value=' Войти '>\n"; |
930 | $show .= "<input type='submit' value=' Войти '>\n"; |
932 | $show .= "</fieldset>\n</form></div>\n"; |
931 | $show .= "</fieldset>\n</form></div>\n"; |
933 | 932 | ||
934 | return $show; |
933 | return $show; |
935 | }
|
934 | }
|
936 | 935 | ||
937 | /**
|
936 | /**
|
938 | * Обновление пароля
|
937 | * Обновление пароля
|
939 | *
|
938 | *
|
940 | * @author Alexander Wolf
|
939 | * @author Alexander Wolf
|
941 | * @category Core
|
940 | * @category Core
|
942 | *
|
941 | *
|
943 | * @param string $word1
|
942 | * @param string $word1
|
944 | * @param string $word2
|
943 | * @param string $word2
|
945 | * @return array
|
944 | * @return array
|
946 | */
|
945 | */
|
947 | public function updatePassword($word1, $word2) { |
946 | public function updatePassword($word1, $word2) { |
948 | $result = array(); |
947 | $result = array(); |
949 | 948 | ||
950 | if ($word1 == $word2) { |
949 | if ($word1 == $word2) { |
951 | $sWord = $this->secure->encryptStr($word1); |
950 | $sWord = $this->secure->encryptStr($word1); |
952 | $r = $this->setOption("passwd", $sWord); |
951 | $r = $this->setOption("passwd", $sWord); |
953 | $result = $r; |
952 | $result = $r; |
954 | } else { |
953 | } else { |
955 | $result["ERR"] = 1; |
954 | $result["ERR"] = 1; |
956 | $result["ERRINFO"] = "Passwords is mismatch"; |
955 | $result["ERRINFO"] = "Passwords is mismatch"; |
957 | }
|
956 | }
|
958 | 957 | ||
959 | return $result; |
958 | return $result; |
960 | }
|
959 | }
|
961 | 960 | ||
962 | /**
|
961 | /**
|
963 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
962 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
964 | *
|
963 | *
|
965 | * @author Alexander Wolf
|
964 | * @author Alexander Wolf
|
966 | * @category Core
|
965 | * @category Core
|
967 | *
|
966 | *
|
968 | * @param string $name
|
967 | * @param string $name
|
969 | * @param string $actor
|
968 | * @param string $actor
|
970 | * @param integer $versionID
|
969 | * @param integer $versionID
|
971 | * @return string
|
970 | * @return string
|
972 | */
|
971 | */
|
973 | public function showDistVersionsForm($versionID = 0, $info = '') { |
972 | public function showDistVersionsForm($versionID = 0, $info = '') { |
974 | $sVersionID = $this->secure->checkInt($versionID); |
973 | $sVersionID = $this->secure->checkInt($versionID); |
975 | $sInfo = $this->secure->checkStr($info, 1); |
974 | $sInfo = $this->secure->checkStr($info, 1); |
976 | if ($sInfo == "") { |
975 | if ($sInfo == "") { |
977 | $sInfo = "Версия дистрибутива"; |
976 | $sInfo = "Версия дистрибутива"; |
978 | }
|
977 | }
|
979 | if ($sVersionID != 0) { |
978 | if ($sVersionID != 0) { |
980 | // Режим редактирования
|
979 | // Режим редактирования
|
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."'"; |
980 | $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); |
981 | $rq =& $this->db->query($query); |
983 | $rq->fetchInto($element); |
982 | $rq->fetchInto($element); |
984 | }
|
983 | }
|
985 | 984 | ||
986 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
985 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
987 | if ($sVersionID != 0) { |
986 | 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"; |
987 | $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 { |
988 | } else { |
990 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
989 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
991 | }
|
990 | }
|
992 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
991 | $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"; |
992 | $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"; |
993 | $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"; |
994 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
996 | 995 | ||
997 | return $show; |
996 | return $show; |
998 | }
|
997 | }
|
999 | 998 | ||
1000 | /**
|
999 | /**
|
1001 | * Парсер схемы адреса репозитория
|
1000 | * Парсер схемы адреса репозитория
|
1002 | * FIXME Возможно не потребуется
|
1001 | * FIXME Возможно не потребуется
|
1003 | *
|
1002 | *
|
1004 | * @author Alexander Wolf
|
1003 | * @author Alexander Wolf
|
1005 | * @category Core
|
1004 | * @category Core
|
1006 | *
|
1005 | *
|
1007 | * @param string $repstring
|
1006 | * @param string $repstring
|
1008 | * @return integer
|
1007 | * @return integer
|
1009 | */
|
1008 | */
|
1010 | public function repositoryParser($repstring) { |
1009 | public function repositoryParser($repstring) { |
1011 | $tokens = array(); |
1010 | $tokens = array(); |
1012 | $sections = array(); |
1011 | $sections = array(); |
1013 | $tokens = split(" ",$repstring); |
1012 | $tokens = split(" ",$repstring); |
1014 | 1013 | ||
1015 | if ($tokens[0] == "deb") { |
1014 | if ($tokens[0] == "deb") { |
1016 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1015 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1017 | $url = parse_url($tokens[1]); |
1016 | $url = parse_url($tokens[1]); |
1018 | $distr = $tokens[2]; |
1017 | $distr = $tokens[2]; |
1019 | 1018 | ||
1020 | for($i=3;$i<count($tokens);$i++) { |
1019 | for($i=3;$i<count($tokens);$i++) { |
1021 | $sections[] = $tokens[$i]; |
1020 | $sections[] = $tokens[$i]; |
1022 | }
|
1021 | }
|
1023 | } else { |
1022 | } else { |
1024 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1023 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1025 | if (stripos($tokens[1],"]")!=0) { |
1024 | if (stripos($tokens[1],"]")!=0) { |
1026 | $sign = $tokens[1]; |
1025 | $sign = $tokens[1]; |
1027 | $url = parse_url($tokens[2]); |
1026 | $url = parse_url($tokens[2]); |
1028 | $base = $tokens[3]; |
1027 | $base = $tokens[3]; |
1029 | $repname = $tokens[4]; |
1028 | $repname = $tokens[4]; |
1030 | } else { |
1029 | } else { |
1031 | $url = parse_url($tokens[1]); |
1030 | $url = parse_url($tokens[1]); |
1032 | $base = $tokens[2]; |
1031 | $base = $tokens[2]; |
1033 | $repname = $tokens[3]; |
1032 | $repname = $tokens[3]; |
1034 | }
|
1033 | }
|
1035 | }
|
1034 | }
|
1036 | 1035 | ||
1037 | $proto = $url["scheme"]."://"; |
1036 | $proto = $url["scheme"]."://"; |
1038 | $addr = $url["host"]; |
1037 | $addr = $url["host"]; |
1039 | if ($url["port"]!="") { |
1038 | if ($url["port"]!="") { |
1040 | $addr .= ":".$url["port"]; |
1039 | $addr .= ":".$url["port"]; |
1041 | }
|
1040 | }
|
1042 | $path = $url["path"]; |
1041 | $path = $url["path"]; |
1043 | 1042 | ||
1044 | return 0; |
1043 | return 0; |
1045 | }
|
1044 | }
|
1046 | 1045 | ||
1047 | /**
|
1046 | /**
|
1048 | * Выгрузка картинок логотипов дистрибутивов
|
1047 | * Выгрузка картинок логотипов дистрибутивов
|
1049 | *
|
1048 | *
|
1050 | * @author Alexander Wolf
|
1049 | * @author Alexander Wolf
|
1051 | * @category Core
|
1050 | * @category Core
|
1052 | *
|
1051 | *
|
1053 | * @param string $path
|
1052 | * @param string $path
|
1054 | * @param string $dist
|
1053 | * @param string $dist
|
1055 | * @param array $datafile
|
1054 | * @param array $datafile
|
1056 | * @return integer
|
1055 | * @return integer
|
1057 | */
|
1056 | */
|
1058 | public function uploadPicture($path, $dist, $datafile) { |
1057 | public function uploadPicture($path, $dist, $datafile) { |
1059 | $folder = $path.$dist."-orig.png"; |
1058 | $folder = $path.$dist."-orig.png"; |
1060 | $folderN = $path.$dist.".png"; |
1059 | $folderN = $path.$dist.".png"; |
1061 | $folderEM = $path.$dist."-em.png"; |
1060 | $folderEM = $path.$dist."-em.png"; |
1062 | 1061 | ||
1063 | $distlogo = 0; |
1062 | $distlogo = 0; |
1064 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1063 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1065 | chmod($folder, 0644); |
1064 | chmod($folder, 0644); |
1066 | list($width, $height) = GetImageSize($folder); |
1065 | list($width, $height) = GetImageSize($folder); |
1067 | $percent = 32/$height; |
1066 | $percent = 32/$height; |
1068 | $newwidth = $width * $percent; |
1067 | $newwidth = $width * $percent; |
1069 | $newheight = $height * $percent; |
1068 | $newheight = $height * $percent; |
1070 | 1069 | ||
1071 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1070 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1072 | $source = ImageCreateFromPNG($folder); |
1071 | $source = ImageCreateFromPNG($folder); |
1073 | 1072 | ||
1074 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1073 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1075 | ImagePNG($output, $folderEM); |
1074 | ImagePNG($output, $folderEM); |
1076 | 1075 | ||
1077 | $percent = 15/$height; |
1076 | $percent = 15/$height; |
1078 | $newwidth = $width * $percent; |
1077 | $newwidth = $width * $percent; |
1079 | $newheight = $height * $percent; |
1078 | $newheight = $height * $percent; |
1080 | 1079 | ||
1081 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1080 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1082 | 1081 | ||
1083 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1082 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1084 | ImagePNG($output, $folderN); |
1083 | ImagePNG($output, $folderN); |
1085 | 1084 | ||
1086 | unlink($folder); |
1085 | unlink($folder); |
1087 | $distlogo = 1; |
1086 | $distlogo = 1; |
1088 | }
|
1087 | }
|
1089 | return $distlogo; |
1088 | return $distlogo; |
1090 | }
|
1089 | }
|
1091 | 1090 | ||
1092 | /**
|
1091 | /**
|
1093 | * Показ списка репозиториев
|
1092 | * Показ списка репозиториев
|
1094 | *
|
1093 | *
|
1095 | * @author Alexander Wolf
|
1094 | * @author Alexander Wolf
|
1096 | * @category Core
|
1095 | * @category Core
|
1097 | *
|
1096 | *
|
1098 | * @param string $name
|
1097 | * @param string $name
|
1099 | * @param string $actor
|
1098 | * @param string $actor
|
1100 | * @param string $format
|
1099 | * @param string $format
|
1101 | * @return string
|
1100 | * @return string
|
1102 | */
|
1101 | */
|
1103 | public function showRepositoriesList($name, $actor, $format = 'list') { |
1102 | public function showRepositoriesList($name, $actor, $format = 'list') { |
1104 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
1103 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
1105 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
1104 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
1106 | $rq =& $this->db->query($query); |
1105 | $rq =& $this->db->query($query); |
1107 | $show = "<ul>"; |
1106 | $show = "<ul>"; |
1108 | while ($rq->fetchInto($element)) { |
1107 | while ($rq->fetchInto($element)) { |
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"; |
1108 | $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 | }
|
1109 | }
|
1111 | $show .= "</ul>"; |
1110 | $show .= "</ul>"; |
1112 | return $show; |
1111 | return $show; |
1113 | }
|
1112 | }
|
1114 | 1113 | ||
1115 | /**
|
1114 | /**
|
1116 | * Форма создания/редактирвоания репозиториев
|
1115 | * Форма создания/редактирвоания репозиториев
|
1117 | *
|
1116 | *
|
1118 | * @author Alexander Wolf
|
1117 | * @author Alexander Wolf
|
1119 | * @category Core
|
1118 | * @category Core
|
1120 | *
|
1119 | *
|
1121 | * @param integer $repID
|
1120 | * @param integer $repID
|
1122 | * @param string $info
|
1121 | * @param string $info
|
1123 | * @param string $reptype
|
1122 | * @param string $reptype
|
1124 | * @return string
|
1123 | * @return string
|
1125 | */
|
1124 | */
|
1126 | public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") { |
1125 | public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") { |
1127 | return $show; |
1126 | return $show; |
1128 | }
|
1127 | }
|
1129 | }
|
1128 | }
|
1130 | 1129 | ||
1131 | ?>
|
1130 | ?>
|