Хранилища Subversion ant

Редакция

Редакция 671 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

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