Хранилища Subversion ant

Редакция

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

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