Хранилища Subversion ant

Редакция

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

Редакция 381 Редакция 382
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
    // Получение названия программы
123
    // Получение названия программы
124
    public function getCodeName() {
124
    public function getCodeName() {
-
 
125
        $cname = $this->getOption("codename");
125
        return $this->secure->checkStr($this->getOption("codename"),1);
126
        return $this->secure->checkStr($cname["OptValue"],1);
126
    }
127
    }
127
128
128
    // Получение и отображение списка версий дистрибутива
129
    // Получение и отображение списка версий дистрибутива
129
    public function showDistVersionsList($name, $distID, $format = 'html') {
130
    public function showDistVersionsList($name, $distID, $format = 'html') {
130
        $distname = $this->getDistName($distID);
131
        $distname = $this->getDistName($distID);
131
        $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
132
        $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
132
        $rq =& $this->db->query($query);
133
        $rq =& $this->db->query($query);
133
        switch ($format) {
134
        switch ($format) {
134
            case 'html':
135
            case 'html':
135
                $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n";                
136
                $show = "<fieldset><legend>Версии ".$distname["DistName"]."</legend>\n<select id='".$name."' name='".$name."'>\n";                
136
                while ($rq->fetchInto($element)) {
137
                while ($rq->fetchInto($element)) {
137
                    $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n";
138
                    $show .= "<option value='".$this->secure->checkInt($element["version_id"])."'>".$this->secure->checkStr($element["version"],1)." ".$this->secure->checkStr($element["vname"],1)."</option>\n";
138
                }
139
                }
139
                $show .= "</select></fieldset>";
140
                $show .= "</select></fieldset>";
140
                break;
141
                break;
141
            case 'json':
142
            case 'json':
142
                $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}';                
143
                $show = '[{value:"",text:"Выбери версию '.$distname["DistName"].'"}';                
143
                while ($rq->fetchInto($element)) {
144
                while ($rq->fetchInto($element)) {
144
                    $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}';
145
                    $show .= ',{value:"'.$this->secure->checkInt($element["version_id"]).'",text:"'.$this->secure->checkStr($element["version"],1).' '.$this->secure->checkStr($element["vname"],1).'"}';
145
                }
146
                }
146
                $show .= ']';
147
                $show .= ']';
147
                break;
148
                break;
148
        }
149
        }
149
        return $show;
150
        return $show;
150
    }
151
    }
151
152
152
    // Получение и отображение списка секций основного (официального) репозитория
153
    // Получение и отображение списка секций основного (официального) репозитория
153
    public function showBranchesList($version, $format = 'html') {
154
    public function showBranchesList($version, $format = 'html') {
154
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
155
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
155
        $rq =& $this->db->query($query);
156
        $rq =& $this->db->query($query);
156
        $rq->fetchInto($types);
157
        $rq->fetchInto($types);
157
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
158
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
158
        $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id ";
159
        $query .= "JOIN ".$this->prefix."sect2rep l ON s.sect_id=l.sect_id ";
159
        $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id ";
160
        $query .= "JOIN ".$this->prefix."repository r ON r.rep_id=l.rep_id ";
160
        $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id ";
161
        $query .= "JOIN ".$this->prefix."rtype t ON r.rtype_id=t.rtype_id ";
161
        $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'";
162
        $query .= "WHERE t.rtype_id='1' AND r.version='".$this->secure->checkInt($version)."'";
162
        $rq =& $this->db->query($query);
163
        $rq =& $this->db->query($query);
163
        switch ($format) {
164
        switch ($format) {
164
            case 'html':
165
            case 'html':
165
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
166
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
166
                while ($rq->fetchInto($element)) {
167
                while ($rq->fetchInto($element)) {
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";
168
                    $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";
168
                }
169
                }
169
                $show .= "</fieldset>\n";
170
                $show .= "</fieldset>\n";
170
                break;
171
                break;
171
            case 'json':
172
            case 'json':
172
                //TODO Доделать JSON-вывод списка секций основного репозитория
173
                //TODO Доделать JSON-вывод списка секций основного репозитория
173
                break;
174
                break;
174
        }
175
        }
175
176
176
        return $show;
177
        return $show;
177
    }
178
    }
178
179
179
    // Получение и отображение списка репозиториев 
180
    // Получение и отображение списка репозиториев 
180
    public function showRepList($version, $reptype, $format = 'html') {
181
    public function showRepList($version, $reptype, $format = 'html') {
181
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
182
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
182
        $rq =& $this->db->query($query);
183
        $rq =& $this->db->query($query);
183
        $rq->fetchInto($types);
184
        $rq->fetchInto($types);
184
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
185
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
185
        $rq =& $this->db->query($query);
186
        $rq =& $this->db->query($query);
186
        switch ($format) {
187
        switch ($format) {
187
            case 'html':
188
            case 'html':
188
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
189
                $show = "<fieldset><legend>".$this->secure->checkStr($types["rtype"],1)."</legend>\n";
189
                while ($rq->fetchInto($types)) {
190
                while ($rq->fetchInto($types)) {
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";
191
                    $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";
191
                }
192
                }
192
                $show .= "</fieldset>\n";
193
                $show .= "</fieldset>\n";
193
                break;
194
                break;
194
            case 'json':
195
            case 'json':
195
                //TODO Доделать JSON-вывод списка репозиториев
196
                //TODO Доделать JSON-вывод списка репозиториев
196
                break;
197
                break;
197
        }
198
        }
198
199
199
        return $show;
200
        return $show;
200
    }
201
    }
201
202
202
    // Добавление поддержки нового apt-дистрибутива
203
    // Добавление поддержки нового apt-дистрибутива
203
    public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) {
204
    public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) {
204
        $result = array();
205
        $result = array();
205
        $sDName = $this->secure->checkStr($distname);
206
        $sDName = $this->secure->checkStr($distname);
206
        $sDType = $this->secure->checkInt($disttype);
207
        $sDType = $this->secure->checkInt($disttype);
207
        $sDUAgt = $this->secure->checkStr($distua);
208
        $sDUAgt = $this->secure->checkStr($distua);
208
        $sDLogo = $this->secure->checkInt($distname);
209
        $sDLogo = $this->secure->checkInt($distname);
209
210
210
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
211
        $query = "INSERT INTO ".$this->prefix."distribution SET distname='".$sDName."', distua='".$sDUAgt."', disttype='".$sDType."', distlogo='".$sDLogo."'";
211
        $rq =& $this->db->query($query);
212
        $rq =& $this->db->query($query);
212
        if (PEAR::isError($this->db)) {
213
        if (PEAR::isError($this->db)) {
213
            $result["ERR"] = 1;
214
            $result["ERR"] = 1;
214
            $result["ERRINFO"] = $this->db->getMessage();
215
            $result["ERRINFO"] = $this->db->getMessage();
215
        } else {
216
        } else {
216
            $rq->fetchInto($element);
217
            $rq->fetchInto($element);
217
            $result["ERR"] = 0;
218
            $result["ERR"] = 0;
218
        }
219
        }
219
220
220
        return $result;
221
        return $result;
221
    }
222
    }
222
223
223
    // Добавление поддержки новой версии apt-дистрибутива
224
    // Добавление поддержки новой версии apt-дистрибутива
224
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
225
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
225
        $result = array();
226
        $result = array();
226
        $sDistID    = $this->secure->checkStr($distID);
227
        $sDistID    = $this->secure->checkStr($distID);
227
        $sDVersion  = $this->secure->checkStr($version);
228
        $sDVersion  = $this->secure->checkStr($version);
228
        $sDVName    = $this->secure->checkStr($vname);
229
        $sDVName    = $this->secure->checkStr($vname);
229
        $sDVCName   = $this->secure->checkInt($vcodename);
230
        $sDVCName   = $this->secure->checkInt($vcodename);
230
231
231
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
232
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
232
        $rq =& $this->db->query($query);
233
        $rq =& $this->db->query($query);
233
        if (PEAR::isError($this->db)) {
234
        if (PEAR::isError($this->db)) {
234
            $result["ERR"] = 1;
235
            $result["ERR"] = 1;
235
            $result["ERRINFO"] = $this->db->getMessage();
236
            $result["ERRINFO"] = $this->db->getMessage();
236
        } else {
237
        } else {
237
            $rq->fetchInto($element);
238
            $rq->fetchInto($element);
238
            $result["ERR"] = 0;
239
            $result["ERR"] = 0;
239
        }
240
        }
240
241
241
        return $result;
242
        return $result;
242
    }
243
    }
243
244
244
    // Отображение типа дистрибутива
245
    // Отображение типа дистрибутива
245
    public function showDistTypeForm($name = "dtype",$type = 0) {
246
    public function showDistTypeForm($name = "dtype",$type = 0) {
246
        $query = "SELECT * FROM ".$this->prefix."dtype";
247
        $query = "SELECT * FROM ".$this->prefix."dtype";
247
        $rq =& $this->db->query($query);
248
        $rq =& $this->db->query($query);
248
        $show = "<select name='".$name."' id='".$name."'>\n";
249
        $show = "<select name='".$name."' id='".$name."'>\n";
249
        while ($rq->fetchInto($element)) {
250
        while ($rq->fetchInto($element)) {
250
            if ($element["type_id"] == $type) {
251
            if ($element["type_id"] == $type) {
251
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
252
                $show .= "<option value='".$element["type_id"]."' selected>".$this->secure->checkStr($element["type"],1)."</option>\n";
252
            } else {
253
            } else {
253
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
254
                $show .= "<option value='".$element["type_id"]."'>".$this->secure->checkStr($element["type"],1)."</option>\n";
254
            }
255
            }
255
        }
256
        }
256
        $show .= "</select>";
257
        $show .= "</select>";
257
258
258
        return $show;
259
        return $show;
259
    }
260
    }
260
261
261
    // Отображение формы создания и редактирования apt-дистрибутива
262
    // Отображение формы создания и редактирования apt-дистрибутива
262
    public function showDistributionForm($distID = 0) {
263
    public function showDistributionForm($distID = 0) {
263
        $sDistID = $this->secure->checkInt($distID);
264
        $sDistID = $this->secure->checkInt($distID);
264
        if ($sDistID != 0) {
265
        if ($sDistID != 0) {
265
            // Режим редактирования
266
            // Режим редактирования
266
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
267
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
267
            $rq =& $this->db->query($query);
268
            $rq =& $this->db->query($query);
268
            $rq->fetchInto($element);
269
            $rq->fetchInto($element);
269
        }
270
        }
270
271
271
        if ($element["distlogo"] == 1) {
272
        if ($element["distlogo"] == 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)."'>";
273
            $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)."'>";
273
        } else {
274
        } else {
274
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
275
            $image = "<img src='./img/d/empty-logo.png' width='32' height='32' id='adm-dist-logo' alt='Логотип дистрибутива' title='Логотип дистрибутива не загружен'>";
275
        }
276
        }
276
277
277
        $show  = "<fieldset><legend>Дистрибутив</legend>\n";
278
        $show  = "<fieldset><legend>Дистрибутив</legend>\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";
279
        $show .= "<div class='inputbox'><label for='dname'>Название дистрибутива:</label> <input type='text' name='dname' id='dname' value='".$this->secure->checkStr($element["distname"],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";
280
        $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";
280
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n";
281
        $show .= "<div class='inputbox'><label for='dtype'>Тип дистрибутива:</label> ".$this->showDistTypeForm("dtype",$element["dtype_id"])."</div>\n";
281
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
282
        $show .= "<div class='inputbox'><table><tr><td class='td-name'>Логотип дистрибутива:</td>\n";
282
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
283
        $show .= "<td>".$image."</td>\n<td><input type='file' name='distlogo'></td>\n</tr></table>\n</div>\n";
283
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
284
        $show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
284
285
285
        return $show;
286
        return $show;
286
    }
287
    }
287
288
288
    // sourses.list
289
    // sourses.list
289
    public function showSourcesList() {
290
    public function showSourcesList() {
290
       //TODO Написать генератор sources.list
291
       //TODO Написать генератор sources.list
291
    }
292
    }
292
   
293
   
293
    // Проверка пароля (из формы авторизации)
294
    // Проверка пароля (из формы авторизации)
294
    public function checkSign($word) {
295
    public function checkSign($word) {
295
        $result = array();
296
        $result = array();
296
297
297
        $sHash = $this->secure->encryptStr($word);
298
        $sHash = $this->secure->encryptStr($word);
298
        $pwd   = $this->getOption("passwd");
299
        $pwd   = $this->getOption("passwd");
299
        if ($sHash == $pwd["OptValue"]) {
300
        if ($sHash == $pwd["OptValue"]) {
300
            $result["ERR"] = 0;
301
            $result["ERR"] = 0;
301
            $result["Location"] = "manager.php";
302
            $result["Location"] = "manager.php";
302
            setcookie($this->cookie, $sHash);
303
            setcookie($this->cookie, $sHash);
303
        } else {
304
        } else {
304
            $result["ERR"] = 1;
305
            $result["ERR"] = 1;
305
            $result["ERRINFO"] = "Password not valid";
306
            $result["ERRINFO"] = "Password not valid";
306
            $result["Location"] = "manager.php?error=1";
307
            $result["Location"] = "manager.php?error=1";
307
        }
308
        }
308
309
309
        return $result;
310
        return $result;
310
    }
311
    }
311
312
312
    // Проверка пароля (из cookies)
313
    // Проверка пароля (из cookies)
313
    public function checkCookieSign($hash) {
314
    public function checkCookieSign($hash) {
314
        $result = array();
315
        $result = array();
315
316
316
        $pwd = $this->getOption("passwd");
317
        $pwd = $this->getOption("passwd");
317
        if ($hash == $pwd["OptValue"]) {
318
        if ($hash == $pwd["OptValue"]) {
318
            $result["ERR"] = 0;
319
            $result["ERR"] = 0;
319
        } else {
320
        } else {
320
            $result["ERR"] = 1;
321
            $result["ERR"] = 1;
321
            $result["ERRINFO"] = "Hash not valid";
322
            $result["ERRINFO"] = "Hash not valid";
322
            $result["Location"] = "manager.php";
323
            $result["Location"] = "manager.php";
323
        }
324
        }
324
325
325
        return $result;
326
        return $result;
326
    }
327
    }
327
328
328
    // Форма ввода пароля
329
    // Форма ввода пароля
329
    public function showSigninForm() {
330
    public function showSigninForm() {
330
        $show  = "<form action='process.php' method='post'>\n";
331
        $show  = "<form action='process.php' method='post'>\n";
331
        $show .= "<fieldset><legend>Пароль</legend>\n";
332
        $show .= "<fieldset><legend>Пароль</legend>\n";
332
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
333
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
333
        $show .= "<input type='text' name='word' value=''>\n<br />";
334
        $show .= "<input type='text' name='word' value=''>\n<br />";
334
        $show .= "<input type='submit' value=' Войти '>\n";
335
        $show .= "<input type='submit' value=' Войти '>\n";
335
        $show .= "</fieldset>\n</form>\n";
336
        $show .= "</fieldset>\n</form>\n";
336
337
337
        return $show;
338
        return $show;
338
    }
339
    }
339
340
340
    // Обновление пароля
341
    // Обновление пароля
341
    public function updatePassword($word1, $word2) {
342
    public function updatePassword($word1, $word2) {
342
        $result = array();
343
        $result = array();
343
344
344
        if ($word1 == $word2) {
345
        if ($word1 == $word2) {
345
            $sWord = $this->secure->encryptStr($word1);
346
            $sWord = $this->secure->encryptStr($word1);
346
            $r = $this->setOption("passwd", $sWord);
347
            $r = $this->setOption("passwd", $sWord);
347
            $result = $r;
348
            $result = $r;
348
        } else {
349
        } else {
349
            $result["ERR"] = 1;
350
            $result["ERR"] = 1;
350
            $result["ERRINFO"] = "Passwords is mismatch";
351
            $result["ERRINFO"] = "Passwords is mismatch";
351
        }
352
        }
352
353
353
        return $result;
354
        return $result;
354
    }
355
    }
355
356
356
}
357
}
357
358
358
?>
359
?>