Хранилища Subversion ant

Редакция

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

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