Хранилища Subversion ant

Редакция

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

Редакция 567 Редакция 568
1
<?php
1
<?php
2
2
3
/**
3
/**
4
 *  
4
 *  
5
 *  Codename: ant-ng - generator of sources.list for apt-distributives
5
 *  Codename: ant-ng - generator of sources.list for apt-distributives
6
 *  http://alex-w.org.ru/p/antng/
6
 *  http://alex-w.org.ru/p/antng/
7
 *
7
 *
8
 *  Copyright (c) 2009 Alexander Wolf
8
 *  Copyright (c) 2009 Alexander Wolf
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
10
 *  http://alex-w.org.ru/p/antng/license
10
 *  http://alex-w.org.ru/p/antng/license
11
 *
11
 *
12
 */
12
 */
13
13
14
class Core {
14
class Core {
15
    protected $db       = NULL;
15
    protected $db       = NULL;
16
    protected $prefix   = NULL;
16
    protected $prefix   = NULL;
17
    protected $secure   = NULL;    
17
    protected $secure   = NULL;    
18
    protected $cookie   = NULL;
18
    protected $cookie   = NULL;
19
19
20
    /**
20
    /**
21
     * Конструктор класса Core - ядро генератора
21
     * Конструктор класса Core - ядро генератора
22
     *
22
     *
23
     * @author Alexander Wolf
23
     * @author Alexander Wolf
24
     * @category Core
24
     * @category Core
25
     *
25
     *
26
     * @param string $database
26
     * @param string $database
27
     * @param string $prefix
27
     * @param string $prefix
28
     * @param object $secure
28
     * @param object $secure
29
     * @param string $cookie
29
     * @param string $cookie
30
     */
30
     */
31
    public function __construct($database, $prefix, $secure, $cookie) {
31
    public function __construct($database, $prefix, $secure, $cookie) {
32
        $this->db       = $database;
32
        $this->db       = $database;
33
        $this->prefix   = $prefix;
33
        $this->prefix   = $prefix;
34
        $this->secure   = $secure;
34
        $this->secure   = $secure;
35
        $this->cookie   = $cookie;
35
        $this->cookie   = $cookie;
36
    }
36
    }
37
37
38
    /**
38
    /**
39
     * Получение данных о настройке
39
     * Получение данных о настройке
40
     *
40
     *
41
     * @author Alexander Wolf
41
     * @author Alexander Wolf
42
     * @category Core
42
     * @category Core
43
     *
43
     *
44
     * @param string $attr
44
     * @param string $attr
45
     * @return array
45
     * @return array
46
     */
46
     */
47
    public function getOption($attr) {
47
    public function getOption($attr) {
48
        $result = array();
48
        $result = array();
49
        $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'";
49
        $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'";
50
        $rq =& $this->db->query($query);
50
        $rq =& $this->db->query($query);
51
        if ($rq->numRows()!=0) {
51
        if ($rq->numRows()!=0) {
52
            $rq->fetchInto($element);
52
            $rq->fetchInto($element);
53
            $result["ERR"] = 0;
53
            $result["ERR"] = 0;
54
            $result["OptValue"] = $element["optvalue"];
54
            $result["OptValue"] = $element["optvalue"];
55
        } else {
55
        } else {
56
            $result["ERR"] = 1;
56
            $result["ERR"] = 1;
57
            $result["ERRINFO"] = "Empty result";
57
            $result["ERRINFO"] = "Empty result";
58
        }
58
        }
59
        return $result;
59
        return $result;
60
    }
60
    }
61
61
62
    /**
62
    /**
63
     * Установка данных о настройке
63
     * Установка данных о настройке
64
     *
64
     *
65
     * @author Alexander Wolf
65
     * @author Alexander Wolf
66
     * @category Core
66
     * @category Core
67
     *
67
     *
68
     * @param string $attr
68
     * @param string $attr
69
     * @param string $value
69
     * @param string $value
70
     * @return array
70
     * @return array
71
     */
71
     */
72
    public function setOption($attr, $value) {
72
    public function setOption($attr, $value) {
73
        $result = array();
73
        $result = array();
74
74
75
        if ($attr != "passwd") {
75
        if ($attr != "passwd") {
76
            $sValue = $this->secure->checkStr($value);
76
            $sValue = $this->secure->checkStr($value);
77
        } else {
77
        } else {
78
            $sValue = $value;
78
            $sValue = $value;
79
        }
79
        }
80
80
81
        $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'";
81
        $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'";
82
        $rq =& $this->db->query($query);
82
        $rq =& $this->db->query($query);
83
        if (PEAR::isError($this->db)) {
83
        if (PEAR::isError($this->db)) {
84
            $result["ERR"] = 1;
84
            $result["ERR"] = 1;
85
            $result["ERRINFO"] = $this->db->getMessage();
85
            $result["ERRINFO"] = $this->db->getMessage();
86
        } else {
86
        } else {
87
            $result["ERR"] = 0;
87
            $result["ERR"] = 0;
88
        }
88
        }
89
89
90
        return $result;
90
        return $result;
91
    }
91
    }
92
92
93
    /**
93
    /**
94
     * Создание настройки
94
     * Создание настройки
95
     *
95
     *
96
     * @author Alexander Wolf
96
     * @author Alexander Wolf
97
     * @category Core
97
     * @category Core
98
     *
98
     *
99
     * @param string $attr
99
     * @param string $attr
100
     * @param string $value
100
     * @param string $value
101
     * @return array
101
     * @return array
102
     */
102
     */
103
    public function addOption($attr, $value) {
103
    public function addOption($attr, $value) {
104
        $result = array();
104
        $result = array();
105
        $sValue = $this->secure->checkStr($value);
105
        $sValue = $this->secure->checkStr($value);
106
106
107
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
107
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
108
        $rq =& $this->db->query($query);
108
        $rq =& $this->db->query($query);
109
        if (PEAR::isError($this->db)) {
109
        if (PEAR::isError($this->db)) {
110
            $result["ERR"] = 1;
110
            $result["ERR"] = 1;
111
            $result["ERRINFO"] = $this->db->getMessage();
111
            $result["ERRINFO"] = $this->db->getMessage();
112
        } else {
112
        } else {
113
            $result["ERR"] = 0;
113
            $result["ERR"] = 0;
114
        }
114
        }
115
115
116
        return $result;
116
        return $result;
117
    }
117
    }
118
       
118
       
119
    /**
119
    /**
120
     * Получение и отображение списка дистрибутвов
120
     * Получение и отображение списка дистрибутвов
121
     *
121
     *
122
     * @author Alexander Wolf
122
     * @author Alexander Wolf
123
     * @category Core
123
     * @category Core
124
     * @deprecated may be deprecated XXX
124
     * @deprecated may be deprecated XXX
125
     *
125
     *
126
     * @param string $name
126
     * @param string $name
127
     * @param string $heads
127
     * @param string $heads
128
     * @param string $info
128
     * @param string $info
129
     * @param string $format
129
     * @param string $format
130
     * @return string
130
     * @return string
131
     */
131
     */
132
    public function showDistributionList($name, $heads = "", $info = "", $format = 'html') {
132
    public function showDistributionList($name, $heads = "", $info = "", $format = 'html') {
133
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
133
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
134
        $rq =& $this->db->query($query);
134
        $rq =& $this->db->query($query);
135
        switch ($format) {
135
        switch ($format) {
136
            case 'html':
136
            case 'html':
137
                $show  = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n";
137
                $show  = "<fieldset><legend>".$heads."</legend>\n<select id='".$name."' name='".$name."'>\n";
138
                $show .= "<option value=''>".$info."</option>\n";
138
                $show .= "<option value=''>".$info."</option>\n";
139
                while ($rq->fetchInto($element)) {
139
                while ($rq->fetchInto($element)) {
140
                    $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n";
140
                    $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n";
141
                }
141
                }
142
                $show .= "</select></fieldset>";
142
                $show .= "</select></fieldset>";
143
                break;
143
                break;
144
            case 'json':
144
            case 'json':
145
                $show = '[{value:"",text:"'.$info.'"}';                
145
                $show = '[{value:"",text:"'.$info.'"}';                
146
                while ($rq->fetchInto($element)) {
146
                while ($rq->fetchInto($element)) {
147
                    $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}';
147
                    $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}';
148
                }
148
                }
149
                $show .= ']';
149
                $show .= ']';
150
                break;
150
                break;
151
            case 'innerhtml':
151
            case 'innerhtml':
152
                $show = "<select id='".$name."' name='".$name."'>\n";
152
                $show = "<select id='".$name."' name='".$name."'>\n";
153
                while ($rq->fetchInto($element)) {
153
                while ($rq->fetchInto($element)) {
154
                    $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n";
154
                    $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n";
155
                }
155
                }
156
                $show .= "</select>";
156
                $show .= "</select>";
157
                break;
157
                break;
158
            case 'list':
158
            case 'list':
159
                $show = "<ul>";
159
                $show = "<ul>";
160
                while ($rq->fetchInto($element)) {
160
                while ($rq->fetchInto($element)) {
161
                    $show .= "<li>[<a href='".$heads."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n";
161
                    $show .= "<li>[<a href='".$heads."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["dist_id"])."' class='edit'>править</a>][<a href='".$heads."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["dist_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)."</li>\n";
162
                }
162
                }
163
                $show .= "</ul>";
163
                $show .= "</ul>";
164
                break;
164
                break;
165
        }
165
        }
166
        return $show;
166
        return $show;
167
    }
167
    }
168
168
169
    /**
169
    /**
170
     * Получение названия дистрибутива
170
     * Получение названия дистрибутива
171
     *
171
     *
172
     * @author Alexander Wolf
172
     * @author Alexander Wolf
173
     * @category Core
173
     * @category Core
174
     *
174
     *
175
     * @param integer $distID
175
     * @param integer $distID
176
     * @return array
176
     * @return array
177
     */
177
     */
178
    public function getDistName($distID) {
178
    public function getDistName($distID) {
179
        $result = array();
179
        $result = array();
180
        $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'";
180
        $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'";
181
        $rq =& $this->db->query($query);
181
        $rq =& $this->db->query($query);
182
        if (PEAR::isError($this->db)) {
182
        if (PEAR::isError($this->db)) {
183
            $result["ERR"] = 1;
183
            $result["ERR"] = 1;
184
            $result["ERRINFO"] = $this->db->getMessage();
184
            $result["ERRINFO"] = $this->db->getMessage();
185
        } else {
185
        } else {
186
            $rq->fetchInto($element);
186
            $rq->fetchInto($element);
187
            $result["ERR"] = 0;
187
            $result["ERR"] = 0;
188
            $result["DistName"] = $this->secure->checkStr($element["distname"],1);
188
            $result["DistName"] = $this->secure->checkStr($element["distname"],1);
189
        }
189
        }
190
190
191
        return $result;
191
        return $result;
192
    }
192
    }
193
193
194
    /**
194
    /**
195
     * Получение названия программы, ее версии и описания
195
     * Получение названия программы, ее версии и описания
196
     *
196
     *
197
     * @author Alexander Wolf
197
     * @author Alexander Wolf
198
     * @category Core
198
     * @category Core
199
     *
199
     *
200
     * @param string $attr
200
     * @param string $attr
201
     * @return string
201
     * @return string
202
     */
202
     */
203
    public function getEngineAttr($attr = 'codename') {
203
    public function getEngineAttr($attr = 'codename') {
204
        $cname = $this->getOption($attr);
204
        $cname = $this->getOption($attr);
205
        return $this->secure->checkStr($cname["OptValue"],1);
205
        return $this->secure->checkStr($cname["OptValue"],1);
206
    }
206
    }
207
207
208
    /**
208
    /**
209
     * Получение и отображение списка версий дистрибутива
209
     * Получение и отображение списка версий дистрибутива
210
     *
210
     *
211
     * @author Alexander Wolf
211
     * @author Alexander Wolf
212
     * @category Core
212
     * @category Core
213
     *
213
     *
214
     * @param string $name
214
     * @param string $name
215
     * @param integer $distID
215
     * @param integer $distID
216
     * @param string $format
216
     * @param string $format
217
     * @return string
217
     * @return string
218
     */
218
     */
219
    public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') {
219
    public function showDistVersionsList($name, $distID, $format = 'html', $actor = '') {
220
        $distname = $this->getDistName($distID);
220
        $distname = $this->getDistName($distID);
221
        if ($distID == 0) {
221
        if ($distID == 0) {
222
            $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ORDER BY d.dist_id,v.version ASC";
222
            $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ORDER BY d.dist_id,v.version ASC";
223
        } else {
223
        } else {
224
            $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
224
            $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
225
        }
225
        }
226
        $rq =& $this->db->query($query);
226
        $rq =& $this->db->query($query);
227
        switch ($format) {
227
        switch ($format) {
228
            case 'html':
228
            case 'html':
229
                $show  = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n";
229
                $show  = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n";
230
                $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n";
230
                $show .= "<option value=''>Выбери версию ".$distname["DistName"]."</option>\n";
231
                while ($rq->fetchInto($element)) {
231
                while ($rq->fetchInto($element)) {
232
                    $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n";
232
                    $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n";
233
                }
233
                }
234
                $show .= "</select></fieldset>";
234
                $show .= "</select></fieldset>";
235
                break;
235
                break;
236
            case 'json':
236
            case 'json':
237
                $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}';                
237
                $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}';                
238
                while ($rq->fetchInto($element)) {
238
                while ($rq->fetchInto($element)) {
239
                    $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}';
239
                    $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}';
240
                }
240
                }
241
                $show .= ']';
241
                $show .= ']';
242
                break;
242
                break;
243
            case 'list':
243
            case 'list':
244
                $show = "<ul>\n";
244
                $show = "<ul>\n";
245
                while ($rq->fetchInto($element)) {
245
                while ($rq->fetchInto($element)) {
246
                    $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." &#8220;<em>".$this->secure->checkStr($element["vname"],1)."</em>&#8221;</li>\n";
246
                    $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["version_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["version_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["distname"],1)." ".$this->secure->checkStr($element["version"],1)." &#8220;<em>".$this->secure->checkStr($element["vname"],1)."</em>&#8221;</li>\n";
247
                }
247
                }
248
                $show .= "</ul>";
248
                $show .= "</ul>";
249
                break;
249
                break;
250
        }
250
        }
251
        return $show;
251
        return $show;
252
    }
252
    }
253
253
254
    /**
254
    /**
255
     * Получение и отображение списка секций основного (официального) репозитория
255
     * Получение и отображение списка секций основного (официального) репозитория
256
     *
256
     *
257
     * @author Alexander Wolf
257
     * @author Alexander Wolf
258
     * @category Core
258
     * @category Core
259
     *
259
     *
260
     * @param integer $version
260
     * @param integer $version
261
     * @param string $format
261
     * @param string $format
262
     * @return string
262
     * @return string
263
     */
263
     */
264
    public function showBranchesList($version, $format = 'html') {
264
    public function showBranchesList($version, $format = 'html') {
265
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
265
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
266
        $rq =& $this->db->query($query);
266
        $rq =& $this->db->query($query);
267
        $rq->fetchInto($types);
267
        $rq->fetchInto($types);
268
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
268
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
269
        $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id ";
269
        $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id ";
270
        $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id ";
270
        $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id ";
271
        $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id ";
271
        $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id ";
272
        $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'";
272
        $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'";
273
        $rq =& $this->db->query($query);
273
        $rq =& $this->db->query($query);
274
        switch ($format) {
274
        switch ($format) {
275
            case 'html':
275
            case 'html':
276
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
276
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
277
                while ($rq->fetchInto($element)) {
277
                while ($rq->fetchInto($element)) {
278
                    $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." &mdash; ".$this->secure->checkStr($element["sectinfo"],1)."</div>\n";
278
                    $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." &mdash; ".$this->secure->checkStr($element["sectinfo"],1)."</div>\n";
279
                }
279
                }
280
                $show .= "</fieldset>\n";
280
                $show .= "</fieldset>\n";
281
                break;
281
                break;
282
            case 'json':
282
            case 'json':
283
                //TODO Доделать JSON-вывод списка секций основного репозитория
283
                //TODO Доделать JSON-вывод списка секций основного репозитория
284
                break;
284
                break;
285
        }
285
        }
286
286
287
        return $show;
287
        return $show;
288
    }
288
    }
289
289
290
    /**
290
    /**
291
     * Получение и отображение списка репозиториев
291
     * Получение и отображение списка репозиториев
292
     *
292
     *
293
     * @author Alexander Wolf
293
     * @author Alexander Wolf
294
     * @category Core
294
     * @category Core
295
     *
295
     *
296
     * @param integer $version
296
     * @param integer $version
297
     * @param integer $reptype
297
     * @param integer $reptype
298
     * @param string $format
298
     * @param string $format
299
     * @return string
299
     * @return string
300
     */
300
     */
301
    public function showRepList($version, $reptype, $format = 'html') {
301
    public function showRepList($version, $reptype, $format = 'html') {
302
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'";
302
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'";
303
        $rq =& $this->db->query($query);
303
        $rq =& $this->db->query($query);
304
        $rq->fetchInto($types);
304
        $rq->fetchInto($types);
305
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
305
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
306
        $rq =& $this->db->query($query);
306
        $rq =& $this->db->query($query);
307
        switch ($format) {
307
        switch ($format) {
308
            case 'html':
308
            case 'html':
309
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
309
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
310
                while ($rq->fetchInto($types)) {
310
                while ($rq->fetchInto($types)) {
311
                    $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." &mdash; ".$this->secure->checkStr($element["repinfo"],1)."</div>\n";
311
                    $show .= "<div class='repository'><input type='checkbox' name='repository[]' value='".$element["rep_id"]."'> ".$this->secure->checkStr($element["repname"],1)." &mdash; ".$this->secure->checkStr($element["repinfo"],1)."</div>\n";
312
                }
312
                }
313
                $show .= "</fieldset>\n";
313
                $show .= "</fieldset>\n";
314
                break;
314
                break;
315
            case 'json':
315
            case 'json':
316
                //TODO Доделать JSON-вывод списка репозиториев
316
                //TODO Доделать JSON-вывод списка репозиториев
317
                break;
317
                break;
318
        }
318
        }
319
319
320
        return $show;
320
        return $show;
321
    }
321
    }
322
322
323
    /**
323
    /**
324
     * Добавление поддержки нового apt-дистрибутива
324
     * Добавление поддержки нового apt-дистрибутива
325
     *
325
     *
326
     * @author Alexander Wolf
326
     * @author Alexander Wolf
327
     * @category Core
327
     * @category Core
328
     *
328
     *
329
     * @param string $distname
329
     * @param string $distname
330
     * @param integer $disttype
330
     * @param integer $disttype
331
     * @param string $distua
331
     * @param string $distua
332
     * @param byte $distlogo
332
     * @param byte $distlogo
333
     * @return array
333
     * @return array
334
     */
334
     */
335
    public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) {
335
    public function addDistribution($distname, $disttype, $distua = '', $distlogo = 0) {
336
        $result = array();
336
        $result = array();
337
        $sDName = $this->secure->checkStr($distname,1);
337
        $sDName = $this->secure->checkStr($distname,1);
338
        $sDType = $this->secure->checkInt($disttype);
338
        $sDType = $this->secure->checkInt($disttype);
339
        $sDUAgt = $this->secure->checkStr($distua,1);
339
        $sDUAgt = $this->secure->checkStr($distua,1);
340
        $sDLogo = $this->secure->checkInt($distlogo);
340
        $sDLogo = $this->secure->checkInt($distlogo);
341
341
342
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
342
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
343
        $rq =& $this->db->query($query);
343
        $rq =& $this->db->query($query);
344
        if (PEAR::isError($this->db)) {
344
        if (PEAR::isError($this->db)) {
345
            $result["ERR"] = 1;
345
            $result["ERR"] = 1;
346
            $result["ERRINFO"] = $this->db->getMessage();
346
            $result["ERRINFO"] = $this->db->getMessage();
347
        } else {            
347
        } else {            
348
            $result["ERR"] = 0;
348
            $result["ERR"] = 0;
349
        }
349
        }
350
350
351
        return $result;
351
        return $result;
352
    }
352
    }
353
353
354
    /**
354
    /**
355
     * Обновление информации о дистрибутиве
355
     * Обновление информации о дистрибутиве
356
     *
356
     *
357
     * @author Alexander Wolf
357
     * @author Alexander Wolf
358
     * @category Core
358
     * @category Core
359
     *
359
     *
360
     * @param integer $distID
360
     * @param integer $distID
361
     * @param string $distname
361
     * @param string $distname
362
     * @param integer $disttype
362
     * @param integer $disttype
363
     * @param string $distua
363
     * @param string $distua
364
     * @param integer $distlogo
364
     * @param integer $distlogo
365
     * @return array
365
     * @return array
366
     */
366
     */
367
    public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) {
367
    public function updateDistribution($distID, $distname, $disttype, $distua, $distlogo = 0) {
368
        $result = array();
368
        $result = array();
369
        $sDID   = $this->secure->checkInt($distID);
369
        $sDID   = $this->secure->checkInt($distID);
370
        $sDName = $this->secure->checkStr($distname,1);
370
        $sDName = $this->secure->checkStr($distname,1);
371
        $sDType = $this->secure->checkInt($disttype);
371
        $sDType = $this->secure->checkInt($disttype);
372
        $sDUAgt = $this->secure->checkStr($distua,1);
372
        $sDUAgt = $this->secure->checkStr($distua,1);
373
        $sDLogo = $this->secure->checkInt($distlogo);
373
        $sDLogo = $this->secure->checkInt($distlogo);
374
374
375
        if ($sDLogo!=0) {
375
        if ($sDLogo!=0) {
376
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'";
376
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."' WHERE dist_id='".$sDID."'";
377
        } else {
377
        } else {
378
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'";
378
            $query = "UPDATE ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."' WHERE dist_id='".$sDID."'";
379
        }
379
        }
380
        $rq =& $this->db->query($query);
380
        $rq =& $this->db->query($query);
381
        if (PEAR::isError($this->db)) {
381
        if (PEAR::isError($this->db)) {
382
            $result["ERR"] = 1;
382
            $result["ERR"] = 1;
383
            $result["ERRINFO"] = $this->db->getMessage();
383
            $result["ERRINFO"] = $this->db->getMessage();
384
        } else {            
384
        } else {            
385
            $result["ERR"] = 0;
385
            $result["ERR"] = 0;
386
        }
386
        }
387
387
388
        return $result;
388
        return $result;
389
    }
389
    }
390
390
391
    /**
391
    /**
392
     * Удаление информации о дистрибутиве
392
     * Удаление информации о дистрибутиве
393
     *
393
     *
394
     * @author Alexander Wolf
394
     * @author Alexander Wolf
395
     * @category Core
395
     * @category Core
396
     *
396
     *
397
     * @param integer $distID
397
     * @param integer $distID
398
     * @return array
398
     * @return array
399
     */
399
     */
400
    public function dropDistribution($distID) {
400
    public function dropDistribution($distID) {
401
        $result = array();
401
        $result = array();
402
        $sDID   = $this->secure->checkInt($distID);
402
        $sDID   = $this->secure->checkInt($distID);
403
403
404
        // Удаление дистрибутива
404
        // Удаление дистрибутива
405
        $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'";
405
        $query = "DELETE FROM ".$this->prefix."distribution WHERE dist_id='".$sDID."'";
406
        $rq =& $this->db->query($query);
406
        $rq =& $this->db->query($query);
407
        if (PEAR::isError($this->db)) {
407
        if (PEAR::isError($this->db)) {
408
            $result["ERR"] = 1;
408
            $result["ERR"] = 1;
409
            $result["ERRINFO"] = $this->db->getMessage();
409
            $result["ERRINFO"] = $this->db->getMessage();
410
        } else {            
410
        } else {            
411
            $result["ERR"] = 0;
411
            $result["ERR"] = 0;
412
        }
412
        }
413
413
414
        // Удаление версий дистрибутива
414
        // Удаление версий дистрибутива
415
        $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'";
415
        $query = "DELETE FROM ".$this->prefix."version WHERE dist_id='".$sDID."'";
416
        $rq =& $this->db->query($query);
416
        $rq =& $this->db->query($query);
417
        if (PEAR::isError($this->db)) {
417
        if (PEAR::isError($this->db)) {
418
            $result["ERR"] = 1;
418
            $result["ERR"] = 1;
419
            $result["ERRINFO"] = $this->db->getMessage();
419
            $result["ERRINFO"] = $this->db->getMessage();
420
        } else {            
420
        } else {            
421
            $result["ERR"] = 0;
421
            $result["ERR"] = 0;
422
        }
422
        }
423
423
424
        return $result;
424
        return $result;
425
    }
425
    }
426
426
427
    /**
427
    /**
428
     * Добавление поддержки новой версии apt-дистрибутива
428
     * Добавление поддержки новой версии apt-дистрибутива
429
     *
429
     *
430
     * @author Alexander Wolf
430
     * @author Alexander Wolf
431
     * @category Core
431
     * @category Core
432
     *
432
     *
433
     * @param integer $distID
433
     * @param integer $distID
434
     * @param integer $version
434
     * @param integer $version
435
     * @param string $vname
435
     * @param string $vname
436
     * @param integer $vcodename
436
     * @param integer $vcodename
437
     * @return array
437
     * @return array
438
     */
438
     */
439
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
439
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
440
        $result = array();
440
        $result = array();
441
        $sDistID    = $this->secure->checkInt($distID);
441
        $sDistID    = $this->secure->checkInt($distID);
442
        $sDVersion  = $this->secure->checkStr($version,1);
442
        $sDVersion  = $this->secure->checkStr($version,1);
443
        $sDVName    = $this->secure->checkStr($vname,1);
443
        $sDVName    = $this->secure->checkStr($vname,1);
444
        $sDVCName   = $this->secure->checkStr($vcodename,1);
444
        $sDVCName   = $this->secure->checkStr($vcodename,1);
445
445
446
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
446
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
447
        $rq =& $this->db->query($query);
447
        $rq =& $this->db->query($query);
448
        if (PEAR::isError($this->db)) {
448
        if (PEAR::isError($this->db)) {
449
            $result["ERR"] = 1;
449
            $result["ERR"] = 1;
450
            $result["ERRINFO"] = $this->db->getMessage();
450
            $result["ERRINFO"] = $this->db->getMessage();
451
        } else {            
451
        } else {            
452
            $result["ERR"] = 0;
452
            $result["ERR"] = 0;
453
        }
453
        }
454
454
455
        return $result;
455
        return $result;
456
    }
456
    }
457
457
458
    /**
458
    /**
459
     * Редактирование информации о версии дистрибутива
459
     * Редактирование информации о версии дистрибутива
460
     *
460
     *
461
     * @author Alexander Wolf
461
     * @author Alexander Wolf
462
     * @category Core
462
     * @category Core
463
     *
463
     *
464
     * @param integer $versionID
464
     * @param integer $versionID
465
     * @param string $version
465
     * @param string $version
466
     * @param string $vname
466
     * @param string $vname
467
     * @param string $vcodename
467
     * @param string $vcodename
468
     * @return array
468
     * @return array
469
     */
469
     */
470
    public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") {
470
    public function updateDistVersion($versionID, $version, $vname = "", $vcodename = "") {
471
        $result = array();
471
        $result = array();
472
        $sVersID    = $this->secure->checkInt($versionID);
472
        $sVersID    = $this->secure->checkInt($versionID);
473
        $sDVersion  = $this->secure->checkStr($version,1);
473
        $sDVersion  = $this->secure->checkStr($version,1);
474
        $sDVName    = $this->secure->checkStr($vname,1);
474
        $sDVName    = $this->secure->checkStr($vname,1);
475
        $sDVCName   = $this->secure->checkStr($vcodename,1);
475
        $sDVCName   = $this->secure->checkStr($vcodename,1);
476
476
477
        $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'";
477
        $query = "UPDATE ".$this->prefix."version SET vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."' WHERE version_id='".$sVersID."'";
478
        $rq =& $this->db->query($query);
478
        $rq =& $this->db->query($query);
479
        if (PEAR::isError($this->db)) {
479
        if (PEAR::isError($this->db)) {
480
            $result["ERR"] = 1;
480
            $result["ERR"] = 1;
481
            $result["ERRINFO"] = $this->db->getMessage();
481
            $result["ERRINFO"] = $this->db->getMessage();
482
        } else {            
482
        } else {            
483
            $result["ERR"] = 0;
483
            $result["ERR"] = 0;
484
        }
484
        }
485
485
486
        return $result;
486
        return $result;
487
    }
487
    }
488
488
489
    /**
489
    /**
490
     * Удаление информации о версии дистрибутива
490
     * Удаление информации о версии дистрибутива
491
     *
491
     *
492
     * @author Alexander Wolf
492
     * @author Alexander Wolf
493
     * @category Core
493
     * @category Core
494
     *
494
     *
495
     * @param integer $versionID
495
     * @param integer $versionID
496
     * @return array
496
     * @return array
497
     */
497
     */
498
    public function dropDistVersion($versionID) {
498
    public function dropDistVersion($versionID) {
499
        $result = array();
499
        $result = array();
500
        $sVersID    = $this->secure->checkInt($versionID);
500
        $sVersID    = $this->secure->checkInt($versionID);
501
501
502
        // Удаление версии дистрибутива
502
        // Удаление версии дистрибутива
503
        $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'";
503
        $query = "DELETE FROM ".$this->prefix."version WHERE version_id='".$sVersID."'";
504
        $rq =& $this->db->query($query);
504
        $rq =& $this->db->query($query);
505
        if (PEAR::isError($this->db)) {
505
        if (PEAR::isError($this->db)) {
506
            $result["ERR"] = 1;
506
            $result["ERR"] = 1;
507
            $result["ERRINFO"] = $this->db->getMessage();
507
            $result["ERRINFO"] = $this->db->getMessage();
508
        } else {            
508
        } else {            
509
            $result["ERR"] = 0;
509
            $result["ERR"] = 0;
510
        }
510
        }
511
511
512
        // Удаление репозиториев этой версии дистрибутива
512
        // Удаление репозиториев этой версии дистрибутива
513
        $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'";
513
        $query = "DELETE FROM ".$this->prefix."repository WHERE version='".$sVersID."'";
514
        $rq =& $this->db->query($query);
514
        $rq =& $this->db->query($query);
515
        if (PEAR::isError($this->db)) {
515
        if (PEAR::isError($this->db)) {
516
            $result["ERR"] = 1;
516
            $result["ERR"] = 1;
517
            $result["ERRINFO"] = $this->db->getMessage();
517
            $result["ERRINFO"] = $this->db->getMessage();
518
        } else {            
518
        } else {            
519
            $result["ERR"] = 0;
519
            $result["ERR"] = 0;
520
        }
520
        }
521
521
522
        return $result;
522
        return $result;
523
    }
523
    }
524
524
525
    /**
525
    /**
526
     * Отображение типа дистрибутива
526
     * Отображение типа дистрибутива
527
     *
527
     *
528
     * @author Alexander Wolf
528
     * @author Alexander Wolf
529
     * @category Core
529
     * @category Core
530
     *
530
     *
531
     * @param string $name
531
     * @param string $name
532
     * @param byte $type
532
     * @param byte $type
533
     * @return string
533
     * @return string
534
     */
534
     */
535
    public function showDistTypeForm($name = "dtype",$type = 0) {
535
    public function showDistTypeForm($name = "dtype",$type = 0) {
536
        $query = "SELECT * FROM ".$this->prefix."dtype";
536
        $query = "SELECT * FROM ".$this->prefix."dtype";
537
        $rq =& $this->db->query($query);
537
        $rq =& $this->db->query($query);
538
        $show = "<select name='".$name."' id='".$name."'>\n";
538
        $show = "<select name='".$name."' id='".$name."'>\n";
539
        while ($rq->fetchInto($element)) {
539
        while ($rq->fetchInto($element)) {
540
            if ($element["type_id"] == $type) {
540
            if ($element["type_id"] == $type) {
541
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
541
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
542
            } else {
542
            } else {
543
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
543
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
544
            }
544
            }
545
        }
545
        }
546
        $show .= "</select>";
546
        $show .= "</select>";
547
547
548
        return $show;
548
        return $show;
549
    }
549
    }
550
550
551
    /**
551
    /**
552
     * Отображение формы создания и редактирования apt-дистрибутива
552
     * Отображение формы создания и редактирования apt-дистрибутива
553
     *
553
     *
554
     * @author Alexander Wolf
554
     * @author Alexander Wolf
555
     * @category Core
555
     * @category Core
556
     *
556
     *
557
     * @param integer $distID
557
     * @param integer $distID
558
     * @return string
558
     * @return string
559
     */
559
     */
560
    public function showDistributionForm($distID = 0, $info = '') {
560
    public function showDistributionForm($distID = 0, $info = '') {
561
        $sDistID = $this->secure->checkInt($distID);
561
        $sDistID = $this->secure->checkInt($distID);
562
        $sInfo = $this->secure->checkStr($info, 1);
562
        $sInfo = $this->secure->checkStr($info, 1);
563
        if ($sInfo == "") {
563
        if ($sInfo == "") {
564
            $sInfo = "Дистрибутив";
564
            $sInfo = "Дистрибутив";
565
        }
565
        }
566
        if ($sDistID != 0) {
566
        if ($sDistID != 0) {
567
            // Режим редактирования
567
            // Режим редактирования
568
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
568
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
569
            $rq =& $this->db->query($query);
569
            $rq =& $this->db->query($query);
570
            $rq->fetchInto($element);
570
            $rq->fetchInto($element);
571
        }
571
        }
572
572
573
        if ($element["distlogo"] == 1) {
573
        if ($element["distlogo"] == 1) {
574
            $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>";
574
            $image = "<img src='./img/d/".$this->secure->checkStr($element["distua"],1).".png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."' title='Логотип дистрибутива ".$this->secure->checkStr($element["distname"],1)."'>";
575
        } else {
575
        } else {
576
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
576
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
577
        }
577
        }
578
578
579
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
579
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
580
        $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n";
580
        $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n";
581
        $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n";
581
        $show .= "<div class='inputbox'><label for='dua'>UA дистрибутива:</label> <input type='text' name='dua' id='dua' value='".$this->secure->checkStr($element["distua"],1)."'></div>\n";
582
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n";
582
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["disttype"])."</div>\n";
583
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
583
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
584
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
584
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
585
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
585
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
586
586
587
        return $show;
587
        return $show;
588
    }
588
    }
589
589
590
    // sourses.list
590
    // sourses.list
591
    public function showSourcesList($distID,$versID,$sectIDs,$repIDs) {
591
    public function showSourcesList($distID,$versID,$sectIDs,$repIDs) {
592
       //TODO Написать генератор sources.list       
592
       //TODO Написать генератор sources.list       
593
    }
593
    }
594
594
595
    /**
595
    /**
596
     * Показывает список секций
596
     * Показывает список секций
597
     *
597
     *
598
     * @author Alexander Wolf
598
     * @author Alexander Wolf
599
     * @category Core
599
     * @category Core
600
     *
600
     *
601
     * @param string $name
601
     * @param string $name
602
     * @param string $actor
602
     * @param string $actor
603
     * @param string $format
603
     * @param string $format
604
     * @return string
604
     * @return string
605
     */
605
     */
606
    public function showSectionsList($name, $actor, $format = 'html') {
606
    public function showSectionsList($name, $actor, $format = 'html') {
607
        switch($format) {
607
        switch($format) {
608
            case 'html':
608
            case 'html':
609
                $query = "SELECT * FROM ".$this->prefix."section";
609
                $query = "SELECT * FROM ".$this->prefix."section";
610
                $rq =& $this->db->query($query);
610
                $rq =& $this->db->query($query);
611
                $show = "<ul>\n";
611
                $show = "<ul>\n";
612
                while ($rq->fetchInto($element)) {
612
                while ($rq->fetchInto($element)) {
613
                    $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sect_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sect_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["secname"],1)."</li>\n";
613
                    $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["sect_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["sect_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["secname"],1)."</li>\n";
614
                }
614
                }
615
                $show .= "</ul>";
615
                $show .= "</ul>";
616
                break;
616
                break;
617
            case 'innerhtml':
617
            case 'innerhtml':
618
                $show = "";
618
                $show = "";
619
                $repID = $this->secure->checkInt($actor);
619
                $repID = $this->secure->checkInt($actor);
620
                if ($repID==0) {
620
                if ($repID==0) {
621
                    $query = "SELECT * FROM ".$this->prefix."section";
621
                    $query = "SELECT * FROM ".$this->prefix."section";
622
                    $rq =& $this->db->query($query);
622
                    $rq =& $this->db->query($query);
623
                    while ($rq->fetchInto($element)) {
623
                    while ($rq->fetchInto($element)) {
624
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
624
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
625
                    }
625
                    }
626
                } else {
626
                } else {
627
                    $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'";
627
                    $query = "SELECT * FROM ".$this->prefix."section s JOIN ".$this->prefix."sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$repID'";
628
                    $rq =& $this->db->query($query);
628
                    $rq =& $this->db->query($query);
629
                    while ($rq->fetchInto($element)) {
629
                    while ($rq->fetchInto($element)) {
630
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
630
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."' checked>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
631
                    }
631
                    }
632
                    $query = "SELECT s.* FROM ".$this->prefix."section s WHERE s.sect_id NOT IN (SELECT sect_id FROM ".$this->prefix."sect2rep WHERE rep_id='$repID')";
632
                    $query = "SELECT s.* FROM ".$this->prefix."section s WHERE s.sect_id NOT IN (SELECT sect_id FROM ".$this->prefix."sect2rep WHERE rep_id='$repID')";
633
                    $rq =& $this->db->query($query);
633
                    $rq =& $this->db->query($query);
634
                    while ($rq->fetchInto($element)) {
634
                    while ($rq->fetchInto($element)) {
635
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
635
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["sect_id"]."'>&nbsp;".$this->secure->checkStr($element["secname"],1)." ";
636
                    }
636
                    }
637
                }
637
                }
638
638
639
                break;
639
                break;
640
        }
640
        }
641
641
642
        return $show;
642
        return $show;
643
    }
643
    }
644
644
645
-
 
646
    /**
645
    /**
647
     * Вывод формы редактирования/добавления секций
646
     * Вывод формы редактирования/добавления секций
648
     *
647
     *
649
     * @author Alexander Wolf
648
     * @author Alexander Wolf
650
     * @category Core
649
     * @category Core
651
     *
650
     *
652
     * @param integer $sectionID
651
     * @param integer $sectionID
653
     * @param string $info
652
     * @param string $info
654
     * @return string
653
     * @return string
655
     */
654
     */
656
    public function showSectionsForm($sectionID = 0, $info = "") {
655
    public function showSectionsForm($sectionID = 0, $info = "") {
657
        $sSectID = $this->secure->checkInt($sectionID);
656
        $sSectID = $this->secure->checkInt($sectionID);
658
        $sInfo = $this->secure->checkStr($info, 1);
657
        $sInfo = $this->secure->checkStr($info, 1);
659
        if ($sInfo == "") {
658
        if ($sInfo == "") {
660
            $sInfo = "Секция";
659
            $sInfo = "Секция";
661
        }
660
        }
662
        if ($sSectID != 0) {
661
        if ($sSectID != 0) {
663
            // Режим редактирования
662
            // Режим редактирования
664
            $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
663
            $query = "SELECT * FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
665
            $rq =& $this->db->query($query);
664
            $rq =& $this->db->query($query);
666
            $rq->fetchInto($element);
665
            $rq->fetchInto($element);
667
        }
666
        }
668
667
669
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
668
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
670
        $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n";
669
        $show .= "<div class='inputbox'><label for='sname'>Название секции:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["secname"],1)."'></div>\n";
671
        $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n";
670
        $show .= "<div class='inputbox'><label for='sinfo'>Описание секции:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sectinfo"],1)."'></div>\n";
672
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
671
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
673
672
674
        return $show;
673
        return $show;
675
    }
674
    }
676
675
677
    /**
676
    /**
678
     * Обновление информации о секции
677
     * Обновление информации о секции
679
     *
678
     *
680
     * @author Alexander Wolf
679
     * @author Alexander Wolf
681
     * @category Core
680
     * @category Core
682
     *
681
     *
683
     * @param integer $sectionID
682
     * @param integer $sectionID
684
     * @param string $sname
683
     * @param string $sname
685
     * @param string $sinfo
684
     * @param string $sinfo
686
     * @return array
685
     * @return array
687
     */
686
     */
688
    public function updateSection($sectionID, $sname, $sinfo = "") {
687
    public function updateSection($sectionID, $sname, $sinfo = "") {
689
        $result = array();
688
        $result = array();
690
        $sSectID    = $this->secure->checkInt($sectionID);
689
        $sSectID    = $this->secure->checkInt($sectionID);
691
        $sSName     = $this->secure->checkStr($sname,1);
690
        $sSName     = $this->secure->checkStr($sname,1);
692
        $sSInfo     = $this->secure->checkStr($sinfo,1);
691
        $sSInfo     = $this->secure->checkStr($sinfo,1);
693
692
694
        $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'";
693
        $query = "UPDATE ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."' WHERE sect_id='".$sSectID."'";
695
        $rq =& $this->db->query($query);
694
        $rq =& $this->db->query($query);
696
        if (PEAR::isError($this->db)) {
695
        if (PEAR::isError($this->db)) {
697
            $result["ERR"] = 1;
696
            $result["ERR"] = 1;
698
            $result["ERRINFO"] = $this->db->getMessage();
697
            $result["ERRINFO"] = $this->db->getMessage();
699
        } else {
698
        } else {
700
            $result["ERR"] = 0;
699
            $result["ERR"] = 0;
701
        }
700
        }
702
701
703
        return $result;
702
        return $result;
704
    }
703
    }
705
704
706
    /**
705
    /**
707
     * Удаление информации о секции
706
     * Удаление информации о секции
708
     *
707
     *
709
     * @author Alexander Wolf
708
     * @author Alexander Wolf
710
     * @category Core
709
     * @category Core
711
     *
710
     *
712
     * @param integer $sectionID
711
     * @param integer $sectionID
713
     * @return array
712
     * @return array
714
     */
713
     */
715
    public function dropSection($sectionID) {
714
    public function dropSection($sectionID) {
716
        $result = array();
715
        $result = array();
717
        $sSectID    = $this->secure->checkInt($sectionID);
716
        $sSectID    = $this->secure->checkInt($sectionID);
718
717
719
        // Удаление секции
718
        // Удаление секции
720
        $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
719
        $query = "DELETE FROM ".$this->prefix."section WHERE sect_id='".$sSectID."'";
721
        $rq =& $this->db->query($query);
720
        $rq =& $this->db->query($query);
722
        if (PEAR::isError($this->db)) {
721
        if (PEAR::isError($this->db)) {
723
            $result["ERR"] = 1;
722
            $result["ERR"] = 1;
724
            $result["ERRINFO"] = $this->db->getMessage();
723
            $result["ERRINFO"] = $this->db->getMessage();
725
        } else {
724
        } else {
726
            $result["ERR"] = 0;
725
            $result["ERR"] = 0;
727
        }
726
        }
728
727
729
        return $result;
728
        return $result;
730
    }
729
    }
731
730
732
    /**
731
    /**
733
     * Добавление новой секции
732
     * Добавление новой секции
734
     *
733
     *
735
     * @author Alexander Wolf
734
     * @author Alexander Wolf
736
     * @category Core
735
     * @category Core
737
     *
736
     *
738
     * @param string $sname
737
     * @param string $sname
739
     * @param string $sinfo
738
     * @param string $sinfo
740
     * @return array
739
     * @return array
741
     */
740
     */
742
    public function addSection($sname, $sinfo = "") {
741
    public function addSection($sname, $sinfo = "") {
743
        $result = array();
742
        $result = array();
744
        $sSName = $this->secure->checkStr($sname,1);
743
        $sSName = $this->secure->checkStr($sname,1);
745
        $sSInfo = $this->secure->checkStr($sinfo,1);
744
        $sSInfo = $this->secure->checkStr($sinfo,1);
746
745
747
        $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'";
746
        $query = "INSERT INTO ".$this->prefix."section SET secname='".$sSName."', sectinfo='".$sSInfo."'";
748
        $rq =& $this->db->query($query);
747
        $rq =& $this->db->query($query);
749
        if (PEAR::isError($this->db)) {
748
        if (PEAR::isError($this->db)) {
750
            $result["ERR"] = 1;
749
            $result["ERR"] = 1;
751
            $result["ERRINFO"] = $this->db->getMessage();
750
            $result["ERRINFO"] = $this->db->getMessage();
752
        } else {
751
        } else {
753
            $result["ERR"] = 0;
752
            $result["ERR"] = 0;
754
        }
753
        }
755
754
756
        return $result;
755
        return $result;
757
    }
756
    }
-
 
757
-
 
758
    /**
-
 
759
     * Вывод списка поддерживаемых архитектур
-
 
760
     *
-
 
761
     * @author Alexander Wolf
-
 
762
     * @category Core
-
 
763
     *
-
 
764
     * @param string $name
-
 
765
     * @param string $actor
-
 
766
     * @param string $format
-
 
767
     * @return string
-
 
768
     */
-
 
769
    public function showArchList($name, $actor, $format = 'list') {
-
 
770
        switch($format) {
-
 
771
            case 'list':
-
 
772
                $query = "SELECT * FROM ".$this->prefix."arch";
-
 
773
                $rq =& $this->db->query($query);
-
 
774
                $show = "<ul>\n";
-
 
775
                while ($rq->fetchInto($element)) {
-
 
776
                    $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["arch_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["arch_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["arch"],1)."</li>\n";
-
 
777
                }
-
 
778
                $show .= "</ul>";
-
 
779
                break;
-
 
780
            case 'innerhtml':
-
 
781
                $show = "";
-
 
782
                $repID = $this->secure->checkInt($actor);
-
 
783
                if ($archID==0) {
-
 
784
                    $query = "SELECT * FROM ".$this->prefix."arch";
-
 
785
                    $rq =& $this->db->query($query);
-
 
786
                    while ($rq->fetchInto($element)) {
-
 
787
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
-
 
788
                    }
-
 
789
                } else {
-
 
790
                    $query = "SELECT * FROM ".$this->prefix."arch a JOIN ".$this->prefix."arch2rep r ON a.arch_id=r.arch_id WHERE r.rep_id='$repID'";
-
 
791
                    $rq =& $this->db->query($query);
-
 
792
                    while ($rq->fetchInto($element)) {
-
 
793
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."' checked>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
-
 
794
                    }
-
 
795
                    $query = "SELECT a.* FROM ".$this->prefix."arch a WHERE a.arch_id NOT IN (SELECT arch_id FROM ".$this->prefix."arch2rep WHERE rep_id='$repID')";
-
 
796
                    $rq =& $this->db->query($query);
-
 
797
                    while ($rq->fetchInto($element)) {
-
 
798
                        $show .= "<input type='checkbox' name='".$name."[]' value='".$element["arch_id"]."'>&nbsp;".$this->secure->checkStr($element["arch"],1)." ";
-
 
799
                    }
-
 
800
                }
-
 
801
                break;
-
 
802
        }
-
 
803
        return $show;
-
 
804
    }
-
 
805
-
 
806
    /**
-
 
807
     * Добавление новой архитектуры
-
 
808
     *
-
 
809
     * @author Alexander Wolf
-
 
810
     * @category Core
-
 
811
     *
-
 
812
     * @param string $arch
-
 
813
     * @return array
-
 
814
     */
-
 
815
    public function addArch($arch) {
-
 
816
        $result = array();
-
 
817
        $sArch = $this->secure->checkStr($arch,1);
-
 
818
-
 
819
        $query = "INSERT INTO ".$this->prefix."arch SET arch='".$sArch."'";
-
 
820
        $rq =& $this->db->query($query);
-
 
821
        if (PEAR::isError($this->db)) {
-
 
822
            $result["ERR"] = 1;
-
 
823
            $result["ERRINFO"] = $this->db->getMessage();
-
 
824
        } else {
-
 
825
            $result["ERR"] = 0;
-
 
826
        }
-
 
827
-
 
828
        return $result;
-
 
829
    }
-
 
830
-
 
831
    /**
-
 
832
     * Удаление информации об архитектуре
-
 
833
     *
-
 
834
     * @author Alexander Wolf
-
 
835
     * @category Core
-
 
836
     *
-
 
837
     * @param integer $archID
-
 
838
     * @return array
-
 
839
     */
-
 
840
    public function dropArch($archID) {
-
 
841
        $result = array();
-
 
842
        $sArchID    = $this->secure->checkInt($archID);
-
 
843
-
 
844
        // Удаление архитектуры
-
 
845
        $query = "DELETE FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'";
-
 
846
        $rq =& $this->db->query($query);
-
 
847
        if (PEAR::isError($this->db)) {
-
 
848
            $result["ERR"] = 1;
-
 
849
            $result["ERRINFO"] = $this->db->getMessage();
-
 
850
        } else {
-
 
851
            $result["ERR"] = 0;
-
 
852
        }
-
 
853
-
 
854
        // Удаление архитектуры из списка репозиториев
-
 
855
        $query = "DELETE FROM ".$this->prefix."arch2rep WHERE arch_id='".$sArchID."'";
-
 
856
        $rq =& $this->db->query($query);
-
 
857
        if (PEAR::isError($this->db)) {
-
 
858
            $result["ERR"] = 1;
-
 
859
            $result["ERRINFO"] = $this->db->getMessage();
-
 
860
        } else {
-
 
861
            $result["ERR"] = 0;
-
 
862
        }
-
 
863
        return $result;
-
 
864
    }
-
 
865
-
 
866
    /**
-
 
867
     * Обновление информации об архитектуре
-
 
868
     *
-
 
869
     * @author Alexander Wolf
-
 
870
     * @category Core
-
 
871
     *
-
 
872
     * @param integer $archID
-
 
873
     * @param string $arch
-
 
874
     * @return array
-
 
875
     */
-
 
876
    public function updateArch($archID, $arch) {
-
 
877
        $result = array();
-
 
878
        $sArchID    = $this->secure->checkInt($archID);
-
 
879
        $sArch      = $this->secure->checkStr($arch,1);
-
 
880
-
 
881
        $query = "UPDATE ".$this->prefix."arch SET arch='".$sArch."' WHERE arch_id='".$sArchID."'";
-
 
882
        $rq =& $this->db->query($query);
-
 
883
        if (PEAR::isError($this->db)) {
-
 
884
            $result["ERR"] = 1;
-
 
885
            $result["ERRINFO"] = $this->db->getMessage();
-
 
886
        } else {
-
 
887
            $result["ERR"] = 0;
-
 
888
        }
-
 
889
-
 
890
        return $result;
-
 
891
    }
-
 
892
-
 
893
    /**
-
 
894
     * Вывод формы редактирования/добавления архитектур
-
 
895
     *
-
 
896
     * @author Alexander Wolf
-
 
897
     * @category Core
-
 
898
     *
-
 
899
     * @param integer $archID
-
 
900
     * @param string $info
-
 
901
     * @return string
-
 
902
     */
-
 
903
    public function showArchForm($archID = 0, $info = "") {
-
 
904
        $sArchID = $this->secure->checkInt($archID);
-
 
905
        $sInfo = $this->secure->checkStr($info, 1);
-
 
906
        if ($sInfo == "") {
-
 
907
            $sInfo = "Архитектура";
-
 
908
        }
-
 
909
        if ($sArchID != 0) {
-
 
910
            // Режим редактирования
-
 
911
            $query = "SELECT * FROM ".$this->prefix."arch WHERE arch_id='".$sArchID."'";
-
 
912
            $rq =& $this->db->query($query);
-
 
913
            $rq->fetchInto($element);
-
 
914
        }
-
 
915
-
 
916
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
-
 
917
        $show .= "<div class='inputbox'><label for='arch'>Архитектура:</label> <input type='text' name='arch' id='arch' value='".$this->secure->checkStr($element["arch"],1)."'></div>\n";
-
 
918
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
-
 
919
-
 
920
        return $show;
-
 
921
    }
758
922
759
    /**
923
    /**
760
     * Показывает список подписей
924
     * Показывает список подписей
761
     *
925
     *
762
     * @author Alexander Wolf
926
     * @author Alexander Wolf
763
     * @category Core
927
     * @category Core
764
     *
928
     *
765
     * @param string $name
929
     * @param string $name
766
     * @param string $actor
930
     * @param string $actor
767
     * @return string
931
     * @return string
768
     */
932
     */
769
    public function showSignsList($name, $actor) {
933
    public function showSignsList($name, $actor) {
770
        $query = "SELECT * FROM ".$this->prefix."signs";
934
        $query = "SELECT * FROM ".$this->prefix."signs";
771
        $rq =& $this->db->query($query);
935
        $rq =& $this->db->query($query);
772
        $show = "<ul>\n";
936
        $show = "<ul>\n";
773
        while ($rq->fetchInto($element)) {
937
        while ($rq->fetchInto($element)) {
774
            $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";
938
            $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";
775
        }
939
        }
776
        $show .= "</ul>";
940
        $show .= "</ul>";
777
941
778
        return $show;
942
        return $show;
779
    }
943
    }
780
944
781
    /**
945
    /**
782
     * Вывод формы редактирования/добавления подписей
946
     * Вывод формы редактирования/добавления подписей
783
     *
947
     *
784
     * @author Alexander Wolf
948
     * @author Alexander Wolf
785
     * @category Core
949
     * @category Core
786
     *
950
     *
787
     * @param integer $sectionID
951
     * @param integer $sectionID
788
     * @param string $info
952
     * @param string $info
789
     * @return string
953
     * @return string
790
     */
954
     */
791
    public function showSignsForm($signID = 0, $info = "") {
955
    public function showSignsForm($signID = 0, $info = "") {
792
        $sSignID = $this->secure->checkInt($signID);
956
        $sSignID = $this->secure->checkInt($signID);
793
        $sInfo = $this->secure->checkStr($info, 1);
957
        $sInfo = $this->secure->checkStr($info, 1);
794
        if ($sInfo == "") {
958
        if ($sInfo == "") {
795
            $sInfo = "Подписи";
959
            $sInfo = "Подписи";
796
        }
960
        }
797
        if ($sSignID != 0) {
961
        if ($sSignID != 0) {
798
            // Режим редактирования
962
            // Режим редактирования
799
            $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
963
            $query = "SELECT * FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
800
            $rq =& $this->db->query($query);
964
            $rq =& $this->db->query($query);
801
            $rq->fetchInto($element);
965
            $rq->fetchInto($element);
802
        }
966
        }
803
967
804
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
968
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
805
        $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n";
969
        $show .= "<div class='inputbox'><label for='sname'>Название подписи:</label> <input type='text' name='sname' id='sname' value='".$this->secure->checkStr($element["sname"],1)."'></div>\n";
806
        $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n";
970
        $show .= "<div class='inputbox'><label for='sinfo'>Описание подписи:</label> <input type='text' name='sinfo' id='sinfo' value='".$this->secure->checkStr($element["sinfo"],1)."'></div>\n";
807
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
971
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
808
972
809
        return $show;
973
        return $show;
810
    }
974
    }
811
975
812
    /**
976
    /**
813
     * Обновление информации о секции
977
     * Обновление информации о секции
814
     *
978
     *
815
     * @author Alexander Wolf
979
     * @author Alexander Wolf
816
     * @category Core
980
     * @category Core
817
     *
981
     *
818
     * @param integer $sectionID
982
     * @param integer $sectionID
819
     * @param string $sname
983
     * @param string $sname
820
     * @param string $sinfo
984
     * @param string $sinfo
821
     * @return array
985
     * @return array
822
     */
986
     */
823
    public function updateSign($signID, $sname, $sinfo = "") {
987
    public function updateSign($signID, $sname, $sinfo = "") {
824
        $result = array();
988
        $result = array();
825
        $sSignID    = $this->secure->checkInt($signID);
989
        $sSignID    = $this->secure->checkInt($signID);
826
        $sSName     = $this->secure->checkStr($sname,1);
990
        $sSName     = $this->secure->checkStr($sname,1);
827
        $sSInfo     = $this->secure->checkStr($sinfo,1);
991
        $sSInfo     = $this->secure->checkStr($sinfo,1);
828
992
829
        $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'";
993
        $query = "UPDATE ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."' WHERE sign_id='".$sSignID."'";
830
        $rq =& $this->db->query($query);
994
        $rq =& $this->db->query($query);
831
        if (PEAR::isError($this->db)) {
995
        if (PEAR::isError($this->db)) {
832
            $result["ERR"] = 1;
996
            $result["ERR"] = 1;
833
            $result["ERRINFO"] = $this->db->getMessage();
997
            $result["ERRINFO"] = $this->db->getMessage();
834
        } else {
998
        } else {
835
            $result["ERR"] = 0;
999
            $result["ERR"] = 0;
836
        }
1000
        }
837
1001
838
        return $result;
1002
        return $result;
839
    }
1003
    }
840
1004
841
    /**
1005
    /**
842
     * Удаление информации о подписи
1006
     * Удаление информации о подписи
843
     *
1007
     *
844
     * @author Alexander Wolf
1008
     * @author Alexander Wolf
845
     * @category Core
1009
     * @category Core
846
     *
1010
     *
847
     * @param integer $sectionID
1011
     * @param integer $sectionID
848
     * @return array
1012
     * @return array
849
     */
1013
     */
850
    public function dropSign($signID) {
1014
    public function dropSign($signID) {
851
        $result = array();
1015
        $result = array();
852
        $sSignID    = $this->secure->checkInt($signID);
1016
        $sSignID    = $this->secure->checkInt($signID);
853
1017
854
        // Удаление подписи
1018
        // Удаление подписи
855
        $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
1019
        $query = "DELETE FROM ".$this->prefix."signs WHERE sign_id='".$sSignID."'";
856
        $rq =& $this->db->query($query);
1020
        $rq =& $this->db->query($query);
857
        if (PEAR::isError($this->db)) {
1021
        if (PEAR::isError($this->db)) {
858
            $result["ERR"] = 1;
1022
            $result["ERR"] = 1;
859
            $result["ERRINFO"] = $this->db->getMessage();
1023
            $result["ERRINFO"] = $this->db->getMessage();
860
        } else {
1024
        } else {
861
            $result["ERR"] = 0;
1025
            $result["ERR"] = 0;
862
        }
1026
        }
863
1027
864
        return $result;
1028
        return $result;
865
    }
1029
    }
866
1030
867
    /**
1031
    /**
868
     * Добавление новой подписи
1032
     * Добавление новой подписи
869
     *
1033
     *
870
     * @author Alexander Wolf
1034
     * @author Alexander Wolf
871
     * @category Core
1035
     * @category Core
872
     *
1036
     *
873
     * @param string $sname
1037
     * @param string $sname
874
     * @param string $sinfo
1038
     * @param string $sinfo
875
     * @return array
1039
     * @return array
876
     */
1040
     */
877
    public function addSign($sname, $sinfo = "") {
1041
    public function addSign($sname, $sinfo = "") {
878
        $result = array();
1042
        $result = array();
879
        $sSName = $this->secure->checkStr($sname,1);
1043
        $sSName = $this->secure->checkStr($sname,1);
880
        $sSInfo = $this->secure->checkStr($sinfo,1);
1044
        $sSInfo = $this->secure->checkStr($sinfo,1);
881
1045
882
        $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'";
1046
        $query = "INSERT INTO ".$this->prefix."signs SET sname='".$sSName."', sinfo='".$sSInfo."'";
883
        $rq =& $this->db->query($query);
1047
        $rq =& $this->db->query($query);
884
        if (PEAR::isError($this->db)) {
1048
        if (PEAR::isError($this->db)) {
885
            $result["ERR"] = 1;
1049
            $result["ERR"] = 1;
886
            $result["ERRINFO"] = $this->db->getMessage();
1050
            $result["ERRINFO"] = $this->db->getMessage();
887
        } else {
1051
        } else {
888
            $result["ERR"] = 0;
1052
            $result["ERR"] = 0;
889
        }
1053
        }
890
1054
891
        return $result;
1055
        return $result;
892
    }
1056
    }
893
   
1057
   
894
    /**
1058
    /**
895
     * Проверка пароля (из формы авторизации)
1059
     * Проверка пароля (из формы авторизации)
896
     *
1060
     *
897
     * @author Alexander Wolf
1061
     * @author Alexander Wolf
898
     * @category Core
1062
     * @category Core
899
     *
1063
     *
900
     * @param string $word
1064
     * @param string $word
901
     * @return array
1065
     * @return array
902
     */
1066
     */
903
    public function checkSign($word) {
1067
    public function checkSign($word) {
904
        $result = array();
1068
        $result = array();
905
1069
906
        $sHash = $this->secure->encryptStr($word);
1070
        $sHash = $this->secure->encryptStr($word);
907
        $pwd   = $this->getOption("passwd");
1071
        $pwd   = $this->getOption("passwd");
908
        if ($sHash == $pwd["OptValue"]) {
1072
        if ($sHash == $pwd["OptValue"]) {
909
            $result["ERR"] = 0;
1073
            $result["ERR"] = 0;
910
            $result["Location"] = "manager.php";
1074
            $result["Location"] = "manager.php";
911
            setcookie($this->cookie, $sHash);
1075
            setcookie($this->cookie, $sHash);
912
        } else {
1076
        } else {
913
            $result["ERR"] = 1;
1077
            $result["ERR"] = 1;
914
            $result["ERRINFO"] = "Password not valid";
1078
            $result["ERRINFO"] = "Password not valid";
915
            $result["Location"] = "manager.php?error=1";
1079
            $result["Location"] = "manager.php?error=1";
916
        }
1080
        }
917
1081
918
        return $result;
1082
        return $result;
919
    }
1083
    }
920
1084
921
    /**
1085
    /**
922
     * Проверка пароля (из cookies)
1086
     * Проверка пароля (из cookies)
923
     *
1087
     *
924
     * @author Alexander Wolf
1088
     * @author Alexander Wolf
925
     * @category Core
1089
     * @category Core
926
     *
1090
     *
927
     * @param string $hash
1091
     * @param string $hash
928
     * @return array
1092
     * @return array
929
     */
1093
     */
930
    public function checkCookieSign($hash) {
1094
    public function checkCookieSign($hash) {
931
        $result = array();
1095
        $result = array();
932
1096
933
        $pwd = $this->getOption("passwd");
1097
        $pwd = $this->getOption("passwd");
934
        if ($hash == $pwd["OptValue"]) {
1098
        if ($hash == $pwd["OptValue"]) {
935
            $result["ERR"] = 0;
1099
            $result["ERR"] = 0;
936
        } else {
1100
        } else {
937
            $result["ERR"] = 1;
1101
            $result["ERR"] = 1;
938
            $result["ERRINFO"] = "Hash not valid";
1102
            $result["ERRINFO"] = "Hash not valid";
939
            $result["Location"] = "manager.php";
1103
            $result["Location"] = "manager.php";
940
        }
1104
        }
941
1105
942
        return $result;
1106
        return $result;
943
    }
1107
    }
944
1108
945
    /**
1109
    /**
946
     * Форма ввода пароля
1110
     * Форма ввода пароля
947
     *
1111
     *
948
     * @author Alexander Wolf
1112
     * @author Alexander Wolf
949
     * @category Core
1113
     * @category Core
950
     *
1114
     *
951
     * @return string
1115
     * @return string
952
     */
1116
     */
953
    public function showSigninForm() {
1117
    public function showSigninForm() {
954
        $show  = "<div id='regform'>";
1118
        $show  = "<div id='regform'>";
955
        $show .= "<form action='process.php' method='post'>\n";
1119
        $show .= "<form action='process.php' method='post'>\n";
956
        $show .= "<fieldset><legend>Пароль</legend>\n";
1120
        $show .= "<fieldset><legend>Пароль</legend>\n";
957
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
1121
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
958
        $show .= "<input type='password' name='word' value=''>\n";
1122
        $show .= "<input type='password' name='word' value=''>\n";
959
        $show .= "<input type='submit' value=' Войти '>\n";
1123
        $show .= "<input type='submit' value=' Войти '>\n";
960
        $show .= "</fieldset>\n</form></div>\n";
1124
        $show .= "</fieldset>\n</form></div>\n";
961
1125
962
        return $show;
1126
        return $show;
963
    }
1127
    }
964
1128
965
    /**
1129
    /**
966
     * Обновление пароля
1130
     * Обновление пароля
967
     *
1131
     *
968
     * @author Alexander Wolf
1132
     * @author Alexander Wolf
969
     * @category Core
1133
     * @category Core
970
     *
1134
     *
971
     * @param string $word1
1135
     * @param string $word1
972
     * @param string $word2
1136
     * @param string $word2
973
     * @return array
1137
     * @return array
974
     */
1138
     */
975
    public function updatePassword($word1, $word2) {
1139
    public function updatePassword($word1, $word2) {
976
        $result = array();
1140
        $result = array();
977
1141
978
        if ($word1 == $word2) {
1142
        if ($word1 == $word2) {
979
            $sWord = $this->secure->encryptStr($word1);
1143
            $sWord = $this->secure->encryptStr($word1);
980
            $r = $this->setOption("passwd", $sWord);
1144
            $r = $this->setOption("passwd", $sWord);
981
            $result = $r;
1145
            $result = $r;
982
        } else {
1146
        } else {
983
            $result["ERR"] = 1;
1147
            $result["ERR"] = 1;
984
            $result["ERRINFO"] = "Passwords is mismatch";
1148
            $result["ERRINFO"] = "Passwords is mismatch";
985
        }
1149
        }
986
1150
987
        return $result;
1151
        return $result;
988
    }
1152
    }
989
1153
990
    /**
1154
    /**
991
     * Отображение формы создания и редактирования версии apt-дистрибутива
1155
     * Отображение формы создания и редактирования версии apt-дистрибутива
992
     *
1156
     *
993
     * @author Alexander Wolf
1157
     * @author Alexander Wolf
994
     * @category Core
1158
     * @category Core
995
     *
1159
     *
996
     * @param string $name
1160
     * @param string $name
997
     * @param string $actor
1161
     * @param string $actor
998
     * @param integer $versionID
1162
     * @param integer $versionID
999
     * @return string
1163
     * @return string
1000
     */
1164
     */
1001
    public function showDistVersionsForm($versionID = 0, $info = '') {
1165
    public function showDistVersionsForm($versionID = 0, $info = '') {
1002
        $sVersionID = $this->secure->checkInt($versionID);
1166
        $sVersionID = $this->secure->checkInt($versionID);
1003
        $sInfo = $this->secure->checkStr($info, 1);
1167
        $sInfo = $this->secure->checkStr($info, 1);
1004
        if ($sInfo == "") {
1168
        if ($sInfo == "") {
1005
            $sInfo = "Версия дистрибутива";
1169
            $sInfo = "Версия дистрибутива";
1006
        }
1170
        }
1007
        if ($sVersionID != 0) {
1171
        if ($sVersionID != 0) {
1008
            // Режим редактирования
1172
            // Режим редактирования
1009
            $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'";
1173
            $query = "SELECT * FROM ".$this->prefix."version v JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id WHERE v.version_id='".$sVersionID."'";
1010
            $rq =& $this->db->query($query);
1174
            $rq =& $this->db->query($query);
1011
            $rq->fetchInto($element);
1175
            $rq->fetchInto($element);
1012
        }
1176
        }
1013
 
1177
 
1014
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1178
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1015
        if ($sVersionID != 0) {
1179
        if ($sVersionID != 0) {
1016
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n";
1180
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> <input type='text' name='distname' value='".$this->secure->checkStr($element["distname"],1)."' readonly='readonly'></div>\n";
1017
        } else {
1181
        } else {
1018
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n";
1182
            $show .= "<div class='inputbox'><label for='distname'>Дистрибутив:</label> ".$this->showDistributionList("distname", "", "", "innerhtml")."</div>\n";
1019
        }
1183
        }
1020
        $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n";
1184
        $show .= "<div class='inputbox'><label for='vname'>Название версии:</label> <input type='text' name='vname' value='".$this->secure->checkStr($element["vname"],1)."'></div>\n";
1021
        $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n";
1185
        $show .= "<div class='inputbox'><label for='version'>Номер версии:</label> <input type='text' name='version' value='".$this->secure->checkStr($element["version"],1)."'></div>\n";
1022
        $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n";
1186
        $show .= "<div class='inputbox'><label for='vcodename'>Кодовое имя версии:</label> <input type='text' name='vcodename' value='".$this->secure->checkStr($element["vcodename"],1)."'></div>\n";
1023
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1187
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1024
1188
1025
        return $show;
1189
        return $show;
1026
    }    
1190
    }    
1027
1191
1028
    /**
1192
    /**
1029
     * Парсер схемы адреса репозитория
1193
     * Парсер схемы адреса репозитория
1030
     * FIXME Возможно не потребуется
1194
     * FIXME Возможно не потребуется
1031
     *
1195
     *
1032
     * @author Alexander Wolf
1196
     * @author Alexander Wolf
1033
     * @category Core
1197
     * @category Core
1034
     *
1198
     *
1035
     * @param string $repstring
1199
     * @param string $repstring
1036
     * @return integer
1200
     * @return integer
1037
     */
1201
     */
1038
    public function repositoryParser($repstring) {
1202
    public function repositoryParser($repstring) {
1039
        $tokens = array();
1203
        $tokens = array();
1040
        $sections = array();
1204
        $sections = array();
1041
        $tokens = split(" ",$repstring);
1205
        $tokens = split(" ",$repstring);
1042
1206
1043
        if ($tokens[0] == "deb") {
1207
        if ($tokens[0] == "deb") {
1044
            // debian/ubuntu репозиторий "type proto://host/folder distr sections"
1208
            // debian/ubuntu репозиторий "type proto://host/folder distr sections"
1045
            $url = parse_url($tokens[1]);
1209
            $url = parse_url($tokens[1]);
1046
            $distr  = $tokens[2];
1210
            $distr  = $tokens[2];
1047
1211
1048
            for($i=3;$i<count($tokens);$i++) {
1212
            for($i=3;$i<count($tokens);$i++) {
1049
                $sections[] = $tokens[$i];
1213
                $sections[] = $tokens[$i];
1050
            }
1214
            }
1051
        } else {
1215
        } else {
1052
            // altlinux репозиторий "type [sign] proto://host/folder base repname"
1216
            // altlinux репозиторий "type [sign] proto://host/folder base repname"
1053
            if (stripos($tokens[1],"]")!=0) {
1217
            if (stripos($tokens[1],"]")!=0) {
1054
                $sign = $tokens[1];
1218
                $sign = $tokens[1];
1055
                $url = parse_url($tokens[2]);
1219
                $url = parse_url($tokens[2]);
1056
                $base = $tokens[3];
1220
                $base = $tokens[3];
1057
                $repname = $tokens[4];
1221
                $repname = $tokens[4];
1058
            } else {
1222
            } else {
1059
                $url = parse_url($tokens[1]);
1223
                $url = parse_url($tokens[1]);
1060
                $base = $tokens[2];
1224
                $base = $tokens[2];
1061
                $repname = $tokens[3];
1225
                $repname = $tokens[3];
1062
            }
1226
            }
1063
        }
1227
        }
1064
1228
1065
        $proto      = $url["scheme"]."://";
1229
        $proto      = $url["scheme"]."://";
1066
        $addr       = $url["host"];
1230
        $addr       = $url["host"];
1067
        if ($url["port"]!="") {
1231
        if ($url["port"]!="") {
1068
            $addr .= ":".$url["port"];
1232
            $addr .= ":".$url["port"];
1069
        }
1233
        }
1070
        $path       = $url["path"];
1234
        $path       = $url["path"];
1071
1235
1072
        return 0;
1236
        return 0;
1073
    }
1237
    }
1074
1238
1075
    /**
1239
    /**
1076
     * Выгрузка картинок логотипов дистрибутивов
1240
     * Выгрузка картинок логотипов дистрибутивов
1077
     *
1241
     *
1078
     * @author Alexander Wolf
1242
     * @author Alexander Wolf
1079
     * @category Core
1243
     * @category Core
1080
     *
1244
     *
1081
     * @param string $path
1245
     * @param string $path
1082
     * @param string $dist
1246
     * @param string $dist
1083
     * @param array $datafile
1247
     * @param array $datafile
1084
     * @return integer
1248
     * @return integer
1085
     */
1249
     */
1086
    public function uploadPicture($path, $dist, $datafile) {
1250
    public function uploadPicture($path, $dist, $datafile) {
1087
        $folder   = $path.$dist."-orig.png";
1251
        $folder   = $path.$dist."-orig.png";
1088
        $folderN  = $path.$dist.".png";
1252
        $folderN  = $path.$dist.".png";
1089
        $folderEM = $path.$dist."-em.png";
1253
        $folderEM = $path.$dist."-em.png";
1090
1254
1091
        $distlogo = 0;
1255
        $distlogo = 0;
1092
        if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) {
1256
        if (move_uploaded_file($datafile["distlogo"]["tmp_name"],$folder)) {
1093
            chmod($folder, 0644);
1257
            chmod($folder, 0644);
1094
            list($width, $height) = GetImageSize($folder);
1258
            list($width, $height) = GetImageSize($folder);
1095
            $percent = 32/$height;
1259
            $percent = 32/$height;
1096
            $newwidth = $width * $percent;
1260
            $newwidth = $width * $percent;
1097
            $newheight = $height * $percent;
1261
            $newheight = $height * $percent;
1098
1262
1099
            $output = ImageCreateTrueColor($newwidth, $newheight);
1263
            $output = ImageCreateTrueColor($newwidth, $newheight);
1100
            $source = ImageCreateFromPNG($folder);
1264
            $source = ImageCreateFromPNG($folder);
1101
1265
1102
            ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1266
            ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1103
            ImagePNG($output, $folderEM);
1267
            ImagePNG($output, $folderEM);
1104
1268
1105
            $percent = 15/$height;
1269
            $percent = 15/$height;
1106
            $newwidth = $width * $percent;
1270
            $newwidth = $width * $percent;
1107
            $newheight = $height * $percent;
1271
            $newheight = $height * $percent;
1108
1272
1109
            $output = ImageCreateTrueColor($newwidth, $newheight);
1273
            $output = ImageCreateTrueColor($newwidth, $newheight);
1110
1274
1111
            ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1275
            ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
1112
            ImagePNG($output, $folderN);
1276
            ImagePNG($output, $folderN);
1113
1277
1114
            unlink($folder);
1278
            unlink($folder);
1115
            $distlogo = 1;
1279
            $distlogo = 1;
1116
        }
1280
        }
1117
        return $distlogo;
1281
        return $distlogo;
1118
    }
1282
    }
1119
1283
1120
    /**
1284
    /**
1121
     * Показ списка репозиториев
1285
     * Показ списка репозиториев
1122
     *
1286
     *
1123
     * @author Alexander Wolf
1287
     * @author Alexander Wolf
1124
     * @category Core
1288
     * @category Core
1125
     *
1289
     *
1126
     * @param string $name
1290
     * @param string $name
1127
     * @param string $actor
1291
     * @param string $actor
1128
     * @param string $format
1292
     * @param string $format
1129
     * @return string
1293
     * @return string
1130
     */
1294
     */
1131
    public function showRepositoriesList($name, $actor, $format = 'list') {
1295
    public function showRepositoriesList($name, $actor, $format = 'list') {
1132
        $query  = "SELECT * FROM ".$this->prefix."repository r ";
1296
        $query  = "SELECT * FROM ".$this->prefix."repository r ";
1133
        $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id ";
1297
        $query .= "JOIN ".$this->prefix."rtype rt ON rt.rtype_id=r.rtype_id ";
1134
        $rq =& $this->db->query($query);
1298
        $rq =& $this->db->query($query);
1135
        $show = "<ul>";
1299
        $show = "<ul>";
1136
        while ($rq->fetchInto($element)) {
1300
        while ($rq->fetchInto($element)) {
1137
            $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["rep_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["rep_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["repname"],1)." (".$this->secure->checkStr($element["rtype"],1).")</li>\n";
1301
            $show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$this->secure->checkInt($element["rep_id"])."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$this->secure->checkInt($element["rep_id"])."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["repname"],1)." (".$this->secure->checkStr($element["rtype"],1).")</li>\n";
1138
        }
1302
        }
1139
        $show .= "</ul>";
1303
        $show .= "</ul>";
1140
        return $show;
1304
        return $show;
1141
    }
1305
    }
1142
1306
1143
    /**
1307
    /**
1144
     * Вывод списка типов репозиториев
1308
     * Вывод списка типов репозиториев
1145
     *
1309
     *
1146
     * @author Alexander Wolf
1310
     * @author Alexander Wolf
1147
     * @category Core
1311
     * @category Core
1148
     *
1312
     *
1149
     * @param integer $reptype
1313
     * @param integer $reptype
1150
     * @param string $name
1314
     * @param string $name
1151
     * @return string
1315
     * @return string
1152
     */
1316
     */
1153
    public function showRepType($reptype = 0, $name = "") {
1317
    public function showRepType($reptype = 0, $name = "") {
1154
        $sRT = $this->secure->checkInt($reptype);
1318
        $sRT = $this->secure->checkInt($reptype);
1155
        $sNM = $this->secure->checkStr($name,1);
1319
        $sNM = $this->secure->checkStr($name,1);
1156
        $query = "SELECT * FROM ".$this->prefix."rtype";
1320
        $query = "SELECT * FROM ".$this->prefix."rtype";
1157
        $rq =& $this->db->query($query);
1321
        $rq =& $this->db->query($query);
1158
        $show = "<select name='".$sNM."' id='".$sNM."'>\n";
1322
        $show = "<select name='".$sNM."' id='".$sNM."'>\n";
1159
        while ($rq->fetchInto($element)) {
1323
        while ($rq->fetchInto($element)) {
1160
            if ($element["rtype_id"]==$sRT) {
1324
            if ($element["rtype_id"]==$sRT) {
1161
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1325
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."' selected>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1162
            } else {
1326
            } else {
1163
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1327
                $show .= "<option value='".$this->secure->checkInt($element["rtype_id"])."'>".$this->secure->checkStr($element["rtype"],1)."</option>\n";
1164
            }
1328
            }
1165
        }
1329
        }
1166
        $show .= "</select>";
1330
        $show .= "</select>";
1167
1331
1168
        return $show;
1332
        return $show;
1169
    }
1333
    }
1170
1334
1171
    /**
1335
    /**
1172
     * Форма создания/редактирвоания репозиториев
1336
     * Форма создания/редактирвоания репозиториев
1173
     *
1337
     *
1174
     * @author Alexander Wolf
1338
     * @author Alexander Wolf
1175
     * @category Core
1339
     * @category Core
1176
     *
1340
     *
1177
     * @param integer $repID
1341
     * @param integer $repID
1178
     * @param string $info
1342
     * @param string $info
1179
     * @param string $reptype
1343
     * @param string $reptype
1180
     * @return string
1344
     * @return string
1181
     */
1345
     */
1182
    public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") {
1346
    public function showRepositoriesForm($repID = 0, $info = "", $reptype = "") {
1183
        $sRepID = $this->secure->checkInt($repID);
1347
        $sRepID = $this->secure->checkInt($repID);
1184
        $sInfo  = $this->secure->checkStr($info, 1);
1348
        $sInfo  = $this->secure->checkStr($info, 1);
1185
        $sRType = $this->secure->checkStr($reptype, 1);
1349
        $sRType = $this->secure->checkStr($reptype, 1);
1186
        if ($sInfo == "") {
1350
        if ($sInfo == "") {
1187
            $sInfo = "Репозиторий";
1351
            $sInfo = "Репозиторий";
1188
        }
1352
        }
1189
        if ($sRType == "") {
1353
        if ($sRType == "") {
1190
            $sRType = "deb";
1354
            $sRType = "deb";
1191
        }
1355
        }
1192
        if ($sRepID != 0) {
1356
        if ($sRepID != 0) {
1193
            // Режим редактирования
1357
            // Режим редактирования
1194
            $query  = "SELECT r.rtype_id,r.repname,r.repinfo,r.repkey,p.proto,h.rhost,f.rfolder,v.*,d.distname,dt.type FROM ".$this->prefix."repository r ";
1358
            $query  = "SELECT r.rtype_id,r.repname,r.repinfo,r.repkey,p.proto,h.rhost,f.rfolder,v.*,d.distname,dt.type FROM ".$this->prefix."repository r ";
1195
            //$query .= "JOIN ".$this->prefix."rtype rt ON r.rtype_id=rt.rtype_id ";
1359
            //$query .= "JOIN ".$this->prefix."rtype rt ON r.rtype_id=rt.rtype_id ";
1196
            $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id ";
1360
            $query .= "JOIN ".$this->prefix."protos p ON r.proto_id=p.proto_id ";
1197
            $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id ";
1361
            $query .= "JOIN ".$this->prefix."rephost h ON r.rhost_id=h.rhost_id ";
1198
            $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id ";
1362
            $query .= "JOIN ".$this->prefix."repfolder f ON r.rfolder_id=f.rfolder_id ";
1199
            $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id ";
1363
            $query .= "JOIN ".$this->prefix."version v ON r.version=v.version_id ";
1200
            $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ";
1364
            $query .= "JOIN ".$this->prefix."distribution d ON v.dist_id=d.dist_id ";
1201
            $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id ";
1365
            $query .= "JOIN ".$this->prefix."dtype dt ON d.disttype=dt.type_id ";
1202
            $query .= "WHERE r.rep_id='".$sRepID."'";
1366
            $query .= "WHERE r.rep_id='".$sRepID."'";
1203
            $rq =& $this->db->query($query);
1367
            $rq =& $this->db->query($query);
1204
            $rq->fetchInto($element);
1368
            $rq->fetchInto($element);
1205
            $sRType = $this->secure->checkStr($element["type"],1);
1369
            $sRType = $this->secure->checkStr($element["type"],1);
1206
        }
1370
        }
1207
1371
1208
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1372
        $show  = "<fieldset><legend>".$sInfo."</legend>\n";
1209
        $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value='".$this->secure->checkStr($element["repname"],1)."'></div>\n";
1373
        $show .= "<div class='inputbox'><label for='rname'>Название репозитория:</label> <input type='text' name='rname' value='".$this->secure->checkStr($element["repname"],1)."'></div>\n";
1210
        $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value='".$this->secure->checkStr($element["repinfo"],1)."'></div>\n";
1374
        $show .= "<div class='inputbox'><label for='rinfo'>Описание репозитория:</label> <input type='text' name='rinfo' value='".$this->secure->checkStr($element["repinfo"],1)."'></div>\n";
1211
        $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value='".$this->secure->checkStr($element["repkey"],1)."'></div>\n";
1375
        $show .= "<div class='inputbox'><label for='rkey'>Ключ подписи репозитория:</label> <input type='text' name='rkey' value='".$this->secure->checkStr($element["repkey"],1)."'></div>\n";
1212
        $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> <input type='text' name='rproto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n";
1376
        $show .= "<div class='inputbox'><label for='rproto'>Протокол доступа:</label> <input type='text' name='rproto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n";
1213
        $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n";
1377
        $show .= "<div class='inputbox'><label for='rhost'>Хост репозитория:</label> <input type='text' name='rhost' value='".$this->secure->checkStr($element["rhost"],1)."'></div>\n";
1214
        $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n";
1378
        $show .= "<div class='inputbox'><label for='rfolder'>Корневая папка:</label> <input type='text' name='rfolder' value='".$this->secure->checkStr($element["rfolder"],1)."'></div>\n";
1215
        $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n";
1379
        $show .= "<div class='inputbox'><label for='rtype'>Тип репозитория:</label> ".$this->showRepType($this->secure->checkInt($element["rtype_id"]), "rtype")."</div>\n";
1216
        $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n";
1380
        $show .= "<div class='inputbox'><label for='rsects'>Секции репозитория:</label> <div class='formwrapper'>".$this->showSectionsList("rsects",$sRepID,"innerhtml")."</div></div>\n";
1217
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1381
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div></fieldset>\n";
1218
1382
1219
        return $show;
1383
        return $show;
1220
        return $show;
1384
        return $show;
1221
    }
1385
    }
1222
   
1386
   
1223
}
1387
}
1224
1388
1225
?>
1389
?>