Хранилища Subversion ant

Редакция

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

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