Хранилища Subversion ant

Редакция

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

Редакция 380 Редакция 381
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
    public function __construct($database, $prefix, $secure, $cookie) {
21
    public function __construct($database, $prefix, $secure, $cookie) {
22
        $this->db       = $database;
22
        $this->db       = $database;
23
        $this->prefix   = $prefix;
23
        $this->prefix   = $prefix;
24
        $this->secure   = $secure;
24
        $this->secure   = $secure;
25
        $this->cookie   = $cookie;
25
        $this->cookie   = $cookie;
26
    }
26
    }
27
27
28
    // Получение данных о настройке
28
    // Получение данных о настройке
29
    public function getOption($attr) {
29
    public function getOption($attr) {
30
        $result = array();
30
        $result = array();
31
        $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'";
31
        $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'";
32
        $rq =& $this->db->query($query);
32
        $rq =& $this->db->query($query);
33
        if ($rq->numRows()!=0) {
33
        if ($rq->numRows()!=0) {
34
            $rq->fetchInto($element);
34
            $rq->fetchInto($element);
35
            $result["ERR"] = 0;
35
            $result["ERR"] = 0;
36
            $result["OptValue"] = $element["optvalue"];
36
            $result["OptValue"] = $element["optvalue"];
37
        } else {
37
        } else {
38
            $result["ERR"] = 1;
38
            $result["ERR"] = 1;
39
            $result["ERRINFO"] = "Empty result";
39
            $result["ERRINFO"] = "Empty result";
40
        }
40
        }
41
        return $result;
41
        return $result;
42
    }
42
    }
43
43
44
    // Установка данных о настройке
44
    // Установка данных о настройке
45
    public function setOption($attr, $value) {
45
    public function setOption($attr, $value) {
46
        $result = array();
46
        $result = array();
47
47
48
        if ($attr != "passwd") {
48
        if ($attr != "passwd") {
49
            $sValue = $this->secure->checkStr($value);
49
            $sValue = $this->secure->checkStr($value);
50
        } else {
50
        } else {
51
            $sValue = $value;
51
            $sValue = $value;
52
        }
52
        }
53
53
54
        $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'";
54
        $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'";
55
        $rq =& $this->db->query($query);
55
        $rq =& $this->db->query($query);
56
        if (PEAR::isError($this->db)) {
56
        if (PEAR::isError($this->db)) {
57
            $result["ERR"] = 1;
57
            $result["ERR"] = 1;
58
            $result["ERRINFO"] = $this->db->getMessage();
58
            $result["ERRINFO"] = $this->db->getMessage();
59
        } else {
59
        } else {
60
            $result["ERR"] = 0;
60
            $result["ERR"] = 0;
61
        }
61
        }
62
62
63
        return $result;
63
        return $result;
64
    }
64
    }
65
65
66
    // Создание настройки
66
    // Создание настройки
67
    public function addOption($attr, $value) {
67
    public function addOption($attr, $value) {
68
        $result = array();
68
        $result = array();
69
        $sValue = $this->secure->checkStr($value);
69
        $sValue = $this->secure->checkStr($value);
70
70
71
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
71
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
72
        $rq =& $this->db->query($query);
72
        $rq =& $this->db->query($query);
73
        if (PEAR::isError($this->db)) {
73
        if (PEAR::isError($this->db)) {
74
            $result["ERR"] = 1;
74
            $result["ERR"] = 1;
75
            $result["ERRINFO"] = $this->db->getMessage();
75
            $result["ERRINFO"] = $this->db->getMessage();
76
        } else {
76
        } else {
77
            $result["ERR"] = 0;
77
            $result["ERR"] = 0;
78
        }
78
        }
79
79
80
        return $result;
80
        return $result;
81
    }
81
    }
82
82
83
    // Получение и отображение списка дистрибутивов
83
    // Получение и отображение списка дистрибутивов
84
    public function showDistributionList($name, $info = "", $format = 'html') {
84
    public function showDistributionList($name, $info = "", $format = 'html') {
85
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
85
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
86
        $rq =& $this->db->query($query);
86
        $rq =& $this->db->query($query);
87
        switch ($format) {
87
        switch ($format) {
88
            case 'html':
88
            case 'html':
89
                $show = "<fieldset><legend>".$info."</legend>\n<select id='".$name."' name='".$name."'>\n";                
89
                $show = "<fieldset><legend>".$info."</legend>\n<select id='".$name."' name='".$name."'>\n";                
90
                while ($rq->fetchInto($element)) {
90
                while ($rq->fetchInto($element)) {
91
                    $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n";
91
                    $show .= "<option value='".$this->secure->checkInt($element["dist_id"])."'>".$this->secure->checkStr($element["distname"],1)."</option>\n";
92
                }
92
                }
93
                $show .= "</select></fieldset>";
93
                $show .= "</select></fieldset>";
94
                break;
94
                break;
95
            case 'json':
95
            case 'json':
96
                $show = '[{value:"",text:"'.$info.'"}';                
96
                $show = '[{value:"",text:"'.$info.'"}';                
97
                while ($rq->fetchInto($element)) {
97
                while ($rq->fetchInto($element)) {
98
                    $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}';
98
                    $show .= ',{value:"'.$this->secure->checkInt($element["dist_id"]).'",text:"'.$this->secure->checkStr($element["distname"],1).'"}';
99
                }
99
                }
100
                $show .= ']';
100
                $show .= ']';
101
                break;
101
                break;
102
        }
102
        }
103
        return $show;
103
        return $show;
104
    }
104
    }
105
105
106
    // Получение названия дистрибутива
106
    // Получение названия дистрибутива
107
    public function getDistName($distID) {
107
    public function getDistName($distID) {
108
        $result = array();
108
        $result = array();
109
        $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'";
109
        $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'";
110
        $rq =& $this->db->query($query);
110
        $rq =& $this->db->query($query);
111
        if (PEAR::isError($this->db)) {
111
        if (PEAR::isError($this->db)) {
112
            $result["ERR"] = 1;
112
            $result["ERR"] = 1;
113
            $result["ERRINFO"] = $this->db->getMessage();
113
            $result["ERRINFO"] = $this->db->getMessage();
114
        } else {
114
        } else {
115
            $rq->fetchInto($element);
115
            $rq->fetchInto($element);
116
            $result["ERR"] = 0;
116
            $result["ERR"] = 0;
117
            $result["DistName"] = $this->secure->checkStr($element["distname"],1);
117
            $result["DistName"] = $this->secure->checkStr($element["distname"],1);
118
        }
118
        }
119
119
120
        return $result;
120
        return $result;
121
    }
121
    }
122
122
-
 
123
    // Получение названия программы
-
 
124
    public function getCodeName() {
-
 
125
        return $this->secure->checkStr($this->getOption("codename"),1);
-
 
126
    }
-
 
127
123
    // Получение и отображение списка версий дистрибутива
128
    // Получение и отображение списка версий дистрибутива
124
    public function showDistVersionsList($name, $distID, $format = 'html') {
129
    public function showDistVersionsList($name, $distID, $format = 'html') {
125
        $distname = $this->getDistName($distID);
130
        $distname = $this->getDistName($distID);
126
        $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
131
        $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
127
        $rq =& $this->db->query($query);
132
        $rq =& $this->db->query($query);
128
        switch ($format) {
133
        switch ($format) {
129
            case 'html':
134
            case 'html':
130
                $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n";                
135
                $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n";                
131
                while ($rq->fetchInto($element)) {
136
                while ($rq->fetchInto($element)) {
132
                    $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n";
137
                    $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n";
133
                }
138
                }
134
                $show .= "</select></fieldset>";
139
                $show .= "</select></fieldset>";
135
                break;
140
                break;
136
            case 'json':
141
            case 'json':
137
                $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}';                
142
                $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}';                
138
                while ($rq->fetchInto($element)) {
143
                while ($rq->fetchInto($element)) {
139
                    $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}';
144
                    $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}';
140
                }
145
                }
141
                $show .= ']';
146
                $show .= ']';
142
                break;
147
                break;
143
        }
148
        }
144
        return $show;
149
        return $show;
145
    }
150
    }
146
151
147
    // Получение и отображение списка секций основного (официального) репозитория
152
    // Получение и отображение списка секций основного (официального) репозитория
148
    public function showBranchesList($version, $format = 'html') {
153
    public function showBranchesList($version, $format = 'html') {
149
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
154
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
150
        $rq =& $this->db->query($query);
155
        $rq =& $this->db->query($query);
151
        $rq->fetchInto($types);
156
        $rq->fetchInto($types);
152
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
157
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
153
        $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id ";
158
        $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id ";
154
        $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id ";
159
        $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id ";
155
        $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id ";
160
        $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id ";
156
        $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'";
161
        $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'";
157
        $rq =& $this->db->query($query);
162
        $rq =& $this->db->query($query);
158
        switch ($format) {
163
        switch ($format) {
159
            case 'html':
164
            case 'html':
160
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
165
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
161
                while ($rq->fetchInto($element)) {
166
                while ($rq->fetchInto($element)) {
162
                    $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." &mdash; ".$this->secure->checkStr($element["secinfo"],1)."</div>\n";
167
                    $show .= "<div class='sections'><input type='checkbox' name='section[]' value='".$element["sect_id"]."'> ".$this->secure->checkStr($element["secname"],1)." &mdash; ".$this->secure->checkStr($element["secinfo"],1)."</div>\n";
163
                }
168
                }
164
                $show .= "</fieldset>\n";
169
                $show .= "</fieldset>\n";
165
                break;
170
                break;
166
            case 'json':
171
            case 'json':
167
                //TODO Доделать JSON-вывод списка секций основного репозитория
172
                //TODO Доделать JSON-вывод списка секций основного репозитория
168
                break;
173
                break;
169
        }
174
        }
170
175
171
        return $show;
176
        return $show;
172
    }
177
    }
173
178
174
    // Получение и отображение списка репозиториев 
179
    // Получение и отображение списка репозиториев 
175
    public function showRepList($version, $reptype, $format = 'html') {
180
    public function showRepList($version, $reptype, $format = 'html') {
176
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
181
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
177
        $rq =& $this->db->query($query);
182
        $rq =& $this->db->query($query);
178
        $rq->fetchInto($types);
183
        $rq->fetchInto($types);
179
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
184
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
180
        $rq =& $this->db->query($query);
185
        $rq =& $this->db->query($query);
181
        switch ($format) {
186
        switch ($format) {
182
            case 'html':
187
            case 'html':
183
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
188
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
184
                while ($rq->fetchInto($types)) {
189
                while ($rq->fetchInto($types)) {
185
                    $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";
190
                    $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";
186
                }
191
                }
187
                $show .= "</fieldset>\n";
192
                $show .= "</fieldset>\n";
188
                break;
193
                break;
189
            case 'json':
194
            case 'json':
190
                //TODO Доделать JSON-вывод списка репозиториев
195
                //TODO Доделать JSON-вывод списка репозиториев
191
                break;
196
                break;
192
        }
197
        }
193
198
194
        return $show;
199
        return $show;
195
    }
200
    }
196
201
197
    // Добавление поддержки нового apt-дистрибутива
202
    // Добавление поддержки нового apt-дистрибутива
198
    public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) {
203
    public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) {
199
        $result = array();
204
        $result = array();
200
        $sDName = $this->secure->checkStr($distname);
205
        $sDName = $this->secure->checkStr($distname);
201
        $sDType = $this->secure->checkInt($disttype);
206
        $sDType = $this->secure->checkInt($disttype);
202
        $sDUAgt = $this->secure->checkStr($distua);
207
        $sDUAgt = $this->secure->checkStr($distua);
203
        $sDLogo = $this->secure->checkInt($distname);
208
        $sDLogo = $this->secure->checkInt($distname);
204
209
205
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
210
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
206
        $rq =& $this->db->query($query);
211
        $rq =& $this->db->query($query);
207
        if (PEAR::isError($this->db)) {
212
        if (PEAR::isError($this->db)) {
208
            $result["ERR"] = 1;
213
            $result["ERR"] = 1;
209
            $result["ERRINFO"] = $this->db->getMessage();
214
            $result["ERRINFO"] = $this->db->getMessage();
210
        } else {
215
        } else {
211
            $rq->fetchInto($element);
216
            $rq->fetchInto($element);
212
            $result["ERR"] = 0;
217
            $result["ERR"] = 0;
213
        }
218
        }
214
219
215
        return $result;
220
        return $result;
216
    }
221
    }
217
222
218
    // Добавление поддержки новой версии apt-дистрибутива
223
    // Добавление поддержки новой версии apt-дистрибутива
219
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
224
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
220
        $result = array();
225
        $result = array();
221
        $sDistID    = $this->secure->checkStr($distID);
226
        $sDistID    = $this->secure->checkStr($distID);
222
        $sDVersion  = $this->secure->checkStr($version);
227
        $sDVersion  = $this->secure->checkStr($version);
223
        $sDVName    = $this->secure->checkStr($vname);
228
        $sDVName    = $this->secure->checkStr($vname);
224
        $sDVCName   = $this->secure->checkInt($vcodename);
229
        $sDVCName   = $this->secure->checkInt($vcodename);
225
230
226
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
231
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
227
        $rq =& $this->db->query($query);
232
        $rq =& $this->db->query($query);
228
        if (PEAR::isError($this->db)) {
233
        if (PEAR::isError($this->db)) {
229
            $result["ERR"] = 1;
234
            $result["ERR"] = 1;
230
            $result["ERRINFO"] = $this->db->getMessage();
235
            $result["ERRINFO"] = $this->db->getMessage();
231
        } else {
236
        } else {
232
            $rq->fetchInto($element);
237
            $rq->fetchInto($element);
233
            $result["ERR"] = 0;
238
            $result["ERR"] = 0;
234
        }
239
        }
235
240
236
        return $result;
241
        return $result;
237
    }
242
    }
238
243
239
    // Отображение типа дистрибутива
244
    // Отображение типа дистрибутива
240
    public function showDistTypeForm($name = "dtype",$type = 0) {
245
    public function showDistTypeForm($name = "dtype",$type = 0) {
241
        $query = "SELECT * FROM ".$this->prefix."dtype";
246
        $query = "SELECT * FROM ".$this->prefix."dtype";
242
        $rq =& $this->db->query($query);
247
        $rq =& $this->db->query($query);
243
        $show = "<select name='".$name."' id='".$name."'>\n";
248
        $show = "<select name='".$name."' id='".$name."'>\n";
244
        while ($rq->fetchInto($element)) {
249
        while ($rq->fetchInto($element)) {
245
            if ($element["type_id"] == $type) {
250
            if ($element["type_id"] == $type) {
246
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
251
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
247
            } else {
252
            } else {
248
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
253
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
249
            }
254
            }
250
        }
255
        }
251
        $show .= "</select>";
256
        $show .= "</select>";
252
257
253
        return $show;
258
        return $show;
254
    }
259
    }
255
260
256
    // Отображение формы создания и редактирования apt-дистрибутива
261
    // Отображение формы создания и редактирования apt-дистрибутива
257
    public function showDistributionForm($distID = 0) {
262
    public function showDistributionForm($distID = 0) {
258
        $sDistID = $this->secure->checkInt($distID);
263
        $sDistID = $this->secure->checkInt($distID);
259
        if ($sDistID != 0) {
264
        if ($sDistID != 0) {
260
            // Режим редактирования
265
            // Режим редактирования
261
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
266
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
262
            $rq =& $this->db->query($query);
267
            $rq =& $this->db->query($query);
263
            $rq->fetchInto($element);
268
            $rq->fetchInto($element);
264
        }
269
        }
265
270
266
        if ($element["distlogo"] == 1) {
271
        if ($element["distlogo"] == 1) {
267
            $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)."'>";
272
            $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)."'>";
268
        } else {
273
        } else {
269
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
274
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
270
        }
275
        }
271
276
272
        $show  = "<fieldset><legend>Дистрибутив</legend>\n";
277
        $show  = "<fieldset><legend>Дистрибутив</legend>\n";
273
        $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n";
278
        $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],1)."'></div>\n";
274
        $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";
279
        $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";
275
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n";
280
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n";
276
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
281
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
277
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
282
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
278
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
283
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
279
284
280
        return $show;
285
        return $show;
281
    }
286
    }
282
287
283
    // sourses.list
288
    // sourses.list
284
    public function showSourcesList() {
289
    public function showSourcesList() {
285
       //TODO Написать генератор sources.list
290
       //TODO Написать генератор sources.list
286
    }
291
    }
287
   
292
   
288
    // Проверка пароля (из формы авторизации)
293
    // Проверка пароля (из формы авторизации)
289
    public function checkSign($word) {
294
    public function checkSign($word) {
290
        $result = array();
295
        $result = array();
291
296
292
        $sHash = $this->secure->encryptStr($word);
297
        $sHash = $this->secure->encryptStr($word);
293
        $pwd   = $this->getOption("passwd");
298
        $pwd   = $this->getOption("passwd");
294
        if ($sHash == $pwd["OptValue"]) {
299
        if ($sHash == $pwd["OptValue"]) {
295
            $result["ERR"] = 0;
300
            $result["ERR"] = 0;
296
            $result["Location"] = "manager.php";
301
            $result["Location"] = "manager.php";
297
            setcookie($this->cookie, $sHash);
302
            setcookie($this->cookie, $sHash);
298
        } else {
303
        } else {
299
            $result["ERR"] = 1;
304
            $result["ERR"] = 1;
300
            $result["ERRINFO"] = "Password not valid";
305
            $result["ERRINFO"] = "Password not valid";
301
            $result["Location"] = "manager.php?error=1";
306
            $result["Location"] = "manager.php?error=1";
302
        }
307
        }
303
308
304
        return $result;
309
        return $result;
305
    }
310
    }
306
311
307
    // Проверка пароля (из cookies)
312
    // Проверка пароля (из cookies)
308
    public function checkCookieSign($hash) {
313
    public function checkCookieSign($hash) {
309
        $result = array();
314
        $result = array();
310
315
311
        $pwd = $this->getOption("passwd");
316
        $pwd = $this->getOption("passwd");
312
        if ($hash == $pwd["OptValue"]) {
317
        if ($hash == $pwd["OptValue"]) {
313
            $result["ERR"] = 0;
318
            $result["ERR"] = 0;
314
        } else {
319
        } else {
315
            $result["ERR"] = 1;
320
            $result["ERR"] = 1;
316
            $result["ERRINFO"] = "Hash not valid";
321
            $result["ERRINFO"] = "Hash not valid";
317
            $result["Location"] = "manager.php";
322
            $result["Location"] = "manager.php";
318
        }
323
        }
319
324
320
        return $result;
325
        return $result;
321
    }
326
    }
322
327
323
    // Форма ввода пароля
328
    // Форма ввода пароля
324
    public function showSigninForm() {
329
    public function showSigninForm() {
325
        $show  = "<form action='process.php' method='post'>\n";
330
        $show  = "<form action='process.php' method='post'>\n";
326
        $show .= "<fieldset><legend>Пароль</legend>\n";
331
        $show .= "<fieldset><legend>Пароль</legend>\n";
327
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
332
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
328
        $show .= "<input type='text' name='word' value=''>\n<br />";
333
        $show .= "<input type='text' name='word' value=''>\n<br />";
329
        $show .= "<input type='submit' value=' Войти '>\n";
334
        $show .= "<input type='submit' value=' Войти '>\n";
330
        $show .= "</fieldset>\n</form>\n";
335
        $show .= "</fieldset>\n</form>\n";
331
336
332
        return $show;
337
        return $show;
333
    }
338
    }
334
339
335
    // Обновление пароля
340
    // Обновление пароля
336
    public function updatePassword($word1, $word2) {
341
    public function updatePassword($word1, $word2) {
337
        $result = array();
342
        $result = array();
338
343
339
        if ($word1 == $word2) {
344
        if ($word1 == $word2) {
340
            $sWord = $this->secure->encryptStr($word1);
345
            $sWord = $this->secure->encryptStr($word1);
341
            $r = $this->setOption("passwd", $sWord);
346
            $r = $this->setOption("passwd", $sWord);
342
            $result = $r;
347
            $result = $r;
343
        } else {
348
        } else {
344
            $result["ERR"] = 1;
349
            $result["ERR"] = 1;
345
            $result["ERRINFO"] = "Passwords is mismatch";
350
            $result["ERRINFO"] = "Passwords is mismatch";
346
        }
351
        }
347
352
348
        return $result;
353
        return $result;
349
    }
354
    }
350
355
351
}
356
}
352
357
353
?>
358
?>