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