Редакция 648 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 648 | Редакция 649 | ||
---|---|---|---|
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 | $query .= "ORDER BY s.sect_id ASC"; |
273 | $query .= "ORDER BY s.sect_id ASC"; |
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($element)) { |
311 | while ($rq->fetchInto($element)) { |
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); |
338 | $sDName = $this->secure->checkStr($distname); |
339 | $sDType = $this->secure->checkInt($disttype); |
339 | $sDType = $this->secure->checkInt($disttype); |
340 | $sDUAgt = $this->secure->checkStr($distua); |
340 | $sDUAgt = $this->secure->checkStr($distua); |
341 | $sDLogo = $this->secure->checkInt($distlogo); |
341 | $sDLogo = $this->secure->checkInt($distlogo); |
342 | 342 | ||
343 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
343 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
344 | $rq =& $this->db->query($query); |
344 | $rq =& $this->db->query($query); |
345 | if (PEAR::isError($this->db)) { |
345 | if (PEAR::isError($this->db)) { |
346 | $result["ERR"] = 1; |
346 | $result["ERR"] = 1; |
347 | $result["ERRINFO"] = $this->db->getMessage(); |
347 | $result["ERRINFO"] = $this->db->getMessage(); |
348 | } else { |
348 | } else { |
349 | $result["ERR"] = 0; |
349 | $result["ERR"] = 0; |
350 | }
|
350 | }
|
351 | 351 | ||
352 | return $result; |
352 | return $result; |
353 | }
|
353 | }
|
354 | 354 | ||
355 | /**
|
355 | /**
|
356 | * Обновление информации о дистрибутиве
|
356 | * Обновление информации о дистрибутиве
|
357 | *
|
357 | *
|
358 | * @author Alexander Wolf
|
358 | * @author Alexander Wolf
|
359 | * @category Core
|
359 | * @category Core
|
360 | *
|
360 | *
|
361 | * @param integer $distID
|
361 | * @param integer $distID
|
362 | * @param string $distname
|
362 | * @param string $distname
|
363 | * @param integer $disttype
|
363 | * @param integer $disttype
|
364 | * @param string $distua
|
364 | * @param string $distua
|
365 | * @param integer $distlogo
|
365 | * @param integer $distlogo
|
366 | * @return array
|
366 | * @return array
|
367 | */
|
367 | */
|
368 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
368 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
369 | $result = array(); |
369 | $result = array(); |
370 | $sDID = $this->secure->checkInt($distID); |
370 | $sDID = $this->secure->checkInt($distID); |
371 | $sDName = $this->secure->checkStr($distname); |
371 | $sDName = $this->secure->checkStr($distname); |
372 | $sDType = $this->secure->checkInt($disttype); |
372 | $sDType = $this->secure->checkInt($disttype); |
373 | $sDUAgt = $this->secure->checkStr($distua); |
373 | $sDUAgt = $this->secure->checkStr($distua); |
374 | $sDLogo = $this->secure->checkInt($distlogo); |
374 | $sDLogo = $this->secure->checkInt($distlogo); |
375 | 375 | ||
376 | if ($sDLogo!=0) { |
376 | if ($sDLogo!=0) { |
377 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
377 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
378 | } else { |
378 | } else { |
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
379 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
380 | }
|
380 | }
|
381 | $rq =& $this->db->query($query); |
381 | $rq =& $this->db->query($query); |
382 | if (PEAR::isError($this->db)) { |
382 | if (PEAR::isError($this->db)) { |
383 | $result["ERR"] = 1; |
383 | $result["ERR"] = 1; |
384 | $result["ERRINFO"] = $this->db->getMessage(); |
384 | $result["ERRINFO"] = $this->db->getMessage(); |
385 | } else { |
385 | } else { |
386 | $result["ERR"] = 0; |
386 | $result["ERR"] = 0; |
387 | }
|
387 | }
|
388 | 388 | ||
389 | return $result; |
389 | return $result; |
390 | }
|
390 | }
|
391 | 391 | ||
392 | /**
|
392 | /**
|
393 | * Удаление информации о дистрибутиве
|
393 | * Удаление информации о дистрибутиве
|
394 | *
|
394 | *
|
395 | * @author Alexander Wolf
|
395 | * @author Alexander Wolf
|
396 | * @category Core
|
396 | * @category Core
|
397 | *
|
397 | *
|
398 | * @param integer $distID
|
398 | * @param integer $distID
|
399 | * @return array
|
399 | * @return array
|
400 | */
|
400 | */
|
401 | public function dropDistribution($distID) { |
401 | public function dropDistribution($distID) { |
402 | $result = array(); |
402 | $result = array(); |
403 | $sDID = $this->secure->checkInt($distID); |
403 | $sDID = $this->secure->checkInt($distID); |
404 | 404 | ||
405 | // Удаление дистрибутива
|
405 | // Удаление дистрибутива
|
406 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
406 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
407 | $rq =& $this->db->query($query); |
407 | $rq =& $this->db->query($query); |
408 | if (PEAR::isError($this->db)) { |
408 | if (PEAR::isError($this->db)) { |
409 | $result["ERR"] = 1; |
409 | $result["ERR"] = 1; |
410 | $result["ERRINFO"] = $this->db->getMessage(); |
410 | $result["ERRINFO"] = $this->db->getMessage(); |
411 | } else { |
411 | } else { |
412 | $result["ERR"] = 0; |
412 | $result["ERR"] = 0; |
413 | }
|
413 | }
|
414 | 414 | ||
415 | // Удаление версий дистрибутива
|
415 | // Удаление версий дистрибутива
|
416 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
416 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
417 | $rq =& $this->db->query($query); |
417 | $rq =& $this->db->query($query); |
418 | if (PEAR::isError($this->db)) { |
418 | if (PEAR::isError($this->db)) { |
419 | $result["ERR"] = 1; |
419 | $result["ERR"] = 1; |
420 | $result["ERRINFO"] = $this->db->getMessage(); |
420 | $result["ERRINFO"] = $this->db->getMessage(); |
421 | } else { |
421 | } else { |
422 | $result["ERR"] = 0; |
422 | $result["ERR"] = 0; |
423 | }
|
423 | }
|
424 | 424 | ||
425 | return $result; |
425 | return $result; |
426 | }
|
426 | }
|
427 | 427 | ||
428 | /**
|
428 | /**
|
429 | * Добавление поддержки новой версии apt-дистрибутива
|
429 | * Добавление поддержки новой версии apt-дистрибутива
|
430 | *
|
430 | *
|
431 | * @author Alexander Wolf
|
431 | * @author Alexander Wolf
|
432 | * @category Core
|
432 | * @category Core
|
433 | *
|
433 | *
|
434 | * @param integer $distID
|
434 | * @param integer $distID
|
435 | * @param integer $version
|
435 | * @param integer $version
|
436 | * @param string $vname
|
436 | * @param string $vname
|
437 | * @param integer $vcodename
|
437 | * @param integer $vcodename
|
438 | * @return array
|
438 | * @return array
|
439 | */
|
439 | */
|
440 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
440 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
441 | $result = array(); |
441 | $result = array(); |
442 | $sDistID = $this->secure->checkInt($distID); |
442 | $sDistID = $this->secure->checkInt($distID); |
443 | $sDVersion = $this->secure->checkStr($version); |
443 | $sDVersion = $this->secure->checkStr($version); |
444 | $sDVName = $this->secure->checkStr($vname); |
444 | $sDVName = $this->secure->checkStr($vname); |
445 | $sDVCName = $this->secure->checkStr($vcodename); |
445 | $sDVCName = $this->secure->checkStr($vcodename); |
446 | 446 | ||
447 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
447 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
448 | $rq =& $this->db->query($query); |
448 | $rq =& $this->db->query($query); |
449 | if (PEAR::isError($this->db)) { |
449 | if (PEAR::isError($this->db)) { |
450 | $result["ERR"] = 1; |
450 | $result["ERR"] = 1; |
451 | $result["ERRINFO"] = $this->db->getMessage(); |
451 | $result["ERRINFO"] = $this->db->getMessage(); |
452 | } else { |
452 | } else { |
453 | $result["ERR"] = 0; |
453 | $result["ERR"] = 0; |
454 | }
|
454 | }
|
455 | 455 | ||
456 | return $result; |
456 | return $result; |
457 | }
|
457 | }
|
458 | 458 | ||
459 | /**
|
459 | /**
|
460 | * Редактирование информации о версии дистрибутива
|
460 | * Редактирование информации о версии дистрибутива
|
461 | *
|
461 | *
|
462 | * @author Alexander Wolf
|
462 | * @author Alexander Wolf
|
463 | * @category Core
|
463 | * @category Core
|
464 | *
|
464 | *
|
465 | * @param integer $versionID
|
465 | * @param integer $versionID
|
466 | * @param string $version
|
466 | * @param string $version
|
467 | * @param string $vname
|
467 | * @param string $vname
|
468 | * @param string $vcodename
|
468 | * @param string $vcodename
|
469 | * @return array
|
469 | * @return array
|
470 | */
|
470 | */
|
471 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
471 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
472 | $result = array(); |
472 | $result = array(); |
473 | $sVersID = $this->secure->checkInt($versionID); |
473 | $sVersID = $this->secure->checkInt($versionID); |
474 | $sDVersion = $this->secure->checkStr($version,1); |
474 | $sDVersion = $this->secure->checkStr($version,1); |
475 | $sDVName = $this->secure->checkStr($vname,1); |
475 | $sDVName = $this->secure->checkStr($vname,1); |
476 | $sDVCName = $this->secure->checkStr($vcodename,1); |
476 | $sDVCName = $this->secure->checkStr($vcodename,1); |
477 | 477 | ||
478 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
478 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
479 | $rq =& $this->db->query($query); |
479 | $rq =& $this->db->query($query); |
480 | if (PEAR::isError($this->db)) { |
480 | if (PEAR::isError($this->db)) { |
481 | $result["ERR"] = 1; |
481 | $result["ERR"] = 1; |
482 | $result["ERRINFO"] = $this->db->getMessage(); |
482 | $result["ERRINFO"] = $this->db->getMessage(); |
483 | } else { |
483 | } else { |
484 | $result["ERR"] = 0; |
484 | $result["ERR"] = 0; |
485 | }
|
485 | }
|
486 | 486 | ||
487 | return $result; |
487 | return $result; |
488 | }
|
488 | }
|
489 | 489 | ||
490 | /**
|
490 | /**
|
491 | * Удаление информации о версии дистрибутива
|
491 | * Удаление информации о версии дистрибутива
|
492 | *
|
492 | *
|
493 | * @author Alexander Wolf
|
493 | * @author Alexander Wolf
|
494 | * @category Core
|
494 | * @category Core
|
495 | *
|
495 | *
|
496 | * @param integer $versionID
|
496 | * @param integer $versionID
|
497 | * @return array
|
497 | * @return array
|
498 | */
|
498 | */
|
499 | public function dropDistVersion($versionID) { |
499 | public function dropDistVersion($versionID) { |
500 | $result = array(); |
500 | $result = array(); |
501 | $sVersID = $this->secure->checkInt($versionID); |
501 | $sVersID = $this->secure->checkInt($versionID); |
502 | 502 | ||
503 | // Удаление версии дистрибутива
|
503 | // Удаление версии дистрибутива
|
504 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
504 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
505 | $rq =& $this->db->query($query); |
505 | $rq =& $this->db->query($query); |
506 | if (PEAR::isError($this->db)) { |
506 | if (PEAR::isError($this->db)) { |
507 | $result["ERR"] = 1; |
507 | $result["ERR"] = 1; |
508 | $result["ERRINFO"] = $this->db->getMessage(); |
508 | $result["ERRINFO"] = $this->db->getMessage(); |
509 | } else { |
509 | } else { |
510 | $result["ERR"] = 0; |
510 | $result["ERR"] = 0; |
511 | }
|
511 | }
|
512 | 512 | ||
513 | // Удаление репозиториев этой версии дистрибутива
|
513 | // Удаление репозиториев этой версии дистрибутива
|
514 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
514 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
515 | $rq =& $this->db->query($query); |
515 | $rq =& $this->db->query($query); |
516 | if (PEAR::isError($this->db)) { |
516 | if (PEAR::isError($this->db)) { |
517 | $result["ERR"] = 1; |
517 | $result["ERR"] = 1; |
518 | $result["ERRINFO"] = $this->db->getMessage(); |
518 | $result["ERRINFO"] = $this->db->getMessage(); |
519 | } else { |
519 | } else { |
520 | $result["ERR"] = 0; |
520 | $result["ERR"] = 0; |
521 | }
|
521 | }
|
522 | 522 | ||
523 | return $result; |
523 | return $result; |
524 | }
|
524 | }
|
525 | 525 | ||
526 | /**
|
526 | /**
|
527 | * Отображение типа дистрибутива
|
527 | * Отображение типа дистрибутива
|
528 | *
|
528 | *
|
529 | * @author Alexander Wolf
|
529 | * @author Alexander Wolf
|
530 | * @category Core
|
530 | * @category Core
|
531 | *
|
531 | *
|
532 | * @param string $name
|
532 | * @param string $name
|
533 | * @param byte $type
|
533 | * @param byte $type
|
534 | * @return string
|
534 | * @return string
|
535 | */
|
535 | */
|
536 | public function showDistTypeForm($name = "dtype",$type = 0) { |
536 | public function showDistTypeForm($name = "dtype",$type = 0) { |
537 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
537 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
538 | $rq =& $this->db->query($query); |
538 | $rq =& $this->db->query($query); |
539 | $show = "<select name='".$name."' id='".$name."'>\n"; |
539 | $show = "<select name='".$name."' id='".$name."'>\n"; |
540 | while ($rq->fetchInto($element)) { |
540 | while ($rq->fetchInto($element)) { |
541 | if ($element["type_id"] == $type) { |
541 | if ($element["type_id"] == $type) { |
542 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
542 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
543 | } else { |
543 | } else { |
544 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
544 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
545 | }
|
545 | }
|
546 | }
|
546 | }
|
547 | $show .= "</select>"; |
547 | $show .= "</select>"; |
548 | 548 | ||
549 | return $show; |
549 | return $show; |
550 | }
|
550 | }
|
551 | 551 | ||
552 | /**
|
552 | /**
|
553 | * Отображение формы создания и редактирования apt-дистрибутива
|
553 | * Отображение формы создания и редактирования apt-дистрибутива
|
554 | *
|
554 | *
|
555 | * @author Alexander Wolf
|
555 | * @author Alexander Wolf
|
556 | * @category Core
|
556 | * @category Core
|
557 | *
|
557 | *
|
558 | * @param integer $distID
|
558 | * @param integer $distID
|
559 | * @return string
|
559 | * @return string
|
560 | */
|
560 | */
|
561 | public function showDistributionForm($distID = 0, $info = '') { |
561 | public function showDistributionForm($distID = 0, $info = '') { |
562 | $sDistID = $this->secure->checkInt($distID); |
562 | $sDistID = $this->secure->checkInt($distID); |
563 | $sInfo = $this->secure->checkStr($info, 1); |
563 | $sInfo = $this->secure->checkStr($info, 1); |
564 | if ($sInfo == "") { |
564 | if ($sInfo == "") { |
565 | $sInfo = "Дистрибутив"; |
565 | $sInfo = "Дистрибутив"; |
566 | }
|
566 | }
|
567 | if ($sDistID != 0) { |
567 | if ($sDistID != 0) { |
568 | // Режим редактирования
|
568 | // Режим редактирования
|
569 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
569 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
570 | $rq =& $this->db->query($query); |
570 | $rq =& $this->db->query($query); |
571 | $rq->fetchInto($element); |
571 | $rq->fetchInto($element); |
572 | }
|
572 | }
|
573 | 573 | ||
574 | if ($element["distlogo"] == 1) { |
574 | if ($element["distlogo"] == 1) { |
575 | $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>"; |
575 | $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>"; |
576 | } else { |
576 | } else { |
577 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
577 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
578 | }
|
578 | }
|
579 | 579 | ||
580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
581 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
581 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
582 | $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n"; |
582 | $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n"; |
583 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
583 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
584 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
584 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
585 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
585 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
586 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
586 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
587 | 587 | ||
588 | return $show; |
588 | return $show; |
589 | }
|
589 | }
|
590 | 590 | ||
591 | /**
|
591 | /**
|
592 | * Генератор sources.list
|
592 | * Генератор sources.list
|
593 | *
|
593 | *
|
594 | * @author Alexander Wolf
|
594 | * @author Alexander Wolf
|
595 | * @category Core
|
595 | * @category Core
|
596 | * @version 1.0
|
596 | * @version 1.0
|
597 | *
|
597 | *
|
598 | * @param array $data
|
598 | * @param array $data
|
599 | * @return string
|
599 | * @return string
|
600 | */
|
600 | */
|
601 | public function showSourcesList($data) { |
601 | public function showSourcesList($data) { |
602 | //TODO Написать генератор sources.list
|
602 | //TODO Написать генератор sources.list
|
603 | // Извлекаем информацию о дистрибутиве и его версии
|
603 | // Извлекаем информацию о дистрибутиве и его версии
|
604 | $query = "SELECT * FROM ".$this->prefix."distribution d "; |
604 | $query = "SELECT * FROM ".$this->prefix."distribution d "; |
605 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=d.version "; |
605 | $query .= "JOIN ".$this->prefix."version v ON v.dist_id=d.dist_id "; |
606 | $query .= "JOIN ".$this->prefix."dtype t ON d.disttype=t.type_id "; |
606 | $query .= "JOIN ".$this->prefix."dtype t ON d.disttype=t.type_id "; |
607 | $query .= "WHERE d.dist_id='".$data["dist_id"]."' AND v.version_id='".$data["version_id"]."'"; |
607 | $query .= "WHERE d.dist_id='".$data["dist_id"]."' AND v.version_id='".$data["version_id"]."'"; |
608 | $rq =& $this->db->query($query); |
608 | $rq =& $this->db->query($query); |
609 | $rq->fetchInto($dist); |
609 | $rq->fetchInto($dist); |
610 | 610 | ||
611 | header("content-type: text/plain\n\n"); |
611 | header("content-type: text/plain\n\n"); |
612 | $show = "# Список репозиториев для ".$this->secure->checkStr($dist["distname"],1)." ".$this->secure->checkStr($dist["version"],1)." ".$this->secure->checkStr($dist["vname"],1); |
612 | $show = "# Список репозиториев для ".$this->secure->checkStr($dist["distname"],1)." ".$this->secure->checkStr($dist["version"],1)." ".$this->secure->checkStr($dist["vname"],1); |
613 | 613 | ||
614 | // Извлекаем информацию о репозиториях и строим sources.list
|
614 | // Извлекаем информацию о репозиториях и строим sources.list
|
615 | if ($dist["type"]=="deb") { |
615 | if ($dist["type"]=="deb") { |
616 | // Базовый репозиторий
|
616 | // Базовый репозиторий
|
617 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
617 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
618 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
618 | $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id "; |
619 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
619 | $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id "; |
620 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=p.rfolder_id "; |
620 | $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=p.rfolder_id "; |
621 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
621 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
622 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
622 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
623 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
623 | $query .= "JOIN ".$this->prefix."repscheme s ON r.scheme_id=s.scheme_id "; |
624 | $query .= "WHERE v.version_id='".$data["version_id"]."' AND rtype_id='1'"; |
624 | $query .= "WHERE v.version_id='".$data["version_id"]."' AND rtype_id='1'"; |
625 | $rq =& $this->db->query($query); |
625 | $rq =& $this->db->query($query); |
626 | $rq->fetchInto($base); |
626 | $rq->fetchInto($base); |
627 | // Формируем type proto://host/folder
|
627 | // Формируем type proto://host/folder
|
628 | $show .= $this->secure->checkStr($dist["type"],1)." ".$this->secure->checkStr($dist["proto"],1).$this->secure->checkStr($dist["rhost"],1).$this->secure->checkStr($dist["rfolder"],1); |
628 | $show .= $this->secure->checkStr($dist["type"],1)." ".$this->secure->checkStr($dist["proto"],1).$this->secure->checkStr($dist["rhost"],1).$this->secure->checkStr($dist["rfolder"],1); |
629 | $dvname = str_replace("{DIST}",$this->secure->checkStr($dist["vcodename"],1),$this->secure->checkStr($dist["scheme"],1)); |
629 | $dvname = str_replace("{DIST}",$this->secure->checkStr($dist["vcodename"],1),$this->secure->checkStr($dist["scheme"],1)); |
630 | // Формируем distname
|
630 | // Формируем distname
|
631 | $show .= " ".$dvname." "; |
631 | $show .= " ".$dvname." "; |
632 | // Формируем sections
|
632 | // Формируем sections
|
633 | $query = "SELECT * FROM ".$this->prefix."section s "; |
633 | $query = "SELECT * FROM ".$this->prefix."section s "; |
634 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
634 | $query .= "JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id "; |
635 | $query .= "WHERE r.rep_id='".$base["rep_id"]."' AND ("; |
635 | $query .= "WHERE r.rep_id='".$base["rep_id"]."' AND ("; |
636 | for($i=0;$i<count($data["section"]);$i++) { |
636 | for($i=0;$i<count($data["section"]);$i++) { |
637 | $query .= "sect_id='".$data["section"][$i]."' "; |
637 | $query .= "sect_id='".$data["section"][$i]."' "; |
638 | if ($i<count($data["section"])-1) { |
638 | if ($i<count($data["section"])-1) { |
639 | $query .= " OR "; |
639 | $query .= " OR "; |
640 | }
|
640 | }
|
641 | }
|
641 | }
|
642 | $query .= ")"; |
642 | $query .= ")"; |
643 | $rq =& $this->db->query($query); |
643 | $rq =& $this->db->query($query); |
644 | while ($rq->fetchInto($sections)) { |
644 | while ($rq->fetchInto($sections)) { |
645 | $show .= $sections["secname"]." "; |
645 | $show .= $sections["secname"]." "; |
646 | }
|
646 | }
|
647 | $show .= "\n"; |
647 | $show .= "\n"; |
648 | 648 | ||
649 | }
|
649 | }
|
650 | 650 | ||
651 | return $show; |
651 | return $show; |
652 | }
|
652 | }
|
653 | 653 | ||
654 | /**
|
654 | /**
|
655 | * Показывает список секций
|
655 | * Показывает список секций
|
656 | *
|
656 | *
|
657 | * @author Alexander Wolf
|
657 | * @author Alexander Wolf
|
658 | * @category Core
|
658 | * @category Core
|
659 | *
|
659 | *
|
660 | * @param string $name
|
660 | * @param string $name
|
661 | * @param string $actor
|
661 | * @param string $actor
|
662 | * @param string $format
|
662 | * @param string $format
|
663 | * @return string
|
663 | * @return string
|
664 | */
|
664 | */
|
665 | public function showSectionsList($name, $actor, $format = 'html') { |
665 | public function showSectionsList($name, $actor, $format = 'html') { |
666 | switch($format) { |
666 | switch($format) { |
667 | case 'html': |
667 | case 'html': |
668 | $query = "SELECT * FROM ".$this->prefix."section"; |
668 | $query = "SELECT * FROM ".$this->prefix."section"; |
669 | $rq =& $this->db->query($query); |
669 | $rq =& $this->db->query($query); |
670 | $show = "<ul>\n"; |
670 | $show = "<ul>\n"; |
671 | while ($rq->fetchInto($element)) { |
671 | while ($rq->fetchInto($element)) { |
672 | $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"; |
672 | $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"; |
673 | }
|
673 | }
|
674 | $show .= "</ul>"; |
674 | $show .= "</ul>"; |
675 | break; |
675 | break; |
676 | case 'innerhtml': |
676 | case 'innerhtml': |
677 | $show = ""; |
677 | $show = ""; |
678 | $repID = $this->secure->checkInt($actor); |
678 | $repID = $this->secure->checkInt($actor); |
679 | if ($repID==0) { |
679 | if ($repID==0) { |
680 | $query = "SELECT * FROM ".$this->prefix."section"; |
680 | $query = "SELECT * FROM ".$this->prefix."section"; |
681 | $rq =& $this->db->query($query); |
681 | $rq =& $this->db->query($query); |
682 | while ($rq->fetchInto($element)) { |
682 | while ($rq->fetchInto($element)) { |
683 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
683 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
684 | }
|
684 | }
|
685 | } else { |
685 | } else { |
686 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
686 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
687 | $rq =& $this->db->query($query); |
687 | $rq =& $this->db->query($query); |
688 | while ($rq->fetchInto($element)) { |
688 | while ($rq->fetchInto($element)) { |
689 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
689 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
690 | }
|
690 | }
|
691 | $query = "SELECT s.* FROM ".$this->prefix."section s WHERE s.sect_id NOT IN (SELECT sect_id FROM ".$this->prefix."sect2rep WHERE rep_id='$repID')"; |
691 | $query = "SELECT s.* FROM ".$this->prefix."section s WHERE s.sect_id NOT IN (SELECT sect_id FROM ".$this->prefix."sect2rep WHERE rep_id='$repID')"; |
692 | $rq =& $this->db->query($query); |
692 | $rq =& $this->db->query($query); |
693 | while ($rq->fetchInto($element)) { |
693 | while ($rq->fetchInto($element)) { |
694 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
694 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
695 | }
|
695 | }
|
696 | }
|
696 | }
|
697 | 697 | ||
698 | break; |
698 | break; |
699 | }
|
699 | }
|
700 | 700 | ||
701 | return $show; |
701 | return $show; |
702 | }
|
702 | }
|
703 | 703 | ||
704 | /**
|
704 | /**
|
705 | * Вывод формы редактирования/добавления секций
|
705 | * Вывод формы редактирования/добавления секций
|
706 | *
|
706 | *
|
707 | * @author Alexander Wolf
|
707 | * @author Alexander Wolf
|
708 | * @category Core
|
708 | * @category Core
|
709 | *
|
709 | *
|
710 | * @param integer $sectionID
|
710 | * @param integer $sectionID
|
711 | * @param string $info
|
711 | * @param string $info
|
712 | * @return string
|
712 | * @return string
|
713 | */
|
713 | */
|
714 | public function showSectionsForm($sectionID = 0, $info = "") { |
714 | public function showSectionsForm($sectionID = 0, $info = "") { |
715 | $sSectID = $this->secure->checkInt($sectionID); |
715 | $sSectID = $this->secure->checkInt($sectionID); |
716 | $sInfo = $this->secure->checkStr($info, 1); |
716 | $sInfo = $this->secure->checkStr($info, 1); |
717 | if ($sInfo == "") { |
717 | if ($sInfo == "") { |
718 | $sInfo = "Секция"; |
718 | $sInfo = "Секция"; |
719 | }
|
719 | }
|
720 | if ($sSectID != 0) { |
720 | if ($sSectID != 0) { |
721 | // Режим редактирования
|
721 | // Режим редактирования
|
722 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
722 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
723 | $rq =& $this->db->query($query); |
723 | $rq =& $this->db->query($query); |
724 | $rq->fetchInto($element); |
724 | $rq->fetchInto($element); |
725 | }
|
725 | }
|
726 | 726 | ||
727 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
727 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
728 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
728 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
729 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
729 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
730 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
730 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
731 | 731 | ||
732 | return $show; |
732 | return $show; |
733 | }
|
733 | }
|
734 | 734 | ||
735 | /**
|
735 | /**
|
736 | * Обновление информации о секции
|
736 | * Обновление информации о секции
|
737 | *
|
737 | *
|
738 | * @author Alexander Wolf
|
738 | * @author Alexander Wolf
|
739 | * @category Core
|
739 | * @category Core
|
740 | *
|
740 | *
|
741 | * @param integer $sectionID
|
741 | * @param integer $sectionID
|
742 | * @param string $sname
|
742 | * @param string $sname
|
743 | * @param string $sinfo
|
743 | * @param string $sinfo
|
744 | * @return array
|
744 | * @return array
|
745 | */
|
745 | */
|
746 | public function updateSection($sectionID, $sname, $sinfo = "") { |
746 | public function updateSection($sectionID, $sname, $sinfo = "") { |
747 | $result = array(); |
747 | $result = array(); |
748 | $sSectID = $this->secure->checkInt($sectionID); |
748 | $sSectID = $this->secure->checkInt($sectionID); |
749 | $sSName = $this->secure->checkStr($sname); |
749 | $sSName = $this->secure->checkStr($sname); |
750 | $sSInfo = $this->secure->checkStr($sinfo); |
750 | $sSInfo = $this->secure->checkStr($sinfo); |
751 | 751 | ||
752 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
752 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
753 | $rq =& $this->db->query($query); |
753 | $rq =& $this->db->query($query); |
754 | if (PEAR::isError($this->db)) { |
754 | if (PEAR::isError($this->db)) { |
755 | $result["ERR"] = 1; |
755 | $result["ERR"] = 1; |
756 | $result["ERRINFO"] = $this->db->getMessage(); |
756 | $result["ERRINFO"] = $this->db->getMessage(); |
757 | } else { |
757 | } else { |
758 | $result["ERR"] = 0; |
758 | $result["ERR"] = 0; |
759 | }
|
759 | }
|
760 | 760 | ||
761 | return $result; |
761 | return $result; |
762 | }
|
762 | }
|
763 | 763 | ||
764 | /**
|
764 | /**
|
765 | * Удаление информации о секции
|
765 | * Удаление информации о секции
|
766 | *
|
766 | *
|
767 | * @author Alexander Wolf
|
767 | * @author Alexander Wolf
|
768 | * @category Core
|
768 | * @category Core
|
769 | *
|
769 | *
|
770 | * @param integer $sectionID
|
770 | * @param integer $sectionID
|
771 | * @return array
|
771 | * @return array
|
772 | */
|
772 | */
|
773 | public function dropSection($sectionID) { |
773 | public function dropSection($sectionID) { |
774 | $result = array(); |
774 | $result = array(); |
775 | $sSectID = $this->secure->checkInt($sectionID); |
775 | $sSectID = $this->secure->checkInt($sectionID); |
776 | 776 | ||
777 | // Удаление секции
|
777 | // Удаление секции
|
778 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
778 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
779 | $rq =& $this->db->query($query); |
779 | $rq =& $this->db->query($query); |
780 | if (PEAR::isError($this->db)) { |
780 | if (PEAR::isError($this->db)) { |
781 | $result["ERR"] = 1; |
781 | $result["ERR"] = 1; |
782 | $result["ERRINFO"] = $this->db->getMessage(); |
782 | $result["ERRINFO"] = $this->db->getMessage(); |
783 | } else { |
783 | } else { |
784 | $result["ERR"] = 0; |
784 | $result["ERR"] = 0; |
785 | }
|
785 | }
|
786 | 786 | ||
787 | return $result; |
787 | return $result; |
788 | }
|
788 | }
|
789 | 789 | ||
790 | /**
|
790 | /**
|
791 | * Добавление новой секции
|
791 | * Добавление новой секции
|
792 | *
|
792 | *
|
793 | * @author Alexander Wolf
|
793 | * @author Alexander Wolf
|
794 | * @category Core
|
794 | * @category Core
|
795 | *
|
795 | *
|
796 | * @param string $sname
|
796 | * @param string $sname
|
797 | * @param string $sinfo
|
797 | * @param string $sinfo
|
798 | * @return array
|
798 | * @return array
|
799 | */
|
799 | */
|
800 | public function addSection($sname, $sinfo = "") { |
800 | public function addSection($sname, $sinfo = "") { |
801 | $result = array(); |
801 | $result = array(); |
802 | $sSName = $this->secure->checkStr($sname); |
802 | $sSName = $this->secure->checkStr($sname); |
803 | $sSInfo = $this->secure->checkStr($sinfo); |
803 | $sSInfo = $this->secure->checkStr($sinfo); |
804 | 804 | ||
805 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
805 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
806 | $rq =& $this->db->query($query); |
806 | $rq =& $this->db->query($query); |
807 | if (PEAR::isError($this->db)) { |
807 | if (PEAR::isError($this->db)) { |
808 | $result["ERR"] = 1; |
808 | $result["ERR"] = 1; |
809 | $result["ERRINFO"] = $this->db->getMessage(); |
809 | $result["ERRINFO"] = $this->db->getMessage(); |
810 | } else { |
810 | } else { |
811 | $result["ERR"] = 0; |
811 | $result["ERR"] = 0; |
812 | }
|
812 | }
|
813 | 813 | ||
814 | return $result; |
814 | return $result; |
815 | }
|
815 | }
|
816 | 816 | ||
817 | /**
|
817 | /**
|
818 | * Вывод списка поддерживаемых архитектур
|
818 | * Вывод списка поддерживаемых архитектур
|
819 | *
|
819 | *
|
820 | * @author Alexander Wolf
|
820 | * @author Alexander Wolf
|
821 | * @category Core
|
821 | * @category Core
|
822 | *
|
822 | *
|
823 | * @param string $name
|
823 | * @param string $name
|
824 | * @param string $actor
|
824 | * @param string $actor
|
825 | * @param string $format
|
825 | * @param string $format
|
826 | * @return string
|
826 | * @return string
|
827 | */
|
827 | */
|
828 | public function showArchList($name, $actor, $format = 'list') { |
828 | public function showArchList($name, $actor, $format = 'list') { |
829 | switch($format) { |
829 | switch($format) { |
830 | case 'list': |
830 | case 'list': |
831 | $query = "SELECT * FROM ".$this->prefix."arch"; |
831 | $query = "SELECT * FROM ".$this->prefix."arch"; |
832 | $rq =& $this->db->query($query); |
832 | $rq =& $this->db->query($query); |
833 | $show = "<ul>\n"; |
833 | $show = "<ul>\n"; |
834 | while ($rq->fetchInto($element)) { |
834 | while ($rq->fetchInto($element)) { |
835 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["arch_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["arch_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["arch"],1)."</li>\n"; |
835 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["arch_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["arch_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["arch"],1)."</li>\n"; |
836 | }
|
836 | }
|
837 | $show .= "</ul>"; |
837 | $show .= "</ul>"; |
838 | break; |
838 | break; |
839 | case 'innerhtml': |
839 | case 'innerhtml': |
840 | $show = ""; |
840 | $show = ""; |
841 | $repID = $this->secure->checkInt($actor); |
841 | $repID = $this->secure->checkInt($actor); |
842 | if ($repID==0) { |
842 | if ($repID==0) { |
843 | $query = "SELECT * FROM ".$this->prefix."arch"; |
843 | $query = "SELECT * FROM ".$this->prefix."arch"; |
844 | $rq =& $this->db->query($query); |
844 | $rq =& $this->db->query($query); |
845 | while ($rq->fetchInto($element)) { |
845 | while ($rq->fetchInto($element)) { |
846 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
846 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
847 | }
|
847 | }
|
848 | } else { |
848 | } else { |
849 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
849 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
850 | $rq =& $this->db->query($query); |
850 | $rq =& $this->db->query($query); |
851 | while ($rq->fetchInto($element)) { |
851 | while ($rq->fetchInto($element)) { |
852 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
852 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
853 | }
|
853 | }
|
854 | $query = "SELECT a.* FROM ".$this->prefix."arch a WHERE a.arch_id NOT IN (SELECT arch_id FROM ".$this->prefix."arch2rep WHERE rep_id='$repID')"; |
854 | $query = "SELECT a.* FROM ".$this->prefix."arch a WHERE a.arch_id NOT IN (SELECT arch_id FROM ".$this->prefix."arch2rep WHERE rep_id='$repID')"; |
855 | $rq =& $this->db->query($query); |
855 | $rq =& $this->db->query($query); |
856 | if ($rq->numRows()>0) { |
856 | if ($rq->numRows()>0) { |
857 | while ($rq->fetchInto($element)) { |
857 | while ($rq->fetchInto($element)) { |
858 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
858 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
859 | }
|
859 | }
|
860 | }
|
860 | }
|
861 | }
|
861 | }
|
862 | break; |
862 | break; |
863 | }
|
863 | }
|
864 | return $show; |
864 | return $show; |
865 | }
|
865 | }
|
866 | 866 | ||
867 | /**
|
867 | /**
|
868 | * Добавление новой архитектуры
|
868 | * Добавление новой архитектуры
|
869 | *
|
869 | *
|
870 | * @author Alexander Wolf
|
870 | * @author Alexander Wolf
|
871 | * @category Core
|
871 | * @category Core
|
872 | *
|
872 | *
|
873 | * @param string $arch
|
873 | * @param string $arch
|
874 | * @return array
|
874 | * @return array
|
875 | */
|
875 | */
|
876 | public function addArch($arch) { |
876 | public function addArch($arch) { |
877 | $result = array(); |
877 | $result = array(); |
878 | $sArch = $this->secure->checkStr($arch); |
878 | $sArch = $this->secure->checkStr($arch); |
879 | 879 | ||
880 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
880 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
881 | $rq =& $this->db->query($query); |
881 | $rq =& $this->db->query($query); |
882 | if (PEAR::isError($this->db)) { |
882 | if (PEAR::isError($this->db)) { |
883 | $result["ERR"] = 1; |
883 | $result["ERR"] = 1; |
884 | $result["ERRINFO"] = $this->db->getMessage(); |
884 | $result["ERRINFO"] = $this->db->getMessage(); |
885 | } else { |
885 | } else { |
886 | $result["ERR"] = 0; |
886 | $result["ERR"] = 0; |
887 | }
|
887 | }
|
888 | 888 | ||
889 | return $result; |
889 | return $result; |
890 | }
|
890 | }
|
891 | 891 | ||
892 | /**
|
892 | /**
|
893 | * Удаление информации об архитектуре
|
893 | * Удаление информации об архитектуре
|
894 | *
|
894 | *
|
895 | * @author Alexander Wolf
|
895 | * @author Alexander Wolf
|
896 | * @category Core
|
896 | * @category Core
|
897 | *
|
897 | *
|
898 | * @param integer $archID
|
898 | * @param integer $archID
|
899 | * @return array
|
899 | * @return array
|
900 | */
|
900 | */
|
901 | public function dropArch($archID) { |
901 | public function dropArch($archID) { |
902 | $result = array(); |
902 | $result = array(); |
903 | $sArchID = $this->secure->checkInt($archID); |
903 | $sArchID = $this->secure->checkInt($archID); |
904 | 904 | ||
905 | // Удаление архитектуры
|
905 | // Удаление архитектуры
|
906 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
906 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
907 | $rq =& $this->db->query($query); |
907 | $rq =& $this->db->query($query); |
908 | if (PEAR::isError($this->db)) { |
908 | if (PEAR::isError($this->db)) { |
909 | $result["ERR"] = 1; |
909 | $result["ERR"] = 1; |
910 | $result["ERRINFO"] = $this->db->getMessage(); |
910 | $result["ERRINFO"] = $this->db->getMessage(); |
911 | } else { |
911 | } else { |
912 | $result["ERR"] = 0; |
912 | $result["ERR"] = 0; |
913 | }
|
913 | }
|
914 | 914 | ||
915 | // Удаление архитектуры из списка репозиториев
|
915 | // Удаление архитектуры из списка репозиториев
|
916 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
916 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
917 | $rq =& $this->db->query($query); |
917 | $rq =& $this->db->query($query); |
918 | if (PEAR::isError($this->db)) { |
918 | if (PEAR::isError($this->db)) { |
919 | $result["ERR"] = 1; |
919 | $result["ERR"] = 1; |
920 | $result["ERRINFO"] = $this->db->getMessage(); |
920 | $result["ERRINFO"] = $this->db->getMessage(); |
921 | } else { |
921 | } else { |
922 | $result["ERR"] = 0; |
922 | $result["ERR"] = 0; |
923 | }
|
923 | }
|
924 | return $result; |
924 | return $result; |
925 | }
|
925 | }
|
926 | 926 | ||
927 | /**
|
927 | /**
|
928 | * Обновление информации об архитектуре
|
928 | * Обновление информации об архитектуре
|
929 | *
|
929 | *
|
930 | * @author Alexander Wolf
|
930 | * @author Alexander Wolf
|
931 | * @category Core
|
931 | * @category Core
|
932 | *
|
932 | *
|
933 | * @param integer $archID
|
933 | * @param integer $archID
|
934 | * @param string $arch
|
934 | * @param string $arch
|
935 | * @return array
|
935 | * @return array
|
936 | */
|
936 | */
|
937 | public function updateArch($archID, $arch) { |
937 | public function updateArch($archID, $arch) { |
938 | $result = array(); |
938 | $result = array(); |
939 | $sArchID = $this->secure->checkInt($archID); |
939 | $sArchID = $this->secure->checkInt($archID); |
940 | $sArch = $this->secure->checkStr($arch); |
940 | $sArch = $this->secure->checkStr($arch); |
941 | 941 | ||
942 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
942 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
943 | $rq =& $this->db->query($query); |
943 | $rq =& $this->db->query($query); |
944 | if (PEAR::isError($this->db)) { |
944 | if (PEAR::isError($this->db)) { |
945 | $result["ERR"] = 1; |
945 | $result["ERR"] = 1; |
946 | $result["ERRINFO"] = $this->db->getMessage(); |
946 | $result["ERRINFO"] = $this->db->getMessage(); |
947 | } else { |
947 | } else { |
948 | $result["ERR"] = 0; |
948 | $result["ERR"] = 0; |
949 | }
|
949 | }
|
950 | 950 | ||
951 | return $result; |
951 | return $result; |
952 | }
|
952 | }
|
953 | 953 | ||
954 | /**
|
954 | /**
|
955 | * Вывод формы редактирования/добавления архитектур
|
955 | * Вывод формы редактирования/добавления архитектур
|
956 | *
|
956 | *
|
957 | * @author Alexander Wolf
|
957 | * @author Alexander Wolf
|
958 | * @category Core
|
958 | * @category Core
|
959 | *
|
959 | *
|
960 | * @param integer $archID
|
960 | * @param integer $archID
|
961 | * @param string $info
|
961 | * @param string $info
|
962 | * @return string
|
962 | * @return string
|
963 | */
|
963 | */
|
964 | public function showArchForm($archID = 0, $info = "") { |
964 | public function showArchForm($archID = 0, $info = "") { |
965 | $sArchID = $this->secure->checkInt($archID); |
965 | $sArchID = $this->secure->checkInt($archID); |
966 | $sInfo = $this->secure->checkStr($info, 1); |
966 | $sInfo = $this->secure->checkStr($info, 1); |
967 | if ($sInfo == "") { |
967 | if ($sInfo == "") { |
968 | $sInfo = "Архитектура"; |
968 | $sInfo = "Архитектура"; |
969 | }
|
969 | }
|
970 | if ($sArchID != 0) { |
970 | if ($sArchID != 0) { |
971 | // Режим редактирования
|
971 | // Режим редактирования
|
972 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
972 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
973 | $rq =& $this->db->query($query); |
973 | $rq =& $this->db->query($query); |
974 | $rq->fetchInto($element); |
974 | $rq->fetchInto($element); |
975 | }
|
975 | }
|
976 | 976 | ||
977 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
977 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
978 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
978 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
979 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
979 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
980 | 980 | ||
981 | return $show; |
981 | return $show; |
982 | }
|
982 | }
|
983 | 983 | ||
984 | /**
|
984 | /**
|
985 | * Вывод списка схем репозиториев
|
985 | * Вывод списка схем репозиториев
|
986 | *
|
986 | *
|
987 | * @author Alexander Wolf
|
987 | * @author Alexander Wolf
|
988 | * @category Core
|
988 | * @category Core
|
989 | *
|
989 | *
|
990 | * @param string $name
|
990 | * @param string $name
|
991 | * @param string $actor
|
991 | * @param string $actor
|
992 | * @param string $format
|
992 | * @param string $format
|
993 | * @return string
|
993 | * @return string
|
994 | */
|
994 | */
|
995 | public function showSchemeList($name, $actor, $format = 'list') { |
995 | public function showSchemeList($name, $actor, $format = 'list') { |
996 | switch($format) { |
996 | switch($format) { |
997 | case 'list': |
997 | case 'list': |
998 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
998 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
999 | $rq =& $this->db->query($query); |
999 | $rq =& $this->db->query($query); |
1000 | $show = "<ul>\n"; |
1000 | $show = "<ul>\n"; |
1001 | while ($rq->fetchInto($element)) { |
1001 | while ($rq->fetchInto($element)) { |
1002 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["scheme_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["scheme_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["scheme"],1)."</li>\n"; |
1002 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["scheme_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["scheme_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["scheme"],1)."</li>\n"; |
1003 | }
|
1003 | }
|
1004 | $show .= "</ul>"; |
1004 | $show .= "</ul>"; |
1005 | break; |
1005 | break; |
1006 | case 'innerhtml': |
1006 | case 'innerhtml': |
1007 | $schemeID = $this->secure->checkInt($actor); |
1007 | $schemeID = $this->secure->checkInt($actor); |
1008 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
1008 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
1009 | $rq =& $this->db->query($query); |
1009 | $rq =& $this->db->query($query); |
1010 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1010 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1011 | while ($rq->fetchInto($element)) { |
1011 | while ($rq->fetchInto($element)) { |
1012 | if ($element["scheme_id"]==$schemeID) { |
1012 | if ($element["scheme_id"]==$schemeID) { |
1013 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
1013 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
1014 | } else { |
1014 | } else { |
1015 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
1015 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
1016 | }
|
1016 | }
|
1017 | }
|
1017 | }
|
1018 | $show .= "</select>"; |
1018 | $show .= "</select>"; |
1019 | break; |
1019 | break; |
1020 | }
|
1020 | }
|
1021 | return $show; |
1021 | return $show; |
1022 | }
|
1022 | }
|
1023 | 1023 | ||
1024 | /**
|
1024 | /**
|
1025 | * Добавление новой схемы репозитория
|
1025 | * Добавление новой схемы репозитория
|
1026 | *
|
1026 | *
|
1027 | * @author Alexander Wolf
|
1027 | * @author Alexander Wolf
|
1028 | * @category Core
|
1028 | * @category Core
|
1029 | *
|
1029 | *
|
1030 | * @param string $scheme
|
1030 | * @param string $scheme
|
1031 | * @return array
|
1031 | * @return array
|
1032 | */
|
1032 | */
|
1033 | public function addScheme($scheme) { |
1033 | public function addScheme($scheme) { |
1034 | $result = array(); |
1034 | $result = array(); |
1035 | $sScheme = $this->secure->checkStr($scheme); |
1035 | $sScheme = $this->secure->checkStr($scheme); |
1036 | 1036 | ||
1037 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
1037 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
1038 | $rq =& $this->db->query($query); |
1038 | $rq =& $this->db->query($query); |
1039 | if (PEAR::isError($this->db)) { |
1039 | if (PEAR::isError($this->db)) { |
1040 | $result["ERR"] = 1; |
1040 | $result["ERR"] = 1; |
1041 | $result["ERRINFO"] = $this->db->getMessage(); |
1041 | $result["ERRINFO"] = $this->db->getMessage(); |
1042 | } else { |
1042 | } else { |
1043 | $result["ERR"] = 0; |
1043 | $result["ERR"] = 0; |
1044 | }
|
1044 | }
|
1045 | 1045 | ||
1046 | return $result; |
1046 | return $result; |
1047 | }
|
1047 | }
|
1048 | 1048 | ||
1049 | /**
|
1049 | /**
|
1050 | * Удаление информации о схеме репозитория
|
1050 | * Удаление информации о схеме репозитория
|
1051 | *
|
1051 | *
|
1052 | * @author Alexander Wolf
|
1052 | * @author Alexander Wolf
|
1053 | * @category Core
|
1053 | * @category Core
|
1054 | *
|
1054 | *
|
1055 | * @param integer $schemeID
|
1055 | * @param integer $schemeID
|
1056 | * @return array
|
1056 | * @return array
|
1057 | */
|
1057 | */
|
1058 | public function dropScheme($schemeID) { |
1058 | public function dropScheme($schemeID) { |
1059 | $result = array(); |
1059 | $result = array(); |
1060 | $sSchemeID = $this->secure->checkInt($schemeID); |
1060 | $sSchemeID = $this->secure->checkInt($schemeID); |
1061 | 1061 | ||
1062 | // Удаление схемы
|
1062 | // Удаление схемы
|
1063 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1063 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1064 | $rq =& $this->db->query($query); |
1064 | $rq =& $this->db->query($query); |
1065 | if (PEAR::isError($this->db)) { |
1065 | if (PEAR::isError($this->db)) { |
1066 | $result["ERR"] = 1; |
1066 | $result["ERR"] = 1; |
1067 | $result["ERRINFO"] = $this->db->getMessage(); |
1067 | $result["ERRINFO"] = $this->db->getMessage(); |
1068 | } else { |
1068 | } else { |
1069 | $result["ERR"] = 0; |
1069 | $result["ERR"] = 0; |
1070 | }
|
1070 | }
|
1071 | 1071 | ||
1072 | return $result; |
1072 | return $result; |
1073 | }
|
1073 | }
|
1074 | 1074 | ||
1075 | /**
|
1075 | /**
|
1076 | * Обновление информации о схеме репозитория
|
1076 | * Обновление информации о схеме репозитория
|
1077 | *
|
1077 | *
|
1078 | * @author Alexander Wolf
|
1078 | * @author Alexander Wolf
|
1079 | * @category Core
|
1079 | * @category Core
|
1080 | *
|
1080 | *
|
1081 | * @param integer $schemeID
|
1081 | * @param integer $schemeID
|
1082 | * @param string $info
|
1082 | * @param string $info
|
1083 | * @return array
|
1083 | * @return array
|
1084 | */
|
1084 | */
|
1085 | public function updateScheme($schemeID, $info) { |
1085 | public function updateScheme($schemeID, $info) { |
1086 | $result = array(); |
1086 | $result = array(); |
1087 | $sSchemeID = $this->secure->checkInt($schemeID); |
1087 | $sSchemeID = $this->secure->checkInt($schemeID); |
1088 | $sScheme = $this->secure->checkStr($info); |
1088 | $sScheme = $this->secure->checkStr($info); |
1089 | 1089 | ||
1090 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
1090 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
1091 | $rq =& $this->db->query($query); |
1091 | $rq =& $this->db->query($query); |
1092 | if (PEAR::isError($this->db)) { |
1092 | if (PEAR::isError($this->db)) { |
1093 | $result["ERR"] = 1; |
1093 | $result["ERR"] = 1; |
1094 | $result["ERRINFO"] = $this->db->getMessage(); |
1094 | $result["ERRINFO"] = $this->db->getMessage(); |
1095 | } else { |
1095 | } else { |
1096 | $result["ERR"] = 0; |
1096 | $result["ERR"] = 0; |
1097 | }
|
1097 | }
|
1098 | 1098 | ||
1099 | return $result; |
1099 | return $result; |
1100 | }
|
1100 | }
|
1101 | 1101 | ||
1102 | /**
|
1102 | /**
|
1103 | * Вывод формы редактирования/добавления схем репозиториев
|
1103 | * Вывод формы редактирования/добавления схем репозиториев
|
1104 | *
|
1104 | *
|
1105 | * @author Alexander Wolf
|
1105 | * @author Alexander Wolf
|
1106 | * @category Core
|
1106 | * @category Core
|
1107 | *
|
1107 | *
|
1108 | * @param integer $schemeID
|
1108 | * @param integer $schemeID
|
1109 | * @param string $info
|
1109 | * @param string $info
|
1110 | * @return string
|
1110 | * @return string
|
1111 | */
|
1111 | */
|
1112 | public function showSchemeForm($schemeID = 0, $info = "") { |
1112 | public function showSchemeForm($schemeID = 0, $info = "") { |
1113 | $sSchemeID = $this->secure->checkInt($schemeID); |
1113 | $sSchemeID = $this->secure->checkInt($schemeID); |
1114 | $sInfo = $this->secure->checkStr($info, 1); |
1114 | $sInfo = $this->secure->checkStr($info, 1); |
1115 | if ($sInfo == "") { |
1115 | if ($sInfo == "") { |
1116 | $sInfo = "Схема репозитория"; |
1116 | $sInfo = "Схема репозитория"; |
1117 | }
|
1117 | }
|
1118 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1118 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1119 | if ($sSchemeID != 0) { |
1119 | if ($sSchemeID != 0) { |
1120 | // Режим редактирования
|
1120 | // Режим редактирования
|
1121 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1121 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1122 | $rq =& $this->db->query($query); |
1122 | $rq =& $this->db->query($query); |
1123 | $rq->fetchInto($element); |
1123 | $rq->fetchInto($element); |
1124 | }
|
1124 | }
|
1125 | 1125 | ||
1126 | $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n"; |
1126 | $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n"; |
1127 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1127 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1128 | 1128 | ||
1129 | return $show; |
1129 | return $show; |
1130 | }
|
1130 | }
|
1131 | 1131 | ||
1132 | /**
|
1132 | /**
|
1133 | * Вывод списка протоколов
|
1133 | * Вывод списка протоколов
|
1134 | *
|
1134 | *
|
1135 | * @author Alexander Wolf
|
1135 | * @author Alexander Wolf
|
1136 | * @category Core
|
1136 | * @category Core
|
1137 | *
|
1137 | *
|
1138 | * @param string $name
|
1138 | * @param string $name
|
1139 | * @param string $actor
|
1139 | * @param string $actor
|
1140 | * @param string $format
|
1140 | * @param string $format
|
1141 | * @return string
|
1141 | * @return string
|
1142 | */
|
1142 | */
|
1143 | public function showProtoList($name, $actor, $format = 'list') { |
1143 | public function showProtoList($name, $actor, $format = 'list') { |
1144 | switch($format) { |
1144 | switch($format) { |
1145 | case 'list': |
1145 | case 'list': |
1146 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1146 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1147 | $rq =& $this->db->query($query); |
1147 | $rq =& $this->db->query($query); |
1148 | $show = "<ul>\n"; |
1148 | $show = "<ul>\n"; |
1149 | while ($rq->fetchInto($element)) { |
1149 | while ($rq->fetchInto($element)) { |
1150 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["proto_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["proto_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["proto"],1)."</li>\n"; |
1150 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["proto_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["proto_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["proto"],1)."</li>\n"; |
1151 | }
|
1151 | }
|
1152 | $show .= "</ul>"; |
1152 | $show .= "</ul>"; |
1153 | break; |
1153 | break; |
1154 | case 'innerhtml': |
1154 | case 'innerhtml': |
1155 | $protoID = $this->secure->checkInt($actor); |
1155 | $protoID = $this->secure->checkInt($actor); |
1156 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1156 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1157 | $rq =& $this->db->query($query); |
1157 | $rq =& $this->db->query($query); |
1158 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1158 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1159 | while ($rq->fetchInto($element)) { |
1159 | while ($rq->fetchInto($element)) { |
1160 | if ($element["proto_id"]==$protoID) { |
1160 | if ($element["proto_id"]==$protoID) { |
1161 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1161 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1162 | } else { |
1162 | } else { |
1163 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1163 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1164 | }
|
1164 | }
|
1165 | }
|
1165 | }
|
1166 | $show .= "</select>"; |
1166 | $show .= "</select>"; |
1167 | break; |
1167 | break; |
1168 | }
|
1168 | }
|
1169 | return $show; |
1169 | return $show; |
1170 | }
|
1170 | }
|
1171 | 1171 | ||
1172 | /**
|
1172 | /**
|
1173 | * Добавление нового протокола
|
1173 | * Добавление нового протокола
|
1174 | *
|
1174 | *
|
1175 | * @author Alexander Wolf
|
1175 | * @author Alexander Wolf
|
1176 | * @category Core
|
1176 | * @category Core
|
1177 | *
|
1177 | *
|
1178 | * @param string $proto
|
1178 | * @param string $proto
|
1179 | * @return array
|
1179 | * @return array
|
1180 | */
|
1180 | */
|
1181 | public function addProto($proto) { |
1181 | public function addProto($proto) { |
1182 | $result = array(); |
1182 | $result = array(); |
1183 | $sProto = $this->secure->checkStr($proto); |
1183 | $sProto = $this->secure->checkStr($proto); |
1184 | 1184 | ||
1185 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
1185 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
1186 | $rq =& $this->db->query($query); |
1186 | $rq =& $this->db->query($query); |
1187 | if (PEAR::isError($this->db)) { |
1187 | if (PEAR::isError($this->db)) { |
1188 | $result["ERR"] = 1; |
1188 | $result["ERR"] = 1; |
1189 | $result["ERRINFO"] = $this->db->getMessage(); |
1189 | $result["ERRINFO"] = $this->db->getMessage(); |
1190 | } else { |
1190 | } else { |
1191 | $result["ERR"] = 0; |
1191 | $result["ERR"] = 0; |
1192 | }
|
1192 | }
|
1193 | 1193 | ||
1194 | return $result; |
1194 | return $result; |
1195 | }
|
1195 | }
|
1196 | 1196 | ||
1197 | /**
|
1197 | /**
|
1198 | * Удаление информации о протоколе
|
1198 | * Удаление информации о протоколе
|
1199 | *
|
1199 | *
|
1200 | * @author Alexander Wolf
|
1200 | * @author Alexander Wolf
|
1201 | * @category Core
|
1201 | * @category Core
|
1202 | *
|
1202 | *
|
1203 | * @param integer $protoID
|
1203 | * @param integer $protoID
|
1204 | * @return array
|
1204 | * @return array
|
1205 | */
|
1205 | */
|
1206 | public function dropProto($protoID) { |
1206 | public function dropProto($protoID) { |
1207 | $result = array(); |
1207 | $result = array(); |
1208 | $sProtoID = $this->secure->checkInt($protoID); |
1208 | $sProtoID = $this->secure->checkInt($protoID); |
1209 | 1209 | ||
1210 | // Удаление протокола
|
1210 | // Удаление протокола
|
1211 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1211 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1212 | $rq =& $this->db->query($query); |
1212 | $rq =& $this->db->query($query); |
1213 | if (PEAR::isError($this->db)) { |
1213 | if (PEAR::isError($this->db)) { |
1214 | $result["ERR"] = 1; |
1214 | $result["ERR"] = 1; |
1215 | $result["ERRINFO"] = $this->db->getMessage(); |
1215 | $result["ERRINFO"] = $this->db->getMessage(); |
1216 | } else { |
1216 | } else { |
1217 | $result["ERR"] = 0; |
1217 | $result["ERR"] = 0; |
1218 | }
|
1218 | }
|
1219 | 1219 | ||
1220 | return $result; |
1220 | return $result; |
1221 | }
|
1221 | }
|
1222 | 1222 | ||
1223 | /**
|
1223 | /**
|
1224 | * Обновление информации о протоколе
|
1224 | * Обновление информации о протоколе
|
1225 | *
|
1225 | *
|
1226 | * @author Alexander Wolf
|
1226 | * @author Alexander Wolf
|
1227 | * @category Core
|
1227 | * @category Core
|
1228 | *
|
1228 | *
|
1229 | * @param integer $protoID
|
1229 | * @param integer $protoID
|
1230 | * @param string $info
|
1230 | * @param string $info
|
1231 | * @return array
|
1231 | * @return array
|
1232 | */
|
1232 | */
|
1233 | public function updateProto($protoID, $info) { |
1233 | public function updateProto($protoID, $info) { |
1234 | $result = array(); |
1234 | $result = array(); |
1235 | $sProtoID = $this->secure->checkInt($protoID); |
1235 | $sProtoID = $this->secure->checkInt($protoID); |
1236 | $sProto = $this->secure->checkStr($info); |
1236 | $sProto = $this->secure->checkStr($info); |
1237 | 1237 | ||
1238 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
1238 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
1239 | $rq =& $this->db->query($query); |
1239 | $rq =& $this->db->query($query); |
1240 | if (PEAR::isError($this->db)) { |
1240 | if (PEAR::isError($this->db)) { |
1241 | $result["ERR"] = 1; |
1241 | $result["ERR"] = 1; |
1242 | $result["ERRINFO"] = $this->db->getMessage(); |
1242 | $result["ERRINFO"] = $this->db->getMessage(); |
1243 | } else { |
1243 | } else { |
1244 | $result["ERR"] = 0; |
1244 | $result["ERR"] = 0; |
1245 | }
|
1245 | }
|
1246 | 1246 | ||
1247 | return $result; |
1247 | return $result; |
1248 | }
|
1248 | }
|
1249 | 1249 | ||
1250 | /**
|
1250 | /**
|
1251 | * Вывод формы редактирования/добавления протоколов
|
1251 | * Вывод формы редактирования/добавления протоколов
|
1252 | *
|
1252 | *
|
1253 | * @author Alexander Wolf
|
1253 | * @author Alexander Wolf
|
1254 | * @category Core
|
1254 | * @category Core
|
1255 | *
|
1255 | *
|
1256 | * @param integer $protoID
|
1256 | * @param integer $protoID
|
1257 | * @param string $info
|
1257 | * @param string $info
|
1258 | * @return string
|
1258 | * @return string
|
1259 | */
|
1259 | */
|
1260 | public function showProtoForm($protoID = 0, $info = "") { |
1260 | public function showProtoForm($protoID = 0, $info = "") { |
1261 | $sProtoID = $this->secure->checkInt($protoID); |
1261 | $sProtoID = $this->secure->checkInt($protoID); |
1262 | $sInfo = $this->secure->checkStr($info, 1); |
1262 | $sInfo = $this->secure->checkStr($info, 1); |
1263 | if ($sInfo == "") { |
1263 | if ($sInfo == "") { |
1264 | $sInfo = "Протокол доступа"; |
1264 | $sInfo = "Протокол доступа"; |
1265 | }
|
1265 | }
|
1266 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1266 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1267 | if ($sProtoID != 0) { |
1267 | if ($sProtoID != 0) { |
1268 | // Режим редактирования
|
1268 | // Режим редактирования
|
1269 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1269 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1270 | $rq =& $this->db->query($query); |
1270 | $rq =& $this->db->query($query); |
1271 | $rq->fetchInto($element); |
1271 | $rq->fetchInto($element); |
1272 | }
|
1272 | }
|
1273 | 1273 | ||
1274 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
1274 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
1275 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1275 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1276 | 1276 | ||
1277 | return $show; |
1277 | return $show; |
1278 | }
|
1278 | }
|
1279 | 1279 | ||
1280 | /**
|
1280 | /**
|
1281 | * Вывод списка хостов
|
1281 | * Вывод списка хостов
|
1282 | *
|
1282 | *
|
1283 | * @author Alexander Wolf
|
1283 | * @author Alexander Wolf
|
1284 | * @category Core
|
1284 | * @category Core
|
1285 | *
|
1285 | *
|
1286 | * @param string $name
|
1286 | * @param string $name
|
1287 | * @param string $actor
|
1287 | * @param string $actor
|
1288 | * @param string $format
|
1288 | * @param string $format
|
1289 | * @return string
|
1289 | * @return string
|
1290 | */
|
1290 | */
|
1291 | public function showHostsList($name, $actor, $format = 'list') { |
1291 | public function showHostsList($name, $actor, $format = 'list') { |
1292 | switch($format) { |
1292 | switch($format) { |
1293 | case 'list': |
1293 | case 'list': |
1294 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1294 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1295 | $rq =& $this->db->query($query); |
1295 | $rq =& $this->db->query($query); |
1296 | $show = "<ul>\n"; |
1296 | $show = "<ul>\n"; |
1297 | while ($rq->fetchInto($element)) { |
1297 | while ($rq->fetchInto($element)) { |
1298 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["rhost_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["rhost_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["rhost"],1)."</li>\n"; |
1298 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["rhost_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["rhost_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["rhost"],1)."</li>\n"; |
1299 | }
|
1299 | }
|
1300 | $show .= "</ul>"; |
1300 | $show .= "</ul>"; |
1301 | break; |
1301 | break; |
1302 | case 'innerhtml': |
1302 | case 'innerhtml': |
1303 | $hostID = $this->secure->checkInt($actor); |
1303 | $hostID = $this->secure->checkInt($actor); |
1304 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1304 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1305 | $rq =& $this->db->query($query); |
1305 | $rq =& $this->db->query($query); |
1306 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1306 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1307 | while ($rq->fetchInto($element)) { |
1307 | while ($rq->fetchInto($element)) { |
1308 | if ($element["rhost_id"]==$hostID) { |
1308 | if ($element["rhost_id"]==$hostID) { |
1309 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1309 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1310 | } else { |
1310 | } else { |
1311 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1311 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1312 | }
|
1312 | }
|
1313 | }
|
1313 | }
|
1314 | $show .= "</select>"; |
1314 | $show .= "</select>"; |
1315 | break; |
1315 | break; |
1316 | }
|
1316 | }
|
1317 | return $show; |
1317 | return $show; |
1318 | }
|
1318 | }
|
1319 | 1319 | ||
1320 | /**
|
1320 | /**
|
1321 | * Добавление нового хоста
|
1321 | * Добавление нового хоста
|
1322 | *
|
1322 | *
|
1323 | * @author Alexander Wolf
|
1323 | * @author Alexander Wolf
|
1324 | * @category Core
|
1324 | * @category Core
|
1325 | *
|
1325 | *
|
1326 | * @param string $host
|
1326 | * @param string $host
|
1327 | * @return array
|
1327 | * @return array
|
1328 | */
|
1328 | */
|
1329 | public function addHost($host) { |
1329 | public function addHost($host) { |
1330 | $result = array(); |
1330 | $result = array(); |
1331 | $sHost = $this->secure->checkStr($host); |
1331 | $sHost = $this->secure->checkStr($host); |
1332 | 1332 | ||
1333 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
1333 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
1334 | $rq =& $this->db->query($query); |
1334 | $rq =& $this->db->query($query); |
1335 | if (PEAR::isError($this->db)) { |
1335 | if (PEAR::isError($this->db)) { |
1336 | $result["ERR"] = 1; |
1336 | $result["ERR"] = 1; |
1337 | $result["ERRINFO"] = $this->db->getMessage(); |
1337 | $result["ERRINFO"] = $this->db->getMessage(); |
1338 | } else { |
1338 | } else { |
1339 | $result["ERR"] = 0; |
1339 | $result["ERR"] = 0; |
1340 | }
|
1340 | }
|
1341 | 1341 | ||
1342 | return $result; |
1342 | return $result; |
1343 | }
|
1343 | }
|
1344 | 1344 | ||
1345 | /**
|
1345 | /**
|
1346 | * Удаление информации о хосте
|
1346 | * Удаление информации о хосте
|
1347 | *
|
1347 | *
|
1348 | * @author Alexander Wolf
|
1348 | * @author Alexander Wolf
|
1349 | * @category Core
|
1349 | * @category Core
|
1350 | *
|
1350 | *
|
1351 | * @param integer $hostID
|
1351 | * @param integer $hostID
|
1352 | * @return array
|
1352 | * @return array
|
1353 | */
|
1353 | */
|
1354 | public function dropHost($hostID) { |
1354 | public function dropHost($hostID) { |
1355 | $result = array(); |
1355 | $result = array(); |
1356 | $sHostID = $this->secure->checkInt($hostID); |
1356 | $sHostID = $this->secure->checkInt($hostID); |
1357 | 1357 | ||
1358 | // Удаление хоста
|
1358 | // Удаление хоста
|
1359 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1359 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1360 | $rq =& $this->db->query($query); |
1360 | $rq =& $this->db->query($query); |
1361 | if (PEAR::isError($this->db)) { |
1361 | if (PEAR::isError($this->db)) { |
1362 | $result["ERR"] = 1; |
1362 | $result["ERR"] = 1; |
1363 | $result["ERRINFO"] = $this->db->getMessage(); |
1363 | $result["ERRINFO"] = $this->db->getMessage(); |
1364 | } else { |
1364 | } else { |
1365 | $result["ERR"] = 0; |
1365 | $result["ERR"] = 0; |
1366 | }
|
1366 | }
|
1367 | 1367 | ||
1368 | return $result; |
1368 | return $result; |
1369 | }
|
1369 | }
|
1370 | 1370 | ||
1371 | /**
|
1371 | /**
|
1372 | * Обновление информации о хосте
|
1372 | * Обновление информации о хосте
|
1373 | *
|
1373 | *
|
1374 | * @author Alexander Wolf
|
1374 | * @author Alexander Wolf
|
1375 | * @category Core
|
1375 | * @category Core
|
1376 | *
|
1376 | *
|
1377 | * @param integer $hostID
|
1377 | * @param integer $hostID
|
1378 | * @param string $info
|
1378 | * @param string $info
|
1379 | * @return array
|
1379 | * @return array
|
1380 | */
|
1380 | */
|
1381 | public function updateHost($hostID, $info) { |
1381 | public function updateHost($hostID, $info) { |
1382 | $result = array(); |
1382 | $result = array(); |
1383 | $sHostID = $this->secure->checkInt($hostID); |
1383 | $sHostID = $this->secure->checkInt($hostID); |
1384 | $sHost = $this->secure->checkStr($info); |
1384 | $sHost = $this->secure->checkStr($info); |
1385 | 1385 | ||
1386 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
1386 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
1387 | $rq =& $this->db->query($query); |
1387 | $rq =& $this->db->query($query); |
1388 | if (PEAR::isError($this->db)) { |
1388 | if (PEAR::isError($this->db)) { |
1389 | $result["ERR"] = 1; |
1389 | $result["ERR"] = 1; |
1390 | $result["ERRINFO"] = $this->db->getMessage(); |
1390 | $result["ERRINFO"] = $this->db->getMessage(); |
1391 | } else { |
1391 | } else { |
1392 | $result["ERR"] = 0; |
1392 | $result["ERR"] = 0; |
1393 | }
|
1393 | }
|
1394 | 1394 | ||
1395 | return $result; |
1395 | return $result; |
1396 | }
|
1396 | }
|
1397 | 1397 | ||
1398 | /**
|
1398 | /**
|
1399 | * Вывод формы редактирования/добавления хостов
|
1399 | * Вывод формы редактирования/добавления хостов
|
1400 | *
|
1400 | *
|
1401 | * @author Alexander Wolf
|
1401 | * @author Alexander Wolf
|
1402 | * @category Core
|
1402 | * @category Core
|
1403 | *
|
1403 | *
|
1404 | * @param integer $hostID
|
1404 | * @param integer $hostID
|
1405 | * @param string $info
|
1405 | * @param string $info
|
1406 | * @return string
|
1406 | * @return string
|
1407 | */
|
1407 | */
|
1408 | public function showHostForm($hostID = 0, $info = "") { |
1408 | public function showHostForm($hostID = 0, $info = "") { |
1409 | $sHostID = $this->secure->checkInt($hostID); |
1409 | $sHostID = $this->secure->checkInt($hostID); |
1410 | $sInfo = $this->secure->checkStr($info, 1); |
1410 | $sInfo = $this->secure->checkStr($info, 1); |
1411 | if ($sInfo == "") { |
1411 | if ($sInfo == "") { |
1412 | $sInfo = "Хост репозитория"; |
1412 | $sInfo = "Хост репозитория"; |
1413 | }
|
1413 | }
|
1414 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1414 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1415 | if ($sHostID != 0) { |
1415 | if ($sHostID != 0) { |
1416 | // Режим редактирования
|
1416 | // Режим редактирования
|
1417 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1417 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1418 | $rq =& $this->db->query($query); |
1418 | $rq =& $this->db->query($query); |
1419 | $rq->fetchInto($element); |
1419 | $rq->fetchInto($element); |
1420 | }
|
1420 | }
|
1421 | 1421 | ||
1422 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
1422 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
1423 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1423 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1424 | 1424 | ||
1425 | return $show; |
1425 | return $show; |
1426 | }
|
1426 | }
|
1427 | 1427 | ||
1428 | /**
|
1428 | /**
|
1429 | * Вывод списка корневых папок
|
1429 | * Вывод списка корневых папок
|
1430 | *
|
1430 | *
|
1431 | * @author Alexander Wolf
|
1431 | * @author Alexander Wolf
|
1432 | * @category Core
|
1432 | * @category Core
|
1433 | *
|
1433 | *
|
1434 | * @param string $name
|
1434 | * @param string $name
|
1435 | * @param string $actor
|
1435 | * @param string $actor
|
1436 | * @param string $format
|
1436 | * @param string $format
|
1437 | * @return string
|
1437 | * @return string
|
1438 | */
|
1438 | */
|
1439 | public function showFoldersList($name, $actor, $format = 'list') { |
1439 | public function showFoldersList($name, $actor, $format = 'list') { |
1440 | switch($format) { |
1440 | switch($format) { |
1441 | case 'list': |
1441 | case 'list': |
1442 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1442 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1443 | $rq =& $this->db->query($query); |
1443 | $rq =& $this->db->query($query); |
1444 | $show = "<ul>\n"; |
1444 | $show = "<ul>\n"; |
1445 | while ($rq->fetchInto($element)) { |
1445 | while ($rq->fetchInto($element)) { |
1446 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["rfolder_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["rfolder_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["rfolder"],1)."</li>\n"; |
1446 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["rfolder_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["rfolder_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["rfolder"],1)."</li>\n"; |
1447 | }
|
1447 | }
|
1448 | $show .= "</ul>"; |
1448 | $show .= "</ul>"; |
1449 | break; |
1449 | break; |
1450 | case 'innerhtml': |
1450 | case 'innerhtml': |
1451 | $folderID = $this->secure->checkInt($actor); |
1451 | $folderID = $this->secure->checkInt($actor); |
1452 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1452 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1453 | $rq =& $this->db->query($query); |
1453 | $rq =& $this->db->query($query); |
1454 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1454 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1455 | while ($rq->fetchInto($element)) { |
1455 | while ($rq->fetchInto($element)) { |
1456 | if ($element["rfolder_id"]==$folderID) { |
1456 | if ($element["rfolder_id"]==$folderID) { |
1457 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1457 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1458 | } else { |
1458 | } else { |
1459 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1459 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1460 | }
|
1460 | }
|
1461 | }
|
1461 | }
|
1462 | $show .= "</select>"; |
1462 | $show .= "</select>"; |
1463 | break; |
1463 | break; |
1464 | }
|
1464 | }
|
1465 | return $show; |
1465 | return $show; |
1466 | }
|
1466 | }
|
1467 | 1467 | ||
1468 | /**
|
1468 | /**
|
1469 | * Добавление нового корневого каталога
|
1469 | * Добавление нового корневого каталога
|
1470 | *
|
1470 | *
|
1471 | * @author Alexander Wolf
|
1471 | * @author Alexander Wolf
|
1472 | * @category Core
|
1472 | * @category Core
|
1473 | *
|
1473 | *
|
1474 | * @param string $flder
|
1474 | * @param string $flder
|
1475 | * @return array
|
1475 | * @return array
|
1476 | */
|
1476 | */
|
1477 | public function addFolder($folder) { |
1477 | public function addFolder($folder) { |
1478 | $result = array(); |
1478 | $result = array(); |
1479 | $sFolder = $this->secure->checkStr($folder); |
1479 | $sFolder = $this->secure->checkStr($folder); |
1480 | 1480 | ||
1481 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
1481 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
1482 | $rq =& $this->db->query($query); |
1482 | $rq =& $this->db->query($query); |
1483 | if (PEAR::isError($this->db)) { |
1483 | if (PEAR::isError($this->db)) { |
1484 | $result["ERR"] = 1; |
1484 | $result["ERR"] = 1; |
1485 | $result["ERRINFO"] = $this->db->getMessage(); |
1485 | $result["ERRINFO"] = $this->db->getMessage(); |
1486 | } else { |
1486 | } else { |
1487 | $result["ERR"] = 0; |
1487 | $result["ERR"] = 0; |
1488 | }
|
1488 | }
|
1489 | 1489 | ||
1490 | return $result; |
1490 | return $result; |
1491 | }
|
1491 | }
|
1492 | 1492 | ||
1493 | /**
|
1493 | /**
|
1494 | * Удаление информации о корневой папке
|
1494 | * Удаление информации о корневой папке
|
1495 | *
|
1495 | *
|
1496 | * @author Alexander Wolf
|
1496 | * @author Alexander Wolf
|
1497 | * @category Core
|
1497 | * @category Core
|
1498 | *
|
1498 | *
|
1499 | * @param integer $folderID
|
1499 | * @param integer $folderID
|
1500 | * @return array
|
1500 | * @return array
|
1501 | */
|
1501 | */
|
1502 | public function dropFolder($folderID) { |
1502 | public function dropFolder($folderID) { |
1503 | $result = array(); |
1503 | $result = array(); |
1504 | $sFolderID = $this->secure->checkInt($folderID); |
1504 | $sFolderID = $this->secure->checkInt($folderID); |
1505 | 1505 | ||
1506 | // Удаление корневой папки
|
1506 | // Удаление корневой папки
|
1507 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1507 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1508 | $rq =& $this->db->query($query); |
1508 | $rq =& $this->db->query($query); |
1509 | if (PEAR::isError($this->db)) { |
1509 | if (PEAR::isError($this->db)) { |
1510 | $result["ERR"] = 1; |
1510 | $result["ERR"] = 1; |
1511 | $result["ERRINFO"] = $this->db->getMessage(); |
1511 | $result["ERRINFO"] = $this->db->getMessage(); |
1512 | } else { |
1512 | } else { |
1513 | $result["ERR"] = 0; |
1513 | $result["ERR"] = 0; |
1514 | }
|
1514 | }
|
1515 | 1515 | ||
1516 | return $result; |
1516 | return $result; |
1517 | }
|
1517 | }
|
1518 | 1518 | ||
1519 | /**
|
1519 | /**
|
1520 | * Обновление информации о корневой папки
|
1520 | * Обновление информации о корневой папки
|
1521 | *
|
1521 | *
|
1522 | * @author Alexander Wolf
|
1522 | * @author Alexander Wolf
|
1523 | * @category Core
|
1523 | * @category Core
|
1524 | *
|
1524 | *
|
1525 | * @param integer $folderID
|
1525 | * @param integer $folderID
|
1526 | * @param string $info
|
1526 | * @param string $info
|
1527 | * @return array
|
1527 | * @return array
|
1528 | */
|
1528 | */
|
1529 | public function updateFolder($folderID, $info) { |
1529 | public function updateFolder($folderID, $info) { |
1530 | $result = array(); |
1530 | $result = array(); |
1531 | $sFolderID = $this->secure->checkInt($folderID); |
1531 | $sFolderID = $this->secure->checkInt($folderID); |
1532 | $sFolder = $this->secure->checkStr($info); |
1532 | $sFolder = $this->secure->checkStr($info); |
1533 | 1533 | ||
1534 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
1534 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
1535 | $rq =& $this->db->query($query); |
1535 | $rq =& $this->db->query($query); |
1536 | if (PEAR::isError($this->db)) { |
1536 | if (PEAR::isError($this->db)) { |
1537 | $result["ERR"] = 1; |
1537 | $result["ERR"] = 1; |
1538 | $result["ERRINFO"] = $this->db->getMessage(); |
1538 | $result["ERRINFO"] = $this->db->getMessage(); |
1539 | } else { |
1539 | } else { |
1540 | $result["ERR"] = 0; |
1540 | $result["ERR"] = 0; |
1541 | }
|
1541 | }
|
1542 | 1542 | ||
1543 | return $result; |
1543 | return $result; |
1544 | }
|
1544 | }
|
1545 | 1545 | ||
1546 | /**
|
1546 | /**
|
1547 | * Вывод формы редактирования/добавления корневых папок
|
1547 | * Вывод формы редактирования/добавления корневых папок
|
1548 | *
|
1548 | *
|
1549 | * @author Alexander Wolf
|
1549 | * @author Alexander Wolf
|
1550 | * @category Core
|
1550 | * @category Core
|
1551 | *
|
1551 | *
|
1552 | * @param integer $folderID
|
1552 | * @param integer $folderID
|
1553 | * @param string $info
|
1553 | * @param string $info
|
1554 | * @return string
|
1554 | * @return string
|
1555 | */
|
1555 | */
|
1556 | public function showFolderForm($folderID = 0, $info = "") { |
1556 | public function showFolderForm($folderID = 0, $info = "") { |
1557 | $sFolderID = $this->secure->checkInt($folderID); |
1557 | $sFolderID = $this->secure->checkInt($folderID); |
1558 | $sInfo = $this->secure->checkStr($info, 1); |
1558 | $sInfo = $this->secure->checkStr($info, 1); |
1559 | if ($sInfo == "") { |
1559 | if ($sInfo == "") { |
1560 | $sInfo = "Корневая папка"; |
1560 | $sInfo = "Корневая папка"; |
1561 | }
|
1561 | }
|
1562 | if ($sFolderID != 0) { |
1562 | if ($sFolderID != 0) { |
1563 | // Режим редактирования
|
1563 | // Режим редактирования
|
1564 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1564 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1565 | $rq =& $this->db->query($query); |
1565 | $rq =& $this->db->query($query); |
1566 | $rq->fetchInto($element); |
1566 | $rq->fetchInto($element); |
1567 | }
|
1567 | }
|
1568 | 1568 | ||
1569 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1569 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1570 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
1570 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
1571 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1571 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1572 | 1572 | ||
1573 | return $show; |
1573 | return $show; |
1574 | }
|
1574 | }
|
1575 | 1575 | ||
1576 | /**
|
1576 | /**
|
1577 | * Показывает список подписей
|
1577 | * Показывает список подписей
|
1578 | *
|
1578 | *
|
1579 | * @author Alexander Wolf
|
1579 | * @author Alexander Wolf
|
1580 | * @category Core
|
1580 | * @category Core
|
1581 | *
|
1581 | *
|
1582 | * @param string $name
|
1582 | * @param string $name
|
1583 | * @param string $actor
|
1583 | * @param string $actor
|
1584 | * @param string $format
|
1584 | * @param string $format
|
1585 | * @return string
|
1585 | * @return string
|
1586 | */
|
1586 | */
|
1587 | public function showSignsList($name, $actor, $format = 'list') { |
1587 | public function showSignsList($name, $actor, $format = 'list') { |
1588 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1588 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1589 | $rq =& $this->db->query($query); |
1589 | $rq =& $this->db->query($query); |
1590 | switch ($format) { |
1590 | switch ($format) { |
1591 | case 'list': |
1591 | case 'list': |
1592 | $show = "<ul>\n"; |
1592 | $show = "<ul>\n"; |
1593 | while ($rq->fetchInto($element)) { |
1593 | while ($rq->fetchInto($element)) { |
1594 | $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"; |
1594 | $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"; |
1595 | }
|
1595 | }
|
1596 | $show .= "</ul>"; |
1596 | $show .= "</ul>"; |
1597 | break; |
1597 | break; |
1598 | case 'innerhtml': |
1598 | case 'innerhtml': |
1599 | $signID = $this->secure->checkInt($actor); |
1599 | $signID = $this->secure->checkInt($actor); |
1600 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1600 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1601 | $show .= "<option value='0'>Подписи нет</option>\n"; |
1601 | $show .= "<option value='0'>Подписи нет</option>\n"; |
1602 | while ($rq->fetchInto($element)) { |
1602 | while ($rq->fetchInto($element)) { |
1603 | if ($element["sign_id"]==$signID) { |
1603 | if ($element["sign_id"]==$signID) { |
1604 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1604 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1605 | } else { |
1605 | } else { |
1606 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1606 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1607 | }
|
1607 | }
|
1608 | }
|
1608 | }
|
1609 | $show .= "</select>\n"; |
1609 | $show .= "</select>\n"; |
1610 | break; |
1610 | break; |
1611 | }
|
1611 | }
|
1612 | 1612 | ||
1613 | return $show; |
1613 | return $show; |
1614 | }
|
1614 | }
|
1615 | 1615 | ||
1616 | /**
|
1616 | /**
|
1617 | * Вывод формы редактирования/добавления подписей
|
1617 | * Вывод формы редактирования/добавления подписей
|
1618 | *
|
1618 | *
|
1619 | * @author Alexander Wolf
|
1619 | * @author Alexander Wolf
|
1620 | * @category Core
|
1620 | * @category Core
|
1621 | *
|
1621 | *
|
1622 | * @param integer $sectionID
|
1622 | * @param integer $sectionID
|
1623 | * @param string $info
|
1623 | * @param string $info
|
1624 | * @return string
|
1624 | * @return string
|
1625 | */
|
1625 | */
|
1626 | public function showSignsForm($signID = 0, $info = "") { |
1626 | public function showSignsForm($signID = 0, $info = "") { |
1627 | $sSignID = $this->secure->checkInt($signID); |
1627 | $sSignID = $this->secure->checkInt($signID); |
1628 | $sInfo = $this->secure->checkStr($info, 1); |
1628 | $sInfo = $this->secure->checkStr($info, 1); |
1629 | if ($sInfo == "") { |
1629 | if ($sInfo == "") { |
1630 | $sInfo = "Подписи"; |
1630 | $sInfo = "Подписи"; |
1631 | }
|
1631 | }
|
1632 | if ($sSignID != 0) { |
1632 | if ($sSignID != 0) { |
1633 | // Режим редактирования
|
1633 | // Режим редактирования
|
1634 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1634 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1635 | $rq =& $this->db->query($query); |
1635 | $rq =& $this->db->query($query); |
1636 | $rq->fetchInto($element); |
1636 | $rq->fetchInto($element); |
1637 | }
|
1637 | }
|
1638 | 1638 | ||
1639 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1639 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1640 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
1640 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
1641 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
1641 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
1642 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1642 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1643 | 1643 | ||
1644 | return $show; |
1644 | return $show; |
1645 | }
|
1645 | }
|
1646 | 1646 | ||
1647 | /**
|
1647 | /**
|
1648 | * Обновление информации о секции
|
1648 | * Обновление информации о секции
|
1649 | *
|
1649 | *
|
1650 | * @author Alexander Wolf
|
1650 | * @author Alexander Wolf
|
1651 | * @category Core
|
1651 | * @category Core
|
1652 | *
|
1652 | *
|
1653 | * @param integer $sectionID
|
1653 | * @param integer $sectionID
|
1654 | * @param string $sname
|
1654 | * @param string $sname
|
1655 | * @param string $sinfo
|
1655 | * @param string $sinfo
|
1656 | * @return array
|
1656 | * @return array
|
1657 | */
|
1657 | */
|
1658 | public function updateSign($signID, $sname, $sinfo = "") { |
1658 | public function updateSign($signID, $sname, $sinfo = "") { |
1659 | $result = array(); |
1659 | $result = array(); |
1660 | $sSignID = $this->secure->checkInt($signID); |
1660 | $sSignID = $this->secure->checkInt($signID); |
1661 | $sSName = $this->secure->checkStr($sname); |
1661 | $sSName = $this->secure->checkStr($sname); |
1662 | $sSInfo = $this->secure->checkStr($sinfo); |
1662 | $sSInfo = $this->secure->checkStr($sinfo); |
1663 | 1663 | ||
1664 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
1664 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
1665 | $rq =& $this->db->query($query); |
1665 | $rq =& $this->db->query($query); |
1666 | if (PEAR::isError($this->db)) { |
1666 | if (PEAR::isError($this->db)) { |
1667 | $result["ERR"] = 1; |
1667 | $result["ERR"] = 1; |
1668 | $result["ERRINFO"] = $this->db->getMessage(); |
1668 | $result["ERRINFO"] = $this->db->getMessage(); |
1669 | } else { |
1669 | } else { |
1670 | $result["ERR"] = 0; |
1670 | $result["ERR"] = 0; |
1671 | }
|
1671 | }
|
1672 | 1672 | ||
1673 | return $result; |
1673 | return $result; |
1674 | }
|
1674 | }
|
1675 | 1675 | ||
1676 | /**
|
1676 | /**
|
1677 | * Удаление информации о подписи
|
1677 | * Удаление информации о подписи
|
1678 | *
|
1678 | *
|
1679 | * @author Alexander Wolf
|
1679 | * @author Alexander Wolf
|
1680 | * @category Core
|
1680 | * @category Core
|
1681 | *
|
1681 | *
|
1682 | * @param integer $sectionID
|
1682 | * @param integer $sectionID
|
1683 | * @return array
|
1683 | * @return array
|
1684 | */
|
1684 | */
|
1685 | public function dropSign($signID) { |
1685 | public function dropSign($signID) { |
1686 | $result = array(); |
1686 | $result = array(); |
1687 | $sSignID = $this->secure->checkInt($signID); |
1687 | $sSignID = $this->secure->checkInt($signID); |
1688 | 1688 | ||
1689 | // Удаление подписи
|
1689 | // Удаление подписи
|
1690 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1690 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1691 | $rq =& $this->db->query($query); |
1691 | $rq =& $this->db->query($query); |
1692 | if (PEAR::isError($this->db)) { |
1692 | if (PEAR::isError($this->db)) { |
1693 | $result["ERR"] = 1; |
1693 | $result["ERR"] = 1; |
1694 | $result["ERRINFO"] = $this->db->getMessage(); |
1694 | $result["ERRINFO"] = $this->db->getMessage(); |
1695 | } else { |
1695 | } else { |
1696 | $result["ERR"] = 0; |
1696 | $result["ERR"] = 0; |
1697 | }
|
1697 | }
|
1698 | 1698 | ||
1699 | return $result; |
1699 | return $result; |
1700 | }
|
1700 | }
|
1701 | 1701 | ||
1702 | /**
|
1702 | /**
|
1703 | * Добавление новой подписи
|
1703 | * Добавление новой подписи
|
1704 | *
|
1704 | *
|
1705 | * @author Alexander Wolf
|
1705 | * @author Alexander Wolf
|
1706 | * @category Core
|
1706 | * @category Core
|
1707 | *
|
1707 | *
|
1708 | * @param string $sname
|
1708 | * @param string $sname
|
1709 | * @param string $sinfo
|
1709 | * @param string $sinfo
|
1710 | * @return array
|
1710 | * @return array
|
1711 | */
|
1711 | */
|
1712 | public function addSign($sname, $sinfo = "") { |
1712 | public function addSign($sname, $sinfo = "") { |
1713 | $result = array(); |
1713 | $result = array(); |
1714 | $sSName = $this->secure->checkStr($sname); |
1714 | $sSName = $this->secure->checkStr($sname); |
1715 | $sSInfo = $this->secure->checkStr($sinfo); |
1715 | $sSInfo = $this->secure->checkStr($sinfo); |
1716 | 1716 | ||
1717 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
1717 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
1718 | $rq =& $this->db->query($query); |
1718 | $rq =& $this->db->query($query); |
1719 | if (PEAR::isError($this->db)) { |
1719 | if (PEAR::isError($this->db)) { |
1720 | $result["ERR"] = 1; |
1720 | $result["ERR"] = 1; |
1721 | $result["ERRINFO"] = $this->db->getMessage(); |
1721 | $result["ERRINFO"] = $this->db->getMessage(); |
1722 | } else { |
1722 | } else { |
1723 | $result["ERR"] = 0; |
1723 | $result["ERR"] = 0; |
1724 | }
|
1724 | }
|
1725 | 1725 | ||
1726 | return $result; |
1726 | return $result; |
1727 | }
|
1727 | }
|
1728 | 1728 | ||
1729 | /**
|
1729 | /**
|
1730 | * Проверка пароля (из формы авторизации)
|
1730 | * Проверка пароля (из формы авторизации)
|
1731 | *
|
1731 | *
|
1732 | * @author Alexander Wolf
|
1732 | * @author Alexander Wolf
|
1733 | * @category Core
|
1733 | * @category Core
|
1734 | *
|
1734 | *
|
1735 | * @param string $word
|
1735 | * @param string $word
|
1736 | * @return array
|
1736 | * @return array
|
1737 | */
|
1737 | */
|
1738 | public function checkSign($word) { |
1738 | public function checkSign($word) { |
1739 | $result = array(); |
1739 | $result = array(); |
1740 | 1740 | ||
1741 | $sHash = $this->secure->encryptStr($word); |
1741 | $sHash = $this->secure->encryptStr($word); |
1742 | $pwd = $this->getOption("passwd"); |
1742 | $pwd = $this->getOption("passwd"); |
1743 | if ($sHash == $pwd["OptValue"]) { |
1743 | if ($sHash == $pwd["OptValue"]) { |
1744 | $result["ERR"] = 0; |
1744 | $result["ERR"] = 0; |
1745 | $result["Location"] = "manager.php"; |
1745 | $result["Location"] = "manager.php"; |
1746 | setcookie($this->cookie, $sHash); |
1746 | setcookie($this->cookie, $sHash); |
1747 | } else { |
1747 | } else { |
1748 | $result["ERR"] = 1; |
1748 | $result["ERR"] = 1; |
1749 | $result["ERRINFO"] = "Password not valid"; |
1749 | $result["ERRINFO"] = "Password not valid"; |
1750 | $result["Location"] = "manager.php?error=1"; |
1750 | $result["Location"] = "manager.php?error=1"; |
1751 | }
|
1751 | }
|
1752 | 1752 | ||
1753 | return $result; |
1753 | return $result; |
1754 | }
|
1754 | }
|
1755 | 1755 | ||
1756 | /**
|
1756 | /**
|
1757 | * Проверка пароля (из cookies)
|
1757 | * Проверка пароля (из cookies)
|
1758 | *
|
1758 | *
|
1759 | * @author Alexander Wolf
|
1759 | * @author Alexander Wolf
|
1760 | * @category Core
|
1760 | * @category Core
|
1761 | *
|
1761 | *
|
1762 | * @param string $hash
|
1762 | * @param string $hash
|
1763 | * @return array
|
1763 | * @return array
|
1764 | */
|
1764 | */
|
1765 | public function checkCookieSign($hash) { |
1765 | public function checkCookieSign($hash) { |
1766 | $result = array(); |
1766 | $result = array(); |
1767 | 1767 | ||
1768 | $pwd = $this->getOption("passwd"); |
1768 | $pwd = $this->getOption("passwd"); |
1769 | if ($hash == $pwd["OptValue"]) { |
1769 | if ($hash == $pwd["OptValue"]) { |
1770 | $result["ERR"] = 0; |
1770 | $result["ERR"] = 0; |
1771 | } else { |
1771 | } else { |
1772 | $result["ERR"] = 1; |
1772 | $result["ERR"] = 1; |
1773 | $result["ERRINFO"] = "Hash not valid"; |
1773 | $result["ERRINFO"] = "Hash not valid"; |
1774 | $result["Location"] = "manager.php"; |
1774 | $result["Location"] = "manager.php"; |
1775 | }
|
1775 | }
|
1776 | 1776 | ||
1777 | return $result; |
1777 | return $result; |
1778 | }
|
1778 | }
|
1779 | 1779 | ||
1780 | /**
|
1780 | /**
|
1781 | * Форма ввода пароля
|
1781 | * Форма ввода пароля
|
1782 | *
|
1782 | *
|
1783 | * @author Alexander Wolf
|
1783 | * @author Alexander Wolf
|
1784 | * @category Core
|
1784 | * @category Core
|
1785 | *
|
1785 | *
|
1786 | * @return string
|
1786 | * @return string
|
1787 | */
|
1787 | */
|
1788 | public function showSigninForm() { |
1788 | public function showSigninForm() { |
1789 | $show = "<div id='regform'>"; |
1789 | $show = "<div id='regform'>"; |
1790 | $show .= "<form action='process.php' method='post'>\n"; |
1790 | $show .= "<form action='process.php' method='post'>\n"; |
1791 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1791 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1792 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
1792 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
1793 | $show .= "<input type='password' name='word' value=''>\n"; |
1793 | $show .= "<input type='password' name='word' value=''>\n"; |
1794 | $show .= "<input type='submit' value=' Войти '>\n"; |
1794 | $show .= "<input type='submit' value=' Войти '>\n"; |
1795 | $show .= "</fieldset>\n</form></div>\n"; |
1795 | $show .= "</fieldset>\n</form></div>\n"; |
1796 | 1796 | ||
1797 | return $show; |
1797 | return $show; |
1798 | }
|
1798 | }
|
1799 | 1799 | ||
1800 | /**
|
1800 | /**
|
1801 | * Обновление пароля
|
1801 | * Обновление пароля
|
1802 | *
|
1802 | *
|
1803 | * @author Alexander Wolf
|
1803 | * @author Alexander Wolf
|
1804 | * @category Core
|
1804 | * @category Core
|
1805 | *
|
1805 | *
|
1806 | * @param string $word1
|
1806 | * @param string $word1
|
1807 | * @param string $word2
|
1807 | * @param string $word2
|
1808 | * @return array
|
1808 | * @return array
|
1809 | */
|
1809 | */
|
1810 | public function updatePassword($word1, $word2) { |
1810 | public function updatePassword($word1, $word2) { |
1811 | $result = array(); |
1811 | $result = array(); |
1812 | 1812 | ||
1813 | if ($word1 == $word2) { |
1813 | if ($word1 == $word2) { |
1814 | $sWord = $this->secure->encryptStr($word1); |
1814 | $sWord = $this->secure->encryptStr($word1); |
1815 | $r = $this->setOption("passwd", $sWord); |
1815 | $r = $this->setOption("passwd", $sWord); |
1816 | $result = $r; |
1816 | $result = $r; |
1817 | } else { |
1817 | } else { |
1818 | $result["ERR"] = 1; |
1818 | $result["ERR"] = 1; |
1819 | $result["ERRINFO"] = "Passwords is mismatch"; |
1819 | $result["ERRINFO"] = "Passwords is mismatch"; |
1820 | }
|
1820 | }
|
1821 | 1821 | ||
1822 | return $result; |
1822 | return $result; |
1823 | }
|
1823 | }
|
1824 | 1824 | ||
1825 | /**
|
1825 | /**
|
1826 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
1826 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
1827 | *
|
1827 | *
|
1828 | * @author Alexander Wolf
|
1828 | * @author Alexander Wolf
|
1829 | * @category Core
|
1829 | * @category Core
|
1830 | *
|
1830 | *
|
1831 | * @param string $name
|
1831 | * @param string $name
|
1832 | * @param string $actor
|
1832 | * @param string $actor
|
1833 | * @param integer $versionID
|
1833 | * @param integer $versionID
|
1834 | * @return string
|
1834 | * @return string
|
1835 | */
|
1835 | */
|
1836 | public function showDistVersionsForm($versionID = 0, $info = '') { |
1836 | public function showDistVersionsForm($versionID = 0, $info = '') { |
1837 | $sVersionID = $this->secure->checkInt($versionID); |
1837 | $sVersionID = $this->secure->checkInt($versionID); |
1838 | $sInfo = $this->secure->checkStr($info, 1); |
1838 | $sInfo = $this->secure->checkStr($info, 1); |
1839 | if ($sInfo == "") { |
1839 | if ($sInfo == "") { |
1840 | $sInfo = "Версия дистрибутива"; |
1840 | $sInfo = "Версия дистрибутива"; |
1841 | }
|
1841 | }
|
1842 | if ($sVersionID != 0) { |
1842 | if ($sVersionID != 0) { |
1843 | // Режим редактирования
|
1843 | // Режим редактирования
|
1844 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'"; |
1844 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'"; |
1845 | $rq =& $this->db->query($query); |
1845 | $rq =& $this->db->query($query); |
1846 | $rq->fetchInto($element); |
1846 | $rq->fetchInto($element); |
1847 | }
|
1847 | }
|
1848 | 1848 | ||
1849 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1849 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1850 | if ($sVersionID != 0) { |
1850 | if ($sVersionID != 0) { |
1851 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
1851 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
1852 | } else { |
1852 | } else { |
1853 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
1853 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
1854 | }
|
1854 | }
|
1855 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1855 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1856 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
1856 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
1857 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
1857 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
1858 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
1858 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
1859 | 1859 | ||
1860 | return $show; |
1860 | return $show; |
1861 | }
|
1861 | }
|
1862 | 1862 | ||
1863 | /**
|
1863 | /**
|
1864 | * Парсер схемы адреса репозитория
|
1864 | * Парсер схемы адреса репозитория
|
1865 | * FIXME Возможно не потребуется
|
1865 | * FIXME Возможно не потребуется
|
1866 | *
|
1866 | *
|
1867 | * @author Alexander Wolf
|
1867 | * @author Alexander Wolf
|
1868 | * @category Core
|
1868 | * @category Core
|
1869 | *
|
1869 | *
|
1870 | * @param string $repstring
|
1870 | * @param string $repstring
|
1871 | * @return integer
|
1871 | * @return integer
|
1872 | */
|
1872 | */
|
1873 | public function repositoryParser($repstring) { |
1873 | public function repositoryParser($repstring) { |
1874 | $tokens = array(); |
1874 | $tokens = array(); |
1875 | $sections = array(); |
1875 | $sections = array(); |
1876 | $tokens = split(" ",$repstring); |
1876 | $tokens = split(" ",$repstring); |
1877 | 1877 | ||
1878 | if ($tokens[0] == "deb") { |
1878 | if ($tokens[0] == "deb") { |
1879 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1879 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1880 | $url = parse_url($tokens[1]); |
1880 | $url = parse_url($tokens[1]); |
1881 | $distr = $tokens[2]; |
1881 | $distr = $tokens[2]; |
1882 | 1882 | ||
1883 | for($i=3;$i<count($tokens);$i++) { |
1883 | for($i=3;$i<count($tokens);$i++) { |
1884 | $sections[] = $tokens[$i]; |
1884 | $sections[] = $tokens[$i]; |
1885 | }
|
1885 | }
|
1886 | } else { |
1886 | } else { |
1887 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1887 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1888 | if (stripos($tokens[1],"]")!=0) { |
1888 | if (stripos($tokens[1],"]")!=0) { |
1889 | $sign = $tokens[1]; |
1889 | $sign = $tokens[1]; |
1890 | $url = parse_url($tokens[2]); |
1890 | $url = parse_url($tokens[2]); |
1891 | $base = $tokens[3]; |
1891 | $base = $tokens[3]; |
1892 | $repname = $tokens[4]; |
1892 | $repname = $tokens[4]; |
1893 | } else { |
1893 | } else { |
1894 | $url = parse_url($tokens[1]); |
1894 | $url = parse_url($tokens[1]); |
1895 | $base = $tokens[2]; |
1895 | $base = $tokens[2]; |
1896 | $repname = $tokens[3]; |
1896 | $repname = $tokens[3]; |
1897 | }
|
1897 | }
|
1898 | }
|
1898 | }
|
1899 | 1899 | ||
1900 | $proto = $url["scheme"]."://"; |
1900 | $proto = $url["scheme"]."://"; |
1901 | $addr = $url["host"]; |
1901 | $addr = $url["host"]; |
1902 | if ($url["port"]!="") { |
1902 | if ($url["port"]!="") { |
1903 | $addr .= ":".$url["port"]; |
1903 | $addr .= ":".$url["port"]; |
1904 | }
|
1904 | }
|
1905 | $path = $url["path"]; |
1905 | $path = $url["path"]; |
1906 | 1906 | ||
1907 | return 0; |
1907 | return 0; |
1908 | }
|
1908 | }
|
1909 | 1909 | ||
1910 | /**
|
1910 | /**
|
1911 | * Выгрузка картинок логотипов дистрибутивов
|
1911 | * Выгрузка картинок логотипов дистрибутивов
|
1912 | *
|
1912 | *
|
1913 | * @author Alexander Wolf
|
1913 | * @author Alexander Wolf
|
1914 | * @category Core
|
1914 | * @category Core
|
1915 | *
|
1915 | *
|
1916 | * @param string $path
|
1916 | * @param string $path
|
1917 | * @param string $dist
|
1917 | * @param string $dist
|
1918 | * @param array $datafile
|
1918 | * @param array $datafile
|
1919 | * @return integer
|
1919 | * @return integer
|
1920 | */
|
1920 | */
|
1921 | public function uploadPicture($path, $dist, $datafile) { |
1921 | public function uploadPicture($path, $dist, $datafile) { |
1922 | $folder = $path.$dist."-orig.png"; |
1922 | $folder = $path.$dist."-orig.png"; |
1923 | $folderN = $path.$dist.".png"; |
1923 | $folderN = $path.$dist.".png"; |
1924 | $folderEM = $path.$dist."-em.png"; |
1924 | $folderEM = $path.$dist."-em.png"; |
1925 | 1925 | ||
1926 | $distlogo = 0; |
1926 | $distlogo = 0; |
1927 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1927 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1928 | chmod($folder, 0644); |
1928 | chmod($folder, 0644); |
1929 | list($width, $height) = GetImageSize($folder); |
1929 | list($width, $height) = GetImageSize($folder); |
1930 | $percent = 32/$height; |
1930 | $percent = 32/$height; |
1931 | $newwidth = $width * $percent; |
1931 | $newwidth = $width * $percent; |
1932 | $newheight = $height * $percent; |
1932 | $newheight = $height * $percent; |
1933 | 1933 | ||
1934 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1934 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1935 | $source = ImageCreateFromPNG($folder); |
1935 | $source = ImageCreateFromPNG($folder); |
1936 | 1936 | ||
1937 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1937 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1938 | ImagePNG($output, $folderEM); |
1938 | ImagePNG($output, $folderEM); |
1939 | 1939 | ||
1940 | $percent = 15/$height; |
1940 | $percent = 15/$height; |
1941 | $newwidth = $width * $percent; |
1941 | $newwidth = $width * $percent; |
1942 | $newheight = $height * $percent; |
1942 | $newheight = $height * $percent; |
1943 | 1943 | ||
1944 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1944 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1945 | 1945 | ||
1946 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1946 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1947 | ImagePNG($output, $folderN); |
1947 | ImagePNG($output, $folderN); |
1948 | 1948 | ||
1949 | unlink($folder); |
1949 | unlink($folder); |
1950 | $distlogo = 1; |
1950 | $distlogo = 1; |
1951 | }
|
1951 | }
|
1952 | return $distlogo; |
1952 | return $distlogo; |
1953 | }
|
1953 | }
|
1954 | 1954 | ||
1955 | /**
|
1955 | /**
|
1956 | * Показ списка репозиториев
|
1956 | * Показ списка репозиториев
|
1957 | *
|
1957 | *
|
1958 | * @author Alexander Wolf
|
1958 | * @author Alexander Wolf
|
1959 | * @category Core
|
1959 | * @category Core
|
1960 | *
|
1960 | *
|
1961 | * @param string $name
|
1961 | * @param string $name
|
1962 | * @param string $actor
|
1962 | * @param string $actor
|
1963 | * @param string $format
|
1963 | * @param string $format
|
1964 | * @return string
|
1964 | * @return string
|
1965 | */
|
1965 | */
|
1966 | public function showRepositoriesList($name, $actor, $format = 'list') { |
1966 | public function showRepositoriesList($name, $actor, $format = 'list') { |
1967 | $query = "SELECT r.*,rt.*,v.version_id,CONCAT(d.distname,' ',v.version,' “',v.vname,'”') AS fullname FROM ".$this->prefix."repository r "; |
1967 | $query = "SELECT r.*,rt.*,v.version_id,CONCAT(d.distname,' ',v.version,' “',v.vname,'”') AS fullname FROM ".$this->prefix."repository r "; |
1968 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
1968 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
1969 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version "; |
1969 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version "; |
1970 | $query .= "JOIN ".$this->prefix."distribution d ON d.dist_id=v.dist_id "; |
1970 | $query .= "JOIN ".$this->prefix."distribution d ON d.dist_id=v.dist_id "; |
1971 | $query .= "ORDER BY v.version_id,r.rep_id ASC"; |
1971 | $query .= "ORDER BY v.version_id,r.rep_id ASC"; |
1972 | $rq =& $this->db->query($query); |
1972 | $rq =& $this->db->query($query); |
1973 | $show = "<ul><li class='nomarker'></li>"; |
1973 | $show = "<ul><li class='nomarker'></li>"; |
1974 | $splitter = 0; |
1974 | $splitter = 0; |
1975 | while ($rq->fetchInto($element)) { |
1975 | while ($rq->fetchInto($element)) { |
1976 | if ($splitter != $this->secure->checkInt($element["version_id"])) { |
1976 | if ($splitter != $this->secure->checkInt($element["version_id"])) { |
1977 | $splitter = $this->secure->checkInt($element["version_id"]); |
1977 | $splitter = $this->secure->checkInt($element["version_id"]); |
1978 | $show .= "</ul><ul><li class='nomarker'><strong>Репозитории для ".$this->secure->checkStr($element["fullname"],1)."</strong></li>"; |
1978 | $show .= "</ul><ul><li class='nomarker'><strong>Репозитории для ".$this->secure->checkStr($element["fullname"],1)."</strong></li>"; |
1979 | }
|
1979 | }
|
1980 | $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)." (<em>".$this->secure->checkStr($element["rtype"],1)."</em>)</li>\n"; |
1980 | $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)." (<em>".$this->secure->checkStr($element["rtype"],1)."</em>)</li>\n"; |
1981 | }
|
1981 | }
|
1982 | $show .= "</ul>"; |
1982 | $show .= "</ul>"; |
1983 | return $show; |
1983 | return $show; |
1984 | }
|
1984 | }
|
1985 | 1985 | ||
1986 | /**
|
1986 | /**
|
1987 | * Вывод списка типов репозиториев
|
1987 | * Вывод списка типов репозиториев
|
1988 | *
|
1988 | *
|
1989 | * @author Alexander Wolf
|
1989 | * @author Alexander Wolf
|
1990 | * @category Core
|
1990 | * @category Core
|
1991 | *
|
1991 | *
|
1992 | * @param integer $reptype
|
1992 | * @param integer $reptype
|
1993 | * @param string $name
|
1993 | * @param string $name
|
1994 | * @return string
|
1994 | * @return string
|
1995 | */
|
1995 | */
|
1996 | public function showRepType($reptype = 0, $name = "") { |
1996 | public function showRepType($reptype = 0, $name = "") { |
1997 | $sRT = $this->secure->checkInt($reptype); |
1997 | $sRT = $this->secure->checkInt($reptype); |
1998 | $sNM = $this->secure->checkStr($name,1); |
1998 | $sNM = $this->secure->checkStr($name,1); |
1999 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
1999 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
2000 | $rq =& $this->db->query($query); |
2000 | $rq =& $this->db->query($query); |
2001 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
2001 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
2002 | while ($rq->fetchInto($element)) { |
2002 | while ($rq->fetchInto($element)) { |
2003 | if ($element["rtype_id"]==$sRT) { |
2003 | if ($element["rtype_id"]==$sRT) { |
2004 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
2004 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
2005 | } else { |
2005 | } else { |
2006 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
2006 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
2007 | }
|
2007 | }
|
2008 | }
|
2008 | }
|
2009 | $show .= "</select>"; |
2009 | $show .= "</select>"; |
2010 | 2010 | ||
2011 | return $show; |
2011 | return $show; |
2012 | }
|
2012 | }
|
2013 | 2013 | ||
2014 | /**
|
2014 | /**
|
2015 | * Вывод списка версий дистрибутивов
|
2015 | * Вывод списка версий дистрибутивов
|
2016 | *
|
2016 | *
|
2017 | * @author Alexander Wolf
|
2017 | * @author Alexander Wolf
|
2018 | * @category Core
|
2018 | * @category Core
|
2019 | *
|
2019 | *
|
2020 | * @param string $name
|
2020 | * @param string $name
|
2021 | * @param integer $versionID
|
2021 | * @param integer $versionID
|
2022 | * @return string
|
2022 | * @return string
|
2023 | */
|
2023 | */
|
2024 | public function showVDList($name, $versionID = 0) { |
2024 | public function showVDList($name, $versionID = 0) { |
2025 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
2025 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
2026 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
2026 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
2027 | $rq =& $this->db->query($query); |
2027 | $rq =& $this->db->query($query); |
2028 | $show = "<select name='".$name."' id='".$name."'>\n"; |
2028 | $show = "<select name='".$name."' id='".$name."'>\n"; |
2029 | while ($rq->fetchInto($element)) { |
2029 | while ($rq->fetchInto($element)) { |
2030 | if ($element["version_id"]==$versionID) { |
2030 | if ($element["version_id"]==$versionID) { |
2031 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
2031 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
2032 | } else { |
2032 | } else { |
2033 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
2033 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
2034 | }
|
2034 | }
|
2035 | }
|
2035 | }
|
2036 | $show .= "</select>"; |
2036 | $show .= "</select>"; |
2037 | return $show; |
2037 | return $show; |
2038 | }
|
2038 | }
|
2039 | 2039 | ||
2040 | /**
|
2040 | /**
|
2041 | * Форма создания/редактирвоания репозиториев
|
2041 | * Форма создания/редактирвоания репозиториев
|
2042 | *
|
2042 | *
|
2043 | * @author Alexander Wolf
|
2043 | * @author Alexander Wolf
|
2044 | * @category Core
|
2044 | * @category Core
|
2045 | *
|
2045 | *
|
2046 | * @param integer $repID
|
2046 | * @param integer $repID
|
2047 | * @param string $info
|
2047 | * @param string $info
|
2048 | * @param string $reptype
|
2048 | * @param string $reptype
|
2049 | * @return string
|
2049 | * @return string
|
2050 | */
|
2050 | */
|
2051 | public function showRepositoriesForm($repID = 0, $info = "") { |
2051 | public function showRepositoriesForm($repID = 0, $info = "") { |
2052 | $sRepID = $this->secure->checkInt($repID); |
2052 | $sRepID = $this->secure->checkInt($repID); |
2053 | $sInfo = $this->secure->checkStr($info, 1); |
2053 | $sInfo = $this->secure->checkStr($info, 1); |
2054 | if ($sInfo == "") { |
2054 | if ($sInfo == "") { |
2055 | $sInfo = "Репозиторий"; |
2055 | $sInfo = "Репозиторий"; |
2056 | }
|
2056 | }
|
2057 | if ($sRepID != 0) { |
2057 | if ($sRepID != 0) { |
2058 | // Режим редактирования
|
2058 | // Режим редактирования
|
2059 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
2059 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
2060 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
2060 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
2061 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
2061 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
2062 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
2062 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
2063 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
2063 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
2064 | $rq =& $this->db->query($query); |
2064 | $rq =& $this->db->query($query); |
2065 | $rq->fetchInto($element); |
2065 | $rq->fetchInto($element); |
2066 | }
|
2066 | }
|
2067 | 2067 | ||
2068 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
2068 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
2069 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
2069 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
2070 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value=\"".$this->secure->checkStr($element["repname"],1)."\"></div>\n"; |
2070 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value=\"".$this->secure->checkStr($element["repname"],1)."\"></div>\n"; |
2071 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value=\"".$this->secure->checkStr($element["repinfo"],1)."\"></div>\n"; |
2071 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value=\"".$this->secure->checkStr($element["repinfo"],1)."\"></div>\n"; |
2072 | $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value=\"".$this->secure->checkStr($element["repkey"],1)."\"></div>\n"; |
2072 | $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value=\"".$this->secure->checkStr($element["repkey"],1)."\"></div>\n"; |
2073 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
2073 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
2074 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
2074 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
2075 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
2075 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
2076 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
2076 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
2077 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
2077 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
2078 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
2078 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
2079 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
2079 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
2080 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
2080 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
2081 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
2081 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
2082 | 2082 | ||
2083 | return $show; |
2083 | return $show; |
2084 | }
|
2084 | }
|
2085 | 2085 | ||
2086 | /**
|
2086 | /**
|
2087 | * Добавление нового репозитория
|
2087 | * Добавление нового репозитория
|
2088 | *
|
2088 | *
|
2089 | * @author Alexander Wolf
|
2089 | * @author Alexander Wolf
|
2090 | * @category Core
|
2090 | * @category Core
|
2091 | *
|
2091 | *
|
2092 | * @param integer $verionID
|
2092 | * @param integer $verionID
|
2093 | * @param string $rname
|
2093 | * @param string $rname
|
2094 | * @param string $rinfo
|
2094 | * @param string $rinfo
|
2095 | * @param string $rkey
|
2095 | * @param string $rkey
|
2096 | * @param integer $proto
|
2096 | * @param integer $proto
|
2097 | * @param integer $rhost
|
2097 | * @param integer $rhost
|
2098 | * @param integer $rfolder
|
2098 | * @param integer $rfolder
|
2099 | * @param integer $rtype
|
2099 | * @param integer $rtype
|
2100 | * @param array $sections
|
2100 | * @param array $sections
|
2101 | * @param array $arch
|
2101 | * @param array $arch
|
2102 | * @param integer $scheme
|
2102 | * @param integer $scheme
|
2103 | * @param integer $sign
|
2103 | * @param integer $sign
|
2104 | * @return array
|
2104 | * @return array
|
2105 | */
|
2105 | */
|
2106 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
2106 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
2107 | $result = array(); |
2107 | $result = array(); |
2108 | $sVersionID = $this->secure->checkInt($verionID); |
2108 | $sVersionID = $this->secure->checkInt($verionID); |
2109 | $sRName = $this->secure->checkStr($rname); |
2109 | $sRName = $this->secure->checkStr($rname); |
2110 | $sRInfo = $this->secure->checkStr($rinfo); |
2110 | $sRInfo = $this->secure->checkStr($rinfo); |
2111 | $sRKey = $this->secure->checkStr($rkey); |
2111 | $sRKey = $this->secure->checkStr($rkey); |
2112 | $sProto = $this->secure->checkInt($proto); |
2112 | $sProto = $this->secure->checkInt($proto); |
2113 | $sRHost = $this->secure->checkInt($rhost); |
2113 | $sRHost = $this->secure->checkInt($rhost); |
2114 | $sRFolder = $this->secure->checkInt($rfolder); |
2114 | $sRFolder = $this->secure->checkInt($rfolder); |
2115 | $sRType = $this->secure->checkInt($rtype); |
2115 | $sRType = $this->secure->checkInt($rtype); |
2116 | $sRScheme = $this->secure->checkInt($scheme); |
2116 | $sRScheme = $this->secure->checkInt($scheme); |
2117 | $sRSign = $this->secure->checkInt($sign); |
2117 | $sRSign = $this->secure->checkInt($sign); |
2118 | 2118 | ||
2119 | $query = "INSERT INTO ".$this->prefix."repository SET proto_id='".$sProto."', rhost_id='".$sRHost."', rfolder_id='".$sRFolder."', version='".$sVersionID."', rtype_id='".$sRType."', scheme_id='".$sRScheme."', sign_id='".$sRSign."', repname='".$sRName."', repinfo='".$sRInfo."', repkey='".$sRKey."'"; |
2119 | $query = "INSERT INTO ".$this->prefix."repository SET proto_id='".$sProto."', rhost_id='".$sRHost."', rfolder_id='".$sRFolder."', version='".$sVersionID."', rtype_id='".$sRType."', scheme_id='".$sRScheme."', sign_id='".$sRSign."', repname='".$sRName."', repinfo='".$sRInfo."', repkey='".$sRKey."'"; |
2120 | $rq =& $this->db->query($query); |
2120 | $rq =& $this->db->query($query); |
2121 | 2121 | ||
2122 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
2122 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
2123 | $rq =& $this->db->query($query); |
2123 | $rq =& $this->db->query($query); |
2124 | $rq->fetchInto($repository); |
2124 | $rq->fetchInto($repository); |
2125 | 2125 | ||
2126 | for($i=0;$i<count($sections);$i++) { |
2126 | for($i=0;$i<count($sections);$i++) { |
2127 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
2127 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
2128 | $rq =& $this->db->query($query); |
2128 | $rq =& $this->db->query($query); |
2129 | }
|
2129 | }
|
2130 | 2130 | ||
2131 | for($i=0;$i<count($arch);$i++) { |
2131 | for($i=0;$i<count($arch);$i++) { |
2132 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
2132 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
2133 | $rq =& $this->db->query($query); |
2133 | $rq =& $this->db->query($query); |
2134 | }
|
2134 | }
|
2135 | 2135 | ||
2136 | if (PEAR::isError($this->db)) { |
2136 | if (PEAR::isError($this->db)) { |
2137 | $result["ERR"] = 1; |
2137 | $result["ERR"] = 1; |
2138 | $result["ERRINFO"] = $this->db->getMessage(); |
2138 | $result["ERRINFO"] = $this->db->getMessage(); |
2139 | } else { |
2139 | } else { |
2140 | $result["ERR"] = 0; |
2140 | $result["ERR"] = 0; |
2141 | }
|
2141 | }
|
2142 | 2142 | ||
2143 | return $result; |
2143 | return $result; |
2144 | }
|
2144 | }
|
2145 | 2145 | ||
2146 | /**
|
2146 | /**
|
2147 | * Обновление информации о репозитории
|
2147 | * Обновление информации о репозитории
|
2148 | *
|
2148 | *
|
2149 | * @author Alexander Wolf
|
2149 | * @author Alexander Wolf
|
2150 | * @category Core
|
2150 | * @category Core
|
2151 | *
|
2151 | *
|
2152 | * @param integer $repID
|
2152 | * @param integer $repID
|
2153 | * @param integer $verionID
|
2153 | * @param integer $verionID
|
2154 | * @param string $rname
|
2154 | * @param string $rname
|
2155 | * @param string $rinfo
|
2155 | * @param string $rinfo
|
2156 | * @param string $rkey
|
2156 | * @param string $rkey
|
2157 | * @param integer $proto
|
2157 | * @param integer $proto
|
2158 | * @param integer $rhost
|
2158 | * @param integer $rhost
|
2159 | * @param integer $rfolder
|
2159 | * @param integer $rfolder
|
2160 | * @param integer $rtype
|
2160 | * @param integer $rtype
|
2161 | * @param array $sections
|
2161 | * @param array $sections
|
2162 | * @param array $arch
|
2162 | * @param array $arch
|
2163 | * @param integer $scheme
|
2163 | * @param integer $scheme
|
2164 | * @param integer $sign
|
2164 | * @param integer $sign
|
2165 | * @return array
|
2165 | * @return array
|
2166 | */
|
2166 | */
|
2167 | public function updateRepository($repID, $verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
2167 | public function updateRepository($repID, $verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
2168 | $result = array(); |
2168 | $result = array(); |
2169 | $sRepID = $this->secure->checkInt($repID); |
2169 | $sRepID = $this->secure->checkInt($repID); |
2170 | $sVersionID = $this->secure->checkInt($verionID); |
2170 | $sVersionID = $this->secure->checkInt($verionID); |
2171 | $sRName = $this->secure->checkStr($rname); |
2171 | $sRName = $this->secure->checkStr($rname); |
2172 | $sRInfo = $this->secure->checkStr($rinfo); |
2172 | $sRInfo = $this->secure->checkStr($rinfo); |
2173 | $sRKey = $this->secure->checkStr($rkey); |
2173 | $sRKey = $this->secure->checkStr($rkey); |
2174 | $sProto = $this->secure->checkInt($proto); |
2174 | $sProto = $this->secure->checkInt($proto); |
2175 | $sRHost = $this->secure->checkInt($rhost); |
2175 | $sRHost = $this->secure->checkInt($rhost); |
2176 | $sRFolder = $this->secure->checkInt($rfolder); |
2176 | $sRFolder = $this->secure->checkInt($rfolder); |
2177 | $sRType = $this->secure->checkInt($rtype); |
2177 | $sRType = $this->secure->checkInt($rtype); |
2178 | $sRScheme = $this->secure->checkInt($scheme); |
2178 | $sRScheme = $this->secure->checkInt($scheme); |
2179 | $sRSign = $this->secure->checkInt($sign); |
2179 | $sRSign = $this->secure->checkInt($sign); |
2180 | 2180 | ||
2181 | $query = "UPDATE ".$this->prefix."repository SET proto_id='".$sProto."', rhost_id='".$sRHost."', rfolder_id='".$sRFolder."', version='".$sVersionID."', rtype_id='".$sRType."', scheme_id='".$sRScheme."', sign_id='".$sRSign."', repname='".$sRName."', repinfo='".$sRInfo."', repkey='".$sRKey."' WHERE rep_id='".$sRepID."'"; |
2181 | $query = "UPDATE ".$this->prefix."repository SET proto_id='".$sProto."', rhost_id='".$sRHost."', rfolder_id='".$sRFolder."', version='".$sVersionID."', rtype_id='".$sRType."', scheme_id='".$sRScheme."', sign_id='".$sRSign."', repname='".$sRName."', repinfo='".$sRInfo."', repkey='".$sRKey."' WHERE rep_id='".$sRepID."'"; |
2182 | $rq =& $this->db->query($query); |
2182 | $rq =& $this->db->query($query); |
2183 | 2183 | ||
2184 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
2184 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
2185 | $rq =& $this->db->query($query); |
2185 | $rq =& $this->db->query($query); |
2186 | for($i=0;$i<count($sections);$i++) { |
2186 | for($i=0;$i<count($sections);$i++) { |
2187 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$sRepID."', sect_id='".$sections[$i]."'"; |
2187 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$sRepID."', sect_id='".$sections[$i]."'"; |
2188 | $rq =& $this->db->query($query); |
2188 | $rq =& $this->db->query($query); |
2189 | }
|
2189 | }
|
2190 | 2190 | ||
2191 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
2191 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
2192 | $rq =& $this->db->query($query); |
2192 | $rq =& $this->db->query($query); |
2193 | for($i=0;$i<count($arch);$i++) { |
2193 | for($i=0;$i<count($arch);$i++) { |
2194 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$sRepID."', arch_id='".$arch[$i]."'"; |
2194 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$sRepID."', arch_id='".$arch[$i]."'"; |
2195 | $rq =& $this->db->query($query); |
2195 | $rq =& $this->db->query($query); |
2196 | }
|
2196 | }
|
2197 | 2197 | ||
2198 | if (PEAR::isError($this->db)) { |
2198 | if (PEAR::isError($this->db)) { |
2199 | $result["ERR"] = 1; |
2199 | $result["ERR"] = 1; |
2200 | $result["ERRINFO"] = $this->db->getMessage(); |
2200 | $result["ERRINFO"] = $this->db->getMessage(); |
2201 | } else { |
2201 | } else { |
2202 | $result["ERR"] = 0; |
2202 | $result["ERR"] = 0; |
2203 | }
|
2203 | }
|
2204 | 2204 | ||
2205 | return $result; |
2205 | return $result; |
2206 | }
|
2206 | }
|
2207 | 2207 | ||
2208 | /**
|
2208 | /**
|
2209 | * Удаление информации о репозитории
|
2209 | * Удаление информации о репозитории
|
2210 | *
|
2210 | *
|
2211 | * @author Alexander Wolf
|
2211 | * @author Alexander Wolf
|
2212 | * @category Core
|
2212 | * @category Core
|
2213 | *
|
2213 | *
|
2214 | * @param integer $repID
|
2214 | * @param integer $repID
|
2215 | * @return array
|
2215 | * @return array
|
2216 | */
|
2216 | */
|
2217 | public function dropRepository($repID) { |
2217 | public function dropRepository($repID) { |
2218 | $result = array(); |
2218 | $result = array(); |
2219 | $sRepID = $this->secure->checkInt($repID); |
2219 | $sRepID = $this->secure->checkInt($repID); |
2220 | 2220 | ||
2221 | // Удаление репозитория
|
2221 | // Удаление репозитория
|
2222 | $query = "DELETE FROM ".$this->prefix."repository WHERE rep_id='".$sRepID."'"; |
2222 | $query = "DELETE FROM ".$this->prefix."repository WHERE rep_id='".$sRepID."'"; |
2223 | $rq =& $this->db->query($query); |
2223 | $rq =& $this->db->query($query); |
2224 | if (PEAR::isError($this->db)) { |
2224 | if (PEAR::isError($this->db)) { |
2225 | $result["ERR"] = 1; |
2225 | $result["ERR"] = 1; |
2226 | $result["ERRINFO"] = $this->db->getMessage(); |
2226 | $result["ERRINFO"] = $this->db->getMessage(); |
2227 | } else { |
2227 | } else { |
2228 | $result["ERR"] = 0; |
2228 | $result["ERR"] = 0; |
2229 | }
|
2229 | }
|
2230 | 2230 | ||
2231 | // Удаление секций репозитория
|
2231 | // Удаление секций репозитория
|
2232 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
2232 | $query = "DELETE FROM ".$this->prefix."sect2rep WHERE rep_id='".$sRepID."'"; |
2233 | $rq =& $this->db->query($query); |
2233 | $rq =& $this->db->query($query); |
2234 | if (PEAR::isError($this->db)) { |
2234 | if (PEAR::isError($this->db)) { |
2235 | $result["ERR"] = 1; |
2235 | $result["ERR"] = 1; |
2236 | $result["ERRINFO"] = $this->db->getMessage(); |
2236 | $result["ERRINFO"] = $this->db->getMessage(); |
2237 | } else { |
2237 | } else { |
2238 | $result["ERR"] = 0; |
2238 | $result["ERR"] = 0; |
2239 | }
|
2239 | }
|
2240 | 2240 | ||
2241 | // Удаление архитектур репозитория
|
2241 | // Удаление архитектур репозитория
|
2242 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
2242 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE rep_id='".$sRepID."'"; |
2243 | $rq =& $this->db->query($query); |
2243 | $rq =& $this->db->query($query); |
2244 | if (PEAR::isError($this->db)) { |
2244 | if (PEAR::isError($this->db)) { |
2245 | $result["ERR"] = 1; |
2245 | $result["ERR"] = 1; |
2246 | $result["ERRINFO"] = $this->db->getMessage(); |
2246 | $result["ERRINFO"] = $this->db->getMessage(); |
2247 | } else { |
2247 | } else { |
2248 | $result["ERR"] = 0; |
2248 | $result["ERR"] = 0; |
2249 | }
|
2249 | }
|
2250 | 2250 | ||
2251 | return $result; |
2251 | return $result; |
2252 | }
|
2252 | }
|
2253 | 2253 | ||
2254 | }
|
2254 | }
|
2255 | 2255 | ||
2256 | ?>
|
2256 | ?>
|