Хранилища Subversion ant

Редакция

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

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