Хранилища Subversion ant

Редакция

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

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