Хранилища Subversion ant

Редакция

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

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