Хранилища Subversion ant

Редакция

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

Редакция 593 Редакция 594
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
        $rq =& $this->db->query($query);
273
        $rq =& $this->db->query($query);
274
        switch ($format) {
274
        switch ($format) {
275
            case 'html':
275
            case 'html':
276
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
276
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
277
                while ($rq->fetchInto($element)) {
277
                while ($rq->fetchInto($element)) {
278
                    $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";
278
                    $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
                }
279
                }
280
                $show .= "</fieldset>\n";
280
                $show .= "</fieldset>\n";
281
                break;
281
                break;
282
            case 'json':
282
            case 'json':
283
                //TODO Доделать JSON-вывод списка секций основного репозитория
283
                //TODO Доделать JSON-вывод списка секций основного репозитория
284
                break;
284
                break;
285
        }
285
        }
286
286
287
        return $show;
287
        return $show;
288
    }
288
    }
289
289
290
    /**
290
    /**
291
     * Получение и отображение списка репозиториев
291
     * Получение и отображение списка репозиториев
292
     *
292
     *
293
     * @author Alexander Wolf
293
     * @author Alexander Wolf
294
     * @category Core
294
     * @category Core
295
     *
295
     *
296
     * @param integer $version
296
     * @param integer $version
297
     * @param integer $reptype
297
     * @param integer $reptype
298
     * @param string $format
298
     * @param string $format
299
     * @return string
299
     * @return string
300
     */
300
     */
301
    public function showRepList($version, $reptype, $format = 'html') {
301
    public function showRepList($version, $reptype, $format = 'html') {
302
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'";
302
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'";
303
        $rq =& $this->db->query($query);
303
        $rq =& $this->db->query($query);
304
        $rq->fetchInto($types);
304
        $rq->fetchInto($types);
305
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
305
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
306
        $rq =& $this->db->query($query);
306
        $rq =& $this->db->query($query);
307
        switch ($format) {
307
        switch ($format) {
308
            case 'html':
308
            case 'html':
309
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
309
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
310
                while ($rq->fetchInto($types)) {
310
                while ($rq->fetchInto($types)) {
311
                    $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";
311
                    $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
                }
312
                }
313
                $show .= "</fieldset>\n";
313
                $show .= "</fieldset>\n";
314
                break;
314
                break;
315
            case 'json':
315
            case 'json':
316
                //TODO Доделать JSON-вывод списка репозиториев
316
                //TODO Доделать JSON-вывод списка репозиториев
317
                break;
317
                break;
318
        }
318
        }
319
319
320
        return $show;
320
        return $show;
321
    }
321
    }
322
322
323
    /**
323
    /**
324
     * Добавление поддержки нового apt-дистрибутива
324
     * Добавление поддержки нового apt-дистрибутива
325
     *
325
     *
326
     * @author Alexander Wolf
326
     * @author Alexander Wolf
327
     * @category Core
327
     * @category Core
328
     *
328
     *
329
     * @param string $distname
329
     * @param string $distname
330
     * @param integer $disttype
330
     * @param integer $disttype
331
     * @param string $distua
331
     * @param string $distua
332
     * @param byte $distlogo
332
     * @param byte $distlogo
333
     * @return array
333
     * @return array
334
     */
334
     */
335
    public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) {
335
    public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) {
336
        $result = array();
336
        $result = array();
337
        $sDName = $this->secure->checkStr($distname);
337
        $sDName = $this->secure->checkStr($distname);
338
        $sDType = $this->secure->checkInt($disttype);
338
        $sDType = $this->secure->checkInt($disttype);
339
        $sDUAgt = $this->secure->checkStr($distua);
339
        $sDUAgt = $this->secure->checkStr($distua);
340
        $sDLogo = $this->secure->checkInt($distlogo);
340
        $sDLogo = $this->secure->checkInt($distlogo);
341
341
342
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
342
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
343
        $rq =& $this->db->query($query);
343
        $rq =& $this->db->query($query);
344
        if (PEAR::isError($this->db)) {
344
        if (PEAR::isError($this->db)) {
345
            $result["ERR"] = 1;
345
            $result["ERR"] = 1;
346
            $result["ERRINFO"] = $this->db->getMessage();
346
            $result["ERRINFO"] = $this->db->getMessage();
347
        } else {            
347
        } else {            
348
            $result["ERR"] = 0;
348
            $result["ERR"] = 0;
349
        }
349
        }
350
350
351
        return $result;
351
        return $result;
352
    }
352
    }
353
353
354
    /**
354
    /**
355
     * Обновление информации о дистрибутиве
355
     * Обновление информации о дистрибутиве
356
     *
356
     *
357
     * @author Alexander Wolf
357
     * @author Alexander Wolf
358
     * @category Core
358
     * @category Core
359
     *
359
     *
360
     * @param integer $distID
360
     * @param integer $distID
361
     * @param string $distname
361
     * @param string $distname
362
     * @param integer $disttype
362
     * @param integer $disttype
363
     * @param string $distua
363
     * @param string $distua
364
     * @param integer $distlogo
364
     * @param integer $distlogo
365
     * @return array
365
     * @return array
366
     */
366
     */
367
    public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) {
367
    public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) {
368
        $result = array();
368
        $result = array();
369
        $sDID   = $this->secure->checkInt($distID);
369
        $sDID   = $this->secure->checkInt($distID);
370
        $sDName = $this->secure->checkStr($distname);
370
        $sDName = $this->secure->checkStr($distname);
371
        $sDType = $this->secure->checkInt($disttype);
371
        $sDType = $this->secure->checkInt($disttype);
372
        $sDUAgt = $this->secure->checkStr($distua);
372
        $sDUAgt = $this->secure->checkStr($distua);
373
        $sDLogo = $this->secure->checkInt($distlogo);
373
        $sDLogo = $this->secure->checkInt($distlogo);
374
374
375
        if ($sDLogo!=0) {
375
        if ($sDLogo!=0) {
376
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'";
376
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'";
377
        } else {
377
        } else {
378
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'";
378
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'";
379
        }
379
        }
380
        $rq =& $this->db->query($query);
380
        $rq =& $this->db->query($query);
381
        if (PEAR::isError($this->db)) {
381
        if (PEAR::isError($this->db)) {
382
            $result["ERR"] = 1;
382
            $result["ERR"] = 1;
383
            $result["ERRINFO"] = $this->db->getMessage();
383
            $result["ERRINFO"] = $this->db->getMessage();
384
        } else {            
384
        } else {            
385
            $result["ERR"] = 0;
385
            $result["ERR"] = 0;
386
        }
386
        }
387
387
388
        return $result;
388
        return $result;
389
    }
389
    }
390
390
391
    /**
391
    /**
392
     * Удаление информации о дистрибутиве
392
     * Удаление информации о дистрибутиве
393
     *
393
     *
394
     * @author Alexander Wolf
394
     * @author Alexander Wolf
395
     * @category Core
395
     * @category Core
396
     *
396
     *
397
     * @param integer $distID
397
     * @param integer $distID
398
     * @return array
398
     * @return array
399
     */
399
     */
400
    public function dropDistribution($distID) {
400
    public function dropDistribution($distID) {
401
        $result = array();
401
        $result = array();
402
        $sDID   = $this->secure->checkInt($distID);
402
        $sDID   = $this->secure->checkInt($distID);
403
403
404
        // Удаление дистрибутива
404
        // Удаление дистрибутива
405
        $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'";
405
        $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'";
406
        $rq =& $this->db->query($query);
406
        $rq =& $this->db->query($query);
407
        if (PEAR::isError($this->db)) {
407
        if (PEAR::isError($this->db)) {
408
            $result["ERR"] = 1;
408
            $result["ERR"] = 1;
409
            $result["ERRINFO"] = $this->db->getMessage();
409
            $result["ERRINFO"] = $this->db->getMessage();
410
        } else {            
410
        } else {            
411
            $result["ERR"] = 0;
411
            $result["ERR"] = 0;
412
        }
412
        }
413
413
414
        // Удаление версий дистрибутива
414
        // Удаление версий дистрибутива
415
        $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'";
415
        $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'";
416
        $rq =& $this->db->query($query);
416
        $rq =& $this->db->query($query);
417
        if (PEAR::isError($this->db)) {
417
        if (PEAR::isError($this->db)) {
418
            $result["ERR"] = 1;
418
            $result["ERR"] = 1;
419
            $result["ERRINFO"] = $this->db->getMessage();
419
            $result["ERRINFO"] = $this->db->getMessage();
420
        } else {            
420
        } else {            
421
            $result["ERR"] = 0;
421
            $result["ERR"] = 0;
422
        }
422
        }
423
423
424
        return $result;
424
        return $result;
425
    }
425
    }
426
426
427
    /**
427
    /**
428
     * Добавление поддержки новой версии apt-дистрибутива
428
     * Добавление поддержки новой версии apt-дистрибутива
429
     *
429
     *
430
     * @author Alexander Wolf
430
     * @author Alexander Wolf
431
     * @category Core
431
     * @category Core
432
     *
432
     *
433
     * @param integer $distID
433
     * @param integer $distID
434
     * @param integer $version
434
     * @param integer $version
435
     * @param string $vname
435
     * @param string $vname
436
     * @param integer $vcodename
436
     * @param integer $vcodename
437
     * @return array
437
     * @return array
438
     */
438
     */
439
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
439
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
440
        $result = array();
440
        $result = array();
441
        $sDistID    = $this->secure->checkInt($distID);
441
        $sDistID    = $this->secure->checkInt($distID);
442
        $sDVersion  = $this->secure->checkStr($version);
442
        $sDVersion  = $this->secure->checkStr($version);
443
        $sDVName    = $this->secure->checkStr($vname);
443
        $sDVName    = $this->secure->checkStr($vname);
444
        $sDVCName   = $this->secure->checkStr($vcodename);
444
        $sDVCName   = $this->secure->checkStr($vcodename);
445
445
446
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
446
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
447
        $rq =& $this->db->query($query);
447
        $rq =& $this->db->query($query);
448
        if (PEAR::isError($this->db)) {
448
        if (PEAR::isError($this->db)) {
449
            $result["ERR"] = 1;
449
            $result["ERR"] = 1;
450
            $result["ERRINFO"] = $this->db->getMessage();
450
            $result["ERRINFO"] = $this->db->getMessage();
451
        } else {            
451
        } else {            
452
            $result["ERR"] = 0;
452
            $result["ERR"] = 0;
453
        }
453
        }
454
454
455
        return $result;
455
        return $result;
456
    }
456
    }
457
457
458
    /**
458
    /**
459
     * Редактирование информации о версии дистрибутива
459
     * Редактирование информации о версии дистрибутива
460
     *
460
     *
461
     * @author Alexander Wolf
461
     * @author Alexander Wolf
462
     * @category Core
462
     * @category Core
463
     *
463
     *
464
     * @param integer $versionID
464
     * @param integer $versionID
465
     * @param string $version
465
     * @param string $version
466
     * @param string $vname
466
     * @param string $vname
467
     * @param string $vcodename
467
     * @param string $vcodename
468
     * @return array
468
     * @return array
469
     */
469
     */
470
    public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") {
470
    public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") {
471
        $result = array();
471
        $result = array();
472
        $sVersID    = $this->secure->checkInt($versionID);
472
        $sVersID    = $this->secure->checkInt($versionID);
473
        $sDVersion  = $this->secure->checkStr($version,1);
473
        $sDVersion  = $this->secure->checkStr($version,1);
474
        $sDVName    = $this->secure->checkStr($vname,1);
474
        $sDVName    = $this->secure->checkStr($vname,1);
475
        $sDVCName   = $this->secure->checkStr($vcodename,1);
475
        $sDVCName   = $this->secure->checkStr($vcodename,1);
476
476
477
        $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'";
477
        $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'";
478
        $rq =& $this->db->query($query);
478
        $rq =& $this->db->query($query);
479
        if (PEAR::isError($this->db)) {
479
        if (PEAR::isError($this->db)) {
480
            $result["ERR"] = 1;
480
            $result["ERR"] = 1;
481
            $result["ERRINFO"] = $this->db->getMessage();
481
            $result["ERRINFO"] = $this->db->getMessage();
482
        } else {            
482
        } else {            
483
            $result["ERR"] = 0;
483
            $result["ERR"] = 0;
484
        }
484
        }
485
485
486
        return $result;
486
        return $result;
487
    }
487
    }
488
488
489
    /**
489
    /**
490
     * Удаление информации о версии дистрибутива
490
     * Удаление информации о версии дистрибутива
491
     *
491
     *
492
     * @author Alexander Wolf
492
     * @author Alexander Wolf
493
     * @category Core
493
     * @category Core
494
     *
494
     *
495
     * @param integer $versionID
495
     * @param integer $versionID
496
     * @return array
496
     * @return array
497
     */
497
     */
498
    public function dropDistVersion($versionID) {
498
    public function dropDistVersion($versionID) {
499
        $result = array();
499
        $result = array();
500
        $sVersID    = $this->secure->checkInt($versionID);
500
        $sVersID    = $this->secure->checkInt($versionID);
501
501
502
        // Удаление версии дистрибутива
502
        // Удаление версии дистрибутива
503
        $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'";
503
        $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'";
504
        $rq =& $this->db->query($query);
504
        $rq =& $this->db->query($query);
505
        if (PEAR::isError($this->db)) {
505
        if (PEAR::isError($this->db)) {
506
            $result["ERR"] = 1;
506
            $result["ERR"] = 1;
507
            $result["ERRINFO"] = $this->db->getMessage();
507
            $result["ERRINFO"] = $this->db->getMessage();
508
        } else {            
508
        } else {            
509
            $result["ERR"] = 0;
509
            $result["ERR"] = 0;
510
        }
510
        }
511
511
512
        // Удаление репозиториев этой версии дистрибутива
512
        // Удаление репозиториев этой версии дистрибутива
513
        $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'";
513
        $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'";
514
        $rq =& $this->db->query($query);
514
        $rq =& $this->db->query($query);
515
        if (PEAR::isError($this->db)) {
515
        if (PEAR::isError($this->db)) {
516
            $result["ERR"] = 1;
516
            $result["ERR"] = 1;
517
            $result["ERRINFO"] = $this->db->getMessage();
517
            $result["ERRINFO"] = $this->db->getMessage();
518
        } else {            
518
        } else {            
519
            $result["ERR"] = 0;
519
            $result["ERR"] = 0;
520
        }
520
        }
521
521
522
        return $result;
522
        return $result;
523
    }
523
    }
524
524
525
    /**
525
    /**
526
     * Отображение типа дистрибутива
526
     * Отображение типа дистрибутива
527
     *
527
     *
528
     * @author Alexander Wolf
528
     * @author Alexander Wolf
529
     * @category Core
529
     * @category Core
530
     *
530
     *
531
     * @param string $name
531
     * @param string $name
532
     * @param byte $type
532
     * @param byte $type
533
     * @return string
533
     * @return string
534
     */
534
     */
535
    public function showDistTypeForm($name = "dtype",$type = 0) {
535
    public function showDistTypeForm($name = "dtype",$type = 0) {
536
        $query = "SELECT * FROM ".$this->prefix."dtype";
536
        $query = "SELECT * FROM ".$this->prefix."dtype";
537
        $rq =& $this->db->query($query);
537
        $rq =& $this->db->query($query);
538
        $show = "<select name='".$name."' id='".$name."'>\n";
538
        $show = "<select name='".$name."' id='".$name."'>\n";
539
        while ($rq->fetchInto($element)) {
539
        while ($rq->fetchInto($element)) {
540
            if ($element["type_id"] == $type) {
540
            if ($element["type_id"] == $type) {
541
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
541
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
542
            } else {
542
            } else {
543
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
543
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
544
            }
544
            }
545
        }
545
        }
546
        $show .= "</select>";
546
        $show .= "</select>";
547
547
548
        return $show;
548
        return $show;
549
    }
549
    }
550
550
551
    /**
551
    /**
552
     * Отображение формы создания и редактирования apt-дистрибутива
552
     * Отображение формы создания и редактирования apt-дистрибутива
553
     *
553
     *
554
     * @author Alexander Wolf
554
     * @author Alexander Wolf
555
     * @category Core
555
     * @category Core
556
     *
556
     *
557
     * @param integer $distID
557
     * @param integer $distID
558
     * @return string
558
     * @return string
559
     */
559
     */
560
    public function showDistributionForm($distID = 0, $info = '') {
560
    public function showDistributionForm($distID = 0, $info = '') {
561
        $sDistID = $this->secure->checkInt($distID);
561
        $sDistID = $this->secure->checkInt($distID);
562
        $sInfo = $this->secure->checkStr($info, 1);
562
        $sInfo = $this->secure->checkStr($info, 1);
563
        if ($sInfo == "") {
563
        if ($sInfo == "") {
564
            $sInfo = "Дистрибутив";
564
            $sInfo = "Дистрибутив";
565
        }
565
        }
566
        if ($sDistID != 0) {
566
        if ($sDistID != 0) {
567
            // Режим редактирования
567
            // Режим редактирования
568
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
568
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
569
            $rq =& $this->db->query($query);
569
            $rq =& $this->db->query($query);
570
            $rq->fetchInto($element);
570
            $rq->fetchInto($element);
571
        }
571
        }
572
572
573
        if ($element["distlogo"] == 1) {
573
        if ($element["distlogo"] == 1) {
574
            $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)."'>";
574
            $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
        } else {
575
        } else {
576
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
576
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
577
        }
577
        }
578
578
579
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
579
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
580
        $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n";
580
        $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='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n";
581
        $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='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n";
582
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n";
583
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
583
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
584
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
584
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
585
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
585
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
586
586
587
        return $show;
587
        return $show;
588
    }
588
    }
589
589
590
    // sourses.list
590
    // sourses.list
591
    public function showSourcesList($distID,$versID,$sectIDs,$repIDs) {
591
    public function showSourcesList($distID,$versID,$sectIDs,$repIDs) {
592
       //TODO Написать генератор sources.list       
592
       //TODO Написать генератор sources.list       
593
    }
593
    }
594
594
595
    /**
595
    /**
596
     * Показывает список секций
596
     * Показывает список секций
597
     *
597
     *
598
     * @author Alexander Wolf
598
     * @author Alexander Wolf
599
     * @category Core
599
     * @category Core
600
     *
600
     *
601
     * @param string $name
601
     * @param string $name
602
     * @param string $actor
602
     * @param string $actor
603
     * @param string $format
603
     * @param string $format
604
     * @return string
604
     * @return string
605
     */
605
     */
606
    public function showSectionsList($name, $actor, $format = 'html') {
606
    public function showSectionsList($name, $actor, $format = 'html') {
607
        switch($format) {
607
        switch($format) {
608
            case 'html':
608
            case 'html':
609
                $query = "SELECT * FROM ".$this->prefix."section";
609
                $query = "SELECT * FROM ".$this->prefix."section";
610
                $rq =& $this->db->query($query);
610
                $rq =& $this->db->query($query);
611
                $show = "<ul>\n";
611
                $show = "<ul>\n";
612
                while ($rq->fetchInto($element)) {
612
                while ($rq->fetchInto($element)) {
613
                    $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";
613
                    $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";
614
                }
614
                }
615
                $show .= "</ul>";
615
                $show .= "</ul>";
616
                break;
616
                break;
617
            case 'innerhtml':
617
            case 'innerhtml':
618
                $show = "";
618
                $show = "";
619
                $repID = $this->secure->checkInt($actor);
619
                $repID = $this->secure->checkInt($actor);
620
                if ($repID==0) {
620
                if ($repID==0) {
621
                    $query = "SELECT * FROM ".$this->prefix."section";
621
                    $query = "SELECT * FROM ".$this->prefix."section";
622
                    $rq =& $this->db->query($query);
622
                    $rq =& $this->db->query($query);
623
                    while ($rq->fetchInto($element)) {
623
                    while ($rq->fetchInto($element)) {
624
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
624
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
625
                    }
625
                    }
626
                } else {
626
                } else {
627
                    $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'";
627
                    $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'";
628
                    $rq =& $this->db->query($query);
628
                    $rq =& $this->db->query($query);
629
                    while ($rq->fetchInto($element)) {
629
                    while ($rq->fetchInto($element)) {
630
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
630
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
631
                    }
631
                    }
632
                    $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')";
632
                    $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')";
633
                    $rq =& $this->db->query($query);
633
                    $rq =& $this->db->query($query);
634
                    while ($rq->fetchInto($element)) {
634
                    while ($rq->fetchInto($element)) {
635
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
635
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
636
                    }
636
                    }
637
                }
637
                }
638
638
639
                break;
639
                break;
640
        }
640
        }
641
641
642
        return $show;
642
        return $show;
643
    }
643
    }
644
644
645
    /**
645
    /**
646
     * Вывод формы редактирования/добавления секций
646
     * Вывод формы редактирования/добавления секций
647
     *
647
     *
648
     * @author Alexander Wolf
648
     * @author Alexander Wolf
649
     * @category Core
649
     * @category Core
650
     *
650
     *
651
     * @param integer $sectionID
651
     * @param integer $sectionID
652
     * @param string $info
652
     * @param string $info
653
     * @return string
653
     * @return string
654
     */
654
     */
655
    public function showSectionsForm($sectionID = 0, $info = "") {
655
    public function showSectionsForm($sectionID = 0, $info = "") {
656
        $sSectID = $this->secure->checkInt($sectionID);
656
        $sSectID = $this->secure->checkInt($sectionID);
657
        $sInfo = $this->secure->checkStr($info, 1);
657
        $sInfo = $this->secure->checkStr($info, 1);
658
        if ($sInfo == "") {
658
        if ($sInfo == "") {
659
            $sInfo = "Секция";
659
            $sInfo = "Секция";
660
        }
660
        }
661
        if ($sSectID != 0) {
661
        if ($sSectID != 0) {
662
            // Режим редактирования
662
            // Режим редактирования
663
            $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
663
            $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
664
            $rq =& $this->db->query($query);
664
            $rq =& $this->db->query($query);
665
            $rq->fetchInto($element);
665
            $rq->fetchInto($element);
666
        }
666
        }
667
667
668
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
668
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
669
        $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n";
669
        $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n";
670
        $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n";
670
        $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n";
671
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
671
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
672
672
673
        return $show;
673
        return $show;
674
    }
674
    }
675
675
676
    /**
676
    /**
677
     * Обновление информации о секции
677
     * Обновление информации о секции
678
     *
678
     *
679
     * @author Alexander Wolf
679
     * @author Alexander Wolf
680
     * @category Core
680
     * @category Core
681
     *
681
     *
682
     * @param integer $sectionID
682
     * @param integer $sectionID
683
     * @param string $sname
683
     * @param string $sname
684
     * @param string $sinfo
684
     * @param string $sinfo
685
     * @return array
685
     * @return array
686
     */
686
     */
687
    public function updateSection($sectionID, $sname, $sinfo = "") {
687
    public function updateSection($sectionID, $sname, $sinfo = "") {
688
        $result = array();
688
        $result = array();
689
        $sSectID    = $this->secure->checkInt($sectionID);
689
        $sSectID    = $this->secure->checkInt($sectionID);
690
        $sSName     = $this->secure->checkStr($sname);
690
        $sSName     = $this->secure->checkStr($sname);
691
        $sSInfo     = $this->secure->checkStr($sinfo);
691
        $sSInfo     = $this->secure->checkStr($sinfo);
692
692
693
        $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'";
693
        $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'";
694
        $rq =& $this->db->query($query);
694
        $rq =& $this->db->query($query);
695
        if (PEAR::isError($this->db)) {
695
        if (PEAR::isError($this->db)) {
696
            $result["ERR"] = 1;
696
            $result["ERR"] = 1;
697
            $result["ERRINFO"] = $this->db->getMessage();
697
            $result["ERRINFO"] = $this->db->getMessage();
698
        } else {
698
        } else {
699
            $result["ERR"] = 0;
699
            $result["ERR"] = 0;
700
        }
700
        }
701
701
702
        return $result;
702
        return $result;
703
    }
703
    }
704
704
705
    /**
705
    /**
706
     * Удаление информации о секции
706
     * Удаление информации о секции
707
     *
707
     *
708
     * @author Alexander Wolf
708
     * @author Alexander Wolf
709
     * @category Core
709
     * @category Core
710
     *
710
     *
711
     * @param integer $sectionID
711
     * @param integer $sectionID
712
     * @return array
712
     * @return array
713
     */
713
     */
714
    public function dropSection($sectionID) {
714
    public function dropSection($sectionID) {
715
        $result = array();
715
        $result = array();
716
        $sSectID    = $this->secure->checkInt($sectionID);
716
        $sSectID    = $this->secure->checkInt($sectionID);
717
717
718
        // Удаление секции
718
        // Удаление секции
719
        $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
719
        $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
720
        $rq =& $this->db->query($query);
720
        $rq =& $this->db->query($query);
721
        if (PEAR::isError($this->db)) {
721
        if (PEAR::isError($this->db)) {
722
            $result["ERR"] = 1;
722
            $result["ERR"] = 1;
723
            $result["ERRINFO"] = $this->db->getMessage();
723
            $result["ERRINFO"] = $this->db->getMessage();
724
        } else {
724
        } else {
725
            $result["ERR"] = 0;
725
            $result["ERR"] = 0;
726
        }
726
        }
727
727
728
        return $result;
728
        return $result;
729
    }
729
    }
730
730
731
    /**
731
    /**
732
     * Добавление новой секции
732
     * Добавление новой секции
733
     *
733
     *
734
     * @author Alexander Wolf
734
     * @author Alexander Wolf
735
     * @category Core
735
     * @category Core
736
     *
736
     *
737
     * @param string $sname
737
     * @param string $sname
738
     * @param string $sinfo
738
     * @param string $sinfo
739
     * @return array
739
     * @return array
740
     */
740
     */
741
    public function addSection($sname, $sinfo = "") {
741
    public function addSection($sname, $sinfo = "") {
742
        $result = array();
742
        $result = array();
743
        $sSName = $this->secure->checkStr($sname);
743
        $sSName = $this->secure->checkStr($sname);
744
        $sSInfo = $this->secure->checkStr($sinfo);
744
        $sSInfo = $this->secure->checkStr($sinfo);
745
745
746
        $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'";
746
        $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'";
747
        $rq =& $this->db->query($query);
747
        $rq =& $this->db->query($query);
748
        if (PEAR::isError($this->db)) {
748
        if (PEAR::isError($this->db)) {
749
            $result["ERR"] = 1;
749
            $result["ERR"] = 1;
750
            $result["ERRINFO"] = $this->db->getMessage();
750
            $result["ERRINFO"] = $this->db->getMessage();
751
        } else {
751
        } else {
752
            $result["ERR"] = 0;
752
            $result["ERR"] = 0;
753
        }
753
        }
754
754
755
        return $result;
755
        return $result;
756
    }
756
    }
757
757
758
    /**
758
    /**
759
     * Вывод списка поддерживаемых архитектур
759
     * Вывод списка поддерживаемых архитектур
760
     *
760
     *
761
     * @author Alexander Wolf
761
     * @author Alexander Wolf
762
     * @category Core
762
     * @category Core
763
     *
763
     *
764
     * @param string $name
764
     * @param string $name
765
     * @param string $actor
765
     * @param string $actor
766
     * @param string $format
766
     * @param string $format
767
     * @return string
767
     * @return string
768
     */
768
     */
769
    public function showArchList($name, $actor, $format = 'list') {
769
    public function showArchList($name, $actor, $format = 'list') {
770
        switch($format) {
770
        switch($format) {
771
            case 'list':
771
            case 'list':
772
                $query = "SELECT * FROM ".$this->prefix."arch";
772
                $query = "SELECT * FROM ".$this->prefix."arch";
773
                $rq =& $this->db->query($query);
773
                $rq =& $this->db->query($query);
774
                $show = "<ul>\n";
774
                $show = "<ul>\n";
775
                while ($rq->fetchInto($element)) {
775
                while ($rq->fetchInto($element)) {
776
                    $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";
776
                    $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";
777
                }
777
                }
778
                $show .= "</ul>";
778
                $show .= "</ul>";
779
                break;
779
                break;
780
            case 'innerhtml':
780
            case 'innerhtml':
781
                $show = "";
781
                $show = "";
782
                $repID = $this->secure->checkInt($actor);
782
                $repID = $this->secure->checkInt($actor);
783
                if ($archID==0) {
783
                if ($archID==0) {
784
                    $query = "SELECT * FROM ".$this->prefix."arch";
784
                    $query = "SELECT * FROM ".$this->prefix."arch";
785
                    $rq =& $this->db->query($query);
785
                    $rq =& $this->db->query($query);
786
                    while ($rq->fetchInto($element)) {
786
                    while ($rq->fetchInto($element)) {
787
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
787
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
788
                    }
788
                    }
789
                } else {
789
                } else {
790
                    $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'";
790
                    $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'";
791
                    $rq =& $this->db->query($query);
791
                    $rq =& $this->db->query($query);
792
                    while ($rq->fetchInto($element)) {
792
                    while ($rq->fetchInto($element)) {
793
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
793
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
794
                    }
794
                    }
795
                    $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')";
795
                    $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')";
796
                    $rq =& $this->db->query($query);
796
                    $rq =& $this->db->query($query);
797
                    while ($rq->fetchInto($element)) {
797
                    while ($rq->fetchInto($element)) {
798
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
798
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
799
                    }
799
                    }
800
                }
800
                }
801
                break;
801
                break;
802
        }
802
        }
803
        return $show;
803
        return $show;
804
    }
804
    }
805
805
806
    /**
806
    /**
807
     * Добавление новой архитектуры
807
     * Добавление новой архитектуры
808
     *
808
     *
809
     * @author Alexander Wolf
809
     * @author Alexander Wolf
810
     * @category Core
810
     * @category Core
811
     *
811
     *
812
     * @param string $arch
812
     * @param string $arch
813
     * @return array
813
     * @return array
814
     */
814
     */
815
    public function addArch($arch) {
815
    public function addArch($arch) {
816
        $result = array();
816
        $result = array();
817
        $sArch = $this->secure->checkStr($arch);
817
        $sArch = $this->secure->checkStr($arch);
818
818
819
        $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'";
819
        $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'";
820
        $rq =& $this->db->query($query);
820
        $rq =& $this->db->query($query);
821
        if (PEAR::isError($this->db)) {
821
        if (PEAR::isError($this->db)) {
822
            $result["ERR"] = 1;
822
            $result["ERR"] = 1;
823
            $result["ERRINFO"] = $this->db->getMessage();
823
            $result["ERRINFO"] = $this->db->getMessage();
824
        } else {
824
        } else {
825
            $result["ERR"] = 0;
825
            $result["ERR"] = 0;
826
        }
826
        }
827
827
828
        return $result;
828
        return $result;
829
    }
829
    }
830
830
831
    /**
831
    /**
832
     * Удаление информации об архитектуре
832
     * Удаление информации об архитектуре
833
     *
833
     *
834
     * @author Alexander Wolf
834
     * @author Alexander Wolf
835
     * @category Core
835
     * @category Core
836
     *
836
     *
837
     * @param integer $archID
837
     * @param integer $archID
838
     * @return array
838
     * @return array
839
     */
839
     */
840
    public function dropArch($archID) {
840
    public function dropArch($archID) {
841
        $result = array();
841
        $result = array();
842
        $sArchID    = $this->secure->checkInt($archID);
842
        $sArchID    = $this->secure->checkInt($archID);
843
843
844
        // Удаление архитектуры
844
        // Удаление архитектуры
845
        $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'";
845
        $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'";
846
        $rq =& $this->db->query($query);
846
        $rq =& $this->db->query($query);
847
        if (PEAR::isError($this->db)) {
847
        if (PEAR::isError($this->db)) {
848
            $result["ERR"] = 1;
848
            $result["ERR"] = 1;
849
            $result["ERRINFO"] = $this->db->getMessage();
849
            $result["ERRINFO"] = $this->db->getMessage();
850
        } else {
850
        } else {
851
            $result["ERR"] = 0;
851
            $result["ERR"] = 0;
852
        }
852
        }
853
853
854
        // Удаление архитектуры из списка репозиториев
854
        // Удаление архитектуры из списка репозиториев
855
        $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'";
855
        $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'";
856
        $rq =& $this->db->query($query);
856
        $rq =& $this->db->query($query);
857
        if (PEAR::isError($this->db)) {
857
        if (PEAR::isError($this->db)) {
858
            $result["ERR"] = 1;
858
            $result["ERR"] = 1;
859
            $result["ERRINFO"] = $this->db->getMessage();
859
            $result["ERRINFO"] = $this->db->getMessage();
860
        } else {
860
        } else {
861
            $result["ERR"] = 0;
861
            $result["ERR"] = 0;
862
        }
862
        }
863
        return $result;
863
        return $result;
864
    }
864
    }
865
865
866
    /**
866
    /**
867
     * Обновление информации об архитектуре
867
     * Обновление информации об архитектуре
868
     *
868
     *
869
     * @author Alexander Wolf
869
     * @author Alexander Wolf
870
     * @category Core
870
     * @category Core
871
     *
871
     *
872
     * @param integer $archID
872
     * @param integer $archID
873
     * @param string $arch
873
     * @param string $arch
874
     * @return array
874
     * @return array
875
     */
875
     */
876
    public function updateArch($archID, $arch) {
876
    public function updateArch($archID, $arch) {
877
        $result = array();
877
        $result = array();
878
        $sArchID    = $this->secure->checkInt($archID);
878
        $sArchID    = $this->secure->checkInt($archID);
879
        $sArch      = $this->secure->checkStr($arch);
879
        $sArch      = $this->secure->checkStr($arch);
880
880
881
        $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'";
881
        $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'";
882
        $rq =& $this->db->query($query);
882
        $rq =& $this->db->query($query);
883
        if (PEAR::isError($this->db)) {
883
        if (PEAR::isError($this->db)) {
884
            $result["ERR"] = 1;
884
            $result["ERR"] = 1;
885
            $result["ERRINFO"] = $this->db->getMessage();
885
            $result["ERRINFO"] = $this->db->getMessage();
886
        } else {
886
        } else {
887
            $result["ERR"] = 0;
887
            $result["ERR"] = 0;
888
        }
888
        }
889
889
890
        return $result;
890
        return $result;
891
    }
891
    }
892
892
893
    /**
893
    /**
894
     * Вывод формы редактирования/добавления архитектур
894
     * Вывод формы редактирования/добавления архитектур
895
     *
895
     *
896
     * @author Alexander Wolf
896
     * @author Alexander Wolf
897
     * @category Core
897
     * @category Core
898
     *
898
     *
899
     * @param integer $archID
899
     * @param integer $archID
900
     * @param string $info
900
     * @param string $info
901
     * @return string
901
     * @return string
902
     */
902
     */
903
    public function showArchForm($archID = 0, $info = "") {
903
    public function showArchForm($archID = 0, $info = "") {
904
        $sArchID = $this->secure->checkInt($archID);
904
        $sArchID = $this->secure->checkInt($archID);
905
        $sInfo = $this->secure->checkStr($info, 1);
905
        $sInfo = $this->secure->checkStr($info, 1);
906
        if ($sInfo == "") {
906
        if ($sInfo == "") {
907
            $sInfo = "Архитектура";
907
            $sInfo = "Архитектура";
908
        }
908
        }
909
        if ($sArchID != 0) {
909
        if ($sArchID != 0) {
910
            // Режим редактирования
910
            // Режим редактирования
911
            $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'";
911
            $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'";
912
            $rq =& $this->db->query($query);
912
            $rq =& $this->db->query($query);
913
            $rq->fetchInto($element);
913
            $rq->fetchInto($element);
914
        }
914
        }
915
915
916
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
916
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
917
        $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n";
917
        $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n";
918
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
918
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
919
919
920
        return $show;
920
        return $show;
921
    }
921
    }
922
922
923
    /**
923
    /**
924
     * Вывод списка схем репозиториев
924
     * Вывод списка схем репозиториев
925
     *
925
     *
926
     * @author Alexander Wolf
926
     * @author Alexander Wolf
927
     * @category Core
927
     * @category Core
928
     *
928
     *
929
     * @param string $name
929
     * @param string $name
930
     * @param string $actor
930
     * @param string $actor
931
     * @param string $format
931
     * @param string $format
932
     * @return string
932
     * @return string
933
     */
933
     */
934
    public function showSchemeList($name, $actor, $format = 'list') {
934
    public function showSchemeList($name, $actor, $format = 'list') {
935
        switch($format) {
935
        switch($format) {
936
            case 'list':
936
            case 'list':
937
                $query = "SELECT * FROM ".$this->prefix."repscheme";
937
                $query = "SELECT * FROM ".$this->prefix."repscheme";
938
                $rq =& $this->db->query($query);
938
                $rq =& $this->db->query($query);
939
                $show = "<ul>\n";
939
                $show = "<ul>\n";
940
                while ($rq->fetchInto($element)) {
940
                while ($rq->fetchInto($element)) {
941
                    $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";
941
                    $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";
942
                }
942
                }
943
                $show .= "</ul>";
943
                $show .= "</ul>";
944
                break;
944
                break;
945
            case 'innerhtml':
945
            case 'innerhtml':
946
                $repID = $this->secure->checkInt($actor);
946
                $repID = $this->secure->checkInt($actor);
947
                $query = "SELECT * FROM ".$this->prefix."repscheme";
947
                $query = "SELECT * FROM ".$this->prefix."repscheme";
948
                $rq =& $this->db->query($query);
948
                $rq =& $this->db->query($query);
949
                $show = "<select name='".$name."' id='".$name."'>\n";
949
                $show = "<select name='".$name."' id='".$name."'>\n";
950
                while ($rq->fetchInto($element)) {
950
                while ($rq->fetchInto($element)) {
951
                    if ($element["scheme_id"]==$repID) {
951
                    if ($element["scheme_id"]==$repID) {
952
                        $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n";
952
                        $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."' selected>".$this->secure->checkStr($element["scheme"],1)."</option>\n";
953
                    } else {
953
                    } else {
954
                    $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n";
954
                    $show .= "<option value='".$this->secure->checkInt($element["scheme_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n";
955
                    }
955
                    }
956
                }
956
                }
957
                $show .= "</select>";
957
                $show .= "</select>";
958
                break;
958
                break;
959
        }
959
        }
960
        return $show;
960
        return $show;
961
    }
961
    }
962
962
963
    /**
963
    /**
964
     * Добавление новой схемы репозитория
964
     * Добавление новой схемы репозитория
965
     *
965
     *
966
     * @author Alexander Wolf
966
     * @author Alexander Wolf
967
     * @category Core
967
     * @category Core
968
     *
968
     *
969
     * @param string $scheme
969
     * @param string $scheme
970
     * @return array
970
     * @return array
971
     */
971
     */
972
    public function addScheme($scheme) {
972
    public function addScheme($scheme) {
973
        $result = array();
973
        $result = array();
974
        $sScheme = $this->secure->checkStr($scheme);
974
        $sScheme = $this->secure->checkStr($scheme);
975
975
976
        $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'";
976
        $query = "INSERT INTO ".$this->prefix."repscheme SET scheme='".$sScheme."'";
977
        $rq =& $this->db->query($query);
977
        $rq =& $this->db->query($query);
978
        if (PEAR::isError($this->db)) {
978
        if (PEAR::isError($this->db)) {
979
            $result["ERR"] = 1;
979
            $result["ERR"] = 1;
980
            $result["ERRINFO"] = $this->db->getMessage();
980
            $result["ERRINFO"] = $this->db->getMessage();
981
        } else {
981
        } else {
982
            $result["ERR"] = 0;
982
            $result["ERR"] = 0;
983
        }
983
        }
984
984
985
        return $result;
985
        return $result;
986
    }
986
    }
987
987
988
    /**
988
    /**
989
     * Удаление информации о схеме репозитория
989
     * Удаление информации о схеме репозитория
990
     *
990
     *
991
     * @author Alexander Wolf
991
     * @author Alexander Wolf
992
     * @category Core
992
     * @category Core
993
     *
993
     *
994
     * @param integer $schemeID
994
     * @param integer $schemeID
995
     * @return array
995
     * @return array
996
     */
996
     */
997
    public function dropScheme($schemeID) {
997
    public function dropScheme($schemeID) {
998
        $result = array();
998
        $result = array();
999
        $sSchemeID    = $this->secure->checkInt($schemeID);
999
        $sSchemeID    = $this->secure->checkInt($schemeID);
1000
1000
1001
        // Удаление схемы
1001
        // Удаление схемы
1002
        $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'";
1002
        $query = "DELETE FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'";
1003
        $rq =& $this->db->query($query);
1003
        $rq =& $this->db->query($query);
1004
        if (PEAR::isError($this->db)) {
1004
        if (PEAR::isError($this->db)) {
1005
            $result["ERR"] = 1;
1005
            $result["ERR"] = 1;
1006
            $result["ERRINFO"] = $this->db->getMessage();
1006
            $result["ERRINFO"] = $this->db->getMessage();
1007
        } else {
1007
        } else {
1008
            $result["ERR"] = 0;
1008
            $result["ERR"] = 0;
1009
        }
1009
        }
1010
       
1010
       
1011
        return $result;
1011
        return $result;
1012
    }
1012
    }
1013
1013
1014
    /**
1014
    /**
1015
     * Обновление информации о схеме репозитория
1015
     * Обновление информации о схеме репозитория
1016
     *
1016
     *
1017
     * @author Alexander Wolf
1017
     * @author Alexander Wolf
1018
     * @category Core
1018
     * @category Core
1019
     *
1019
     *
1020
     * @param integer $schemeID
1020
     * @param integer $schemeID
1021
     * @param string $info
1021
     * @param string $info
1022
     * @return array
1022
     * @return array
1023
     */
1023
     */
1024
    public function updateScheme($schemeID, $info) {
1024
    public function updateScheme($schemeID, $info) {
1025
        $result = array();
1025
        $result = array();
1026
        $sSchemeID    = $this->secure->checkInt($schemeID);
1026
        $sSchemeID    = $this->secure->checkInt($schemeID);
1027
        $sScheme      = $this->secure->checkStr($info);
1027
        $sScheme      = $this->secure->checkStr($info);
1028
1028
1029
        $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'";
1029
        $query = "UPDATE ".$this->prefix."repscheme SET scheme='".$sScheme."' WHERE scheme_id='".$sSchemeID."'";
1030
        $rq =& $this->db->query($query);
1030
        $rq =& $this->db->query($query);
1031
        if (PEAR::isError($this->db)) {
1031
        if (PEAR::isError($this->db)) {
1032
            $result["ERR"] = 1;
1032
            $result["ERR"] = 1;
1033
            $result["ERRINFO"] = $this->db->getMessage();
1033
            $result["ERRINFO"] = $this->db->getMessage();
1034
        } else {
1034
        } else {
1035
            $result["ERR"] = 0;
1035
            $result["ERR"] = 0;
1036
        }
1036
        }
1037
1037
1038
        return $result;
1038
        return $result;
1039
    }
1039
    }
1040
1040
1041
    /**
1041
    /**
1042
     * Вывод формы редактирования/добавления схем репозиториев
1042
     * Вывод формы редактирования/добавления схем репозиториев
1043
     *
1043
     *
1044
     * @author Alexander Wolf
1044
     * @author Alexander Wolf
1045
     * @category Core
1045
     * @category Core
1046
     *
1046
     *
1047
     * @param integer $schemeID
1047
     * @param integer $schemeID
1048
     * @param string $info
1048
     * @param string $info
1049
     * @return string
1049
     * @return string
1050
     */
1050
     */
1051
    public function showSchemeForm($schemeID = 0, $info = "") {
1051
    public function showSchemeForm($schemeID = 0, $info = "") {
1052
        $sSchemeID = $this->secure->checkInt($schemeID);
1052
        $sSchemeID = $this->secure->checkInt($schemeID);
1053
        $sInfo = $this->secure->checkStr($info, 1);
1053
        $sInfo = $this->secure->checkStr($info, 1);
1054
        if ($sInfo == "") {
1054
        if ($sInfo == "") {
1055
            $sInfo = "Схема репозитория";
1055
            $sInfo = "Схема репозитория";
1056
        }
1056
        }
1057
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1057
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1058
        if ($sSchemeID != 0) {
1058
        if ($sSchemeID != 0) {
1059
            // Режим редактирования
1059
            // Режим редактирования
1060
            $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'";
1060
            $query = "SELECT * FROM ".$this->prefix."repscheme WHERE scheme_id='".$sSchemeID."'";
1061
            $rq =& $this->db->query($query);
1061
            $rq =& $this->db->query($query);
1062
            $rq->fetchInto($element);            
1062
            $rq->fetchInto($element);            
1063
        }
1063
        }
1064
       
1064
       
1065
        $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n";
1065
        $show .= "<div class='inputbox'><label for='scheme'>Схема репозитория:</label> <input type='text' name='scheme' id='scheme' value='".$this->secure->checkStr($element["scheme"],1)."'></div>\n";
1066
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1066
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1067
1067
1068
        return $show;
1068
        return $show;
1069
    }
1069
    }
1070
1070
1071
    /**
1071
    /**
1072
     * Вывод списка протоколов
1072
     * Вывод списка протоколов
1073
     *
1073
     *
1074
     * @author Alexander Wolf
1074
     * @author Alexander Wolf
1075
     * @category Core
1075
     * @category Core
1076
     *
1076
     *
1077
     * @param string $name
1077
     * @param string $name
1078
     * @param string $actor
1078
     * @param string $actor
1079
     * @param string $format
1079
     * @param string $format
1080
     * @return string
1080
     * @return string
1081
     */
1081
     */
1082
    public function showProtoList($name, $actor, $format = 'list') {
1082
    public function showProtoList($name, $actor, $format = 'list') {
1083
        switch($format) {
1083
        switch($format) {
1084
            case 'list':
1084
            case 'list':
1085
                $query = "SELECT * FROM ".$this->prefix."protos";
1085
                $query = "SELECT * FROM ".$this->prefix."protos";
1086
                $rq =& $this->db->query($query);
1086
                $rq =& $this->db->query($query);
1087
                $show = "<ul>\n";
1087
                $show = "<ul>\n";
1088
                while ($rq->fetchInto($element)) {
1088
                while ($rq->fetchInto($element)) {
1089
                    $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";
1089
                    $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";
1090
                }
1090
                }
1091
                $show .= "</ul>";
1091
                $show .= "</ul>";
1092
                break;
1092
                break;
1093
            case 'innerhtml':
1093
            case 'innerhtml':
1094
                $protoID = $this->secure->checkInt($actor);
1094
                $protoID = $this->secure->checkInt($actor);
1095
                $query = "SELECT * FROM ".$this->prefix."protos";
1095
                $query = "SELECT * FROM ".$this->prefix."protos";
1096
                $rq =& $this->db->query($query);
1096
                $rq =& $this->db->query($query);
1097
                $show = "<select name='".$name."' id='".$name."'>\n";
1097
                $show = "<select name='".$name."' id='".$name."'>\n";
1098
                while ($rq->fetchInto($element)) {
1098
                while ($rq->fetchInto($element)) {
1099
                    if ($element["proto_id"]==$protoID) {
1099
                    if ($element["proto_id"]==$protoID) {
1100
                        $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n";
1100
                        $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n";
1101
                    } else {
1101
                    } else {
1102
                        $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n";
1102
                        $show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["proto"],1)."</option>\n";
1103
                    }
1103
                    }
1104
                }
1104
                }
1105
                $show .= "</select>";
1105
                $show .= "</select>";
1106
                break;
1106
                break;
1107
        }
1107
        }
1108
        return $show;
1108
        return $show;
1109
    }
1109
    }
1110
1110
1111
    /**
1111
    /**
1112
     * Добавление нового протокола
1112
     * Добавление нового протокола
1113
     *
1113
     *
1114
     * @author Alexander Wolf
1114
     * @author Alexander Wolf
1115
     * @category Core
1115
     * @category Core
1116
     *
1116
     *
1117
     * @param string $proto
1117
     * @param string $proto
1118
     * @return array
1118
     * @return array
1119
     */
1119
     */
1120
    public function addProto($proto) {
1120
    public function addProto($proto) {
1121
        $result = array();
1121
        $result = array();
1122
        $sProto = $this->secure->checkStr($proto);
1122
        $sProto = $this->secure->checkStr($proto);
1123
1123
1124
        $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'";
1124
        $query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'";
1125
        $rq =& $this->db->query($query);
1125
        $rq =& $this->db->query($query);
1126
        if (PEAR::isError($this->db)) {
1126
        if (PEAR::isError($this->db)) {
1127
            $result["ERR"] = 1;
1127
            $result["ERR"] = 1;
1128
            $result["ERRINFO"] = $this->db->getMessage();
1128
            $result["ERRINFO"] = $this->db->getMessage();
1129
        } else {
1129
        } else {
1130
            $result["ERR"] = 0;
1130
            $result["ERR"] = 0;
1131
        }
1131
        }
1132
1132
1133
        return $result;
1133
        return $result;
1134
    }
1134
    }
1135
1135
1136
    /**
1136
    /**
1137
     * Удаление информации о протоколе
1137
     * Удаление информации о протоколе
1138
     *
1138
     *
1139
     * @author Alexander Wolf
1139
     * @author Alexander Wolf
1140
     * @category Core
1140
     * @category Core
1141
     *
1141
     *
1142
     * @param integer $protoID
1142
     * @param integer $protoID
1143
     * @return array
1143
     * @return array
1144
     */
1144
     */
1145
    public function dropProto($protoID) {
1145
    public function dropProto($protoID) {
1146
        $result = array();
1146
        $result = array();
1147
        $sProtoID    = $this->secure->checkInt($protoID);
1147
        $sProtoID    = $this->secure->checkInt($protoID);
1148
1148
1149
        // Удаление протокола
1149
        // Удаление протокола
1150
        $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'";
1150
        $query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'";
1151
        $rq =& $this->db->query($query);
1151
        $rq =& $this->db->query($query);
1152
        if (PEAR::isError($this->db)) {
1152
        if (PEAR::isError($this->db)) {
1153
            $result["ERR"] = 1;
1153
            $result["ERR"] = 1;
1154
            $result["ERRINFO"] = $this->db->getMessage();
1154
            $result["ERRINFO"] = $this->db->getMessage();
1155
        } else {
1155
        } else {
1156
            $result["ERR"] = 0;
1156
            $result["ERR"] = 0;
1157
        }
1157
        }
1158
1158
1159
        return $result;
1159
        return $result;
1160
    }
1160
    }
1161
1161
1162
    /**
1162
    /**
1163
     * Обновление информации о протоколе
1163
     * Обновление информации о протоколе
1164
     *
1164
     *
1165
     * @author Alexander Wolf
1165
     * @author Alexander Wolf
1166
     * @category Core
1166
     * @category Core
1167
     *
1167
     *
1168
     * @param integer $protoID
1168
     * @param integer $protoID
1169
     * @param string $info
1169
     * @param string $info
1170
     * @return array
1170
     * @return array
1171
     */
1171
     */
1172
    public function updateProto($protoID, $info) {
1172
    public function updateProto($protoID, $info) {
1173
        $result = array();
1173
        $result = array();
1174
        $sProtoID    = $this->secure->checkInt($protoID);
1174
        $sProtoID    = $this->secure->checkInt($protoID);
1175
        $sProto      = $this->secure->checkStr($info);
1175
        $sProto      = $this->secure->checkStr($info);
1176
1176
1177
        $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'";
1177
        $query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'";
1178
        $rq =& $this->db->query($query);
1178
        $rq =& $this->db->query($query);
1179
        if (PEAR::isError($this->db)) {
1179
        if (PEAR::isError($this->db)) {
1180
            $result["ERR"] = 1;
1180
            $result["ERR"] = 1;
1181
            $result["ERRINFO"] = $this->db->getMessage();
1181
            $result["ERRINFO"] = $this->db->getMessage();
1182
        } else {
1182
        } else {
1183
            $result["ERR"] = 0;
1183
            $result["ERR"] = 0;
1184
        }
1184
        }
1185
1185
1186
        return $result;
1186
        return $result;
1187
    }
1187
    }
1188
1188
1189
    /**
1189
    /**
1190
     * Вывод формы редактирования/добавления протоколов
1190
     * Вывод формы редактирования/добавления протоколов
1191
     *
1191
     *
1192
     * @author Alexander Wolf
1192
     * @author Alexander Wolf
1193
     * @category Core
1193
     * @category Core
1194
     *
1194
     *
1195
     * @param integer $protoID
1195
     * @param integer $protoID
1196
     * @param string $info
1196
     * @param string $info
1197
     * @return string
1197
     * @return string
1198
     */
1198
     */
1199
    public function showProtoForm($protoID = 0, $info = "") {
1199
    public function showProtoForm($protoID = 0, $info = "") {
1200
        $sProtoID = $this->secure->checkInt($protoID);
1200
        $sProtoID = $this->secure->checkInt($protoID);
1201
        $sInfo = $this->secure->checkStr($info, 1);
1201
        $sInfo = $this->secure->checkStr($info, 1);
1202
        if ($sInfo == "") {
1202
        if ($sInfo == "") {
1203
            $sInfo = "Протокол доступа";
1203
            $sInfo = "Протокол доступа";
1204
        }
1204
        }
1205
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1205
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1206
        if ($sProtoID != 0) {
1206
        if ($sProtoID != 0) {
1207
            // Режим редактирования
1207
            // Режим редактирования
1208
            $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'";
1208
            $query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'";
1209
            $rq =& $this->db->query($query);
1209
            $rq =& $this->db->query($query);
1210
            $rq->fetchInto($element);
1210
            $rq->fetchInto($element);
1211
        }
1211
        }
1212
1212
1213
        $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n";
1213
        $show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n";
1214
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1214
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1215
1215
1216
        return $show;
1216
        return $show;
1217
    }
1217
    }
1218
1218
1219
    /**
1219
    /**
1220
     * Вывод списка хостов
1220
     * Вывод списка хостов
1221
     *
1221
     *
1222
     * @author Alexander Wolf
1222
     * @author Alexander Wolf
1223
     * @category Core
1223
     * @category Core
1224
     *
1224
     *
1225
     * @param string $name
1225
     * @param string $name
1226
     * @param string $actor
1226
     * @param string $actor
1227
     * @param string $format
1227
     * @param string $format
1228
     * @return string
1228
     * @return string
1229
     */
1229
     */
1230
    public function showHostsList($name, $actor, $format = 'list') {
1230
    public function showHostsList($name, $actor, $format = 'list') {
1231
        switch($format) {
1231
        switch($format) {
1232
            case 'list':
1232
            case 'list':
1233
                $query = "SELECT * FROM ".$this->prefix."rephost";
1233
                $query = "SELECT * FROM ".$this->prefix."rephost";
1234
                $rq =& $this->db->query($query);
1234
                $rq =& $this->db->query($query);
1235
                $show = "<ul>\n";
1235
                $show = "<ul>\n";
1236
                while ($rq->fetchInto($element)) {
1236
                while ($rq->fetchInto($element)) {
1237
                    $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";
1237
                    $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";
1238
                }
1238
                }
1239
                $show .= "</ul>";
1239
                $show .= "</ul>";
1240
                break;
1240
                break;
1241
            case 'innerhtml':
1241
            case 'innerhtml':
1242
                $hostID = $this->secure->checkInt($actor);
1242
                $hostID = $this->secure->checkInt($actor);
1243
                $query = "SELECT * FROM ".$this->prefix."rephost";
1243
                $query = "SELECT * FROM ".$this->prefix."rephost";
1244
                $rq =& $this->db->query($query);
1244
                $rq =& $this->db->query($query);
1245
                $show = "<select name='".$name."' id='".$name."'>\n";
1245
                $show = "<select name='".$name."' id='".$name."'>\n";
1246
                while ($rq->fetchInto($element)) {
1246
                while ($rq->fetchInto($element)) {
1247
                    if ($element["rhost_id"]==$hostID) {
1247
                    if ($element["rhost_id"]==$hostID) {
1248
                        $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n";
1248
                        $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."' selected>".$this->secure->checkStr($element["rhost"],1)."</option>\n";
1249
                    } else {
1249
                    } else {
1250
                        $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n";
1250
                        $show .= "<option value='".$this->secure->checkInt($element["rhost_id"])."'>".$this->secure->checkStr($element["rhost"],1)."</option>\n";
1251
                    }
1251
                    }
1252
                }
1252
                }
1253
                $show .= "</select>";
1253
                $show .= "</select>";
1254
                break;
1254
                break;
1255
        }
1255
        }
1256
        return $show;
1256
        return $show;
1257
    }
1257
    }
1258
1258
1259
    /**
1259
    /**
1260
     * Добавление нового хоста
1260
     * Добавление нового хоста
1261
     *
1261
     *
1262
     * @author Alexander Wolf
1262
     * @author Alexander Wolf
1263
     * @category Core
1263
     * @category Core
1264
     *
1264
     *
1265
     * @param string $host
1265
     * @param string $host
1266
     * @return array
1266
     * @return array
1267
     */
1267
     */
1268
    public function addHost($host) {
1268
    public function addHost($host) {
1269
        $result = array();
1269
        $result = array();
1270
        $sHost = $this->secure->checkStr($host);
1270
        $sHost = $this->secure->checkStr($host);
1271
1271
1272
        $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'";
1272
        $query = "INSERT INTO ".$this->prefix."rephost SET rhost='".$sHost."'";
1273
        $rq =& $this->db->query($query);
1273
        $rq =& $this->db->query($query);
1274
        if (PEAR::isError($this->db)) {
1274
        if (PEAR::isError($this->db)) {
1275
            $result["ERR"] = 1;
1275
            $result["ERR"] = 1;
1276
            $result["ERRINFO"] = $this->db->getMessage();
1276
            $result["ERRINFO"] = $this->db->getMessage();
1277
        } else {
1277
        } else {
1278
            $result["ERR"] = 0;
1278
            $result["ERR"] = 0;
1279
        }
1279
        }
1280
1280
1281
        return $result;
1281
        return $result;
1282
    }
1282
    }
1283
1283
1284
    /**
1284
    /**
1285
     * Удаление информации о хосте
1285
     * Удаление информации о хосте
1286
     *
1286
     *
1287
     * @author Alexander Wolf
1287
     * @author Alexander Wolf
1288
     * @category Core
1288
     * @category Core
1289
     *
1289
     *
1290
     * @param integer $hostID
1290
     * @param integer $hostID
1291
     * @return array
1291
     * @return array
1292
     */
1292
     */
1293
    public function dropHost($hostID) {
1293
    public function dropHost($hostID) {
1294
        $result = array();
1294
        $result = array();
1295
        $sHostID    = $this->secure->checkInt($hostID);
1295
        $sHostID    = $this->secure->checkInt($hostID);
1296
1296
1297
        // Удаление хоста
1297
        // Удаление хоста
1298
        $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'";
1298
        $query = "DELETE FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'";
1299
        $rq =& $this->db->query($query);
1299
        $rq =& $this->db->query($query);
1300
        if (PEAR::isError($this->db)) {
1300
        if (PEAR::isError($this->db)) {
1301
            $result["ERR"] = 1;
1301
            $result["ERR"] = 1;
1302
            $result["ERRINFO"] = $this->db->getMessage();
1302
            $result["ERRINFO"] = $this->db->getMessage();
1303
        } else {
1303
        } else {
1304
            $result["ERR"] = 0;
1304
            $result["ERR"] = 0;
1305
        }
1305
        }
1306
1306
1307
        return $result;
1307
        return $result;
1308
    }
1308
    }
1309
1309
1310
    /**
1310
    /**
1311
     * Обновление информации о хосте
1311
     * Обновление информации о хосте
1312
     *
1312
     *
1313
     * @author Alexander Wolf
1313
     * @author Alexander Wolf
1314
     * @category Core
1314
     * @category Core
1315
     *
1315
     *
1316
     * @param integer $hostID
1316
     * @param integer $hostID
1317
     * @param string $info
1317
     * @param string $info
1318
     * @return array
1318
     * @return array
1319
     */
1319
     */
1320
    public function updateHost($hostID, $info) {
1320
    public function updateHost($hostID, $info) {
1321
        $result = array();
1321
        $result = array();
1322
        $sHostID    = $this->secure->checkInt($hostID);
1322
        $sHostID    = $this->secure->checkInt($hostID);
1323
        $sHost      = $this->secure->checkStr($info);
1323
        $sHost      = $this->secure->checkStr($info);
1324
1324
1325
        $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'";
1325
        $query = "UPDATE ".$this->prefix."rephost SET rhost='".$sHost."' WHERE rhost_id='".$sHostID."'";
1326
        $rq =& $this->db->query($query);
1326
        $rq =& $this->db->query($query);
1327
        if (PEAR::isError($this->db)) {
1327
        if (PEAR::isError($this->db)) {
1328
            $result["ERR"] = 1;
1328
            $result["ERR"] = 1;
1329
            $result["ERRINFO"] = $this->db->getMessage();
1329
            $result["ERRINFO"] = $this->db->getMessage();
1330
        } else {
1330
        } else {
1331
            $result["ERR"] = 0;
1331
            $result["ERR"] = 0;
1332
        }
1332
        }
1333
1333
1334
        return $result;
1334
        return $result;
1335
    }
1335
    }
1336
1336
1337
    /**
1337
    /**
1338
     * Вывод формы редактирования/добавления хостов
1338
     * Вывод формы редактирования/добавления хостов
1339
     *
1339
     *
1340
     * @author Alexander Wolf
1340
     * @author Alexander Wolf
1341
     * @category Core
1341
     * @category Core
1342
     *
1342
     *
1343
     * @param integer $hostID
1343
     * @param integer $hostID
1344
     * @param string $info
1344
     * @param string $info
1345
     * @return string
1345
     * @return string
1346
     */
1346
     */
1347
    public function showHostForm($hostID = 0, $info = "") {
1347
    public function showHostForm($hostID = 0, $info = "") {
1348
        $sHostID = $this->secure->checkInt($hostID);
1348
        $sHostID = $this->secure->checkInt($hostID);
1349
        $sInfo = $this->secure->checkStr($info, 1);
1349
        $sInfo = $this->secure->checkStr($info, 1);
1350
        if ($sInfo == "") {
1350
        if ($sInfo == "") {
1351
            $sInfo = "Хост репозитория";
1351
            $sInfo = "Хост репозитория";
1352
        }
1352
        }
1353
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1353
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1354
        if ($sHostID != 0) {
1354
        if ($sHostID != 0) {
1355
            // Режим редактирования
1355
            // Режим редактирования
1356
            $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'";
1356
            $query = "SELECT * FROM ".$this->prefix."rephost WHERE rhost_id='".$sHostID."'";
1357
            $rq =& $this->db->query($query);
1357
            $rq =& $this->db->query($query);
1358
            $rq->fetchInto($element);
1358
            $rq->fetchInto($element);
1359
        }
1359
        }
1360
1360
1361
        $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n";
1361
        $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' id='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n";
1362
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1362
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1363
1363
1364
        return $show;
1364
        return $show;
1365
    }
1365
    }
1366
1366
1367
    /**
1367
    /**
1368
     * Вывод списка корневых папок
1368
     * Вывод списка корневых папок
1369
     *
1369
     *
1370
     * @author Alexander Wolf
1370
     * @author Alexander Wolf
1371
     * @category Core
1371
     * @category Core
1372
     *
1372
     *
1373
     * @param string $name
1373
     * @param string $name
1374
     * @param string $actor
1374
     * @param string $actor
1375
     * @param string $format
1375
     * @param string $format
1376
     * @return string
1376
     * @return string
1377
     */
1377
     */
1378
    public function showFoldersList($name, $actor, $format = 'list') {
1378
    public function showFoldersList($name, $actor, $format = 'list') {
1379
        switch($format) {
1379
        switch($format) {
1380
            case 'list':
1380
            case 'list':
1381
                $query = "SELECT * FROM ".$this->prefix."repfolder";
1381
                $query = "SELECT * FROM ".$this->prefix."repfolder";
1382
                $rq =& $this->db->query($query);
1382
                $rq =& $this->db->query($query);
1383
                $show = "<ul>\n";
1383
                $show = "<ul>\n";
1384
                while ($rq->fetchInto($element)) {
1384
                while ($rq->fetchInto($element)) {
1385
                    $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";
1385
                    $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";
1386
                }
1386
                }
1387
                $show .= "</ul>";
1387
                $show .= "</ul>";
1388
                break;
1388
                break;
1389
            case 'innerhtml':
1389
            case 'innerhtml':
1390
                $folderID = $this->secure->checkInt($actor);
1390
                $folderID = $this->secure->checkInt($actor);
1391
                $query = "SELECT * FROM ".$this->prefix."repfolder";
1391
                $query = "SELECT * FROM ".$this->prefix."repfolder";
1392
                $rq =& $this->db->query($query);
1392
                $rq =& $this->db->query($query);
1393
                $show = "<select name='".$name."' id='".$name."'>\n";
1393
                $show = "<select name='".$name."' id='".$name."'>\n";
1394
                while ($rq->fetchInto($element)) {
1394
                while ($rq->fetchInto($element)) {
1395
                    if ($element["rfolder_id"]==$folderID) {
1395
                    if ($element["rfolder_id"]==$folderID) {
1396
                        $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n";
1396
                        $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."' selected>".$this->secure->checkStr($element["rfolder"],1)."</option>\n";
1397
                    } else {
1397
                    } else {
1398
                        $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n";
1398
                        $show .= "<option value='".$this->secure->checkInt($element["rfolder_id"])."'>".$this->secure->checkStr($element["rfolder"],1)."</option>\n";
1399
                    }
1399
                    }
1400
                }
1400
                }
1401
                $show .= "</select>";
1401
                $show .= "</select>";
1402
                break;
1402
                break;
1403
        }
1403
        }
1404
        return $show;
1404
        return $show;
1405
    }
1405
    }
1406
1406
1407
    /**
1407
    /**
1408
     * Добавление нового корневого каталога
1408
     * Добавление нового корневого каталога
1409
     *
1409
     *
1410
     * @author Alexander Wolf
1410
     * @author Alexander Wolf
1411
     * @category Core
1411
     * @category Core
1412
     *
1412
     *
1413
     * @param string $flder
1413
     * @param string $flder
1414
     * @return array
1414
     * @return array
1415
     */
1415
     */
1416
    public function addFolder($folder) {
1416
    public function addFolder($folder) {
1417
        $result = array();
1417
        $result = array();
1418
        $sFolder = $this->secure->checkStr($folder);
1418
        $sFolder = $this->secure->checkStr($folder);
1419
1419
1420
        $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'";
1420
        $query = "INSERT INTO ".$this->prefix."repfolder SET rfolder='".$sFolder."'";
1421
        $rq =& $this->db->query($query);
1421
        $rq =& $this->db->query($query);
1422
        if (PEAR::isError($this->db)) {
1422
        if (PEAR::isError($this->db)) {
1423
            $result["ERR"] = 1;
1423
            $result["ERR"] = 1;
1424
            $result["ERRINFO"] = $this->db->getMessage();
1424
            $result["ERRINFO"] = $this->db->getMessage();
1425
        } else {
1425
        } else {
1426
            $result["ERR"] = 0;
1426
            $result["ERR"] = 0;
1427
        }
1427
        }
1428
1428
1429
        return $result;
1429
        return $result;
1430
    }
1430
    }
1431
1431
1432
    /**
1432
    /**
1433
     * Удаление информации о корневой папке
1433
     * Удаление информации о корневой папке
1434
     *
1434
     *
1435
     * @author Alexander Wolf
1435
     * @author Alexander Wolf
1436
     * @category Core
1436
     * @category Core
1437
     *
1437
     *
1438
     * @param integer $folderID
1438
     * @param integer $folderID
1439
     * @return array
1439
     * @return array
1440
     */
1440
     */
1441
    public function dropFolder($folderID) {
1441
    public function dropFolder($folderID) {
1442
        $result = array();
1442
        $result = array();
1443
        $sFolderID    = $this->secure->checkInt($folderID);
1443
        $sFolderID    = $this->secure->checkInt($folderID);
1444
1444
1445
        // Удаление корневой папки
1445
        // Удаление корневой папки
1446
        $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'";
1446
        $query = "DELETE FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'";
1447
        $rq =& $this->db->query($query);
1447
        $rq =& $this->db->query($query);
1448
        if (PEAR::isError($this->db)) {
1448
        if (PEAR::isError($this->db)) {
1449
            $result["ERR"] = 1;
1449
            $result["ERR"] = 1;
1450
            $result["ERRINFO"] = $this->db->getMessage();
1450
            $result["ERRINFO"] = $this->db->getMessage();
1451
        } else {
1451
        } else {
1452
            $result["ERR"] = 0;
1452
            $result["ERR"] = 0;
1453
        }
1453
        }
1454
1454
1455
        return $result;
1455
        return $result;
1456
    }
1456
    }
1457
1457
1458
    /**
1458
    /**
1459
     * Обновление информации о корневой папки
1459
     * Обновление информации о корневой папки
1460
     *
1460
     *
1461
     * @author Alexander Wolf
1461
     * @author Alexander Wolf
1462
     * @category Core
1462
     * @category Core
1463
     *
1463
     *
1464
     * @param integer $folderID
1464
     * @param integer $folderID
1465
     * @param string $info
1465
     * @param string $info
1466
     * @return array
1466
     * @return array
1467
     */
1467
     */
1468
    public function updateFolder($folderID, $info) {
1468
    public function updateFolder($folderID, $info) {
1469
        $result = array();
1469
        $result = array();
1470
        $sFolderID    = $this->secure->checkInt($folderID);
1470
        $sFolderID    = $this->secure->checkInt($folderID);
1471
        $sFolder      = $this->secure->checkStr($info);
1471
        $sFolder      = $this->secure->checkStr($info);
1472
1472
1473
        $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'";
1473
        $query = "UPDATE ".$this->prefix."repfolder SET rfolder='".$sFolder."' WHERE rfolder_id='".$sFolderID."'";
1474
        $rq =& $this->db->query($query);
1474
        $rq =& $this->db->query($query);
1475
        if (PEAR::isError($this->db)) {
1475
        if (PEAR::isError($this->db)) {
1476
            $result["ERR"] = 1;
1476
            $result["ERR"] = 1;
1477
            $result["ERRINFO"] = $this->db->getMessage();
1477
            $result["ERRINFO"] = $this->db->getMessage();
1478
        } else {
1478
        } else {
1479
            $result["ERR"] = 0;
1479
            $result["ERR"] = 0;
1480
        }
1480
        }
1481
1481
1482
        return $result;
1482
        return $result;
1483
    }
1483
    }
1484
1484
1485
    /**
1485
    /**
1486
     * Вывод формы редактирования/добавления корневых папок
1486
     * Вывод формы редактирования/добавления корневых папок
1487
     *
1487
     *
1488
     * @author Alexander Wolf
1488
     * @author Alexander Wolf
1489
     * @category Core
1489
     * @category Core
1490
     *
1490
     *
1491
     * @param integer $folderID
1491
     * @param integer $folderID
1492
     * @param string $info
1492
     * @param string $info
1493
     * @return string
1493
     * @return string
1494
     */
1494
     */
1495
    public function showFolderForm($folderID = 0, $info = "") {
1495
    public function showFolderForm($folderID = 0, $info = "") {
1496
        $sFolderID = $this->secure->checkInt($folderID);
1496
        $sFolderID = $this->secure->checkInt($folderID);
1497
        $sInfo = $this->secure->checkStr($info, 1);
1497
        $sInfo = $this->secure->checkStr($info, 1);
1498
        if ($sInfo == "") {
1498
        if ($sInfo == "") {
1499
            $sInfo = "Корневая папка";
1499
            $sInfo = "Корневая папка";
1500
        }
1500
        }
1501
        if ($sFolderID != 0) {
1501
        if ($sFolderID != 0) {
1502
            // Режим редактирования
1502
            // Режим редактирования
1503
            $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'";
1503
            $query = "SELECT * FROM ".$this->prefix."repfolder WHERE rfolder_id='".$sFolderID."'";
1504
            $rq =& $this->db->query($query);
1504
            $rq =& $this->db->query($query);
1505
            $rq->fetchInto($element);
1505
            $rq->fetchInto($element);
1506
        }
1506
        }
1507
1507
1508
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1508
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1509
        $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n";
1509
        $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' id='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n";
1510
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1510
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1511
1511
1512
        return $show;
1512
        return $show;
1513
    }
1513
    }
1514
1514
1515
    /**
1515
    /**
1516
     * Показывает список подписей
1516
     * Показывает список подписей
1517
     *
1517
     *
1518
     * @author Alexander Wolf
1518
     * @author Alexander Wolf
1519
     * @category Core
1519
     * @category Core
1520
     *
1520
     *
1521
     * @param string $name
1521
     * @param string $name
1522
     * @param string $actor
1522
     * @param string $actor
1523
     * @return string
1523
     * @return string
1524
     */
1524
     */
1525
    public function showSignsList($name, $actor) {
1525
    public function showSignsList($name, $actor, $format = 'list') {
1526
        $query = "SELECT * FROM ".$this->prefix."signs";
1526
        $query = "SELECT * FROM ".$this->prefix."signs";
1527
        $rq =& $this->db->query($query);
1527
        $rq =& $this->db->query($query);
-
 
1528
        switch ($format) {
-
 
1529
            case 'list':
-
 
1530
                $show = "<ul>\n";
-
 
1531
                while ($rq->fetchInto($element)) {
1528
        $show = "<ul>\n";
1532
                    $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";
-
 
1533
                }
-
 
1534
                $show .= "</ul>";
-
 
1535
                break;
-
 
1536
            case 'innerhtml':
-
 
1537
                $signID = $this->secure->checkInt($actor);
-
 
1538
                $show  = "<select name='".$name."' id='".$name."'>\n";
-
 
1539
                $show .= "<option value='0'>Подписи нет</option>\n";
1529
        while ($rq->fetchInto($element)) {
1540
                while ($rq->fetchInto($element)) {
-
 
1541
                    if ($element["sign_id"]==$signID) {
-
 
1542
                        $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."' selected>".$this->secure->checkStr($element["sname"],1)."</option>\n";
-
 
1543
                    } else {
-
 
1544
                        $show .= "<option value='".$this->secure->checkInt($element["sign_id"])."'>".$this->secure->checkStr($element["sname"],1)."</option>\n";
-
 
1545
                    }
-
 
1546
                }
-
 
1547
                $show .= "</select>\n";
1530
            $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";
1548
                break;
1531
        }
1549
        }
1532
        $show .= "</ul>";
-
 
1533
1550
1534
        return $show;
1551
        return $show;
1535
    }
1552
    }
1536
1553
1537
    /**
1554
    /**
1538
     * Вывод формы редактирования/добавления подписей
1555
     * Вывод формы редактирования/добавления подписей
1539
     *
1556
     *
1540
     * @author Alexander Wolf
1557
     * @author Alexander Wolf
1541
     * @category Core
1558
     * @category Core
1542
     *
1559
     *
1543
     * @param integer $sectionID
1560
     * @param integer $sectionID
1544
     * @param string $info
1561
     * @param string $info
1545
     * @return string
1562
     * @return string
1546
     */
1563
     */
1547
    public function showSignsForm($signID = 0, $info = "") {
1564
    public function showSignsForm($signID = 0, $info = "") {
1548
        $sSignID = $this->secure->checkInt($signID);
1565
        $sSignID = $this->secure->checkInt($signID);
1549
        $sInfo = $this->secure->checkStr($info, 1);
1566
        $sInfo = $this->secure->checkStr($info, 1);
1550
        if ($sInfo == "") {
1567
        if ($sInfo == "") {
1551
            $sInfo = "Подписи";
1568
            $sInfo = "Подписи";
1552
        }
1569
        }
1553
        if ($sSignID != 0) {
1570
        if ($sSignID != 0) {
1554
            // Режим редактирования
1571
            // Режим редактирования
1555
            $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
1572
            $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
1556
            $rq =& $this->db->query($query);
1573
            $rq =& $this->db->query($query);
1557
            $rq->fetchInto($element);
1574
            $rq->fetchInto($element);
1558
        }
1575
        }
1559
1576
1560
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1577
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1561
        $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n";
1578
        $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n";
1562
        $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n";
1579
        $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n";
1563
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1580
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
1564
1581
1565
        return $show;
1582
        return $show;
1566
    }
1583
    }
1567
1584
1568
    /**
1585
    /**
1569
     * Обновление информации о секции
1586
     * Обновление информации о секции
1570
     *
1587
     *
1571
     * @author Alexander Wolf
1588
     * @author Alexander Wolf
1572
     * @category Core
1589
     * @category Core
1573
     *
1590
     *
1574
     * @param integer $sectionID
1591
     * @param integer $sectionID
1575
     * @param string $sname
1592
     * @param string $sname
1576
     * @param string $sinfo
1593
     * @param string $sinfo
1577
     * @return array
1594
     * @return array
1578
     */
1595
     */
1579
    public function updateSign($signID, $sname, $sinfo = "") {
1596
    public function updateSign($signID, $sname, $sinfo = "") {
1580
        $result = array();
1597
        $result = array();
1581
        $sSignID    = $this->secure->checkInt($signID);
1598
        $sSignID    = $this->secure->checkInt($signID);
1582
        $sSName     = $this->secure->checkStr($sname);
1599
        $sSName     = $this->secure->checkStr($sname);
1583
        $sSInfo     = $this->secure->checkStr($sinfo);
1600
        $sSInfo     = $this->secure->checkStr($sinfo);
1584
1601
1585
        $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'";
1602
        $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'";
1586
        $rq =& $this->db->query($query);
1603
        $rq =& $this->db->query($query);
1587
        if (PEAR::isError($this->db)) {
1604
        if (PEAR::isError($this->db)) {
1588
            $result["ERR"] = 1;
1605
            $result["ERR"] = 1;
1589
            $result["ERRINFO"] = $this->db->getMessage();
1606
            $result["ERRINFO"] = $this->db->getMessage();
1590
        } else {
1607
        } else {
1591
            $result["ERR"] = 0;
1608
            $result["ERR"] = 0;
1592
        }
1609
        }
1593
1610
1594
        return $result;
1611
        return $result;
1595
    }
1612
    }
1596
1613
1597
    /**
1614
    /**
1598
     * Удаление информации о подписи
1615
     * Удаление информации о подписи
1599
     *
1616
     *
1600
     * @author Alexander Wolf
1617
     * @author Alexander Wolf
1601
     * @category Core
1618
     * @category Core
1602
     *
1619
     *
1603
     * @param integer $sectionID
1620
     * @param integer $sectionID
1604
     * @return array
1621
     * @return array
1605
     */
1622
     */
1606
    public function dropSign($signID) {
1623
    public function dropSign($signID) {
1607
        $result = array();
1624
        $result = array();
1608
        $sSignID    = $this->secure->checkInt($signID);
1625
        $sSignID    = $this->secure->checkInt($signID);
1609
1626
1610
        // Удаление подписи
1627
        // Удаление подписи
1611
        $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
1628
        $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
1612
        $rq =& $this->db->query($query);
1629
        $rq =& $this->db->query($query);
1613
        if (PEAR::isError($this->db)) {
1630
        if (PEAR::isError($this->db)) {
1614
            $result["ERR"] = 1;
1631
            $result["ERR"] = 1;
1615
            $result["ERRINFO"] = $this->db->getMessage();
1632
            $result["ERRINFO"] = $this->db->getMessage();
1616
        } else {
1633
        } else {
1617
            $result["ERR"] = 0;
1634
            $result["ERR"] = 0;
1618
        }
1635
        }
1619
1636
1620
        return $result;
1637
        return $result;
1621
    }
1638
    }
1622
1639
1623
    /**
1640
    /**
1624
     * Добавление новой подписи
1641
     * Добавление новой подписи
1625
     *
1642
     *
1626
     * @author Alexander Wolf
1643
     * @author Alexander Wolf
1627
     * @category Core
1644
     * @category Core
1628
     *
1645
     *
1629
     * @param string $sname
1646
     * @param string $sname
1630
     * @param string $sinfo
1647
     * @param string $sinfo
1631
     * @return array
1648
     * @return array
1632
     */
1649
     */
1633
    public function addSign($sname, $sinfo = "") {
1650
    public function addSign($sname, $sinfo = "") {
1634
        $result = array();
1651
        $result = array();
1635
        $sSName = $this->secure->checkStr($sname);
1652
        $sSName = $this->secure->checkStr($sname);
1636
        $sSInfo = $this->secure->checkStr($sinfo);
1653
        $sSInfo = $this->secure->checkStr($sinfo);
1637
1654
1638
        $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'";
1655
        $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'";
1639
        $rq =& $this->db->query($query);
1656
        $rq =& $this->db->query($query);
1640
        if (PEAR::isError($this->db)) {
1657
        if (PEAR::isError($this->db)) {
1641
            $result["ERR"] = 1;
1658
            $result["ERR"] = 1;
1642
            $result["ERRINFO"] = $this->db->getMessage();
1659
            $result["ERRINFO"] = $this->db->getMessage();
1643
        } else {
1660
        } else {
1644
            $result["ERR"] = 0;
1661
            $result["ERR"] = 0;
1645
        }
1662
        }
1646
1663
1647
        return $result;
1664
        return $result;
1648
    }
1665
    }
1649
   
1666
   
1650
    /**
1667
    /**
1651
     * Проверка пароля (из формы авторизации)
1668
     * Проверка пароля (из формы авторизации)
1652
     *
1669
     *
1653
     * @author Alexander Wolf
1670
     * @author Alexander Wolf
1654
     * @category Core
1671
     * @category Core
1655
     *
1672
     *
1656
     * @param string $word
1673
     * @param string $word
1657
     * @return array
1674
     * @return array
1658
     */
1675
     */
1659
    public function checkSign($word) {
1676
    public function checkSign($word) {
1660
        $result = array();
1677
        $result = array();
1661
1678
1662
        $sHash = $this->secure->encryptStr($word);
1679
        $sHash = $this->secure->encryptStr($word);
1663
        $pwd   = $this->getOption("passwd");
1680
        $pwd   = $this->getOption("passwd");
1664
        if ($sHash == $pwd["OptValue"]) {
1681
        if ($sHash == $pwd["OptValue"]) {
1665
            $result["ERR"] = 0;
1682
            $result["ERR"] = 0;
1666
            $result["Location"] = "manager.php";
1683
            $result["Location"] = "manager.php";
1667
            setcookie($this->cookie, $sHash);
1684
            setcookie($this->cookie, $sHash);
1668
        } else {
1685
        } else {
1669
            $result["ERR"] = 1;
1686
            $result["ERR"] = 1;
1670
            $result["ERRINFO"] = "Password not valid";
1687
            $result["ERRINFO"] = "Password not valid";
1671
            $result["Location"] = "manager.php?error=1";
1688
            $result["Location"] = "manager.php?error=1";
1672
        }
1689
        }
1673
1690
1674
        return $result;
1691
        return $result;
1675
    }
1692
    }
1676
1693
1677
    /**
1694
    /**
1678
     * Проверка пароля (из cookies)
1695
     * Проверка пароля (из cookies)
1679
     *
1696
     *
1680
     * @author Alexander Wolf
1697
     * @author Alexander Wolf
1681
     * @category Core
1698
     * @category Core
1682
     *
1699
     *
1683
     * @param string $hash
1700
     * @param string $hash
1684
     * @return array
1701
     * @return array
1685
     */
1702
     */
1686
    public function checkCookieSign($hash) {
1703
    public function checkCookieSign($hash) {
1687
        $result = array();
1704
        $result = array();
1688
1705
1689
        $pwd = $this->getOption("passwd");
1706
        $pwd = $this->getOption("passwd");
1690
        if ($hash == $pwd["OptValue"]) {
1707
        if ($hash == $pwd["OptValue"]) {
1691
            $result["ERR"] = 0;
1708
            $result["ERR"] = 0;
1692
        } else {
1709
        } else {
1693
            $result["ERR"] = 1;
1710
            $result["ERR"] = 1;
1694
            $result["ERRINFO"] = "Hash not valid";
1711
            $result["ERRINFO"] = "Hash not valid";
1695
            $result["Location"] = "manager.php";
1712
            $result["Location"] = "manager.php";
1696
        }
1713
        }
1697
1714
1698
        return $result;
1715
        return $result;
1699
    }
1716
    }
1700
1717
1701
    /**
1718
    /**
1702
     * Форма ввода пароля
1719
     * Форма ввода пароля
1703
     *
1720
     *
1704
     * @author Alexander Wolf
1721
     * @author Alexander Wolf
1705
     * @category Core
1722
     * @category Core
1706
     *
1723
     *
1707
     * @return string
1724
     * @return string
1708
     */
1725
     */
1709
    public function showSigninForm() {
1726
    public function showSigninForm() {
1710
        $show  = "<div id='regform'>";
1727
        $show  = "<div id='regform'>";
1711
        $show .= "<form action='process.php' method='post'>\n";
1728
        $show .= "<form action='process.php' method='post'>\n";
1712
        $show .= "<fieldset><legend>Пароль</legend>\n";
1729
        $show .= "<fieldset><legend>Пароль</legend>\n";
1713
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
1730
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
1714
        $show .= "<input type='password' name='word' value=''>\n";
1731
        $show .= "<input type='password' name='word' value=''>\n";
1715
        $show .= "<input type='submit' value=' Войти '>\n";
1732
        $show .= "<input type='submit' value=' Войти '>\n";
1716
        $show .= "</fieldset>\n</form></div>\n";
1733
        $show .= "</fieldset>\n</form></div>\n";
1717
1734
1718
        return $show;
1735
        return $show;
1719
    }
1736
    }
1720
1737
1721
    /**
1738
    /**
1722
     * Обновление пароля
1739
     * Обновление пароля
1723
     *
1740
     *
1724
     * @author Alexander Wolf
1741
     * @author Alexander Wolf
1725
     * @category Core
1742
     * @category Core
1726
     *
1743
     *
1727
     * @param string $word1
1744
     * @param string $word1
1728
     * @param string $word2
1745
     * @param string $word2
1729
     * @return array
1746
     * @return array
1730
     */
1747
     */
1731
    public function updatePassword($word1, $word2) {
1748
    public function updatePassword($word1, $word2) {
1732
        $result = array();
1749
        $result = array();
1733
1750
1734
        if ($word1 == $word2) {
1751
        if ($word1 == $word2) {
1735
            $sWord = $this->secure->encryptStr($word1);
1752
            $sWord = $this->secure->encryptStr($word1);
1736
            $r = $this->setOption("passwd", $sWord);
1753
            $r = $this->setOption("passwd", $sWord);
1737
            $result = $r;
1754
            $result = $r;
1738
        } else {
1755
        } else {
1739
            $result["ERR"] = 1;
1756
            $result["ERR"] = 1;
1740
            $result["ERRINFO"] = "Passwords is mismatch";
1757
            $result["ERRINFO"] = "Passwords is mismatch";
1741
        }
1758
        }
1742
1759
1743
        return $result;
1760
        return $result;
1744
    }
1761
    }
1745
1762
1746
    /**
1763
    /**
1747
     * Отображение формы создания и редактирования версии apt-дистрибутива
1764
     * Отображение формы создания и редактирования версии apt-дистрибутива
1748
     *
1765
     *
1749
     * @author Alexander Wolf
1766
     * @author Alexander Wolf
1750
     * @category Core
1767
     * @category Core
1751
     *
1768
     *
1752
     * @param string $name
1769
     * @param string $name
1753
     * @param string $actor
1770
     * @param string $actor
1754
     * @param integer $versionID
1771
     * @param integer $versionID
1755
     * @return string
1772
     * @return string
1756
     */
1773
     */
1757
    public function showDistVersionsForm($versionID = 0, $info = '') {
1774
    public function showDistVersionsForm($versionID = 0, $info = '') {
1758
        $sVersionID = $this->secure->checkInt($versionID);
1775
        $sVersionID = $this->secure->checkInt($versionID);
1759
        $sInfo = $this->secure->checkStr($info, 1);
1776
        $sInfo = $this->secure->checkStr($info, 1);
1760
        if ($sInfo == "") {
1777
        if ($sInfo == "") {
1761
            $sInfo = "Версия дистрибутива";
1778
            $sInfo = "Версия дистрибутива";
1762
        }
1779
        }
1763
        if ($sVersionID != 0) {
1780
        if ($sVersionID != 0) {
1764
            // Режим редактирования
1781
            // Режим редактирования
1765
            $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'";
1782
            $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'";
1766
            $rq =& $this->db->query($query);
1783
            $rq =& $this->db->query($query);
1767
            $rq->fetchInto($element);
1784
            $rq->fetchInto($element);
1768
        }
1785
        }
1769
 
1786
 
1770
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1787
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1771
        if ($sVersionID != 0) {
1788
        if ($sVersionID != 0) {
1772
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n";
1789
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n";
1773
        } else {
1790
        } else {
1774
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n";
1791
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n";
1775
        }
1792
        }
1776
        $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n";
1793
        $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n";
1777
        $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n";
1794
        $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n";
1778
        $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n";
1795
        $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n";
1779
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1796
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1780
1797
1781
        return $show;
1798
        return $show;
1782
    }    
1799
    }    
1783
1800
1784
    /**
1801
    /**
1785
     * Парсер схемы адреса репозитория
1802
     * Парсер схемы адреса репозитория
1786
     * FIXME Возможно не потребуется
1803
     * FIXME Возможно не потребуется
1787
     *
1804
     *
1788
     * @author Alexander Wolf
1805
     * @author Alexander Wolf
1789
     * @category Core
1806
     * @category Core
1790
     *
1807
     *
1791
     * @param string $repstring
1808
     * @param string $repstring
1792
     * @return integer
1809
     * @return integer
1793
     */
1810
     */
1794
    public function repositoryParser($repstring) {
1811
    public function repositoryParser($repstring) {
1795
        $tokens = array();
1812
        $tokens = array();
1796
        $sections = array();
1813
        $sections = array();
1797
        $tokens = split(" ",$repstring);
1814
        $tokens = split(" ",$repstring);
1798
1815
1799
        if ($tokens[0] == "deb") {
1816
        if ($tokens[0] == "deb") {
1800
            // debian/ubuntu репозиторий "type proto://host/folder distr sections"
1817
            // debian/ubuntu репозиторий "type proto://host/folder distr sections"
1801
            $url = parse_url($tokens[1]);
1818
            $url = parse_url($tokens[1]);
1802
            $distr  = $tokens[2];
1819
            $distr  = $tokens[2];
1803
1820
1804
            for($i=3;$i<count($tokens);$i++) {
1821
            for($i=3;$i<count($tokens);$i++) {
1805
                $sections[] = $tokens[$i];
1822
                $sections[] = $tokens[$i];
1806
            }
1823
            }
1807
        } else {
1824
        } else {
1808
            // altlinux репозиторий "type [sign] proto://host/folder base repname"
1825
            // altlinux репозиторий "type [sign] proto://host/folder base repname"
1809
            if (stripos($tokens[1],"]")!=0) {
1826
            if (stripos($tokens[1],"]")!=0) {
1810
                $sign = $tokens[1];
1827
                $sign = $tokens[1];
1811
                $url = parse_url($tokens[2]);
1828
                $url = parse_url($tokens[2]);
1812
                $base = $tokens[3];
1829
                $base = $tokens[3];
1813
                $repname = $tokens[4];
1830
                $repname = $tokens[4];
1814
            } else {
1831
            } else {
1815
                $url = parse_url($tokens[1]);
1832
                $url = parse_url($tokens[1]);
1816
                $base = $tokens[2];
1833
                $base = $tokens[2];
1817
                $repname = $tokens[3];
1834
                $repname = $tokens[3];
1818
            }
1835
            }
1819
        }
1836
        }
1820
1837
1821
        $proto      = $url["scheme"]."://";
1838
        $proto      = $url["scheme"]."://";
1822
        $addr       = $url["host"];
1839
        $addr       = $url["host"];
1823
        if ($url["port"]!="") {
1840
        if ($url["port"]!="") {
1824
            $addr .= ":".$url["port"];
1841
            $addr .= ":".$url["port"];
1825
        }
1842
        }
1826
        $path       = $url["path"];
1843
        $path       = $url["path"];
1827
1844
1828
        return 0;
1845
        return 0;
1829
    }
1846
    }
1830
1847
1831
    /**
1848
    /**
1832
     * Выгрузка картинок логотипов дистрибутивов
1849
     * Выгрузка картинок логотипов дистрибутивов
1833
     *
1850
     *
1834
     * @author Alexander Wolf
1851
     * @author Alexander Wolf
1835
     * @category Core
1852
     * @category Core
1836
     *
1853
     *
1837
     * @param string $path
1854
     * @param string $path
1838
     * @param string $dist
1855
     * @param string $dist
1839
     * @param array $datafile
1856
     * @param array $datafile
1840
     * @return integer
1857
     * @return integer
1841
     */
1858
     */
1842
    public function uploadPicture($path, $dist, $datafile) {
1859
    public function uploadPicture($path, $dist, $datafile) {
1843
        $folder   = $path.$dist."-orig.png";
1860
        $folder   = $path.$dist."-orig.png";
1844
        $folderN  = $path.$dist.".png";
1861
        $folderN  = $path.$dist.".png";
1845
        $folderEM = $path.$dist."-em.png";
1862
        $folderEM = $path.$dist."-em.png";
1846
1863
1847
        $distlogo = 0;
1864
        $distlogo = 0;
1848
        if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) {
1865
        if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) {
1849
            chmod($folder, 0644);
1866
            chmod($folder, 0644);
1850
            list($width, $height) = GetImageSize($folder);
1867
            list($width, $height) = GetImageSize($folder);
1851
            $percent = 32/$height;
1868
            $percent = 32/$height;
1852
            $newwidth = $width * $percent;
1869
            $newwidth = $width * $percent;
1853
            $newheight = $height * $percent;
1870
            $newheight = $height * $percent;
1854
1871
1855
            $output = ImageCreateTrueColor($newwidth, $newheight);
1872
            $output = ImageCreateTrueColor($newwidth, $newheight);
1856
            $source = ImageCreateFromPNG($folder);
1873
            $source = ImageCreateFromPNG($folder);
1857
1874
1858
            ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1875
            ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1859
            ImagePNG($output, $folderEM);
1876
            ImagePNG($output, $folderEM);
1860
1877
1861
            $percent = 15/$height;
1878
            $percent = 15/$height;
1862
            $newwidth = $width * $percent;
1879
            $newwidth = $width * $percent;
1863
            $newheight = $height * $percent;
1880
            $newheight = $height * $percent;
1864
1881
1865
            $output = ImageCreateTrueColor($newwidth, $newheight);
1882
            $output = ImageCreateTrueColor($newwidth, $newheight);
1866
1883
1867
            ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1884
            ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1868
            ImagePNG($output, $folderN);
1885
            ImagePNG($output, $folderN);
1869
1886
1870
            unlink($folder);
1887
            unlink($folder);
1871
            $distlogo = 1;
1888
            $distlogo = 1;
1872
        }
1889
        }
1873
        return $distlogo;
1890
        return $distlogo;
1874
    }
1891
    }
1875
1892
1876
    /**
1893
    /**
1877
     * Показ списка репозиториев
1894
     * Показ списка репозиториев
1878
     *
1895
     *
1879
     * @author Alexander Wolf
1896
     * @author Alexander Wolf
1880
     * @category Core
1897
     * @category Core
1881
     *
1898
     *
1882
     * @param string $name
1899
     * @param string $name
1883
     * @param string $actor
1900
     * @param string $actor
1884
     * @param string $format
1901
     * @param string $format
1885
     * @return string
1902
     * @return string
1886
     */
1903
     */
1887
    public function showRepositoriesList($name, $actor, $format = 'list') {
1904
    public function showRepositoriesList($name, $actor, $format = 'list') {
1888
        $query  = "SELECT * FROM ".$this->prefix."repository r ";
1905
        $query  = "SELECT * FROM ".$this->prefix."repository r ";
1889
        $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id ";
1906
        $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id ";
1890
        $rq =& $this->db->query($query);
1907
        $rq =& $this->db->query($query);
1891
        $show = "<ul>";
1908
        $show = "<ul>";
1892
        while ($rq->fetchInto($element)) {
1909
        while ($rq->fetchInto($element)) {
1893
            $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)." (".$this->secure->checkStr($element["rtype"],1).")</li>\n";
1910
            $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)." (".$this->secure->checkStr($element["rtype"],1).")</li>\n";
1894
        }
1911
        }
1895
        $show .= "</ul>";
1912
        $show .= "</ul>";
1896
        return $show;
1913
        return $show;
1897
    }
1914
    }
1898
1915
1899
    /**
1916
    /**
1900
     * Вывод списка типов репозиториев
1917
     * Вывод списка типов репозиториев
1901
     *
1918
     *
1902
     * @author Alexander Wolf
1919
     * @author Alexander Wolf
1903
     * @category Core
1920
     * @category Core
1904
     *
1921
     *
1905
     * @param integer $reptype
1922
     * @param integer $reptype
1906
     * @param string $name
1923
     * @param string $name
1907
     * @return string
1924
     * @return string
1908
     */
1925
     */
1909
    public function showRepType($reptype = 0, $name = "") {
1926
    public function showRepType($reptype = 0, $name = "") {
1910
        $sRT = $this->secure->checkInt($reptype);
1927
        $sRT = $this->secure->checkInt($reptype);
1911
        $sNM = $this->secure->checkStr($name,1);
1928
        $sNM = $this->secure->checkStr($name,1);
1912
        $query = "SELECT * FROM ".$this->prefix."rtype";
1929
        $query = "SELECT * FROM ".$this->prefix."rtype";
1913
        $rq =& $this->db->query($query);
1930
        $rq =& $this->db->query($query);
1914
        $show = "<select name='".$sNM."' id='".$sNM."'>\n";
1931
        $show = "<select name='".$sNM."' id='".$sNM."'>\n";
1915
        while ($rq->fetchInto($element)) {
1932
        while ($rq->fetchInto($element)) {
1916
            if ($element["rtype_id"]==$sRT) {
1933
            if ($element["rtype_id"]==$sRT) {
1917
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1934
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1918
            } else {
1935
            } else {
1919
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1936
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1920
            }
1937
            }
1921
        }
1938
        }
1922
        $show .= "</select>";
1939
        $show .= "</select>";
1923
1940
1924
        return $show;
1941
        return $show;
1925
    }
1942
    }
1926
1943
1927
    public function showVDList($name, $versionID = 0) {
1944
    public function showVDList($name, $versionID = 0) {
1928
        $query  = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v ";
1945
        $query  = "SELECT v.version_id, CONCAT(d.distname, ' ', v.version, ' ', v.vname) AS fullname FROM ".$this->prefix."version v ";
1929
        $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id";
1946
        $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id";
1930
        $rq =& $this->db->query($query);
1947
        $rq =& $this->db->query($query);
1931
        $show = "<select name='".$name."' id='".$name."'>\n";
1948
        $show = "<select name='".$name."' id='".$name."'>\n";
1932
        while ($rq->fetchInto($element)) {
1949
        while ($rq->fetchInto($element)) {
1933
            if ($element["version_id"]==$versionID) {
1950
            if ($element["version_id"]==$versionID) {
1934
                $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n";
1951
                $show .= "<option value='".$this->secure->checkInt($element["version_id"])."' selected>".$this->secure->checkStr($element["fullname"],1)."</option>\n";
1935
            } else {
1952
            } else {
1936
                $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n";
1953
                $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["fullname"],1)."</option>\n";
1937
            }
1954
            }
1938
        }
1955
        }
1939
        $show .= "</select>";
1956
        $show .= "</select>";
1940
        return $show;
1957
        return $show;
1941
    }
1958
    }
1942
1959
1943
    /**
1960
    /**
1944
     * Форма создания/редактирвоания репозиториев
1961
     * Форма создания/редактирвоания репозиториев
1945
     *
1962
     *
1946
     * @author Alexander Wolf
1963
     * @author Alexander Wolf
1947
     * @category Core
1964
     * @category Core
1948
     *
1965
     *
1949
     * @param integer $repID
1966
     * @param integer $repID
1950
     * @param string $info
1967
     * @param string $info
1951
     * @param string $reptype
1968
     * @param string $reptype
1952
     * @return string
1969
     * @return string
1953
     */
1970
     */
1954
    public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") {
1971
    public function showRepositoriesForm($repID = 0, $info = "") {
1955
        $sRepID = $this->secure->checkInt($repID);
1972
        $sRepID = $this->secure->checkInt($repID);
1956
        $sInfo  = $this->secure->checkStr($info, 1);
1973
        $sInfo  = $this->secure->checkStr($info, 1);        
1957
        $sRType = $this->secure->checkStr($reptype, 1);
-
 
1958
        if ($sInfo == "") {
1974
        if ($sInfo == "") {
1959
            $sInfo = "Репозиторий";
1975
            $sInfo = "Репозиторий";
1960
        }
1976
        }
1961
        if ($sRType == "") {
-
 
1962
            $sRType = "deb";
-
 
1963
        }
-
 
1964
        if ($sRepID != 0) {
1977
        if ($sRepID != 0) {
1965
            // Режим редактирования
1978
            // Режим редактирования
1966
            $query  = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r ";
1979
            $query  = "SELECT r.*,v.*,d.dist_id,dt.type FROM ".$this->prefix."repository r ";
1967
            $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id ";
1980
            $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id ";
1968
            $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ";
1981
            $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ";
1969
            $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id ";
1982
            $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id ";
1970
            $query .= "WHERE r.rep_id='".$sRepID."'";
1983
            $query .= "WHERE r.rep_id='".$sRepID."'";
1971
            $rq =& $this->db->query($query);
1984
            $rq =& $this->db->query($query);
1972
            $rq->fetchInto($element);
1985
            $rq->fetchInto($element);            
1973
            $sRType = $this->secure->checkStr($element["type"],1);
-
 
1974
        }
1986
        }
1975
1987
1976
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1988
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";        
1977
        $show .= "<input type='hidden' name='rtype' value='".$sRType."'>";
-
 
1978
        $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["dist_id"]),"innerhtml")."</div>\n";
1989
        $show .= "<div class='inputbox'><label for='rdist'>Дистрибутив:</label> ".$this->showVDList("rdist",$this->secure->checkInt($element["dist_id"]),"innerhtml")."</div>\n";
1979
        $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value='".$this->secure->checkStr($element["repname"],1)."'></div>\n";
1990
        $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value='".$this->secure->checkStr($element["repname"],1)."'></div>\n";
1980
        $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value='".$this->secure->checkStr($element["repinfo"],1)."'></div>\n";
1991
        $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value='".$this->secure->checkStr($element["repinfo"],1)."'></div>\n";
1981
        $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value='".$this->secure->checkStr($element["repkey"],1)."'></div>\n";
1992
        $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value='".$this->secure->checkStr($element["repkey"],1)."'></div>\n";
1982
        $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n";
1993
        $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> ".$this->showProtoList("rproto",$this->secure->checkInt($element["proto_id"]),"innerhtml")."</div>\n";
1983
        $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n";
1994
        $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> ".$this->showHostsList("rhost",$this->secure->checkInt($element["rhost_id"]),"innerhtml")."</div>\n";
1984
        $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rhost",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n";
1995
        $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> ".$this->showFoldersList("rhost",$this->secure->checkInt($element["rfolder_id"]),"innerhtml")."</div>\n";
1985
        $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n";
1996
        $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n";
1986
        $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n";
1997
        $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n";
1987
        $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n";
1998
        $show .= "<div class='inputbox'><label for='rarchs'>Архитектуры:</label> <div class='formwrapper'>".$this->showArchList("rarchs",$sRepID,"innerhtml")."</div></div>\n";
1988
        $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$sRepID,"innerhtml")."</div>\n";
1999
        $show .= "<div class='inputbox'><label for='rscheme'>Схема репозитория:</label> ".$this->showSchemeList("rscheme",$sRepID,"innerhtml")."</div>\n";
-
 
2000
        $show .= "<div class='inputbox'><label for='rsign'>Подпись репозитория:</label> ".$this->showSignsList("rsign",$sRepID,"innerhtml")."</div>\n";
1989
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
2001
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1990
       
2002
       
1991
        return $show;
2003
        return $show;
1992
    }
2004
    }
1993
   
2005
   
1994
}
2006
}
1995
2007
1996
?>
2008
?>