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