Хранилища Subversion ant

Редакция

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

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