Редакция 616 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 616 | Редакция 617 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | /**
|
3 | /**
|
4 | *
|
4 | *
|
5 | * Codename: ant-ng - generator of sources.list for apt-distributives
|
5 | * Codename: ant-ng - generator of sources.list for apt-distributives
|
6 | * http://alex-w.org.ru/p/antng/
|
6 | * http://alex-w.org.ru/p/antng/
|
7 | *
|
7 | *
|
8 | * Copyright (c) 2009 Alexander Wolf
|
8 | * Copyright (c) 2009 Alexander Wolf
|
9 | * Dual licensed under the MIT and GNU LGPL licenses.
|
9 | * Dual licensed under the MIT and GNU LGPL licenses.
|
10 | * http://alex-w.org.ru/p/antng/license
|
10 | * http://alex-w.org.ru/p/antng/license
|
11 | *
|
11 | *
|
12 | */
|
12 | */
|
13 | 13 | ||
14 | class Core { |
14 | class Core { |
15 | protected $db = NULL; |
15 | protected $db = NULL; |
16 | protected $prefix = NULL; |
16 | protected $prefix = NULL; |
17 | protected $secure = NULL; |
17 | protected $secure = NULL; |
18 | protected $cookie = NULL; |
18 | protected $cookie = NULL; |
19 | 19 | ||
20 | /**
|
20 | /**
|
21 | * Конструктор класса Core - ядро генератора
|
21 | * Конструктор класса Core - ядро генератора
|
22 | *
|
22 | *
|
23 | * @author Alexander Wolf
|
23 | * @author Alexander Wolf
|
24 | * @category Core
|
24 | * @category Core
|
25 | *
|
25 | *
|
26 | * @param string $database
|
26 | * @param string $database
|
27 | * @param string $prefix
|
27 | * @param string $prefix
|
28 | * @param object $secure
|
28 | * @param object $secure
|
29 | * @param string $cookie
|
29 | * @param string $cookie
|
30 | */
|
30 | */
|
31 | public function __construct($database, $prefix, $secure, $cookie) { |
31 | public function __construct($database, $prefix, $secure, $cookie) { |
32 | $this->db = $database; |
32 | $this->db = $database; |
33 | $this->prefix = $prefix; |
33 | $this->prefix = $prefix; |
34 | $this->secure = $secure; |
34 | $this->secure = $secure; |
35 | $this->cookie = $cookie; |
35 | $this->cookie = $cookie; |
36 | }
|
36 | }
|
37 | 37 | ||
38 | /**
|
38 | /**
|
39 | * Получение данных о настройке
|
39 | * Получение данных о настройке
|
40 | *
|
40 | *
|
41 | * @author Alexander Wolf
|
41 | * @author Alexander Wolf
|
42 | * @category Core
|
42 | * @category Core
|
43 | *
|
43 | *
|
44 | * @param string $attr
|
44 | * @param string $attr
|
45 | * @return array
|
45 | * @return array
|
46 | */
|
46 | */
|
47 | public function getOption($attr) { |
47 | public function getOption($attr) { |
48 | $result = array(); |
48 | $result = array(); |
49 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
49 | $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'"; |
50 | $rq =& $this->db->query($query); |
50 | $rq =& $this->db->query($query); |
51 | if ($rq->numRows()!=0) { |
51 | if ($rq->numRows()!=0) { |
52 | $rq->fetchInto($element); |
52 | $rq->fetchInto($element); |
53 | $result["ERR"] = 0; |
53 | $result["ERR"] = 0; |
54 | $result["OptValue"] = $element["optvalue"]; |
54 | $result["OptValue"] = $element["optvalue"]; |
55 | } else { |
55 | } else { |
56 | $result["ERR"] = 1; |
56 | $result["ERR"] = 1; |
57 | $result["ERRINFO"] = "Empty result"; |
57 | $result["ERRINFO"] = "Empty result"; |
58 | }
|
58 | }
|
59 | return $result; |
59 | return $result; |
60 | }
|
60 | }
|
61 | 61 | ||
62 | /**
|
62 | /**
|
63 | * Установка данных о настройке
|
63 | * Установка данных о настройке
|
64 | *
|
64 | *
|
65 | * @author Alexander Wolf
|
65 | * @author Alexander Wolf
|
66 | * @category Core
|
66 | * @category Core
|
67 | *
|
67 | *
|
68 | * @param string $attr
|
68 | * @param string $attr
|
69 | * @param string $value
|
69 | * @param string $value
|
70 | * @return array
|
70 | * @return array
|
71 | */
|
71 | */
|
72 | public function setOption($attr, $value) { |
72 | public function setOption($attr, $value) { |
73 | $result = array(); |
73 | $result = array(); |
74 | 74 | ||
75 | if ($attr != "passwd") { |
75 | if ($attr != "passwd") { |
76 | $sValue = $this->secure->checkStr($value); |
76 | $sValue = $this->secure->checkStr($value); |
77 | } else { |
77 | } else { |
78 | $sValue = $value; |
78 | $sValue = $value; |
79 | }
|
79 | }
|
80 | 80 | ||
81 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
81 | $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'"; |
82 | $rq =& $this->db->query($query); |
82 | $rq =& $this->db->query($query); |
83 | if (PEAR::isError($this->db)) { |
83 | if (PEAR::isError($this->db)) { |
84 | $result["ERR"] = 1; |
84 | $result["ERR"] = 1; |
85 | $result["ERRINFO"] = $this->db->getMessage(); |
85 | $result["ERRINFO"] = $this->db->getMessage(); |
86 | } else { |
86 | } else { |
87 | $result["ERR"] = 0; |
87 | $result["ERR"] = 0; |
88 | }
|
88 | }
|
89 | 89 | ||
90 | return $result; |
90 | return $result; |
91 | }
|
91 | }
|
92 | 92 | ||
93 | /**
|
93 | /**
|
94 | * Создание настройки
|
94 | * Создание настройки
|
95 | *
|
95 | *
|
96 | * @author Alexander Wolf
|
96 | * @author Alexander Wolf
|
97 | * @category Core
|
97 | * @category Core
|
98 | *
|
98 | *
|
99 | * @param string $attr
|
99 | * @param string $attr
|
100 | * @param string $value
|
100 | * @param string $value
|
101 | * @return array
|
101 | * @return array
|
102 | */
|
102 | */
|
103 | public function addOption($attr, $value) { |
103 | public function addOption($attr, $value) { |
104 | $result = array(); |
104 | $result = array(); |
105 | $sValue = $this->secure->checkStr($value); |
105 | $sValue = $this->secure->checkStr($value); |
106 | 106 | ||
107 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
107 | $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'"; |
108 | $rq =& $this->db->query($query); |
108 | $rq =& $this->db->query($query); |
109 | if (PEAR::isError($this->db)) { |
109 | if (PEAR::isError($this->db)) { |
110 | $result["ERR"] = 1; |
110 | $result["ERR"] = 1; |
111 | $result["ERRINFO"] = $this->db->getMessage(); |
111 | $result["ERRINFO"] = $this->db->getMessage(); |
112 | } else { |
112 | } else { |
113 | $result["ERR"] = 0; |
113 | $result["ERR"] = 0; |
114 | }
|
114 | }
|
115 | 115 | ||
116 | return $result; |
116 | return $result; |
117 | }
|
117 | }
|
118 | 118 | ||
119 | /**
|
119 | /**
|
120 | * Получение и отображение списка дистрибутвов
|
120 | * Получение и отображение списка дистрибутвов
|
121 | *
|
121 | *
|
122 | * @author Alexander Wolf
|
122 | * @author Alexander Wolf
|
123 | * @category Core
|
123 | * @category Core
|
124 | * @deprecated may be deprecated XXX
|
124 | * @deprecated may be deprecated XXX
|
125 | *
|
125 | *
|
126 | * @param string $name
|
126 | * @param string $name
|
127 | * @param string $heads
|
127 | * @param string $heads
|
128 | * @param string $info
|
128 | * @param string $info
|
129 | * @param string $format
|
129 | * @param string $format
|
130 | * @return string
|
130 | * @return string
|
131 | */
|
131 | */
|
132 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
132 | public function showDistributionList($name, $heads = "", $info = "", $format = 'html') { |
133 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
133 | $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC"; |
134 | $rq =& $this->db->query($query); |
134 | $rq =& $this->db->query($query); |
135 | switch ($format) { |
135 | switch ($format) { |
136 | case 'html': |
136 | case 'html': |
137 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
137 | $show = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
138 | $show .= "<option value=''>".$info."</option>\n"; |
138 | $show .= "<option value=''>".$info."</option>\n"; |
139 | while ($rq->fetchInto($element)) { |
139 | while ($rq->fetchInto($element)) { |
140 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
140 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
141 | }
|
141 | }
|
142 | $show .= "</select></fieldset>"; |
142 | $show .= "</select></fieldset>"; |
143 | break; |
143 | break; |
144 | case 'json': |
144 | case 'json': |
145 | $show = '[{value:"",text:"'.$info.'"}'; |
145 | $show = '[{value:"",text:"'.$info.'"}'; |
146 | while ($rq->fetchInto($element)) { |
146 | while ($rq->fetchInto($element)) { |
147 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
147 | $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}'; |
148 | }
|
148 | }
|
149 | $show .= ']'; |
149 | $show .= ']'; |
150 | break; |
150 | break; |
151 | case 'innerhtml': |
151 | case 'innerhtml': |
152 | $show = "<select id='".$name."' name='".$name."'>\n"; |
152 | $show = "<select id='".$name."' name='".$name."'>\n"; |
153 | while ($rq->fetchInto($element)) { |
153 | while ($rq->fetchInto($element)) { |
154 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
154 | $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n"; |
155 | }
|
155 | }
|
156 | $show .= "</select>"; |
156 | $show .= "</select>"; |
157 | break; |
157 | break; |
158 | case 'list': |
158 | case 'list': |
159 | $show = "<ul>"; |
159 | $show = "<ul>"; |
160 | while ($rq->fetchInto($element)) { |
160 | while ($rq->fetchInto($element)) { |
161 | $show .= "<li>[<a href='".$heads."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n"; |
161 | $show .= "<li>[<a href='".$heads."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n"; |
162 | }
|
162 | }
|
163 | $show .= "</ul>"; |
163 | $show .= "</ul>"; |
164 | break; |
164 | break; |
165 | }
|
165 | }
|
166 | return $show; |
166 | return $show; |
167 | }
|
167 | }
|
168 | 168 | ||
169 | /**
|
169 | /**
|
170 | * Получение названия дистрибутива
|
170 | * Получение названия дистрибутива
|
171 | *
|
171 | *
|
172 | * @author Alexander Wolf
|
172 | * @author Alexander Wolf
|
173 | * @category Core
|
173 | * @category Core
|
174 | *
|
174 | *
|
175 | * @param integer $distID
|
175 | * @param integer $distID
|
176 | * @return array
|
176 | * @return array
|
177 | */
|
177 | */
|
178 | public function getDistName($distID) { |
178 | public function getDistName($distID) { |
179 | $result = array(); |
179 | $result = array(); |
180 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
180 | $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'"; |
181 | $rq =& $this->db->query($query); |
181 | $rq =& $this->db->query($query); |
182 | if (PEAR::isError($this->db)) { |
182 | if (PEAR::isError($this->db)) { |
183 | $result["ERR"] = 1; |
183 | $result["ERR"] = 1; |
184 | $result["ERRINFO"] = $this->db->getMessage(); |
184 | $result["ERRINFO"] = $this->db->getMessage(); |
185 | } else { |
185 | } else { |
186 | $rq->fetchInto($element); |
186 | $rq->fetchInto($element); |
187 | $result["ERR"] = 0; |
187 | $result["ERR"] = 0; |
188 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
188 | $result["DistName"] = $this->secure->checkStr($element["distname"],1); |
189 | }
|
189 | }
|
190 | 190 | ||
191 | return $result; |
191 | return $result; |
192 | }
|
192 | }
|
193 | 193 | ||
194 | /**
|
194 | /**
|
195 | * Получение названия программы, ее версии и описания
|
195 | * Получение названия программы, ее версии и описания
|
196 | *
|
196 | *
|
197 | * @author Alexander Wolf
|
197 | * @author Alexander Wolf
|
198 | * @category Core
|
198 | * @category Core
|
199 | *
|
199 | *
|
200 | * @param string $attr
|
200 | * @param string $attr
|
201 | * @return string
|
201 | * @return string
|
202 | */
|
202 | */
|
203 | public function getEngineAttr($attr = 'codename') { |
203 | public function getEngineAttr($attr = 'codename') { |
204 | $cname = $this->getOption($attr); |
204 | $cname = $this->getOption($attr); |
205 | return $this->secure->checkStr($cname["OptValue"],1); |
205 | return $this->secure->checkStr($cname["OptValue"],1); |
206 | }
|
206 | }
|
207 | 207 | ||
208 | /**
|
208 | /**
|
209 | * Получение и отображение списка версий дистрибутива
|
209 | * Получение и отображение списка версий дистрибутива
|
210 | *
|
210 | *
|
211 | * @author Alexander Wolf
|
211 | * @author Alexander Wolf
|
212 | * @category Core
|
212 | * @category Core
|
213 | *
|
213 | *
|
214 | * @param string $name
|
214 | * @param string $name
|
215 | * @param integer $distID
|
215 | * @param integer $distID
|
216 | * @param string $format
|
216 | * @param string $format
|
217 | * @return string
|
217 | * @return string
|
218 | */
|
218 | */
|
219 | public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') { |
219 | public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') { |
220 | $distname = $this->getDistName($distID); |
220 | $distname = $this->getDistName($distID); |
221 | if ($distID == 0) { |
221 | if ($distID == 0) { |
222 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ORDER BY d.dist_id,v.version ASC"; |
222 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ORDER BY d.dist_id,v.version ASC"; |
223 | } else { |
223 | } else { |
224 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
224 | $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC"; |
225 | }
|
225 | }
|
226 | $rq =& $this->db->query($query); |
226 | $rq =& $this->db->query($query); |
227 | switch ($format) { |
227 | switch ($format) { |
228 | case 'html': |
228 | case 'html': |
229 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
229 | $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n"; |
230 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
230 | $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n"; |
231 | while ($rq->fetchInto($element)) { |
231 | while ($rq->fetchInto($element)) { |
232 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
232 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n"; |
233 | }
|
233 | }
|
234 | $show .= "</select></fieldset>"; |
234 | $show .= "</select></fieldset>"; |
235 | break; |
235 | break; |
236 | case 'json': |
236 | case 'json': |
237 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
237 | $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}'; |
238 | while ($rq->fetchInto($element)) { |
238 | while ($rq->fetchInto($element)) { |
239 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
239 | $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}'; |
240 | }
|
240 | }
|
241 | $show .= ']'; |
241 | $show .= ']'; |
242 | break; |
242 | break; |
243 | case 'list': |
243 | case 'list': |
244 | $show = "<ul>\n"; |
244 | $show = "<ul>\n"; |
245 | while ($rq->fetchInto($element)) { |
245 | while ($rq->fetchInto($element)) { |
246 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." “<em>".$this->secure->checkStr($element["vname"],1)."</em>”</li>\n"; |
246 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." “<em>".$this->secure->checkStr($element["vname"],1)."</em>”</li>\n"; |
247 | }
|
247 | }
|
248 | $show .= "</ul>"; |
248 | $show .= "</ul>"; |
249 | break; |
249 | break; |
250 | }
|
250 | }
|
251 | return $show; |
251 | return $show; |
252 | }
|
252 | }
|
253 | 253 | ||
254 | /**
|
254 | /**
|
255 | * Получение и отображение списка секций основного (официального) репозитория
|
255 | * Получение и отображение списка секций основного (официального) репозитория
|
256 | *
|
256 | *
|
257 | * @author Alexander Wolf
|
257 | * @author Alexander Wolf
|
258 | * @category Core
|
258 | * @category Core
|
259 | *
|
259 | *
|
260 | * @param integer $version
|
260 | * @param integer $version
|
261 | * @param string $format
|
261 | * @param string $format
|
262 | * @return string
|
262 | * @return string
|
263 | */
|
263 | */
|
264 | public function showBranchesList($version, $format = 'html') { |
264 | public function showBranchesList($version, $format = 'html') { |
265 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
265 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'"; |
266 | $rq =& $this->db->query($query); |
266 | $rq =& $this->db->query($query); |
267 | $rq->fetchInto($types); |
267 | $rq->fetchInto($types); |
268 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
268 | $query = "SELECT s.*,t.rtype FROM ".$this->prefix."section s "; |
269 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
269 | $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id "; |
270 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
270 | $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id "; |
271 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
271 | $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id "; |
272 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
272 | $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'"; |
273 | $rq =& $this->db->query($query); |
273 | $rq =& $this->db->query($query); |
274 | switch ($format) { |
274 | switch ($format) { |
275 | case 'html': |
275 | case 'html': |
276 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
276 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
277 | while ($rq->fetchInto($element)) { |
277 | while ($rq->fetchInto($element)) { |
278 | $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." — ".$this->secure->checkStr($element["sectinfo"],1)."</div>\n"; |
278 | $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." — ".$this->secure->checkStr($element["sectinfo"],1)."</div>\n"; |
279 | }
|
279 | }
|
280 | $show .= "</fieldset>\n"; |
280 | $show .= "</fieldset>\n"; |
281 | break; |
281 | break; |
282 | case 'json': |
282 | case 'json': |
283 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
283 | //TODO Доделать JSON-вывод списка секций основного репозитория
|
284 | break; |
284 | break; |
285 | }
|
285 | }
|
286 | 286 | ||
287 | return $show; |
287 | return $show; |
288 | }
|
288 | }
|
289 | 289 | ||
290 | /**
|
290 | /**
|
291 | * Получение и отображение списка репозиториев
|
291 | * Получение и отображение списка репозиториев
|
292 | *
|
292 | *
|
293 | * @author Alexander Wolf
|
293 | * @author Alexander Wolf
|
294 | * @category Core
|
294 | * @category Core
|
295 | *
|
295 | *
|
296 | * @param integer $version
|
296 | * @param integer $version
|
297 | * @param integer $reptype
|
297 | * @param integer $reptype
|
298 | * @param string $format
|
298 | * @param string $format
|
299 | * @return string
|
299 | * @return string
|
300 | */
|
300 | */
|
301 | public function showRepList($version, $reptype, $format = 'html') { |
301 | public function showRepList($version, $reptype, $format = 'html') { |
302 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
302 | $query = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'"; |
303 | $rq =& $this->db->query($query); |
303 | $rq =& $this->db->query($query); |
304 | $rq->fetchInto($types); |
304 | $rq->fetchInto($types); |
305 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
305 | $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'"; |
306 | $rq =& $this->db->query($query); |
306 | $rq =& $this->db->query($query); |
307 | switch ($format) { |
307 | switch ($format) { |
308 | case 'html': |
308 | case 'html': |
309 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
309 | $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n"; |
310 | while ($rq->fetchInto($element)) { |
310 | while ($rq->fetchInto($element)) { |
311 | $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." — ".$this->secure->checkStr($element["repinfo"],1)."</div>\n"; |
311 | $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." — ".$this->secure->checkStr($element["repinfo"],1)."</div>\n"; |
312 | }
|
312 | }
|
313 | $show .= "</fieldset>\n"; |
313 | $show .= "</fieldset>\n"; |
314 | break; |
314 | break; |
315 | case 'json': |
315 | case 'json': |
316 | //TODO Доделать JSON-вывод списка репозиториев
|
316 | //TODO Доделать JSON-вывод списка репозиториев
|
317 | break; |
317 | break; |
318 | }
|
318 | }
|
319 | 319 | ||
320 | return $show; |
320 | return $show; |
321 | }
|
321 | }
|
322 | 322 | ||
323 | /**
|
323 | /**
|
324 | * Добавление поддержки нового apt-дистрибутива
|
324 | * Добавление поддержки нового apt-дистрибутива
|
325 | *
|
325 | *
|
326 | * @author Alexander Wolf
|
326 | * @author Alexander Wolf
|
327 | * @category Core
|
327 | * @category Core
|
328 | *
|
328 | *
|
329 | * @param string $distname
|
329 | * @param string $distname
|
330 | * @param integer $disttype
|
330 | * @param integer $disttype
|
331 | * @param string $distua
|
331 | * @param string $distua
|
332 | * @param byte $distlogo
|
332 | * @param byte $distlogo
|
333 | * @return array
|
333 | * @return array
|
334 | */
|
334 | */
|
335 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
335 | public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) { |
336 | $result = array(); |
336 | $result = array(); |
337 | $sDName = $this->secure->checkStr($distname); |
337 | $sDName = $this->secure->checkStr($distname); |
338 | $sDType = $this->secure->checkInt($disttype); |
338 | $sDType = $this->secure->checkInt($disttype); |
339 | $sDUAgt = $this->secure->checkStr($distua); |
339 | $sDUAgt = $this->secure->checkStr($distua); |
340 | $sDLogo = $this->secure->checkInt($distlogo); |
340 | $sDLogo = $this->secure->checkInt($distlogo); |
341 | 341 | ||
342 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
342 | $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'"; |
343 | $rq =& $this->db->query($query); |
343 | $rq =& $this->db->query($query); |
344 | if (PEAR::isError($this->db)) { |
344 | if (PEAR::isError($this->db)) { |
345 | $result["ERR"] = 1; |
345 | $result["ERR"] = 1; |
346 | $result["ERRINFO"] = $this->db->getMessage(); |
346 | $result["ERRINFO"] = $this->db->getMessage(); |
347 | } else { |
347 | } else { |
348 | $result["ERR"] = 0; |
348 | $result["ERR"] = 0; |
349 | }
|
349 | }
|
350 | 350 | ||
351 | return $result; |
351 | return $result; |
352 | }
|
352 | }
|
353 | 353 | ||
354 | /**
|
354 | /**
|
355 | * Обновление информации о дистрибутиве
|
355 | * Обновление информации о дистрибутиве
|
356 | *
|
356 | *
|
357 | * @author Alexander Wolf
|
357 | * @author Alexander Wolf
|
358 | * @category Core
|
358 | * @category Core
|
359 | *
|
359 | *
|
360 | * @param integer $distID
|
360 | * @param integer $distID
|
361 | * @param string $distname
|
361 | * @param string $distname
|
362 | * @param integer $disttype
|
362 | * @param integer $disttype
|
363 | * @param string $distua
|
363 | * @param string $distua
|
364 | * @param integer $distlogo
|
364 | * @param integer $distlogo
|
365 | * @return array
|
365 | * @return array
|
366 | */
|
366 | */
|
367 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
367 | public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) { |
368 | $result = array(); |
368 | $result = array(); |
369 | $sDID = $this->secure->checkInt($distID); |
369 | $sDID = $this->secure->checkInt($distID); |
370 | $sDName = $this->secure->checkStr($distname); |
370 | $sDName = $this->secure->checkStr($distname); |
371 | $sDType = $this->secure->checkInt($disttype); |
371 | $sDType = $this->secure->checkInt($disttype); |
372 | $sDUAgt = $this->secure->checkStr($distua); |
372 | $sDUAgt = $this->secure->checkStr($distua); |
373 | $sDLogo = $this->secure->checkInt($distlogo); |
373 | $sDLogo = $this->secure->checkInt($distlogo); |
374 | 374 | ||
375 | if ($sDLogo!=0) { |
375 | if ($sDLogo!=0) { |
376 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
376 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'"; |
377 | } else { |
377 | } else { |
378 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
378 | $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'"; |
379 | }
|
379 | }
|
380 | $rq =& $this->db->query($query); |
380 | $rq =& $this->db->query($query); |
381 | if (PEAR::isError($this->db)) { |
381 | if (PEAR::isError($this->db)) { |
382 | $result["ERR"] = 1; |
382 | $result["ERR"] = 1; |
383 | $result["ERRINFO"] = $this->db->getMessage(); |
383 | $result["ERRINFO"] = $this->db->getMessage(); |
384 | } else { |
384 | } else { |
385 | $result["ERR"] = 0; |
385 | $result["ERR"] = 0; |
386 | }
|
386 | }
|
387 | 387 | ||
388 | return $result; |
388 | return $result; |
389 | }
|
389 | }
|
390 | 390 | ||
391 | /**
|
391 | /**
|
392 | * Удаление информации о дистрибутиве
|
392 | * Удаление информации о дистрибутиве
|
393 | *
|
393 | *
|
394 | * @author Alexander Wolf
|
394 | * @author Alexander Wolf
|
395 | * @category Core
|
395 | * @category Core
|
396 | *
|
396 | *
|
397 | * @param integer $distID
|
397 | * @param integer $distID
|
398 | * @return array
|
398 | * @return array
|
399 | */
|
399 | */
|
400 | public function dropDistribution($distID) { |
400 | public function dropDistribution($distID) { |
401 | $result = array(); |
401 | $result = array(); |
402 | $sDID = $this->secure->checkInt($distID); |
402 | $sDID = $this->secure->checkInt($distID); |
403 | 403 | ||
404 | // Удаление дистрибутива
|
404 | // Удаление дистрибутива
|
405 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
405 | $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'"; |
406 | $rq =& $this->db->query($query); |
406 | $rq =& $this->db->query($query); |
407 | if (PEAR::isError($this->db)) { |
407 | if (PEAR::isError($this->db)) { |
408 | $result["ERR"] = 1; |
408 | $result["ERR"] = 1; |
409 | $result["ERRINFO"] = $this->db->getMessage(); |
409 | $result["ERRINFO"] = $this->db->getMessage(); |
410 | } else { |
410 | } else { |
411 | $result["ERR"] = 0; |
411 | $result["ERR"] = 0; |
412 | }
|
412 | }
|
413 | 413 | ||
414 | // Удаление версий дистрибутива
|
414 | // Удаление версий дистрибутива
|
415 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
415 | $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'"; |
416 | $rq =& $this->db->query($query); |
416 | $rq =& $this->db->query($query); |
417 | if (PEAR::isError($this->db)) { |
417 | if (PEAR::isError($this->db)) { |
418 | $result["ERR"] = 1; |
418 | $result["ERR"] = 1; |
419 | $result["ERRINFO"] = $this->db->getMessage(); |
419 | $result["ERRINFO"] = $this->db->getMessage(); |
420 | } else { |
420 | } else { |
421 | $result["ERR"] = 0; |
421 | $result["ERR"] = 0; |
422 | }
|
422 | }
|
423 | 423 | ||
424 | return $result; |
424 | return $result; |
425 | }
|
425 | }
|
426 | 426 | ||
427 | /**
|
427 | /**
|
428 | * Добавление поддержки новой версии apt-дистрибутива
|
428 | * Добавление поддержки новой версии apt-дистрибутива
|
429 | *
|
429 | *
|
430 | * @author Alexander Wolf
|
430 | * @author Alexander Wolf
|
431 | * @category Core
|
431 | * @category Core
|
432 | *
|
432 | *
|
433 | * @param integer $distID
|
433 | * @param integer $distID
|
434 | * @param integer $version
|
434 | * @param integer $version
|
435 | * @param string $vname
|
435 | * @param string $vname
|
436 | * @param integer $vcodename
|
436 | * @param integer $vcodename
|
437 | * @return array
|
437 | * @return array
|
438 | */
|
438 | */
|
439 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
439 | public function addDistVersion($distID, $version, $vname = "", $vcodename = "") { |
440 | $result = array(); |
440 | $result = array(); |
441 | $sDistID = $this->secure->checkInt($distID); |
441 | $sDistID = $this->secure->checkInt($distID); |
442 | $sDVersion = $this->secure->checkStr($version); |
442 | $sDVersion = $this->secure->checkStr($version); |
443 | $sDVName = $this->secure->checkStr($vname); |
443 | $sDVName = $this->secure->checkStr($vname); |
444 | $sDVCName = $this->secure->checkStr($vcodename); |
444 | $sDVCName = $this->secure->checkStr($vcodename); |
445 | 445 | ||
446 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
446 | $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'"; |
447 | $rq =& $this->db->query($query); |
447 | $rq =& $this->db->query($query); |
448 | if (PEAR::isError($this->db)) { |
448 | if (PEAR::isError($this->db)) { |
449 | $result["ERR"] = 1; |
449 | $result["ERR"] = 1; |
450 | $result["ERRINFO"] = $this->db->getMessage(); |
450 | $result["ERRINFO"] = $this->db->getMessage(); |
451 | } else { |
451 | } else { |
452 | $result["ERR"] = 0; |
452 | $result["ERR"] = 0; |
453 | }
|
453 | }
|
454 | 454 | ||
455 | return $result; |
455 | return $result; |
456 | }
|
456 | }
|
457 | 457 | ||
458 | /**
|
458 | /**
|
459 | * Редактирование информации о версии дистрибутива
|
459 | * Редактирование информации о версии дистрибутива
|
460 | *
|
460 | *
|
461 | * @author Alexander Wolf
|
461 | * @author Alexander Wolf
|
462 | * @category Core
|
462 | * @category Core
|
463 | *
|
463 | *
|
464 | * @param integer $versionID
|
464 | * @param integer $versionID
|
465 | * @param string $version
|
465 | * @param string $version
|
466 | * @param string $vname
|
466 | * @param string $vname
|
467 | * @param string $vcodename
|
467 | * @param string $vcodename
|
468 | * @return array
|
468 | * @return array
|
469 | */
|
469 | */
|
470 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
470 | public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") { |
471 | $result = array(); |
471 | $result = array(); |
472 | $sVersID = $this->secure->checkInt($versionID); |
472 | $sVersID = $this->secure->checkInt($versionID); |
473 | $sDVersion = $this->secure->checkStr($version,1); |
473 | $sDVersion = $this->secure->checkStr($version,1); |
474 | $sDVName = $this->secure->checkStr($vname,1); |
474 | $sDVName = $this->secure->checkStr($vname,1); |
475 | $sDVCName = $this->secure->checkStr($vcodename,1); |
475 | $sDVCName = $this->secure->checkStr($vcodename,1); |
476 | 476 | ||
477 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
477 | $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'"; |
478 | $rq =& $this->db->query($query); |
478 | $rq =& $this->db->query($query); |
479 | if (PEAR::isError($this->db)) { |
479 | if (PEAR::isError($this->db)) { |
480 | $result["ERR"] = 1; |
480 | $result["ERR"] = 1; |
481 | $result["ERRINFO"] = $this->db->getMessage(); |
481 | $result["ERRINFO"] = $this->db->getMessage(); |
482 | } else { |
482 | } else { |
483 | $result["ERR"] = 0; |
483 | $result["ERR"] = 0; |
484 | }
|
484 | }
|
485 | 485 | ||
486 | return $result; |
486 | return $result; |
487 | }
|
487 | }
|
488 | 488 | ||
489 | /**
|
489 | /**
|
490 | * Удаление информации о версии дистрибутива
|
490 | * Удаление информации о версии дистрибутива
|
491 | *
|
491 | *
|
492 | * @author Alexander Wolf
|
492 | * @author Alexander Wolf
|
493 | * @category Core
|
493 | * @category Core
|
494 | *
|
494 | *
|
495 | * @param integer $versionID
|
495 | * @param integer $versionID
|
496 | * @return array
|
496 | * @return array
|
497 | */
|
497 | */
|
498 | public function dropDistVersion($versionID) { |
498 | public function dropDistVersion($versionID) { |
499 | $result = array(); |
499 | $result = array(); |
500 | $sVersID = $this->secure->checkInt($versionID); |
500 | $sVersID = $this->secure->checkInt($versionID); |
501 | 501 | ||
502 | // Удаление версии дистрибутива
|
502 | // Удаление версии дистрибутива
|
503 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
503 | $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'"; |
504 | $rq =& $this->db->query($query); |
504 | $rq =& $this->db->query($query); |
505 | if (PEAR::isError($this->db)) { |
505 | if (PEAR::isError($this->db)) { |
506 | $result["ERR"] = 1; |
506 | $result["ERR"] = 1; |
507 | $result["ERRINFO"] = $this->db->getMessage(); |
507 | $result["ERRINFO"] = $this->db->getMessage(); |
508 | } else { |
508 | } else { |
509 | $result["ERR"] = 0; |
509 | $result["ERR"] = 0; |
510 | }
|
510 | }
|
511 | 511 | ||
512 | // Удаление репозиториев этой версии дистрибутива
|
512 | // Удаление репозиториев этой версии дистрибутива
|
513 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
513 | $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'"; |
514 | $rq =& $this->db->query($query); |
514 | $rq =& $this->db->query($query); |
515 | if (PEAR::isError($this->db)) { |
515 | if (PEAR::isError($this->db)) { |
516 | $result["ERR"] = 1; |
516 | $result["ERR"] = 1; |
517 | $result["ERRINFO"] = $this->db->getMessage(); |
517 | $result["ERRINFO"] = $this->db->getMessage(); |
518 | } else { |
518 | } else { |
519 | $result["ERR"] = 0; |
519 | $result["ERR"] = 0; |
520 | }
|
520 | }
|
521 | 521 | ||
522 | return $result; |
522 | return $result; |
523 | }
|
523 | }
|
524 | 524 | ||
525 | /**
|
525 | /**
|
526 | * Отображение типа дистрибутива
|
526 | * Отображение типа дистрибутива
|
527 | *
|
527 | *
|
528 | * @author Alexander Wolf
|
528 | * @author Alexander Wolf
|
529 | * @category Core
|
529 | * @category Core
|
530 | *
|
530 | *
|
531 | * @param string $name
|
531 | * @param string $name
|
532 | * @param byte $type
|
532 | * @param byte $type
|
533 | * @return string
|
533 | * @return string
|
534 | */
|
534 | */
|
535 | public function showDistTypeForm($name = "dtype",$type = 0) { |
535 | public function showDistTypeForm($name = "dtype",$type = 0) { |
536 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
536 | $query = "SELECT * FROM ".$this->prefix."dtype"; |
537 | $rq =& $this->db->query($query); |
537 | $rq =& $this->db->query($query); |
538 | $show = "<select name='".$name."' id='".$name."'>\n"; |
538 | $show = "<select name='".$name."' id='".$name."'>\n"; |
539 | while ($rq->fetchInto($element)) { |
539 | while ($rq->fetchInto($element)) { |
540 | if ($element["type_id"] == $type) { |
540 | if ($element["type_id"] == $type) { |
541 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
541 | $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
542 | } else { |
542 | } else { |
543 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
543 | $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n"; |
544 | }
|
544 | }
|
545 | }
|
545 | }
|
546 | $show .= "</select>"; |
546 | $show .= "</select>"; |
547 | 547 | ||
548 | return $show; |
548 | return $show; |
549 | }
|
549 | }
|
550 | 550 | ||
551 | /**
|
551 | /**
|
552 | * Отображение формы создания и редактирования apt-дистрибутива
|
552 | * Отображение формы создания и редактирования apt-дистрибутива
|
553 | *
|
553 | *
|
554 | * @author Alexander Wolf
|
554 | * @author Alexander Wolf
|
555 | * @category Core
|
555 | * @category Core
|
556 | *
|
556 | *
|
557 | * @param integer $distID
|
557 | * @param integer $distID
|
558 | * @return string
|
558 | * @return string
|
559 | */
|
559 | */
|
560 | public function showDistributionForm($distID = 0, $info = '') { |
560 | public function showDistributionForm($distID = 0, $info = '') { |
561 | $sDistID = $this->secure->checkInt($distID); |
561 | $sDistID = $this->secure->checkInt($distID); |
562 | $sInfo = $this->secure->checkStr($info, 1); |
562 | $sInfo = $this->secure->checkStr($info, 1); |
563 | if ($sInfo == "") { |
563 | if ($sInfo == "") { |
564 | $sInfo = "Дистрибутив"; |
564 | $sInfo = "Дистрибутив"; |
565 | }
|
565 | }
|
566 | if ($sDistID != 0) { |
566 | if ($sDistID != 0) { |
567 | // Режим редактирования
|
567 | // Режим редактирования
|
568 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
568 | $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'"; |
569 | $rq =& $this->db->query($query); |
569 | $rq =& $this->db->query($query); |
570 | $rq->fetchInto($element); |
570 | $rq->fetchInto($element); |
571 | }
|
571 | }
|
572 | 572 | ||
573 | if ($element["distlogo"] == 1) { |
573 | if ($element["distlogo"] == 1) { |
574 | $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>"; |
574 | $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>"; |
575 | } else { |
575 | } else { |
576 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
576 | $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>"; |
577 | }
|
577 | }
|
578 | 578 | ||
579 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
579 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
580 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
580 | $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n"; |
581 | $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n"; |
581 | $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n"; |
582 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
582 | $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n"; |
583 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
583 | $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n"; |
584 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
584 | $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n"; |
585 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
585 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
586 | 586 | ||
587 | return $show; |
587 | return $show; |
588 | }
|
588 | }
|
589 | 589 | ||
590 | // sourses.list
|
590 | // sourses.list
|
591 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
591 | public function showSourcesList($distID,$versID,$sectIDs,$repIDs) { |
592 | //TODO Написать генератор sources.list
|
592 | //TODO Написать генератор sources.list
|
593 | }
|
593 | }
|
594 | 594 | ||
595 | /**
|
595 | /**
|
596 | * Показывает список секций
|
596 | * Показывает список секций
|
597 | *
|
597 | *
|
598 | * @author Alexander Wolf
|
598 | * @author Alexander Wolf
|
599 | * @category Core
|
599 | * @category Core
|
600 | *
|
600 | *
|
601 | * @param string $name
|
601 | * @param string $name
|
602 | * @param string $actor
|
602 | * @param string $actor
|
603 | * @param string $format
|
603 | * @param string $format
|
604 | * @return string
|
604 | * @return string
|
605 | */
|
605 | */
|
606 | public function showSectionsList($name, $actor, $format = 'html') { |
606 | public function showSectionsList($name, $actor, $format = 'html') { |
607 | switch($format) { |
607 | switch($format) { |
608 | case 'html': |
608 | case 'html': |
609 | $query = "SELECT * FROM ".$this->prefix."section"; |
609 | $query = "SELECT * FROM ".$this->prefix."section"; |
610 | $rq =& $this->db->query($query); |
610 | $rq =& $this->db->query($query); |
611 | $show = "<ul>\n"; |
611 | $show = "<ul>\n"; |
612 | while ($rq->fetchInto($element)) { |
612 | while ($rq->fetchInto($element)) { |
613 | $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"; |
613 | $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"; |
614 | }
|
614 | }
|
615 | $show .= "</ul>"; |
615 | $show .= "</ul>"; |
616 | break; |
616 | break; |
617 | case 'innerhtml': |
617 | case 'innerhtml': |
618 | $show = ""; |
618 | $show = ""; |
619 | $repID = $this->secure->checkInt($actor); |
619 | $repID = $this->secure->checkInt($actor); |
620 | if ($repID==0) { |
620 | if ($repID==0) { |
621 | $query = "SELECT * FROM ".$this->prefix."section"; |
621 | $query = "SELECT * FROM ".$this->prefix."section"; |
622 | $rq =& $this->db->query($query); |
622 | $rq =& $this->db->query($query); |
623 | while ($rq->fetchInto($element)) { |
623 | while ($rq->fetchInto($element)) { |
624 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
624 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
625 | }
|
625 | }
|
626 | } else { |
626 | } else { |
627 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
627 | $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'"; |
628 | $rq =& $this->db->query($query); |
628 | $rq =& $this->db->query($query); |
629 | while ($rq->fetchInto($element)) { |
629 | while ($rq->fetchInto($element)) { |
630 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
630 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked> ".$this->secure->checkStr($element["secname"],1)." "; |
631 | }
|
631 | }
|
632 | $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')"; |
632 | $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')"; |
633 | $rq =& $this->db->query($query); |
633 | $rq =& $this->db->query($query); |
634 | while ($rq->fetchInto($element)) { |
634 | while ($rq->fetchInto($element)) { |
635 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
635 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." "; |
636 | }
|
636 | }
|
637 | }
|
637 | }
|
638 | 638 | ||
639 | break; |
639 | break; |
640 | }
|
640 | }
|
641 | 641 | ||
642 | return $show; |
642 | return $show; |
643 | }
|
643 | }
|
644 | 644 | ||
645 | /**
|
645 | /**
|
646 | * Вывод формы редактирования/добавления секций
|
646 | * Вывод формы редактирования/добавления секций
|
647 | *
|
647 | *
|
648 | * @author Alexander Wolf
|
648 | * @author Alexander Wolf
|
649 | * @category Core
|
649 | * @category Core
|
650 | *
|
650 | *
|
651 | * @param integer $sectionID
|
651 | * @param integer $sectionID
|
652 | * @param string $info
|
652 | * @param string $info
|
653 | * @return string
|
653 | * @return string
|
654 | */
|
654 | */
|
655 | public function showSectionsForm($sectionID = 0, $info = "") { |
655 | public function showSectionsForm($sectionID = 0, $info = "") { |
656 | $sSectID = $this->secure->checkInt($sectionID); |
656 | $sSectID = $this->secure->checkInt($sectionID); |
657 | $sInfo = $this->secure->checkStr($info, 1); |
657 | $sInfo = $this->secure->checkStr($info, 1); |
658 | if ($sInfo == "") { |
658 | if ($sInfo == "") { |
659 | $sInfo = "Секция"; |
659 | $sInfo = "Секция"; |
660 | }
|
660 | }
|
661 | if ($sSectID != 0) { |
661 | if ($sSectID != 0) { |
662 | // Режим редактирования
|
662 | // Режим редактирования
|
663 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
663 | $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
664 | $rq =& $this->db->query($query); |
664 | $rq =& $this->db->query($query); |
665 | $rq->fetchInto($element); |
665 | $rq->fetchInto($element); |
666 | }
|
666 | }
|
667 | 667 | ||
668 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
668 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
669 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
669 | $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n"; |
670 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
670 | $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n"; |
671 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
671 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
672 | 672 | ||
673 | return $show; |
673 | return $show; |
674 | }
|
674 | }
|
675 | 675 | ||
676 | /**
|
676 | /**
|
677 | * Обновление информации о секции
|
677 | * Обновление информации о секции
|
678 | *
|
678 | *
|
679 | * @author Alexander Wolf
|
679 | * @author Alexander Wolf
|
680 | * @category Core
|
680 | * @category Core
|
681 | *
|
681 | *
|
682 | * @param integer $sectionID
|
682 | * @param integer $sectionID
|
683 | * @param string $sname
|
683 | * @param string $sname
|
684 | * @param string $sinfo
|
684 | * @param string $sinfo
|
685 | * @return array
|
685 | * @return array
|
686 | */
|
686 | */
|
687 | public function updateSection($sectionID, $sname, $sinfo = "") { |
687 | public function updateSection($sectionID, $sname, $sinfo = "") { |
688 | $result = array(); |
688 | $result = array(); |
689 | $sSectID = $this->secure->checkInt($sectionID); |
689 | $sSectID = $this->secure->checkInt($sectionID); |
690 | $sSName = $this->secure->checkStr($sname); |
690 | $sSName = $this->secure->checkStr($sname); |
691 | $sSInfo = $this->secure->checkStr($sinfo); |
691 | $sSInfo = $this->secure->checkStr($sinfo); |
692 | 692 | ||
693 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
693 | $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'"; |
694 | $rq =& $this->db->query($query); |
694 | $rq =& $this->db->query($query); |
695 | if (PEAR::isError($this->db)) { |
695 | if (PEAR::isError($this->db)) { |
696 | $result["ERR"] = 1; |
696 | $result["ERR"] = 1; |
697 | $result["ERRINFO"] = $this->db->getMessage(); |
697 | $result["ERRINFO"] = $this->db->getMessage(); |
698 | } else { |
698 | } else { |
699 | $result["ERR"] = 0; |
699 | $result["ERR"] = 0; |
700 | }
|
700 | }
|
701 | 701 | ||
702 | return $result; |
702 | return $result; |
703 | }
|
703 | }
|
704 | 704 | ||
705 | /**
|
705 | /**
|
706 | * Удаление информации о секции
|
706 | * Удаление информации о секции
|
707 | *
|
707 | *
|
708 | * @author Alexander Wolf
|
708 | * @author Alexander Wolf
|
709 | * @category Core
|
709 | * @category Core
|
710 | *
|
710 | *
|
711 | * @param integer $sectionID
|
711 | * @param integer $sectionID
|
712 | * @return array
|
712 | * @return array
|
713 | */
|
713 | */
|
714 | public function dropSection($sectionID) { |
714 | public function dropSection($sectionID) { |
715 | $result = array(); |
715 | $result = array(); |
716 | $sSectID = $this->secure->checkInt($sectionID); |
716 | $sSectID = $this->secure->checkInt($sectionID); |
717 | 717 | ||
718 | // Удаление секции
|
718 | // Удаление секции
|
719 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
719 | $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'"; |
720 | $rq =& $this->db->query($query); |
720 | $rq =& $this->db->query($query); |
721 | if (PEAR::isError($this->db)) { |
721 | if (PEAR::isError($this->db)) { |
722 | $result["ERR"] = 1; |
722 | $result["ERR"] = 1; |
723 | $result["ERRINFO"] = $this->db->getMessage(); |
723 | $result["ERRINFO"] = $this->db->getMessage(); |
724 | } else { |
724 | } else { |
725 | $result["ERR"] = 0; |
725 | $result["ERR"] = 0; |
726 | }
|
726 | }
|
727 | 727 | ||
728 | return $result; |
728 | return $result; |
729 | }
|
729 | }
|
730 | 730 | ||
731 | /**
|
731 | /**
|
732 | * Добавление новой секции
|
732 | * Добавление новой секции
|
733 | *
|
733 | *
|
734 | * @author Alexander Wolf
|
734 | * @author Alexander Wolf
|
735 | * @category Core
|
735 | * @category Core
|
736 | *
|
736 | *
|
737 | * @param string $sname
|
737 | * @param string $sname
|
738 | * @param string $sinfo
|
738 | * @param string $sinfo
|
739 | * @return array
|
739 | * @return array
|
740 | */
|
740 | */
|
741 | public function addSection($sname, $sinfo = "") { |
741 | public function addSection($sname, $sinfo = "") { |
742 | $result = array(); |
742 | $result = array(); |
743 | $sSName = $this->secure->checkStr($sname); |
743 | $sSName = $this->secure->checkStr($sname); |
744 | $sSInfo = $this->secure->checkStr($sinfo); |
744 | $sSInfo = $this->secure->checkStr($sinfo); |
745 | 745 | ||
746 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
746 | $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'"; |
747 | $rq =& $this->db->query($query); |
747 | $rq =& $this->db->query($query); |
748 | if (PEAR::isError($this->db)) { |
748 | if (PEAR::isError($this->db)) { |
749 | $result["ERR"] = 1; |
749 | $result["ERR"] = 1; |
750 | $result["ERRINFO"] = $this->db->getMessage(); |
750 | $result["ERRINFO"] = $this->db->getMessage(); |
751 | } else { |
751 | } else { |
752 | $result["ERR"] = 0; |
752 | $result["ERR"] = 0; |
753 | }
|
753 | }
|
754 | 754 | ||
755 | return $result; |
755 | return $result; |
756 | }
|
756 | }
|
757 | 757 | ||
758 | /**
|
758 | /**
|
759 | * Вывод списка поддерживаемых архитектур
|
759 | * Вывод списка поддерживаемых архитектур
|
760 | *
|
760 | *
|
761 | * @author Alexander Wolf
|
761 | * @author Alexander Wolf
|
762 | * @category Core
|
762 | * @category Core
|
763 | *
|
763 | *
|
764 | * @param string $name
|
764 | * @param string $name
|
765 | * @param string $actor
|
765 | * @param string $actor
|
766 | * @param string $format
|
766 | * @param string $format
|
767 | * @return string
|
767 | * @return string
|
768 | */
|
768 | */
|
769 | public function showArchList($name, $actor, $format = 'list') { |
769 | public function showArchList($name, $actor, $format = 'list') { |
770 | switch($format) { |
770 | switch($format) { |
771 | case 'list': |
771 | case 'list': |
772 | $query = "SELECT * FROM ".$this->prefix."arch"; |
772 | $query = "SELECT * FROM ".$this->prefix."arch"; |
773 | $rq =& $this->db->query($query); |
773 | $rq =& $this->db->query($query); |
774 | $show = "<ul>\n"; |
774 | $show = "<ul>\n"; |
775 | while ($rq->fetchInto($element)) { |
775 | while ($rq->fetchInto($element)) { |
776 | $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"; |
776 | $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"; |
777 | }
|
777 | }
|
778 | $show .= "</ul>"; |
778 | $show .= "</ul>"; |
779 | break; |
779 | break; |
780 | case 'innerhtml': |
780 | case 'innerhtml': |
781 | $show = ""; |
781 | $show = ""; |
782 | $repID = $this->secure->checkInt($actor); |
782 | $repID = $this->secure->checkInt($actor); |
783 | if ($repID==0) { |
783 | if ($repID==0) { |
784 | $query = "SELECT * FROM ".$this->prefix."arch"; |
784 | $query = "SELECT * FROM ".$this->prefix."arch"; |
785 | $rq =& $this->db->query($query); |
785 | $rq =& $this->db->query($query); |
786 | while ($rq->fetchInto($element)) { |
786 | while ($rq->fetchInto($element)) { |
787 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
787 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
788 | }
|
788 | }
|
789 | } else { |
789 | } else { |
790 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
790 | $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'"; |
791 | $rq =& $this->db->query($query); |
791 | $rq =& $this->db->query($query); |
792 | while ($rq->fetchInto($element)) { |
792 | while ($rq->fetchInto($element)) { |
793 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
793 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked> ".$this->secure->checkStr($element["arch"],1)." "; |
794 | }
|
794 | }
|
795 | $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')"; |
795 | $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')"; |
796 | $rq =& $this->db->query($query); |
796 | $rq =& $this->db->query($query); |
797 | if ($rq->numRows()>0) { |
797 | if ($rq->numRows()>0) { |
798 | while ($rq->fetchInto($element)) { |
798 | while ($rq->fetchInto($element)) { |
799 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
799 | $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'> ".$this->secure->checkStr($element["arch"],1)." "; |
800 | }
|
800 | }
|
801 | }
|
801 | }
|
802 | }
|
802 | }
|
803 | break; |
803 | break; |
804 | }
|
804 | }
|
805 | return $show; |
805 | return $show; |
806 | }
|
806 | }
|
807 | 807 | ||
808 | /**
|
808 | /**
|
809 | * Добавление новой архитектуры
|
809 | * Добавление новой архитектуры
|
810 | *
|
810 | *
|
811 | * @author Alexander Wolf
|
811 | * @author Alexander Wolf
|
812 | * @category Core
|
812 | * @category Core
|
813 | *
|
813 | *
|
814 | * @param string $arch
|
814 | * @param string $arch
|
815 | * @return array
|
815 | * @return array
|
816 | */
|
816 | */
|
817 | public function addArch($arch) { |
817 | public function addArch($arch) { |
818 | $result = array(); |
818 | $result = array(); |
819 | $sArch = $this->secure->checkStr($arch); |
819 | $sArch = $this->secure->checkStr($arch); |
820 | 820 | ||
821 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
821 | $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'"; |
822 | $rq =& $this->db->query($query); |
822 | $rq =& $this->db->query($query); |
823 | if (PEAR::isError($this->db)) { |
823 | if (PEAR::isError($this->db)) { |
824 | $result["ERR"] = 1; |
824 | $result["ERR"] = 1; |
825 | $result["ERRINFO"] = $this->db->getMessage(); |
825 | $result["ERRINFO"] = $this->db->getMessage(); |
826 | } else { |
826 | } else { |
827 | $result["ERR"] = 0; |
827 | $result["ERR"] = 0; |
828 | }
|
828 | }
|
829 | 829 | ||
830 | return $result; |
830 | return $result; |
831 | }
|
831 | }
|
832 | 832 | ||
833 | /**
|
833 | /**
|
834 | * Удаление информации об архитектуре
|
834 | * Удаление информации об архитектуре
|
835 | *
|
835 | *
|
836 | * @author Alexander Wolf
|
836 | * @author Alexander Wolf
|
837 | * @category Core
|
837 | * @category Core
|
838 | *
|
838 | *
|
839 | * @param integer $archID
|
839 | * @param integer $archID
|
840 | * @return array
|
840 | * @return array
|
841 | */
|
841 | */
|
842 | public function dropArch($archID) { |
842 | public function dropArch($archID) { |
843 | $result = array(); |
843 | $result = array(); |
844 | $sArchID = $this->secure->checkInt($archID); |
844 | $sArchID = $this->secure->checkInt($archID); |
845 | 845 | ||
846 | // Удаление архитектуры
|
846 | // Удаление архитектуры
|
847 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
847 | $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
848 | $rq =& $this->db->query($query); |
848 | $rq =& $this->db->query($query); |
849 | if (PEAR::isError($this->db)) { |
849 | if (PEAR::isError($this->db)) { |
850 | $result["ERR"] = 1; |
850 | $result["ERR"] = 1; |
851 | $result["ERRINFO"] = $this->db->getMessage(); |
851 | $result["ERRINFO"] = $this->db->getMessage(); |
852 | } else { |
852 | } else { |
853 | $result["ERR"] = 0; |
853 | $result["ERR"] = 0; |
854 | }
|
854 | }
|
855 | 855 | ||
856 | // Удаление архитектуры из списка репозиториев
|
856 | // Удаление архитектуры из списка репозиториев
|
857 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
857 | $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'"; |
858 | $rq =& $this->db->query($query); |
858 | $rq =& $this->db->query($query); |
859 | if (PEAR::isError($this->db)) { |
859 | if (PEAR::isError($this->db)) { |
860 | $result["ERR"] = 1; |
860 | $result["ERR"] = 1; |
861 | $result["ERRINFO"] = $this->db->getMessage(); |
861 | $result["ERRINFO"] = $this->db->getMessage(); |
862 | } else { |
862 | } else { |
863 | $result["ERR"] = 0; |
863 | $result["ERR"] = 0; |
864 | }
|
864 | }
|
865 | return $result; |
865 | return $result; |
866 | }
|
866 | }
|
867 | 867 | ||
868 | /**
|
868 | /**
|
869 | * Обновление информации об архитектуре
|
869 | * Обновление информации об архитектуре
|
870 | *
|
870 | *
|
871 | * @author Alexander Wolf
|
871 | * @author Alexander Wolf
|
872 | * @category Core
|
872 | * @category Core
|
873 | *
|
873 | *
|
874 | * @param integer $archID
|
874 | * @param integer $archID
|
875 | * @param string $arch
|
875 | * @param string $arch
|
876 | * @return array
|
876 | * @return array
|
877 | */
|
877 | */
|
878 | public function updateArch($archID, $arch) { |
878 | public function updateArch($archID, $arch) { |
879 | $result = array(); |
879 | $result = array(); |
880 | $sArchID = $this->secure->checkInt($archID); |
880 | $sArchID = $this->secure->checkInt($archID); |
881 | $sArch = $this->secure->checkStr($arch); |
881 | $sArch = $this->secure->checkStr($arch); |
882 | 882 | ||
883 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
883 | $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'"; |
884 | $rq =& $this->db->query($query); |
884 | $rq =& $this->db->query($query); |
885 | if (PEAR::isError($this->db)) { |
885 | if (PEAR::isError($this->db)) { |
886 | $result["ERR"] = 1; |
886 | $result["ERR"] = 1; |
887 | $result["ERRINFO"] = $this->db->getMessage(); |
887 | $result["ERRINFO"] = $this->db->getMessage(); |
888 | } else { |
888 | } else { |
889 | $result["ERR"] = 0; |
889 | $result["ERR"] = 0; |
890 | }
|
890 | }
|
891 | 891 | ||
892 | return $result; |
892 | return $result; |
893 | }
|
893 | }
|
894 | 894 | ||
895 | /**
|
895 | /**
|
896 | * Вывод формы редактирования/добавления архитектур
|
896 | * Вывод формы редактирования/добавления архитектур
|
897 | *
|
897 | *
|
898 | * @author Alexander Wolf
|
898 | * @author Alexander Wolf
|
899 | * @category Core
|
899 | * @category Core
|
900 | *
|
900 | *
|
901 | * @param integer $archID
|
901 | * @param integer $archID
|
902 | * @param string $info
|
902 | * @param string $info
|
903 | * @return string
|
903 | * @return string
|
904 | */
|
904 | */
|
905 | public function showArchForm($archID = 0, $info = "") { |
905 | public function showArchForm($archID = 0, $info = "") { |
906 | $sArchID = $this->secure->checkInt($archID); |
906 | $sArchID = $this->secure->checkInt($archID); |
907 | $sInfo = $this->secure->checkStr($info, 1); |
907 | $sInfo = $this->secure->checkStr($info, 1); |
908 | if ($sInfo == "") { |
908 | if ($sInfo == "") { |
909 | $sInfo = "Архитектура"; |
909 | $sInfo = "Архитектура"; |
910 | }
|
910 | }
|
911 | if ($sArchID != 0) { |
911 | if ($sArchID != 0) { |
912 | // Режим редактирования
|
912 | // Режим редактирования
|
913 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
913 | $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'"; |
914 | $rq =& $this->db->query($query); |
914 | $rq =& $this->db->query($query); |
915 | $rq->fetchInto($element); |
915 | $rq->fetchInto($element); |
916 | }
|
916 | }
|
917 | 917 | ||
918 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
918 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
919 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
919 | $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n"; |
920 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
920 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
921 | 921 | ||
922 | return $show; |
922 | return $show; |
923 | }
|
923 | }
|
924 | 924 | ||
925 | /**
|
925 | /**
|
926 | * Вывод списка схем репозиториев
|
926 | * Вывод списка схем репозиториев
|
927 | *
|
927 | *
|
928 | * @author Alexander Wolf
|
928 | * @author Alexander Wolf
|
929 | * @category Core
|
929 | * @category Core
|
930 | *
|
930 | *
|
931 | * @param string $name
|
931 | * @param string $name
|
932 | * @param string $actor
|
932 | * @param string $actor
|
933 | * @param string $format
|
933 | * @param string $format
|
934 | * @return string
|
934 | * @return string
|
935 | */
|
935 | */
|
936 | public function showSchemeList($name, $actor, $format = 'list') { |
936 | public function showSchemeList($name, $actor, $format = 'list') { |
937 | switch($format) { |
937 | switch($format) { |
938 | case 'list': |
938 | case 'list': |
939 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
939 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
940 | $rq =& $this->db->query($query); |
940 | $rq =& $this->db->query($query); |
941 | $show = "<ul>\n"; |
941 | $show = "<ul>\n"; |
942 | while ($rq->fetchInto($element)) { |
942 | while ($rq->fetchInto($element)) { |
943 | $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"; |
943 | $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"; |
944 | }
|
944 | }
|
945 | $show .= "</ul>"; |
945 | $show .= "</ul>"; |
946 | break; |
946 | break; |
947 | case 'innerhtml': |
947 | case 'innerhtml': |
948 | $schemeID = $this->secure->checkInt($actor); |
948 | $schemeID = $this->secure->checkInt($actor); |
949 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
949 | $query = "SELECT * FROM ".$this->prefix."repscheme"; |
950 | $rq =& $this->db->query($query); |
950 | $rq =& $this->db->query($query); |
951 | $show = "<select name='".$name."' id='".$name."'>\n"; |
951 | $show = "<select name='".$name."' id='".$name."'>\n"; |
952 | while ($rq->fetchInto($element)) { |
952 | while ($rq->fetchInto($element)) { |
953 | if ($element["scheme_id"]==$schemeID) { |
953 | if ($element["scheme_id"]==$schemeID) { |
954 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
954 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
955 | } else { |
955 | } else { |
956 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
956 | $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n"; |
957 | }
|
957 | }
|
958 | }
|
958 | }
|
959 | $show .= "</select>"; |
959 | $show .= "</select>"; |
960 | break; |
960 | break; |
961 | }
|
961 | }
|
962 | return $show; |
962 | return $show; |
963 | }
|
963 | }
|
964 | 964 | ||
965 | /**
|
965 | /**
|
966 | * Добавление новой схемы репозитория
|
966 | * Добавление новой схемы репозитория
|
967 | *
|
967 | *
|
968 | * @author Alexander Wolf
|
968 | * @author Alexander Wolf
|
969 | * @category Core
|
969 | * @category Core
|
970 | *
|
970 | *
|
971 | * @param string $scheme
|
971 | * @param string $scheme
|
972 | * @return array
|
972 | * @return array
|
973 | */
|
973 | */
|
974 | public function addScheme($scheme) { |
974 | public function addScheme($scheme) { |
975 | $result = array(); |
975 | $result = array(); |
976 | $sScheme = $this->secure->checkStr($scheme); |
976 | $sScheme = $this->secure->checkStr($scheme); |
977 | 977 | ||
978 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
978 | $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'"; |
979 | $rq =& $this->db->query($query); |
979 | $rq =& $this->db->query($query); |
980 | if (PEAR::isError($this->db)) { |
980 | if (PEAR::isError($this->db)) { |
981 | $result["ERR"] = 1; |
981 | $result["ERR"] = 1; |
982 | $result["ERRINFO"] = $this->db->getMessage(); |
982 | $result["ERRINFO"] = $this->db->getMessage(); |
983 | } else { |
983 | } else { |
984 | $result["ERR"] = 0; |
984 | $result["ERR"] = 0; |
985 | }
|
985 | }
|
986 | 986 | ||
987 | return $result; |
987 | return $result; |
988 | }
|
988 | }
|
989 | 989 | ||
990 | /**
|
990 | /**
|
991 | * Удаление информации о схеме репозитория
|
991 | * Удаление информации о схеме репозитория
|
992 | *
|
992 | *
|
993 | * @author Alexander Wolf
|
993 | * @author Alexander Wolf
|
994 | * @category Core
|
994 | * @category Core
|
995 | *
|
995 | *
|
996 | * @param integer $schemeID
|
996 | * @param integer $schemeID
|
997 | * @return array
|
997 | * @return array
|
998 | */
|
998 | */
|
999 | public function dropScheme($schemeID) { |
999 | public function dropScheme($schemeID) { |
1000 | $result = array(); |
1000 | $result = array(); |
1001 | $sSchemeID = $this->secure->checkInt($schemeID); |
1001 | $sSchemeID = $this->secure->checkInt($schemeID); |
1002 | 1002 | ||
1003 | // Удаление схемы
|
1003 | // Удаление схемы
|
1004 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1004 | $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1005 | $rq =& $this->db->query($query); |
1005 | $rq =& $this->db->query($query); |
1006 | if (PEAR::isError($this->db)) { |
1006 | if (PEAR::isError($this->db)) { |
1007 | $result["ERR"] = 1; |
1007 | $result["ERR"] = 1; |
1008 | $result["ERRINFO"] = $this->db->getMessage(); |
1008 | $result["ERRINFO"] = $this->db->getMessage(); |
1009 | } else { |
1009 | } else { |
1010 | $result["ERR"] = 0; |
1010 | $result["ERR"] = 0; |
1011 | }
|
1011 | }
|
1012 | 1012 | ||
1013 | return $result; |
1013 | return $result; |
1014 | }
|
1014 | }
|
1015 | 1015 | ||
1016 | /**
|
1016 | /**
|
1017 | * Обновление информации о схеме репозитория
|
1017 | * Обновление информации о схеме репозитория
|
1018 | *
|
1018 | *
|
1019 | * @author Alexander Wolf
|
1019 | * @author Alexander Wolf
|
1020 | * @category Core
|
1020 | * @category Core
|
1021 | *
|
1021 | *
|
1022 | * @param integer $schemeID
|
1022 | * @param integer $schemeID
|
1023 | * @param string $info
|
1023 | * @param string $info
|
1024 | * @return array
|
1024 | * @return array
|
1025 | */
|
1025 | */
|
1026 | public function updateScheme($schemeID, $info) { |
1026 | public function updateScheme($schemeID, $info) { |
1027 | $result = array(); |
1027 | $result = array(); |
1028 | $sSchemeID = $this->secure->checkInt($schemeID); |
1028 | $sSchemeID = $this->secure->checkInt($schemeID); |
1029 | $sScheme = $this->secure->checkStr($info); |
1029 | $sScheme = $this->secure->checkStr($info); |
1030 | 1030 | ||
1031 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
1031 | $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'"; |
1032 | $rq =& $this->db->query($query); |
1032 | $rq =& $this->db->query($query); |
1033 | if (PEAR::isError($this->db)) { |
1033 | if (PEAR::isError($this->db)) { |
1034 | $result["ERR"] = 1; |
1034 | $result["ERR"] = 1; |
1035 | $result["ERRINFO"] = $this->db->getMessage(); |
1035 | $result["ERRINFO"] = $this->db->getMessage(); |
1036 | } else { |
1036 | } else { |
1037 | $result["ERR"] = 0; |
1037 | $result["ERR"] = 0; |
1038 | }
|
1038 | }
|
1039 | 1039 | ||
1040 | return $result; |
1040 | return $result; |
1041 | }
|
1041 | }
|
1042 | 1042 | ||
1043 | /**
|
1043 | /**
|
1044 | * Вывод формы редактирования/добавления схем репозиториев
|
1044 | * Вывод формы редактирования/добавления схем репозиториев
|
1045 | *
|
1045 | *
|
1046 | * @author Alexander Wolf
|
1046 | * @author Alexander Wolf
|
1047 | * @category Core
|
1047 | * @category Core
|
1048 | *
|
1048 | *
|
1049 | * @param integer $schemeID
|
1049 | * @param integer $schemeID
|
1050 | * @param string $info
|
1050 | * @param string $info
|
1051 | * @return string
|
1051 | * @return string
|
1052 | */
|
1052 | */
|
1053 | public function showSchemeForm($schemeID = 0, $info = "") { |
1053 | public function showSchemeForm($schemeID = 0, $info = "") { |
1054 | $sSchemeID = $this->secure->checkInt($schemeID); |
1054 | $sSchemeID = $this->secure->checkInt($schemeID); |
1055 | $sInfo = $this->secure->checkStr($info, 1); |
1055 | $sInfo = $this->secure->checkStr($info, 1); |
1056 | if ($sInfo == "") { |
1056 | if ($sInfo == "") { |
1057 | $sInfo = "Схема репозитория"; |
1057 | $sInfo = "Схема репозитория"; |
1058 | }
|
1058 | }
|
1059 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1059 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1060 | if ($sSchemeID != 0) { |
1060 | if ($sSchemeID != 0) { |
1061 | // Режим редактирования
|
1061 | // Режим редактирования
|
1062 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1062 | $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'"; |
1063 | $rq =& $this->db->query($query); |
1063 | $rq =& $this->db->query($query); |
1064 | $rq->fetchInto($element); |
1064 | $rq->fetchInto($element); |
1065 | }
|
1065 | }
|
1066 | 1066 | ||
1067 | $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n"; |
1067 | $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n"; |
1068 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1068 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1069 | 1069 | ||
1070 | return $show; |
1070 | return $show; |
1071 | }
|
1071 | }
|
1072 | 1072 | ||
1073 | /**
|
1073 | /**
|
1074 | * Вывод списка протоколов
|
1074 | * Вывод списка протоколов
|
1075 | *
|
1075 | *
|
1076 | * @author Alexander Wolf
|
1076 | * @author Alexander Wolf
|
1077 | * @category Core
|
1077 | * @category Core
|
1078 | *
|
1078 | *
|
1079 | * @param string $name
|
1079 | * @param string $name
|
1080 | * @param string $actor
|
1080 | * @param string $actor
|
1081 | * @param string $format
|
1081 | * @param string $format
|
1082 | * @return string
|
1082 | * @return string
|
1083 | */
|
1083 | */
|
1084 | public function showProtoList($name, $actor, $format = 'list') { |
1084 | public function showProtoList($name, $actor, $format = 'list') { |
1085 | switch($format) { |
1085 | switch($format) { |
1086 | case 'list': |
1086 | case 'list': |
1087 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1087 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1088 | $rq =& $this->db->query($query); |
1088 | $rq =& $this->db->query($query); |
1089 | $show = "<ul>\n"; |
1089 | $show = "<ul>\n"; |
1090 | while ($rq->fetchInto($element)) { |
1090 | while ($rq->fetchInto($element)) { |
1091 | $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"; |
1091 | $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"; |
1092 | }
|
1092 | }
|
1093 | $show .= "</ul>"; |
1093 | $show .= "</ul>"; |
1094 | break; |
1094 | break; |
1095 | case 'innerhtml': |
1095 | case 'innerhtml': |
1096 | $protoID = $this->secure->checkInt($actor); |
1096 | $protoID = $this->secure->checkInt($actor); |
1097 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1097 | $query = "SELECT * FROM ".$this->prefix."protos"; |
1098 | $rq =& $this->db->query($query); |
1098 | $rq =& $this->db->query($query); |
1099 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1099 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1100 | while ($rq->fetchInto($element)) { |
1100 | while ($rq->fetchInto($element)) { |
1101 | if ($element["proto_id"]==$protoID) { |
1101 | if ($element["proto_id"]==$protoID) { |
1102 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1102 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1103 | } else { |
1103 | } else { |
1104 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1104 | $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n"; |
1105 | }
|
1105 | }
|
1106 | }
|
1106 | }
|
1107 | $show .= "</select>"; |
1107 | $show .= "</select>"; |
1108 | break; |
1108 | break; |
1109 | }
|
1109 | }
|
1110 | return $show; |
1110 | return $show; |
1111 | }
|
1111 | }
|
1112 | 1112 | ||
1113 | /**
|
1113 | /**
|
1114 | * Добавление нового протокола
|
1114 | * Добавление нового протокола
|
1115 | *
|
1115 | *
|
1116 | * @author Alexander Wolf
|
1116 | * @author Alexander Wolf
|
1117 | * @category Core
|
1117 | * @category Core
|
1118 | *
|
1118 | *
|
1119 | * @param string $proto
|
1119 | * @param string $proto
|
1120 | * @return array
|
1120 | * @return array
|
1121 | */
|
1121 | */
|
1122 | public function addProto($proto) { |
1122 | public function addProto($proto) { |
1123 | $result = array(); |
1123 | $result = array(); |
1124 | $sProto = $this->secure->checkStr($proto); |
1124 | $sProto = $this->secure->checkStr($proto); |
1125 | 1125 | ||
1126 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
1126 | $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'"; |
1127 | $rq =& $this->db->query($query); |
1127 | $rq =& $this->db->query($query); |
1128 | if (PEAR::isError($this->db)) { |
1128 | if (PEAR::isError($this->db)) { |
1129 | $result["ERR"] = 1; |
1129 | $result["ERR"] = 1; |
1130 | $result["ERRINFO"] = $this->db->getMessage(); |
1130 | $result["ERRINFO"] = $this->db->getMessage(); |
1131 | } else { |
1131 | } else { |
1132 | $result["ERR"] = 0; |
1132 | $result["ERR"] = 0; |
1133 | }
|
1133 | }
|
1134 | 1134 | ||
1135 | return $result; |
1135 | return $result; |
1136 | }
|
1136 | }
|
1137 | 1137 | ||
1138 | /**
|
1138 | /**
|
1139 | * Удаление информации о протоколе
|
1139 | * Удаление информации о протоколе
|
1140 | *
|
1140 | *
|
1141 | * @author Alexander Wolf
|
1141 | * @author Alexander Wolf
|
1142 | * @category Core
|
1142 | * @category Core
|
1143 | *
|
1143 | *
|
1144 | * @param integer $protoID
|
1144 | * @param integer $protoID
|
1145 | * @return array
|
1145 | * @return array
|
1146 | */
|
1146 | */
|
1147 | public function dropProto($protoID) { |
1147 | public function dropProto($protoID) { |
1148 | $result = array(); |
1148 | $result = array(); |
1149 | $sProtoID = $this->secure->checkInt($protoID); |
1149 | $sProtoID = $this->secure->checkInt($protoID); |
1150 | 1150 | ||
1151 | // Удаление протокола
|
1151 | // Удаление протокола
|
1152 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1152 | $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1153 | $rq =& $this->db->query($query); |
1153 | $rq =& $this->db->query($query); |
1154 | if (PEAR::isError($this->db)) { |
1154 | if (PEAR::isError($this->db)) { |
1155 | $result["ERR"] = 1; |
1155 | $result["ERR"] = 1; |
1156 | $result["ERRINFO"] = $this->db->getMessage(); |
1156 | $result["ERRINFO"] = $this->db->getMessage(); |
1157 | } else { |
1157 | } else { |
1158 | $result["ERR"] = 0; |
1158 | $result["ERR"] = 0; |
1159 | }
|
1159 | }
|
1160 | 1160 | ||
1161 | return $result; |
1161 | return $result; |
1162 | }
|
1162 | }
|
1163 | 1163 | ||
1164 | /**
|
1164 | /**
|
1165 | * Обновление информации о протоколе
|
1165 | * Обновление информации о протоколе
|
1166 | *
|
1166 | *
|
1167 | * @author Alexander Wolf
|
1167 | * @author Alexander Wolf
|
1168 | * @category Core
|
1168 | * @category Core
|
1169 | *
|
1169 | *
|
1170 | * @param integer $protoID
|
1170 | * @param integer $protoID
|
1171 | * @param string $info
|
1171 | * @param string $info
|
1172 | * @return array
|
1172 | * @return array
|
1173 | */
|
1173 | */
|
1174 | public function updateProto($protoID, $info) { |
1174 | public function updateProto($protoID, $info) { |
1175 | $result = array(); |
1175 | $result = array(); |
1176 | $sProtoID = $this->secure->checkInt($protoID); |
1176 | $sProtoID = $this->secure->checkInt($protoID); |
1177 | $sProto = $this->secure->checkStr($info); |
1177 | $sProto = $this->secure->checkStr($info); |
1178 | 1178 | ||
1179 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
1179 | $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'"; |
1180 | $rq =& $this->db->query($query); |
1180 | $rq =& $this->db->query($query); |
1181 | if (PEAR::isError($this->db)) { |
1181 | if (PEAR::isError($this->db)) { |
1182 | $result["ERR"] = 1; |
1182 | $result["ERR"] = 1; |
1183 | $result["ERRINFO"] = $this->db->getMessage(); |
1183 | $result["ERRINFO"] = $this->db->getMessage(); |
1184 | } else { |
1184 | } else { |
1185 | $result["ERR"] = 0; |
1185 | $result["ERR"] = 0; |
1186 | }
|
1186 | }
|
1187 | 1187 | ||
1188 | return $result; |
1188 | return $result; |
1189 | }
|
1189 | }
|
1190 | 1190 | ||
1191 | /**
|
1191 | /**
|
1192 | * Вывод формы редактирования/добавления протоколов
|
1192 | * Вывод формы редактирования/добавления протоколов
|
1193 | *
|
1193 | *
|
1194 | * @author Alexander Wolf
|
1194 | * @author Alexander Wolf
|
1195 | * @category Core
|
1195 | * @category Core
|
1196 | *
|
1196 | *
|
1197 | * @param integer $protoID
|
1197 | * @param integer $protoID
|
1198 | * @param string $info
|
1198 | * @param string $info
|
1199 | * @return string
|
1199 | * @return string
|
1200 | */
|
1200 | */
|
1201 | public function showProtoForm($protoID = 0, $info = "") { |
1201 | public function showProtoForm($protoID = 0, $info = "") { |
1202 | $sProtoID = $this->secure->checkInt($protoID); |
1202 | $sProtoID = $this->secure->checkInt($protoID); |
1203 | $sInfo = $this->secure->checkStr($info, 1); |
1203 | $sInfo = $this->secure->checkStr($info, 1); |
1204 | if ($sInfo == "") { |
1204 | if ($sInfo == "") { |
1205 | $sInfo = "Протокол доступа"; |
1205 | $sInfo = "Протокол доступа"; |
1206 | }
|
1206 | }
|
1207 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1207 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1208 | if ($sProtoID != 0) { |
1208 | if ($sProtoID != 0) { |
1209 | // Режим редактирования
|
1209 | // Режим редактирования
|
1210 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1210 | $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'"; |
1211 | $rq =& $this->db->query($query); |
1211 | $rq =& $this->db->query($query); |
1212 | $rq->fetchInto($element); |
1212 | $rq->fetchInto($element); |
1213 | }
|
1213 | }
|
1214 | 1214 | ||
1215 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
1215 | $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n"; |
1216 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1216 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1217 | 1217 | ||
1218 | return $show; |
1218 | return $show; |
1219 | }
|
1219 | }
|
1220 | 1220 | ||
1221 | /**
|
1221 | /**
|
1222 | * Вывод списка хостов
|
1222 | * Вывод списка хостов
|
1223 | *
|
1223 | *
|
1224 | * @author Alexander Wolf
|
1224 | * @author Alexander Wolf
|
1225 | * @category Core
|
1225 | * @category Core
|
1226 | *
|
1226 | *
|
1227 | * @param string $name
|
1227 | * @param string $name
|
1228 | * @param string $actor
|
1228 | * @param string $actor
|
1229 | * @param string $format
|
1229 | * @param string $format
|
1230 | * @return string
|
1230 | * @return string
|
1231 | */
|
1231 | */
|
1232 | public function showHostsList($name, $actor, $format = 'list') { |
1232 | public function showHostsList($name, $actor, $format = 'list') { |
1233 | switch($format) { |
1233 | switch($format) { |
1234 | case 'list': |
1234 | case 'list': |
1235 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1235 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1236 | $rq =& $this->db->query($query); |
1236 | $rq =& $this->db->query($query); |
1237 | $show = "<ul>\n"; |
1237 | $show = "<ul>\n"; |
1238 | while ($rq->fetchInto($element)) { |
1238 | while ($rq->fetchInto($element)) { |
1239 | $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"; |
1239 | $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"; |
1240 | }
|
1240 | }
|
1241 | $show .= "</ul>"; |
1241 | $show .= "</ul>"; |
1242 | break; |
1242 | break; |
1243 | case 'innerhtml': |
1243 | case 'innerhtml': |
1244 | $hostID = $this->secure->checkInt($actor); |
1244 | $hostID = $this->secure->checkInt($actor); |
1245 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1245 | $query = "SELECT * FROM ".$this->prefix."rephost"; |
1246 | $rq =& $this->db->query($query); |
1246 | $rq =& $this->db->query($query); |
1247 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1247 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1248 | while ($rq->fetchInto($element)) { |
1248 | while ($rq->fetchInto($element)) { |
1249 | if ($element["rhost_id"]==$hostID) { |
1249 | if ($element["rhost_id"]==$hostID) { |
1250 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1250 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1251 | } else { |
1251 | } else { |
1252 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1252 | $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n"; |
1253 | }
|
1253 | }
|
1254 | }
|
1254 | }
|
1255 | $show .= "</select>"; |
1255 | $show .= "</select>"; |
1256 | break; |
1256 | break; |
1257 | }
|
1257 | }
|
1258 | return $show; |
1258 | return $show; |
1259 | }
|
1259 | }
|
1260 | 1260 | ||
1261 | /**
|
1261 | /**
|
1262 | * Добавление нового хоста
|
1262 | * Добавление нового хоста
|
1263 | *
|
1263 | *
|
1264 | * @author Alexander Wolf
|
1264 | * @author Alexander Wolf
|
1265 | * @category Core
|
1265 | * @category Core
|
1266 | *
|
1266 | *
|
1267 | * @param string $host
|
1267 | * @param string $host
|
1268 | * @return array
|
1268 | * @return array
|
1269 | */
|
1269 | */
|
1270 | public function addHost($host) { |
1270 | public function addHost($host) { |
1271 | $result = array(); |
1271 | $result = array(); |
1272 | $sHost = $this->secure->checkStr($host); |
1272 | $sHost = $this->secure->checkStr($host); |
1273 | 1273 | ||
1274 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
1274 | $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'"; |
1275 | $rq =& $this->db->query($query); |
1275 | $rq =& $this->db->query($query); |
1276 | if (PEAR::isError($this->db)) { |
1276 | if (PEAR::isError($this->db)) { |
1277 | $result["ERR"] = 1; |
1277 | $result["ERR"] = 1; |
1278 | $result["ERRINFO"] = $this->db->getMessage(); |
1278 | $result["ERRINFO"] = $this->db->getMessage(); |
1279 | } else { |
1279 | } else { |
1280 | $result["ERR"] = 0; |
1280 | $result["ERR"] = 0; |
1281 | }
|
1281 | }
|
1282 | 1282 | ||
1283 | return $result; |
1283 | return $result; |
1284 | }
|
1284 | }
|
1285 | 1285 | ||
1286 | /**
|
1286 | /**
|
1287 | * Удаление информации о хосте
|
1287 | * Удаление информации о хосте
|
1288 | *
|
1288 | *
|
1289 | * @author Alexander Wolf
|
1289 | * @author Alexander Wolf
|
1290 | * @category Core
|
1290 | * @category Core
|
1291 | *
|
1291 | *
|
1292 | * @param integer $hostID
|
1292 | * @param integer $hostID
|
1293 | * @return array
|
1293 | * @return array
|
1294 | */
|
1294 | */
|
1295 | public function dropHost($hostID) { |
1295 | public function dropHost($hostID) { |
1296 | $result = array(); |
1296 | $result = array(); |
1297 | $sHostID = $this->secure->checkInt($hostID); |
1297 | $sHostID = $this->secure->checkInt($hostID); |
1298 | 1298 | ||
1299 | // Удаление хоста
|
1299 | // Удаление хоста
|
1300 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1300 | $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1301 | $rq =& $this->db->query($query); |
1301 | $rq =& $this->db->query($query); |
1302 | if (PEAR::isError($this->db)) { |
1302 | if (PEAR::isError($this->db)) { |
1303 | $result["ERR"] = 1; |
1303 | $result["ERR"] = 1; |
1304 | $result["ERRINFO"] = $this->db->getMessage(); |
1304 | $result["ERRINFO"] = $this->db->getMessage(); |
1305 | } else { |
1305 | } else { |
1306 | $result["ERR"] = 0; |
1306 | $result["ERR"] = 0; |
1307 | }
|
1307 | }
|
1308 | 1308 | ||
1309 | return $result; |
1309 | return $result; |
1310 | }
|
1310 | }
|
1311 | 1311 | ||
1312 | /**
|
1312 | /**
|
1313 | * Обновление информации о хосте
|
1313 | * Обновление информации о хосте
|
1314 | *
|
1314 | *
|
1315 | * @author Alexander Wolf
|
1315 | * @author Alexander Wolf
|
1316 | * @category Core
|
1316 | * @category Core
|
1317 | *
|
1317 | *
|
1318 | * @param integer $hostID
|
1318 | * @param integer $hostID
|
1319 | * @param string $info
|
1319 | * @param string $info
|
1320 | * @return array
|
1320 | * @return array
|
1321 | */
|
1321 | */
|
1322 | public function updateHost($hostID, $info) { |
1322 | public function updateHost($hostID, $info) { |
1323 | $result = array(); |
1323 | $result = array(); |
1324 | $sHostID = $this->secure->checkInt($hostID); |
1324 | $sHostID = $this->secure->checkInt($hostID); |
1325 | $sHost = $this->secure->checkStr($info); |
1325 | $sHost = $this->secure->checkStr($info); |
1326 | 1326 | ||
1327 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
1327 | $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'"; |
1328 | $rq =& $this->db->query($query); |
1328 | $rq =& $this->db->query($query); |
1329 | if (PEAR::isError($this->db)) { |
1329 | if (PEAR::isError($this->db)) { |
1330 | $result["ERR"] = 1; |
1330 | $result["ERR"] = 1; |
1331 | $result["ERRINFO"] = $this->db->getMessage(); |
1331 | $result["ERRINFO"] = $this->db->getMessage(); |
1332 | } else { |
1332 | } else { |
1333 | $result["ERR"] = 0; |
1333 | $result["ERR"] = 0; |
1334 | }
|
1334 | }
|
1335 | 1335 | ||
1336 | return $result; |
1336 | return $result; |
1337 | }
|
1337 | }
|
1338 | 1338 | ||
1339 | /**
|
1339 | /**
|
1340 | * Вывод формы редактирования/добавления хостов
|
1340 | * Вывод формы редактирования/добавления хостов
|
1341 | *
|
1341 | *
|
1342 | * @author Alexander Wolf
|
1342 | * @author Alexander Wolf
|
1343 | * @category Core
|
1343 | * @category Core
|
1344 | *
|
1344 | *
|
1345 | * @param integer $hostID
|
1345 | * @param integer $hostID
|
1346 | * @param string $info
|
1346 | * @param string $info
|
1347 | * @return string
|
1347 | * @return string
|
1348 | */
|
1348 | */
|
1349 | public function showHostForm($hostID = 0, $info = "") { |
1349 | public function showHostForm($hostID = 0, $info = "") { |
1350 | $sHostID = $this->secure->checkInt($hostID); |
1350 | $sHostID = $this->secure->checkInt($hostID); |
1351 | $sInfo = $this->secure->checkStr($info, 1); |
1351 | $sInfo = $this->secure->checkStr($info, 1); |
1352 | if ($sInfo == "") { |
1352 | if ($sInfo == "") { |
1353 | $sInfo = "Хост репозитория"; |
1353 | $sInfo = "Хост репозитория"; |
1354 | }
|
1354 | }
|
1355 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1355 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1356 | if ($sHostID != 0) { |
1356 | if ($sHostID != 0) { |
1357 | // Режим редактирования
|
1357 | // Режим редактирования
|
1358 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1358 | $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'"; |
1359 | $rq =& $this->db->query($query); |
1359 | $rq =& $this->db->query($query); |
1360 | $rq->fetchInto($element); |
1360 | $rq->fetchInto($element); |
1361 | }
|
1361 | }
|
1362 | 1362 | ||
1363 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
1363 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n"; |
1364 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1364 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1365 | 1365 | ||
1366 | return $show; |
1366 | return $show; |
1367 | }
|
1367 | }
|
1368 | 1368 | ||
1369 | /**
|
1369 | /**
|
1370 | * Вывод списка корневых папок
|
1370 | * Вывод списка корневых папок
|
1371 | *
|
1371 | *
|
1372 | * @author Alexander Wolf
|
1372 | * @author Alexander Wolf
|
1373 | * @category Core
|
1373 | * @category Core
|
1374 | *
|
1374 | *
|
1375 | * @param string $name
|
1375 | * @param string $name
|
1376 | * @param string $actor
|
1376 | * @param string $actor
|
1377 | * @param string $format
|
1377 | * @param string $format
|
1378 | * @return string
|
1378 | * @return string
|
1379 | */
|
1379 | */
|
1380 | public function showFoldersList($name, $actor, $format = 'list') { |
1380 | public function showFoldersList($name, $actor, $format = 'list') { |
1381 | switch($format) { |
1381 | switch($format) { |
1382 | case 'list': |
1382 | case 'list': |
1383 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1383 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1384 | $rq =& $this->db->query($query); |
1384 | $rq =& $this->db->query($query); |
1385 | $show = "<ul>\n"; |
1385 | $show = "<ul>\n"; |
1386 | while ($rq->fetchInto($element)) { |
1386 | while ($rq->fetchInto($element)) { |
1387 | $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"; |
1387 | $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"; |
1388 | }
|
1388 | }
|
1389 | $show .= "</ul>"; |
1389 | $show .= "</ul>"; |
1390 | break; |
1390 | break; |
1391 | case 'innerhtml': |
1391 | case 'innerhtml': |
1392 | $folderID = $this->secure->checkInt($actor); |
1392 | $folderID = $this->secure->checkInt($actor); |
1393 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1393 | $query = "SELECT * FROM ".$this->prefix."repfolder"; |
1394 | $rq =& $this->db->query($query); |
1394 | $rq =& $this->db->query($query); |
1395 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1395 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1396 | while ($rq->fetchInto($element)) { |
1396 | while ($rq->fetchInto($element)) { |
1397 | if ($element["rfolder_id"]==$folderID) { |
1397 | if ($element["rfolder_id"]==$folderID) { |
1398 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1398 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1399 | } else { |
1399 | } else { |
1400 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1400 | $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n"; |
1401 | }
|
1401 | }
|
1402 | }
|
1402 | }
|
1403 | $show .= "</select>"; |
1403 | $show .= "</select>"; |
1404 | break; |
1404 | break; |
1405 | }
|
1405 | }
|
1406 | return $show; |
1406 | return $show; |
1407 | }
|
1407 | }
|
1408 | 1408 | ||
1409 | /**
|
1409 | /**
|
1410 | * Добавление нового корневого каталога
|
1410 | * Добавление нового корневого каталога
|
1411 | *
|
1411 | *
|
1412 | * @author Alexander Wolf
|
1412 | * @author Alexander Wolf
|
1413 | * @category Core
|
1413 | * @category Core
|
1414 | *
|
1414 | *
|
1415 | * @param string $flder
|
1415 | * @param string $flder
|
1416 | * @return array
|
1416 | * @return array
|
1417 | */
|
1417 | */
|
1418 | public function addFolder($folder) { |
1418 | public function addFolder($folder) { |
1419 | $result = array(); |
1419 | $result = array(); |
1420 | $sFolder = $this->secure->checkStr($folder); |
1420 | $sFolder = $this->secure->checkStr($folder); |
1421 | 1421 | ||
1422 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
1422 | $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'"; |
1423 | $rq =& $this->db->query($query); |
1423 | $rq =& $this->db->query($query); |
1424 | if (PEAR::isError($this->db)) { |
1424 | if (PEAR::isError($this->db)) { |
1425 | $result["ERR"] = 1; |
1425 | $result["ERR"] = 1; |
1426 | $result["ERRINFO"] = $this->db->getMessage(); |
1426 | $result["ERRINFO"] = $this->db->getMessage(); |
1427 | } else { |
1427 | } else { |
1428 | $result["ERR"] = 0; |
1428 | $result["ERR"] = 0; |
1429 | }
|
1429 | }
|
1430 | 1430 | ||
1431 | return $result; |
1431 | return $result; |
1432 | }
|
1432 | }
|
1433 | 1433 | ||
1434 | /**
|
1434 | /**
|
1435 | * Удаление информации о корневой папке
|
1435 | * Удаление информации о корневой папке
|
1436 | *
|
1436 | *
|
1437 | * @author Alexander Wolf
|
1437 | * @author Alexander Wolf
|
1438 | * @category Core
|
1438 | * @category Core
|
1439 | *
|
1439 | *
|
1440 | * @param integer $folderID
|
1440 | * @param integer $folderID
|
1441 | * @return array
|
1441 | * @return array
|
1442 | */
|
1442 | */
|
1443 | public function dropFolder($folderID) { |
1443 | public function dropFolder($folderID) { |
1444 | $result = array(); |
1444 | $result = array(); |
1445 | $sFolderID = $this->secure->checkInt($folderID); |
1445 | $sFolderID = $this->secure->checkInt($folderID); |
1446 | 1446 | ||
1447 | // Удаление корневой папки
|
1447 | // Удаление корневой папки
|
1448 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1448 | $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1449 | $rq =& $this->db->query($query); |
1449 | $rq =& $this->db->query($query); |
1450 | if (PEAR::isError($this->db)) { |
1450 | if (PEAR::isError($this->db)) { |
1451 | $result["ERR"] = 1; |
1451 | $result["ERR"] = 1; |
1452 | $result["ERRINFO"] = $this->db->getMessage(); |
1452 | $result["ERRINFO"] = $this->db->getMessage(); |
1453 | } else { |
1453 | } else { |
1454 | $result["ERR"] = 0; |
1454 | $result["ERR"] = 0; |
1455 | }
|
1455 | }
|
1456 | 1456 | ||
1457 | return $result; |
1457 | return $result; |
1458 | }
|
1458 | }
|
1459 | 1459 | ||
1460 | /**
|
1460 | /**
|
1461 | * Обновление информации о корневой папки
|
1461 | * Обновление информации о корневой папки
|
1462 | *
|
1462 | *
|
1463 | * @author Alexander Wolf
|
1463 | * @author Alexander Wolf
|
1464 | * @category Core
|
1464 | * @category Core
|
1465 | *
|
1465 | *
|
1466 | * @param integer $folderID
|
1466 | * @param integer $folderID
|
1467 | * @param string $info
|
1467 | * @param string $info
|
1468 | * @return array
|
1468 | * @return array
|
1469 | */
|
1469 | */
|
1470 | public function updateFolder($folderID, $info) { |
1470 | public function updateFolder($folderID, $info) { |
1471 | $result = array(); |
1471 | $result = array(); |
1472 | $sFolderID = $this->secure->checkInt($folderID); |
1472 | $sFolderID = $this->secure->checkInt($folderID); |
1473 | $sFolder = $this->secure->checkStr($info); |
1473 | $sFolder = $this->secure->checkStr($info); |
1474 | 1474 | ||
1475 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
1475 | $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'"; |
1476 | $rq =& $this->db->query($query); |
1476 | $rq =& $this->db->query($query); |
1477 | if (PEAR::isError($this->db)) { |
1477 | if (PEAR::isError($this->db)) { |
1478 | $result["ERR"] = 1; |
1478 | $result["ERR"] = 1; |
1479 | $result["ERRINFO"] = $this->db->getMessage(); |
1479 | $result["ERRINFO"] = $this->db->getMessage(); |
1480 | } else { |
1480 | } else { |
1481 | $result["ERR"] = 0; |
1481 | $result["ERR"] = 0; |
1482 | }
|
1482 | }
|
1483 | 1483 | ||
1484 | return $result; |
1484 | return $result; |
1485 | }
|
1485 | }
|
1486 | 1486 | ||
1487 | /**
|
1487 | /**
|
1488 | * Вывод формы редактирования/добавления корневых папок
|
1488 | * Вывод формы редактирования/добавления корневых папок
|
1489 | *
|
1489 | *
|
1490 | * @author Alexander Wolf
|
1490 | * @author Alexander Wolf
|
1491 | * @category Core
|
1491 | * @category Core
|
1492 | *
|
1492 | *
|
1493 | * @param integer $folderID
|
1493 | * @param integer $folderID
|
1494 | * @param string $info
|
1494 | * @param string $info
|
1495 | * @return string
|
1495 | * @return string
|
1496 | */
|
1496 | */
|
1497 | public function showFolderForm($folderID = 0, $info = "") { |
1497 | public function showFolderForm($folderID = 0, $info = "") { |
1498 | $sFolderID = $this->secure->checkInt($folderID); |
1498 | $sFolderID = $this->secure->checkInt($folderID); |
1499 | $sInfo = $this->secure->checkStr($info, 1); |
1499 | $sInfo = $this->secure->checkStr($info, 1); |
1500 | if ($sInfo == "") { |
1500 | if ($sInfo == "") { |
1501 | $sInfo = "Корневая папка"; |
1501 | $sInfo = "Корневая папка"; |
1502 | }
|
1502 | }
|
1503 | if ($sFolderID != 0) { |
1503 | if ($sFolderID != 0) { |
1504 | // Режим редактирования
|
1504 | // Режим редактирования
|
1505 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1505 | $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'"; |
1506 | $rq =& $this->db->query($query); |
1506 | $rq =& $this->db->query($query); |
1507 | $rq->fetchInto($element); |
1507 | $rq->fetchInto($element); |
1508 | }
|
1508 | }
|
1509 | 1509 | ||
1510 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1510 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1511 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
1511 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n"; |
1512 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1512 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1513 | 1513 | ||
1514 | return $show; |
1514 | return $show; |
1515 | }
|
1515 | }
|
1516 | 1516 | ||
1517 | /**
|
1517 | /**
|
1518 | * Показывает список подписей
|
1518 | * Показывает список подписей
|
1519 | *
|
1519 | *
|
1520 | * @author Alexander Wolf
|
1520 | * @author Alexander Wolf
|
1521 | * @category Core
|
1521 | * @category Core
|
1522 | *
|
1522 | *
|
1523 | * @param string $name
|
1523 | * @param string $name
|
1524 | * @param string $actor
|
1524 | * @param string $actor
|
1525 | * @param string $format
|
1525 | * @param string $format
|
1526 | * @return string
|
1526 | * @return string
|
1527 | */
|
1527 | */
|
1528 | public function showSignsList($name, $actor, $format = 'list') { |
1528 | public function showSignsList($name, $actor, $format = 'list') { |
1529 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1529 | $query = "SELECT * FROM ".$this->prefix."signs"; |
1530 | $rq =& $this->db->query($query); |
1530 | $rq =& $this->db->query($query); |
1531 | switch ($format) { |
1531 | switch ($format) { |
1532 | case 'list': |
1532 | case 'list': |
1533 | $show = "<ul>\n"; |
1533 | $show = "<ul>\n"; |
1534 | while ($rq->fetchInto($element)) { |
1534 | while ($rq->fetchInto($element)) { |
1535 | $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"; |
1535 | $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"; |
1536 | }
|
1536 | }
|
1537 | $show .= "</ul>"; |
1537 | $show .= "</ul>"; |
1538 | break; |
1538 | break; |
1539 | case 'innerhtml': |
1539 | case 'innerhtml': |
1540 | $signID = $this->secure->checkInt($actor); |
1540 | $signID = $this->secure->checkInt($actor); |
1541 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1541 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1542 | $show .= "<option value='0'>Подписи нет</option>\n"; |
1542 | $show .= "<option value='0'>Подписи нет</option>\n"; |
1543 | while ($rq->fetchInto($element)) { |
1543 | while ($rq->fetchInto($element)) { |
1544 | if ($element["sign_id"]==$signID) { |
1544 | if ($element["sign_id"]==$signID) { |
1545 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1545 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1546 | } else { |
1546 | } else { |
1547 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1547 | $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n"; |
1548 | }
|
1548 | }
|
1549 | }
|
1549 | }
|
1550 | $show .= "</select>\n"; |
1550 | $show .= "</select>\n"; |
1551 | break; |
1551 | break; |
1552 | }
|
1552 | }
|
1553 | 1553 | ||
1554 | return $show; |
1554 | return $show; |
1555 | }
|
1555 | }
|
1556 | 1556 | ||
1557 | /**
|
1557 | /**
|
1558 | * Вывод формы редактирования/добавления подписей
|
1558 | * Вывод формы редактирования/добавления подписей
|
1559 | *
|
1559 | *
|
1560 | * @author Alexander Wolf
|
1560 | * @author Alexander Wolf
|
1561 | * @category Core
|
1561 | * @category Core
|
1562 | *
|
1562 | *
|
1563 | * @param integer $sectionID
|
1563 | * @param integer $sectionID
|
1564 | * @param string $info
|
1564 | * @param string $info
|
1565 | * @return string
|
1565 | * @return string
|
1566 | */
|
1566 | */
|
1567 | public function showSignsForm($signID = 0, $info = "") { |
1567 | public function showSignsForm($signID = 0, $info = "") { |
1568 | $sSignID = $this->secure->checkInt($signID); |
1568 | $sSignID = $this->secure->checkInt($signID); |
1569 | $sInfo = $this->secure->checkStr($info, 1); |
1569 | $sInfo = $this->secure->checkStr($info, 1); |
1570 | if ($sInfo == "") { |
1570 | if ($sInfo == "") { |
1571 | $sInfo = "Подписи"; |
1571 | $sInfo = "Подписи"; |
1572 | }
|
1572 | }
|
1573 | if ($sSignID != 0) { |
1573 | if ($sSignID != 0) { |
1574 | // Режим редактирования
|
1574 | // Режим редактирования
|
1575 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1575 | $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1576 | $rq =& $this->db->query($query); |
1576 | $rq =& $this->db->query($query); |
1577 | $rq->fetchInto($element); |
1577 | $rq->fetchInto($element); |
1578 | }
|
1578 | }
|
1579 | 1579 | ||
1580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1580 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1581 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
1581 | $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n"; |
1582 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
1582 | $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n"; |
1583 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1583 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n"; |
1584 | 1584 | ||
1585 | return $show; |
1585 | return $show; |
1586 | }
|
1586 | }
|
1587 | 1587 | ||
1588 | /**
|
1588 | /**
|
1589 | * Обновление информации о секции
|
1589 | * Обновление информации о секции
|
1590 | *
|
1590 | *
|
1591 | * @author Alexander Wolf
|
1591 | * @author Alexander Wolf
|
1592 | * @category Core
|
1592 | * @category Core
|
1593 | *
|
1593 | *
|
1594 | * @param integer $sectionID
|
1594 | * @param integer $sectionID
|
1595 | * @param string $sname
|
1595 | * @param string $sname
|
1596 | * @param string $sinfo
|
1596 | * @param string $sinfo
|
1597 | * @return array
|
1597 | * @return array
|
1598 | */
|
1598 | */
|
1599 | public function updateSign($signID, $sname, $sinfo = "") { |
1599 | public function updateSign($signID, $sname, $sinfo = "") { |
1600 | $result = array(); |
1600 | $result = array(); |
1601 | $sSignID = $this->secure->checkInt($signID); |
1601 | $sSignID = $this->secure->checkInt($signID); |
1602 | $sSName = $this->secure->checkStr($sname); |
1602 | $sSName = $this->secure->checkStr($sname); |
1603 | $sSInfo = $this->secure->checkStr($sinfo); |
1603 | $sSInfo = $this->secure->checkStr($sinfo); |
1604 | 1604 | ||
1605 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
1605 | $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'"; |
1606 | $rq =& $this->db->query($query); |
1606 | $rq =& $this->db->query($query); |
1607 | if (PEAR::isError($this->db)) { |
1607 | if (PEAR::isError($this->db)) { |
1608 | $result["ERR"] = 1; |
1608 | $result["ERR"] = 1; |
1609 | $result["ERRINFO"] = $this->db->getMessage(); |
1609 | $result["ERRINFO"] = $this->db->getMessage(); |
1610 | } else { |
1610 | } else { |
1611 | $result["ERR"] = 0; |
1611 | $result["ERR"] = 0; |
1612 | }
|
1612 | }
|
1613 | 1613 | ||
1614 | return $result; |
1614 | return $result; |
1615 | }
|
1615 | }
|
1616 | 1616 | ||
1617 | /**
|
1617 | /**
|
1618 | * Удаление информации о подписи
|
1618 | * Удаление информации о подписи
|
1619 | *
|
1619 | *
|
1620 | * @author Alexander Wolf
|
1620 | * @author Alexander Wolf
|
1621 | * @category Core
|
1621 | * @category Core
|
1622 | *
|
1622 | *
|
1623 | * @param integer $sectionID
|
1623 | * @param integer $sectionID
|
1624 | * @return array
|
1624 | * @return array
|
1625 | */
|
1625 | */
|
1626 | public function dropSign($signID) { |
1626 | public function dropSign($signID) { |
1627 | $result = array(); |
1627 | $result = array(); |
1628 | $sSignID = $this->secure->checkInt($signID); |
1628 | $sSignID = $this->secure->checkInt($signID); |
1629 | 1629 | ||
1630 | // Удаление подписи
|
1630 | // Удаление подписи
|
1631 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1631 | $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'"; |
1632 | $rq =& $this->db->query($query); |
1632 | $rq =& $this->db->query($query); |
1633 | if (PEAR::isError($this->db)) { |
1633 | if (PEAR::isError($this->db)) { |
1634 | $result["ERR"] = 1; |
1634 | $result["ERR"] = 1; |
1635 | $result["ERRINFO"] = $this->db->getMessage(); |
1635 | $result["ERRINFO"] = $this->db->getMessage(); |
1636 | } else { |
1636 | } else { |
1637 | $result["ERR"] = 0; |
1637 | $result["ERR"] = 0; |
1638 | }
|
1638 | }
|
1639 | 1639 | ||
1640 | return $result; |
1640 | return $result; |
1641 | }
|
1641 | }
|
1642 | 1642 | ||
1643 | /**
|
1643 | /**
|
1644 | * Добавление новой подписи
|
1644 | * Добавление новой подписи
|
1645 | *
|
1645 | *
|
1646 | * @author Alexander Wolf
|
1646 | * @author Alexander Wolf
|
1647 | * @category Core
|
1647 | * @category Core
|
1648 | *
|
1648 | *
|
1649 | * @param string $sname
|
1649 | * @param string $sname
|
1650 | * @param string $sinfo
|
1650 | * @param string $sinfo
|
1651 | * @return array
|
1651 | * @return array
|
1652 | */
|
1652 | */
|
1653 | public function addSign($sname, $sinfo = "") { |
1653 | public function addSign($sname, $sinfo = "") { |
1654 | $result = array(); |
1654 | $result = array(); |
1655 | $sSName = $this->secure->checkStr($sname); |
1655 | $sSName = $this->secure->checkStr($sname); |
1656 | $sSInfo = $this->secure->checkStr($sinfo); |
1656 | $sSInfo = $this->secure->checkStr($sinfo); |
1657 | 1657 | ||
1658 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
1658 | $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'"; |
1659 | $rq =& $this->db->query($query); |
1659 | $rq =& $this->db->query($query); |
1660 | if (PEAR::isError($this->db)) { |
1660 | if (PEAR::isError($this->db)) { |
1661 | $result["ERR"] = 1; |
1661 | $result["ERR"] = 1; |
1662 | $result["ERRINFO"] = $this->db->getMessage(); |
1662 | $result["ERRINFO"] = $this->db->getMessage(); |
1663 | } else { |
1663 | } else { |
1664 | $result["ERR"] = 0; |
1664 | $result["ERR"] = 0; |
1665 | }
|
1665 | }
|
1666 | 1666 | ||
1667 | return $result; |
1667 | return $result; |
1668 | }
|
1668 | }
|
1669 | 1669 | ||
1670 | /**
|
1670 | /**
|
1671 | * Проверка пароля (из формы авторизации)
|
1671 | * Проверка пароля (из формы авторизации)
|
1672 | *
|
1672 | *
|
1673 | * @author Alexander Wolf
|
1673 | * @author Alexander Wolf
|
1674 | * @category Core
|
1674 | * @category Core
|
1675 | *
|
1675 | *
|
1676 | * @param string $word
|
1676 | * @param string $word
|
1677 | * @return array
|
1677 | * @return array
|
1678 | */
|
1678 | */
|
1679 | public function checkSign($word) { |
1679 | public function checkSign($word) { |
1680 | $result = array(); |
1680 | $result = array(); |
1681 | 1681 | ||
1682 | $sHash = $this->secure->encryptStr($word); |
1682 | $sHash = $this->secure->encryptStr($word); |
1683 | $pwd = $this->getOption("passwd"); |
1683 | $pwd = $this->getOption("passwd"); |
1684 | if ($sHash == $pwd["OptValue"]) { |
1684 | if ($sHash == $pwd["OptValue"]) { |
1685 | $result["ERR"] = 0; |
1685 | $result["ERR"] = 0; |
1686 | $result["Location"] = "manager.php"; |
1686 | $result["Location"] = "manager.php"; |
1687 | setcookie($this->cookie, $sHash); |
1687 | setcookie($this->cookie, $sHash); |
1688 | } else { |
1688 | } else { |
1689 | $result["ERR"] = 1; |
1689 | $result["ERR"] = 1; |
1690 | $result["ERRINFO"] = "Password not valid"; |
1690 | $result["ERRINFO"] = "Password not valid"; |
1691 | $result["Location"] = "manager.php?error=1"; |
1691 | $result["Location"] = "manager.php?error=1"; |
1692 | }
|
1692 | }
|
1693 | 1693 | ||
1694 | return $result; |
1694 | return $result; |
1695 | }
|
1695 | }
|
1696 | 1696 | ||
1697 | /**
|
1697 | /**
|
1698 | * Проверка пароля (из cookies)
|
1698 | * Проверка пароля (из cookies)
|
1699 | *
|
1699 | *
|
1700 | * @author Alexander Wolf
|
1700 | * @author Alexander Wolf
|
1701 | * @category Core
|
1701 | * @category Core
|
1702 | *
|
1702 | *
|
1703 | * @param string $hash
|
1703 | * @param string $hash
|
1704 | * @return array
|
1704 | * @return array
|
1705 | */
|
1705 | */
|
1706 | public function checkCookieSign($hash) { |
1706 | public function checkCookieSign($hash) { |
1707 | $result = array(); |
1707 | $result = array(); |
1708 | 1708 | ||
1709 | $pwd = $this->getOption("passwd"); |
1709 | $pwd = $this->getOption("passwd"); |
1710 | if ($hash == $pwd["OptValue"]) { |
1710 | if ($hash == $pwd["OptValue"]) { |
1711 | $result["ERR"] = 0; |
1711 | $result["ERR"] = 0; |
1712 | } else { |
1712 | } else { |
1713 | $result["ERR"] = 1; |
1713 | $result["ERR"] = 1; |
1714 | $result["ERRINFO"] = "Hash not valid"; |
1714 | $result["ERRINFO"] = "Hash not valid"; |
1715 | $result["Location"] = "manager.php"; |
1715 | $result["Location"] = "manager.php"; |
1716 | }
|
1716 | }
|
1717 | 1717 | ||
1718 | return $result; |
1718 | return $result; |
1719 | }
|
1719 | }
|
1720 | 1720 | ||
1721 | /**
|
1721 | /**
|
1722 | * Форма ввода пароля
|
1722 | * Форма ввода пароля
|
1723 | *
|
1723 | *
|
1724 | * @author Alexander Wolf
|
1724 | * @author Alexander Wolf
|
1725 | * @category Core
|
1725 | * @category Core
|
1726 | *
|
1726 | *
|
1727 | * @return string
|
1727 | * @return string
|
1728 | */
|
1728 | */
|
1729 | public function showSigninForm() { |
1729 | public function showSigninForm() { |
1730 | $show = "<div id='regform'>"; |
1730 | $show = "<div id='regform'>"; |
1731 | $show .= "<form action='process.php' method='post'>\n"; |
1731 | $show .= "<form action='process.php' method='post'>\n"; |
1732 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1732 | $show .= "<fieldset><legend>Пароль</legend>\n"; |
1733 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
1733 | $show .= "<input type='hidden' name='mode' value='authorize'>\n"; |
1734 | $show .= "<input type='password' name='word' value=''>\n"; |
1734 | $show .= "<input type='password' name='word' value=''>\n"; |
1735 | $show .= "<input type='submit' value=' Войти '>\n"; |
1735 | $show .= "<input type='submit' value=' Войти '>\n"; |
1736 | $show .= "</fieldset>\n</form></div>\n"; |
1736 | $show .= "</fieldset>\n</form></div>\n"; |
1737 | 1737 | ||
1738 | return $show; |
1738 | return $show; |
1739 | }
|
1739 | }
|
1740 | 1740 | ||
1741 | /**
|
1741 | /**
|
1742 | * Обновление пароля
|
1742 | * Обновление пароля
|
1743 | *
|
1743 | *
|
1744 | * @author Alexander Wolf
|
1744 | * @author Alexander Wolf
|
1745 | * @category Core
|
1745 | * @category Core
|
1746 | *
|
1746 | *
|
1747 | * @param string $word1
|
1747 | * @param string $word1
|
1748 | * @param string $word2
|
1748 | * @param string $word2
|
1749 | * @return array
|
1749 | * @return array
|
1750 | */
|
1750 | */
|
1751 | public function updatePassword($word1, $word2) { |
1751 | public function updatePassword($word1, $word2) { |
1752 | $result = array(); |
1752 | $result = array(); |
1753 | 1753 | ||
1754 | if ($word1 == $word2) { |
1754 | if ($word1 == $word2) { |
1755 | $sWord = $this->secure->encryptStr($word1); |
1755 | $sWord = $this->secure->encryptStr($word1); |
1756 | $r = $this->setOption("passwd", $sWord); |
1756 | $r = $this->setOption("passwd", $sWord); |
1757 | $result = $r; |
1757 | $result = $r; |
1758 | } else { |
1758 | } else { |
1759 | $result["ERR"] = 1; |
1759 | $result["ERR"] = 1; |
1760 | $result["ERRINFO"] = "Passwords is mismatch"; |
1760 | $result["ERRINFO"] = "Passwords is mismatch"; |
1761 | }
|
1761 | }
|
1762 | 1762 | ||
1763 | return $result; |
1763 | return $result; |
1764 | }
|
1764 | }
|
1765 | 1765 | ||
1766 | /**
|
1766 | /**
|
1767 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
1767 | * Отображение формы создания и редактирования версии apt-дистрибутива
|
1768 | *
|
1768 | *
|
1769 | * @author Alexander Wolf
|
1769 | * @author Alexander Wolf
|
1770 | * @category Core
|
1770 | * @category Core
|
1771 | *
|
1771 | *
|
1772 | * @param string $name
|
1772 | * @param string $name
|
1773 | * @param string $actor
|
1773 | * @param string $actor
|
1774 | * @param integer $versionID
|
1774 | * @param integer $versionID
|
1775 | * @return string
|
1775 | * @return string
|
1776 | */
|
1776 | */
|
1777 | public function showDistVersionsForm($versionID = 0, $info = '') { |
1777 | public function showDistVersionsForm($versionID = 0, $info = '') { |
1778 | $sVersionID = $this->secure->checkInt($versionID); |
1778 | $sVersionID = $this->secure->checkInt($versionID); |
1779 | $sInfo = $this->secure->checkStr($info, 1); |
1779 | $sInfo = $this->secure->checkStr($info, 1); |
1780 | if ($sInfo == "") { |
1780 | if ($sInfo == "") { |
1781 | $sInfo = "Версия дистрибутива"; |
1781 | $sInfo = "Версия дистрибутива"; |
1782 | }
|
1782 | }
|
1783 | if ($sVersionID != 0) { |
1783 | if ($sVersionID != 0) { |
1784 | // Режим редактирования
|
1784 | // Режим редактирования
|
1785 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'"; |
1785 | $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'"; |
1786 | $rq =& $this->db->query($query); |
1786 | $rq =& $this->db->query($query); |
1787 | $rq->fetchInto($element); |
1787 | $rq->fetchInto($element); |
1788 | }
|
1788 | }
|
1789 | 1789 | ||
1790 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1790 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1791 | if ($sVersionID != 0) { |
1791 | if ($sVersionID != 0) { |
1792 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
1792 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n"; |
1793 | } else { |
1793 | } else { |
1794 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
1794 | $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n"; |
1795 | }
|
1795 | }
|
1796 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1796 | $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n"; |
1797 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
1797 | $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n"; |
1798 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
1798 | $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n"; |
1799 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
1799 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
1800 | 1800 | ||
1801 | return $show; |
1801 | return $show; |
1802 | }
|
1802 | }
|
1803 | 1803 | ||
1804 | /**
|
1804 | /**
|
1805 | * Парсер схемы адреса репозитория
|
1805 | * Парсер схемы адреса репозитория
|
1806 | * FIXME Возможно не потребуется
|
1806 | * FIXME Возможно не потребуется
|
1807 | *
|
1807 | *
|
1808 | * @author Alexander Wolf
|
1808 | * @author Alexander Wolf
|
1809 | * @category Core
|
1809 | * @category Core
|
1810 | *
|
1810 | *
|
1811 | * @param string $repstring
|
1811 | * @param string $repstring
|
1812 | * @return integer
|
1812 | * @return integer
|
1813 | */
|
1813 | */
|
1814 | public function repositoryParser($repstring) { |
1814 | public function repositoryParser($repstring) { |
1815 | $tokens = array(); |
1815 | $tokens = array(); |
1816 | $sections = array(); |
1816 | $sections = array(); |
1817 | $tokens = split(" ",$repstring); |
1817 | $tokens = split(" ",$repstring); |
1818 | 1818 | ||
1819 | if ($tokens[0] == "deb") { |
1819 | if ($tokens[0] == "deb") { |
1820 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1820 | // debian/ubuntu репозиторий "type proto://host/folder distr sections"
|
1821 | $url = parse_url($tokens[1]); |
1821 | $url = parse_url($tokens[1]); |
1822 | $distr = $tokens[2]; |
1822 | $distr = $tokens[2]; |
1823 | 1823 | ||
1824 | for($i=3;$i<count($tokens);$i++) { |
1824 | for($i=3;$i<count($tokens);$i++) { |
1825 | $sections[] = $tokens[$i]; |
1825 | $sections[] = $tokens[$i]; |
1826 | }
|
1826 | }
|
1827 | } else { |
1827 | } else { |
1828 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1828 | // altlinux репозиторий "type [sign] proto://host/folder base repname"
|
1829 | if (stripos($tokens[1],"]")!=0) { |
1829 | if (stripos($tokens[1],"]")!=0) { |
1830 | $sign = $tokens[1]; |
1830 | $sign = $tokens[1]; |
1831 | $url = parse_url($tokens[2]); |
1831 | $url = parse_url($tokens[2]); |
1832 | $base = $tokens[3]; |
1832 | $base = $tokens[3]; |
1833 | $repname = $tokens[4]; |
1833 | $repname = $tokens[4]; |
1834 | } else { |
1834 | } else { |
1835 | $url = parse_url($tokens[1]); |
1835 | $url = parse_url($tokens[1]); |
1836 | $base = $tokens[2]; |
1836 | $base = $tokens[2]; |
1837 | $repname = $tokens[3]; |
1837 | $repname = $tokens[3]; |
1838 | }
|
1838 | }
|
1839 | }
|
1839 | }
|
1840 | 1840 | ||
1841 | $proto = $url["scheme"]."://"; |
1841 | $proto = $url["scheme"]."://"; |
1842 | $addr = $url["host"]; |
1842 | $addr = $url["host"]; |
1843 | if ($url["port"]!="") { |
1843 | if ($url["port"]!="") { |
1844 | $addr .= ":".$url["port"]; |
1844 | $addr .= ":".$url["port"]; |
1845 | }
|
1845 | }
|
1846 | $path = $url["path"]; |
1846 | $path = $url["path"]; |
1847 | 1847 | ||
1848 | return 0; |
1848 | return 0; |
1849 | }
|
1849 | }
|
1850 | 1850 | ||
1851 | /**
|
1851 | /**
|
1852 | * Выгрузка картинок логотипов дистрибутивов
|
1852 | * Выгрузка картинок логотипов дистрибутивов
|
1853 | *
|
1853 | *
|
1854 | * @author Alexander Wolf
|
1854 | * @author Alexander Wolf
|
1855 | * @category Core
|
1855 | * @category Core
|
1856 | *
|
1856 | *
|
1857 | * @param string $path
|
1857 | * @param string $path
|
1858 | * @param string $dist
|
1858 | * @param string $dist
|
1859 | * @param array $datafile
|
1859 | * @param array $datafile
|
1860 | * @return integer
|
1860 | * @return integer
|
1861 | */
|
1861 | */
|
1862 | public function uploadPicture($path, $dist, $datafile) { |
1862 | public function uploadPicture($path, $dist, $datafile) { |
1863 | $folder = $path.$dist."-orig.png"; |
1863 | $folder = $path.$dist."-orig.png"; |
1864 | $folderN = $path.$dist.".png"; |
1864 | $folderN = $path.$dist.".png"; |
1865 | $folderEM = $path.$dist."-em.png"; |
1865 | $folderEM = $path.$dist."-em.png"; |
1866 | 1866 | ||
1867 | $distlogo = 0; |
1867 | $distlogo = 0; |
1868 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1868 | if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) { |
1869 | chmod($folder, 0644); |
1869 | chmod($folder, 0644); |
1870 | list($width, $height) = GetImageSize($folder); |
1870 | list($width, $height) = GetImageSize($folder); |
1871 | $percent = 32/$height; |
1871 | $percent = 32/$height; |
1872 | $newwidth = $width * $percent; |
1872 | $newwidth = $width * $percent; |
1873 | $newheight = $height * $percent; |
1873 | $newheight = $height * $percent; |
1874 | 1874 | ||
1875 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1875 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1876 | $source = ImageCreateFromPNG($folder); |
1876 | $source = ImageCreateFromPNG($folder); |
1877 | 1877 | ||
1878 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1878 | ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1879 | ImagePNG($output, $folderEM); |
1879 | ImagePNG($output, $folderEM); |
1880 | 1880 | ||
1881 | $percent = 15/$height; |
1881 | $percent = 15/$height; |
1882 | $newwidth = $width * $percent; |
1882 | $newwidth = $width * $percent; |
1883 | $newheight = $height * $percent; |
1883 | $newheight = $height * $percent; |
1884 | 1884 | ||
1885 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1885 | $output = ImageCreateTrueColor($newwidth, $newheight); |
1886 | 1886 | ||
1887 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1887 | ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); |
1888 | ImagePNG($output, $folderN); |
1888 | ImagePNG($output, $folderN); |
1889 | 1889 | ||
1890 | unlink($folder); |
1890 | unlink($folder); |
1891 | $distlogo = 1; |
1891 | $distlogo = 1; |
1892 | }
|
1892 | }
|
1893 | return $distlogo; |
1893 | return $distlogo; |
1894 | }
|
1894 | }
|
1895 | 1895 | ||
1896 | /**
|
1896 | /**
|
1897 | * Показ списка репозиториев
|
1897 | * Показ списка репозиториев
|
1898 | *
|
1898 | *
|
1899 | * @author Alexander Wolf
|
1899 | * @author Alexander Wolf
|
1900 | * @category Core
|
1900 | * @category Core
|
1901 | *
|
1901 | *
|
1902 | * @param string $name
|
1902 | * @param string $name
|
1903 | * @param string $actor
|
1903 | * @param string $actor
|
1904 | * @param string $format
|
1904 | * @param string $format
|
1905 | * @return string
|
1905 | * @return string
|
1906 | */
|
1906 | */
|
1907 | public function showRepositoriesList($name, $actor, $format = 'list') { |
1907 | public function showRepositoriesList($name, $actor, $format = 'list') { |
1908 | $query = "SELECT * FROM ".$this->prefix."repository r "; |
1908 | $query = "SELECT r.*,rt.*,CONCAT(v.version,' ',v.vname) AS fullname FROM ".$this->prefix."repository r "; |
1909 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
1909 | $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id "; |
1910 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version"; |
1910 | $query .= "JOIN ".$this->prefix."version v ON v.version_id=r.version"; |
1911 | $rq =& $this->db->query($query); |
1911 | $rq =& $this->db->query($query); |
1912 | $show = "<ul>"; |
1912 | $show = "<ul>"; |
1913 | while ($rq->fetchInto($element)) { |
1913 | while ($rq->fetchInto($element)) { |
1914 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["rep_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["rep_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["repname"],1)." (".$this->secure->checkStr($element["rtype"],1)."; <em>".$this->secure->checkStr($element["vname"],1)."</em>)</li>\n"; |
1914 | $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["rep_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["rep_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["repname"],1)." (".$this->secure->checkStr($element["fullname"],1)." — ".$this->secure->checkStr($element["rtype"],1).")</li>\n"; |
1915 | }
|
1915 | }
|
1916 | $show .= "</ul>"; |
1916 | $show .= "</ul>"; |
1917 | return $show; |
1917 | return $show; |
1918 | }
|
1918 | }
|
1919 | 1919 | ||
1920 | /**
|
1920 | /**
|
1921 | * Вывод списка типов репозиториев
|
1921 | * Вывод списка типов репозиториев
|
1922 | *
|
1922 | *
|
1923 | * @author Alexander Wolf
|
1923 | * @author Alexander Wolf
|
1924 | * @category Core
|
1924 | * @category Core
|
1925 | *
|
1925 | *
|
1926 | * @param integer $reptype
|
1926 | * @param integer $reptype
|
1927 | * @param string $name
|
1927 | * @param string $name
|
1928 | * @return string
|
1928 | * @return string
|
1929 | */
|
1929 | */
|
1930 | public function showRepType($reptype = 0, $name = "") { |
1930 | public function showRepType($reptype = 0, $name = "") { |
1931 | $sRT = $this->secure->checkInt($reptype); |
1931 | $sRT = $this->secure->checkInt($reptype); |
1932 | $sNM = $this->secure->checkStr($name,1); |
1932 | $sNM = $this->secure->checkStr($name,1); |
1933 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
1933 | $query = "SELECT * FROM ".$this->prefix."rtype"; |
1934 | $rq =& $this->db->query($query); |
1934 | $rq =& $this->db->query($query); |
1935 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
1935 | $show = "<select name='".$sNM."' id='".$sNM."'>\n"; |
1936 | while ($rq->fetchInto($element)) { |
1936 | while ($rq->fetchInto($element)) { |
1937 | if ($element["rtype_id"]==$sRT) { |
1937 | if ($element["rtype_id"]==$sRT) { |
1938 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
1938 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
1939 | } else { |
1939 | } else { |
1940 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
1940 | $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n"; |
1941 | }
|
1941 | }
|
1942 | }
|
1942 | }
|
1943 | $show .= "</select>"; |
1943 | $show .= "</select>"; |
1944 | 1944 | ||
1945 | return $show; |
1945 | return $show; |
1946 | }
|
1946 | }
|
1947 | 1947 | ||
1948 | public function showVDList($name, $versionID = 0) { |
1948 | public function showVDList($name, $versionID = 0) { |
1949 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
1949 | $query = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v "; |
1950 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
1950 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id"; |
1951 | $rq =& $this->db->query($query); |
1951 | $rq =& $this->db->query($query); |
1952 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1952 | $show = "<select name='".$name."' id='".$name."'>\n"; |
1953 | while ($rq->fetchInto($element)) { |
1953 | while ($rq->fetchInto($element)) { |
1954 | if ($element["version_id"]==$versionID) { |
1954 | if ($element["version_id"]==$versionID) { |
1955 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
1955 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
1956 | } else { |
1956 | } else { |
1957 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
1957 | $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n"; |
1958 | }
|
1958 | }
|
1959 | }
|
1959 | }
|
1960 | $show .= "</select>"; |
1960 | $show .= "</select>"; |
1961 | return $show; |
1961 | return $show; |
1962 | }
|
1962 | }
|
1963 | 1963 | ||
1964 | /**
|
1964 | /**
|
1965 | * Форма создания/редактирвоания репозиториев
|
1965 | * Форма создания/редактирвоания репозиториев
|
1966 | *
|
1966 | *
|
1967 | * @author Alexander Wolf
|
1967 | * @author Alexander Wolf
|
1968 | * @category Core
|
1968 | * @category Core
|
1969 | *
|
1969 | *
|
1970 | * @param integer $repID
|
1970 | * @param integer $repID
|
1971 | * @param string $info
|
1971 | * @param string $info
|
1972 | * @param string $reptype
|
1972 | * @param string $reptype
|
1973 | * @return string
|
1973 | * @return string
|
1974 | */
|
1974 | */
|
1975 | public function showRepositoriesForm($repID = 0, $info = "") { |
1975 | public function showRepositoriesForm($repID = 0, $info = "") { |
1976 | $sRepID = $this->secure->checkInt($repID); |
1976 | $sRepID = $this->secure->checkInt($repID); |
1977 | $sInfo = $this->secure->checkStr($info, 1); |
1977 | $sInfo = $this->secure->checkStr($info, 1); |
1978 | if ($sInfo == "") { |
1978 | if ($sInfo == "") { |
1979 | $sInfo = "Репозиторий"; |
1979 | $sInfo = "Репозиторий"; |
1980 | }
|
1980 | }
|
1981 | if ($sRepID != 0) { |
1981 | if ($sRepID != 0) { |
1982 | // Режим редактирования
|
1982 | // Режим редактирования
|
1983 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
1983 | $query = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r "; |
1984 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
1984 | $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id "; |
1985 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
1985 | $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id "; |
1986 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
1986 | $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id "; |
1987 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
1987 | $query .= "WHERE r.rep_id='".$sRepID."'"; |
1988 | $rq =& $this->db->query($query); |
1988 | $rq =& $this->db->query($query); |
1989 | $rq->fetchInto($element); |
1989 | $rq->fetchInto($element); |
1990 | }
|
1990 | }
|
1991 | 1991 | ||
1992 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1992 | $show = "<fieldset><legend>".$sInfo."</legend>\n"; |
1993 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
1993 | $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["version_id"]),"innerhtml")."</div>\n"; |
1994 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value='".$this->secure->checkStr($element["repname"],1)."'></div>\n"; |
1994 | $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value='".$this->secure->checkStr($element["repname"],1)."'></div>\n"; |
1995 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value='".$this->secure->checkStr($element["repinfo"],1)."'></div>\n"; |
1995 | $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value='".$this->secure->checkStr($element["repinfo"],1)."'></div>\n"; |
1996 | $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value='".$this->secure->checkStr($element["repkey"],1)."'></div>\n"; |
1996 | $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value='".$this->secure->checkStr($element["repkey"],1)."'></div>\n"; |
1997 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
1997 | $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n"; |
1998 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
1998 | $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n"; |
1999 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
1999 | $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rfolder",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n"; |
2000 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
2000 | $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n"; |
2001 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
2001 | $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n"; |
2002 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
2002 | $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n"; |
2003 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
2003 | $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$this->secure->checkInt($element["scheme_id"]),"innerhtml")."</div>\n"; |
2004 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
2004 | $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$this->secure->checkInt($element["sign_id"]),"innerhtml")."</div>\n"; |
2005 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
2005 | $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n"; |
2006 | 2006 | ||
2007 | return $show; |
2007 | return $show; |
2008 | }
|
2008 | }
|
2009 | 2009 | ||
2010 | /**
|
2010 | /**
|
2011 | * Добавление нового репозитория
|
2011 | * Добавление нового репозитория
|
2012 | *
|
2012 | *
|
2013 | * @author Alexander Wolf
|
2013 | * @author Alexander Wolf
|
2014 | * @category Core
|
2014 | * @category Core
|
2015 | *
|
2015 | *
|
2016 | * @param integer $verionID
|
2016 | * @param integer $verionID
|
2017 | * @param string $rname
|
2017 | * @param string $rname
|
2018 | * @param string $rinfo
|
2018 | * @param string $rinfo
|
2019 | * @param string $rkey
|
2019 | * @param string $rkey
|
2020 | * @param integer $proto
|
2020 | * @param integer $proto
|
2021 | * @param integer $rhost
|
2021 | * @param integer $rhost
|
2022 | * @param integer $rfolder
|
2022 | * @param integer $rfolder
|
2023 | * @param integer $rtype
|
2023 | * @param integer $rtype
|
2024 | * @param array $sections
|
2024 | * @param array $sections
|
2025 | * @param array $arch
|
2025 | * @param array $arch
|
2026 | * @param integer $scheme
|
2026 | * @param integer $scheme
|
2027 | * @param integer $sign
|
2027 | * @param integer $sign
|
2028 | * @return array
|
2028 | * @return array
|
2029 | */
|
2029 | */
|
2030 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
2030 | public function addRepository($verionID, $rname, $rinfo, $rkey, $proto, $rhost, $rfolder, $rtype, $scheme, $sign, $sections, $arch) { |
2031 | $result = array(); |
2031 | $result = array(); |
2032 | $sVersionID = $this->secure->checkInt($verionID); |
2032 | $sVersionID = $this->secure->checkInt($verionID); |
2033 | $sRName = $this->secure->checkStr($rname); |
2033 | $sRName = $this->secure->checkStr($rname); |
2034 | $sRInfo = $this->secure->checkStr($rinfo); |
2034 | $sRInfo = $this->secure->checkStr($rinfo); |
2035 | $sRKey = $this->secure->checkStr($rkey); |
2035 | $sRKey = $this->secure->checkStr($rkey); |
2036 | $sProto = $this->secure->checkInt($proto); |
2036 | $sProto = $this->secure->checkInt($proto); |
2037 | $sRHost = $this->secure->checkInt($rhost); |
2037 | $sRHost = $this->secure->checkInt($rhost); |
2038 | $sRFolder = $this->secure->checkInt($rfolder); |
2038 | $sRFolder = $this->secure->checkInt($rfolder); |
2039 | $sRType = $this->secure->checkInt($rtype); |
2039 | $sRType = $this->secure->checkInt($rtype); |
2040 | $sRScheme = $this->secure->checkInt($scheme); |
2040 | $sRScheme = $this->secure->checkInt($scheme); |
2041 | $sRSign = $this->secure->checkInt($sign); |
2041 | $sRSign = $this->secure->checkInt($sign); |
2042 | 2042 | ||
2043 | $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."'"; |
2043 | $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."'"; |
2044 | $rq =& $this->db->query($query); |
2044 | $rq =& $this->db->query($query); |
2045 | 2045 | ||
2046 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
2046 | $query = "SELECT rep_id FROM ".$this->prefix."repository ORDER BY rep_id DESC LIMIT 0, 1"; |
2047 | $rq =& $this->db->query($query); |
2047 | $rq =& $this->db->query($query); |
2048 | $rq->fetchInto($repository); |
2048 | $rq->fetchInto($repository); |
2049 | 2049 | ||
2050 | for($i=0;$i<count($sections);$i++) { |
2050 | for($i=0;$i<count($sections);$i++) { |
2051 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
2051 | $query = "INSERT INTO ".$this->prefix."sect2rep SET rep_id='".$repository["rep_id"]."', sect_id='".$sections[$i]."'"; |
2052 | $rq =& $this->db->query($query); |
2052 | $rq =& $this->db->query($query); |
2053 | }
|
2053 | }
|
2054 | 2054 | ||
2055 | for($i=0;$i<count($arch);$i++) { |
2055 | for($i=0;$i<count($arch);$i++) { |
2056 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
2056 | $query = "INSERT INTO ".$this->prefix."arch2rep SET rep_id='".$repository["rep_id"]."', arch_id='".$arch[$i]."'"; |
2057 | $rq =& $this->db->query($query); |
2057 | $rq =& $this->db->query($query); |
2058 | }
|
2058 | }
|
2059 | 2059 | ||
2060 | if (PEAR::isError($this->db)) { |
2060 | if (PEAR::isError($this->db)) { |
2061 | $result["ERR"] = 1; |
2061 | $result["ERR"] = 1; |
2062 | $result["ERRINFO"] = $this->db->getMessage(); |
2062 | $result["ERRINFO"] = $this->db->getMessage(); |
2063 | } else { |
2063 | } else { |
2064 | $result["ERR"] = 0; |
2064 | $result["ERR"] = 0; |
2065 | }
|
2065 | }
|
2066 | 2066 | ||
2067 | return $result; |
2067 | return $result; |
2068 | }
|
2068 | }
|
2069 | 2069 | ||
2070 | }
|
2070 | }
|
2071 | 2071 | ||
2072 | ?>
|
2072 | ?>
|