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