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