Хранилища Subversion ant

Редакция

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

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