Хранилища Subversion ant

Редакция

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

Редакция 459 Редакция 463
Строка 16... Строка 16...
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
    /**
-
 
22
     * Конструктор класса Core - ядро генератора
-
 
23
     *
-
 
24
     * @author Alexander Wolf
-
 
25
     * @category Core
-
 
26
     *
-
 
27
     * @param string $database
-
 
28
     * @param string $prefix
-
 
29
     * @param object $secure
-
 
30
     * @param string $cookie
-
 
31
     */
21
    public function __construct($database, $prefix, $secure, $cookie) {
32
    public function __construct($database, $prefix, $secure, $cookie) {
22
        $this->db       = $database;
33
        $this->db       = $database;
23
        $this->prefix   = $prefix;
34
        $this->prefix   = $prefix;
24
        $this->secure   = $secure;
35
        $this->secure   = $secure;
25
        $this->cookie   = $cookie;
36
        $this->cookie   = $cookie;
26
    }
37
    }
27
38
-
 
39
    /**
28
    // Получение данных о настройке
40
     * Получение данных о настройке
-
 
41
     *
-
 
42
     * @author Alexander Wolf
-
 
43
     * @category Core
-
 
44
     *
-
 
45
     * @param string $attr
-
 
46
     * @return array
-
 
47
     */
29
    public function getOption($attr) {
48
    public function getOption($attr) {
30
        $result = array();
49
        $result = array();
31
        $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'";
50
        $query = "SELECT optvalue FROM ".$this->prefix."settings WHERE opt='".$this->secure->checkStr($attr)."'";
32
        $rq =& $this->db->query($query);
51
        $rq =& $this->db->query($query);
33
        if ($rq->numRows()!=0) {
52
        if ($rq->numRows()!=0) {
Строка 39... Строка 58...
39
            $result["ERRINFO"] = "Empty result";
58
            $result["ERRINFO"] = "Empty result";
40
        }
59
        }
41
        return $result;
60
        return $result;
42
    }
61
    }
43
62
-
 
63
    /**
44
    // Установка данных о настройке
64
     * Установка данных о настройке
-
 
65
     *
-
 
66
     * @author Alexander Wolf
-
 
67
     * @category Core
-
 
68
     *
-
 
69
     * @param string $attr
-
 
70
     * @param string $value
-
 
71
     * @return array
-
 
72
     */
45
    public function setOption($attr, $value) {
73
    public function setOption($attr, $value) {
46
        $result = array();
74
        $result = array();
47
75
48
        if ($attr != "passwd") {
76
        if ($attr != "passwd") {
49
            $sValue = $this->secure->checkStr($value);
77
            $sValue = $this->secure->checkStr($value);
Строка 61... Строка 89...
61
        }
89
        }
62
90
63
        return $result;
91
        return $result;
64
    }
92
    }
65
93
-
 
94
    /**
66
    // Создание настройки
95
     * Создание настройки
-
 
96
     *
-
 
97
     * @author Alexander Wolf
-
 
98
     * @category Core
-
 
99
     *
-
 
100
     * @param string $attr
-
 
101
     * @param string $value
-
 
102
     * @return array
-
 
103
     */
67
    public function addOption($attr, $value) {
104
    public function addOption($attr, $value) {
68
        $result = array();
105
        $result = array();
69
        $sValue = $this->secure->checkStr($value);
106
        $sValue = $this->secure->checkStr($value);
70
107
71
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
108
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
Строка 77... Строка 114...
77
            $result["ERR"] = 0;
114
            $result["ERR"] = 0;
78
        }
115
        }
79
116
80
        return $result;
117
        return $result;
81
    }
118
    }
82
119
       
-
 
120
    /**
83
    // Получение и отображение списка дистрибутивов
121
     * Получение и отображение списка дистрибутивов
-
 
122
     *
-
 
123
     * @author Alexander Wolf
-
 
124
     * @category Core
-
 
125
     * @deprecated may be deprecated XXX
-
 
126
     *
-
 
127
     * @param string $name
-
 
128
     * @param string $heads
-
 
129
     * @param string $info
-
 
130
     * @param string $format
84
    // XXX deprecated ?
131
     * @return string
-
 
132
     */
85
    public function showDistributionList($name, $heads = "", $info = "", $format = 'html') {
133
    public function showDistributionList($name, $heads = "", $info = "", $format = 'html') {
86
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
134
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
87
        $rq =& $this->db->query($query);
135
        $rq =& $this->db->query($query);
88
        switch ($format) {
136
        switch ($format) {
89
            case 'html':
137
            case 'html':
Строка 103... Строка 151...
103
                break;
151
                break;
104
        }
152
        }
105
        return $show;
153
        return $show;
106
    }
154
    }
107
155
-
 
156
    /**
108
    // Получение названия дистрибутива
157
     * Получение названия дистрибутива
-
 
158
     *
-
 
159
     * @author Alexander Wolf
-
 
160
     * @category Core
-
 
161
     *
-
 
162
     * @param integer $distID
-
 
163
     * @return array
-
 
164
     */
109
    public function getDistName($distID) {
165
    public function getDistName($distID) {
110
        $result = array();
166
        $result = array();
111
        $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'";
167
        $query = "SELECT distname FROM ".$this->prefix."distribution WHERE dist_id='".$this->secure->checkInt($distID)."'";
112
        $rq =& $this->db->query($query);
168
        $rq =& $this->db->query($query);
113
        if (PEAR::isError($this->db)) {
169
        if (PEAR::isError($this->db)) {
Строка 120... Строка 176...
120
        }
176
        }
121
177
122
        return $result;
178
        return $result;
123
    }
179
    }
124
180
-
 
181
    /**
125
    // Получение названия программы, ее версии и описания
182
     * Получение названия программы, ее версии и описания
-
 
183
     *
-
 
184
     * @author Alexander Wolf
-
 
185
     * @category Core
-
 
186
     *
-
 
187
     * @param string $attr
-
 
188
     * @return string
-
 
189
     */
126
    public function getEngineAttr($attr = 'codename') {
190
    public function getEngineAttr($attr = 'codename') {
127
        $cname = $this->getOption($attr);
191
        $cname = $this->getOption($attr);
128
        return $this->secure->checkStr($cname["OptValue"],1);
192
        return $this->secure->checkStr($cname["OptValue"],1);
129
    }
193
    }
130
194
-
 
195
    /**
131
    // Получение и отображение списка версий дистрибутива
196
     * Получение и отображение списка версий дистрибутива
-
 
197
     *
-
 
198
     * @author Alexander Wolf
-
 
199
     * @category Core
-
 
200
     *
-
 
201
     * @param string $name
-
 
202
     * @param integer $distID
-
 
203
     * @param string $format
-
 
204
     * @return string
-
 
205
     */
132
    public function showDistVersionsList($name, $distID, $format = 'html') {
206
    public function showDistVersionsList($name, $distID, $format = 'html') {
133
        $distname = $this->getDistName($distID);
207
        $distname = $this->getDistName($distID);
134
        $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
208
        $query = "SELECT * FROM ".$this->prefix."version WHERE dist_id='".$this->secure->checkInt($distID)."' ORDER BY version ASC";
135
        $rq =& $this->db->query($query);
209
        $rq =& $this->db->query($query);
136
        switch ($format) {
210
        switch ($format) {
Строка 151... Строка 225...
151
                break;
225
                break;
152
        }
226
        }
153
        return $show;
227
        return $show;
154
    }
228
    }
155
229
-
 
230
    /**
156
    // Получение и отображение списка секций основного (официального) репозитория
231
     * Получение и отображение списка секций основного (официального) репозитория
-
 
232
     *
-
 
233
     * @author Alexander Wolf
-
 
234
     * @category Core
-
 
235
     *
-
 
236
     * @param integer $version
-
 
237
     * @param string $format
-
 
238
     * @return string
-
 
239
     */
157
    public function showBranchesList($version, $format = 'html') {
240
    public function showBranchesList($version, $format = 'html') {
158
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
241
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='1'";
159
        $rq =& $this->db->query($query);
242
        $rq =& $this->db->query($query);
160
        $rq->fetchInto($types);
243
        $rq->fetchInto($types);
161
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
244
        $query  = "SELECT s.*,t.rtype FROM ".$this->prefix."section s ";
Строка 178... Строка 261...
178
        }
261
        }
179
262
180
        return $show;
263
        return $show;
181
    }
264
    }
182
265
-
 
266
    /**
183
    // Получение и отображение списка репозиториев 
267
     * Получение и отображение списка репозиториев
-
 
268
     *
-
 
269
     * @author Alexander Wolf
-
 
270
     * @category Core
-
 
271
     *
-
 
272
     * @param integer $version
-
 
273
     * @param integer $reptype
-
 
274
     * @param string $format
-
 
275
     * @return string
-
 
276
     */
184
    public function showRepList($version, $reptype, $format = 'html') {
277
    public function showRepList($version, $reptype, $format = 'html') {
185
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'";
278
        $query  = "SELECT rtype FROM ".$this->prefix."rtype WHERE rtype_id='".$this->secure->checkInt($reptype)."'";
186
        $rq =& $this->db->query($query);
279
        $rq =& $this->db->query($query);
187
        $rq->fetchInto($types);
280
        $rq->fetchInto($types);
188
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
281
        $query = "SELECT * FROM ".$this->prefix."repository WHERE version='".$this->secure->checkInt($version)."' AND rtype_id='".$this->secure->checkInt($reptype)."'";
Строка 201... Строка 294...
201
        }
294
        }
202
295
203
        return $show;
296
        return $show;
204
    }
297
    }
205
298
-
 
299
    /**
206
    // Добавление поддержки нового apt-дистрибутива
300
     * Добавление поддержки нового apt-дистрибутива
-
 
301
     *
-
 
302
     * @author Alexander Wolf
-
 
303
     * @category Core
-
 
304
     *
-
 
305
     * @param string $distname
-
 
306
     * @param integer $disttype
-
 
307
     * @param string $distua
-
 
308
     * @param byte $distlogo
-
 
309
     * @return array
-
 
310
     */
207
    public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) {
311
    public function addDistribution($distname, $disttype, $distua = 1, $distlogo = 0) {
208
        $result = array();
312
        $result = array();
209
        $sDName = $this->secure->checkStr($distname);
313
        $sDName = $this->secure->checkStr($distname);
210
        $sDType = $this->secure->checkInt($disttype);
314
        $sDType = $this->secure->checkInt($disttype);
211
        $sDUAgt = $this->secure->checkStr($distua);
315
        $sDUAgt = $this->secure->checkStr($distua);
Строка 222... Строка 326...
222
        }
326
        }
223
327
224
        return $result;
328
        return $result;
225
    }
329
    }
226
330
-
 
331
    /**
227
    // Добавление поддержки новой версии apt-дистрибутива
332
     * Добавление поддержки новой версии apt-дистрибутива
-
 
333
     *
-
 
334
     * @author Alexander Wolf
-
 
335
     * @category Core
-
 
336
     *
-
 
337
     * @param integer $distID
-
 
338
     * @param integer $version
-
 
339
     * @param string $vname
-
 
340
     * @param integer $vcodename
-
 
341
     * @return array
-
 
342
     */
228
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
343
    public function addDistVersion($distID, $version, $vname = "", $vcodename = "") {
229
        $result = array();
344
        $result = array();
230
        $sDistID    = $this->secure->checkStr($distID);
345
        $sDistID    = $this->secure->checkInt($distID);
231
        $sDVersion  = $this->secure->checkStr($version);
346
        $sDVersion  = $this->secure->checkStr($version);
232
        $sDVName    = $this->secure->checkStr($vname);
347
        $sDVName    = $this->secure->checkStr($vname);
233
        $sDVCName   = $this->secure->checkInt($vcodename);
348
        $sDVCName   = $this->secure->checkInt($vcodename);
234
349
235
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
350
        $query = "INSERT INTO ".$this->prefix."version SET dist_id='".$sDistID."', vname='".$sDVName."', version='".$sDVersion."', vcodename='".$sDVCName."'";
Строка 243... Строка 358...
243
        }
358
        }
244
359
245
        return $result;
360
        return $result;
246
    }
361
    }
247
362
-
 
363
    /**
248
    // Отображение типа дистрибутива
364
     * Отображение типа дистрибутива
-
 
365
     *
-
 
366
     * @author Alexander Wolf
-
 
367
     * @category Core
-
 
368
     *
-
 
369
     * @param string $name
-
 
370
     * @param byte $type
-
 
371
     * @return string
-
 
372
     */
249
    public function showDistTypeForm($name = "dtype",$type = 0) {
373
    public function showDistTypeForm($name = "dtype",$type = 0) {
250
        $query = "SELECT * FROM ".$this->prefix."dtype";
374
        $query = "SELECT * FROM ".$this->prefix."dtype";
251
        $rq =& $this->db->query($query);
375
        $rq =& $this->db->query($query);
252
        $show = "<select name='".$name."' id='".$name."'>\n";
376
        $show = "<select name='".$name."' id='".$name."'>\n";
253
        while ($rq->fetchInto($element)) {
377
        while ($rq->fetchInto($element)) {
Строка 260... Строка 384...
260
        $show .= "</select>";
384
        $show .= "</select>";
261
385
262
        return $show;
386
        return $show;
263
    }
387
    }
264
388
-
 
389
    /**
265
    // Отображение формы создания и редактирования apt-дистрибутива
390
     * Отображение формы создания и редактирования apt-дистрибутива
-
 
391
     *
-
 
392
     * @author Alexander Wolf
-
 
393
     * @category Core
-
 
394
     *
-
 
395
     * @param integer $distID
-
 
396
     * @return string
-
 
397
     */
266
    public function showDistributionForm($distID = 0) {
398
    public function showDistributionForm($distID = 0) {
267
        $sDistID = $this->secure->checkInt($distID);
399
        $sDistID = $this->secure->checkInt($distID);
268
        if ($sDistID != 0) {
400
        if ($sDistID != 0) {
269
            // Режим редактирования
401
            // Режим редактирования
270
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
402
            $query = "SELECT * FROM ".$this->prefix."distribution WHERE dist_id='".$sDistID."'";
Строка 292... Строка 424...
292
    // sourses.list
424
    // sourses.list
293
    public function showSourcesList($distID,$versID,$sectIDs,$repIDs) {
425
    public function showSourcesList($distID,$versID,$sectIDs,$repIDs) {
294
       //TODO Написать генератор sources.list       
426
       //TODO Написать генератор sources.list       
295
    }
427
    }
296
   
428
   
-
 
429
    /**
297
    // Проверка пароля (из формы авторизации)
430
     * Проверка пароля (из формы авторизации)
-
 
431
     *
-
 
432
     * @author Alexander Wolf
-
 
433
     * @category Core
-
 
434
     *
-
 
435
     * @param string $word
-
 
436
     * @return array
-
 
437
     */
298
    public function checkSign($word) {
438
    public function checkSign($word) {
299
        $result = array();
439
        $result = array();
300
440
301
        $sHash = $this->secure->encryptStr($word);
441
        $sHash = $this->secure->encryptStr($word);
302
        $pwd   = $this->getOption("passwd");
442
        $pwd   = $this->getOption("passwd");
Строка 311... Строка 451...
311
        }
451
        }
312
452
313
        return $result;
453
        return $result;
314
    }
454
    }
315
455
-
 
456
    /**
316
    // Проверка пароля (из cookies)
457
     * Проверка пароля (из cookies)
-
 
458
     *
-
 
459
     * @author Alexander Wolf
-
 
460
     * @category Core
-
 
461
     *
-
 
462
     * @param string $hash
-
 
463
     * @return array
-
 
464
     */
317
    public function checkCookieSign($hash) {
465
    public function checkCookieSign($hash) {
318
        $result = array();
466
        $result = array();
319
467
320
        $pwd = $this->getOption("passwd");
468
        $pwd = $this->getOption("passwd");
321
        if ($hash == $pwd["OptValue"]) {
469
        if ($hash == $pwd["OptValue"]) {
Строка 327... Строка 475...
327
        }
475
        }
328
476
329
        return $result;
477
        return $result;
330
    }
478
    }
331
479
-
 
480
    /**
332
    // Форма ввода пароля
481
     * Форма ввода пароля
-
 
482
     *
-
 
483
     * @author Alexander Wolf
-
 
484
     * @category Core
-
 
485
     *
-
 
486
     * @return string
-
 
487
     */
333
    public function showSigninForm() {
488
    public function showSigninForm() {
334
        $show  = "<div id='regform'>";
489
        $show  = "<div id='regform'>";
335
        $show .= "<form action='process.php' method='post'>\n";
490
        $show .= "<form action='process.php' method='post'>\n";
336
        $show .= "<fieldset><legend>Пароль</legend>\n";
491
        $show .= "<fieldset><legend>Пароль</legend>\n";
337
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
492
        $show .= "<input type='hidden' name='mode' value='authorize'>\n";
Строка 340... Строка 495...
340
        $show .= "</fieldset>\n</form></div>\n";
495
        $show .= "</fieldset>\n</form></div>\n";
341
496
342
        return $show;
497
        return $show;
343
    }
498
    }
344
499
-
 
500
    /**
345
    // Обновление пароля
501
     * Обновление пароля
-
 
502
     *
-
 
503
     * @author Alexander Wolf
-
 
504
     * @category Core
-
 
505
     *
-
 
506
     * @param string $word1
-
 
507
     * @param string $word2
-
 
508
     * @return array
-
 
509
     */
346
    public function updatePassword($word1, $word2) {
510
    public function updatePassword($word1, $word2) {
347
        $result = array();
511
        $result = array();
348
512
349
        if ($word1 == $word2) {
513
        if ($word1 == $word2) {
350
            $sWord = $this->secure->encryptStr($word1);
514
            $sWord = $this->secure->encryptStr($word1);