Хранилища Subversion ant

Редакция

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

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