Хранилища Subversion ant

Редакция

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

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