Хранилища Subversion ant

Редакция

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

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