Хранилища Subversion ant

Редакция

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

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