Хранилища Subversion ant

Редакция

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

Редакция 358 Редакция 359
Строка 14... Строка 14...
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
20
20
-
 
21
    function __construct($database, $prefix, $secure) {
21
    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
    }
26
    }
26
27
27
    // Получение данных о настройке
28
    // Получение данных о настройке
28
    function getOption($attr) {
29
    function getOption($attr) {
29
        $result = array();
30
        $result = array();
Строка 38... Строка 39...
38
            $result["ERRINFO"] = "Empty result";
39
            $result["ERRINFO"] = "Empty result";
39
        }
40
        }
40
        return $result;
41
        return $result;
41
    }
42
    }
42
43
-
 
44
    // Установка данных о настройке
-
 
45
    function setOption($attr, $value) {
-
 
46
        $result = array();
-
 
47
-
 
48
        if ($attr != "passwd") {
-
 
49
            $sValue = $this->secure->checkStr($value);
-
 
50
        } else {
-
 
51
            $sValue = $value;
-
 
52
        }
-
 
53
-
 
54
        $query = "UPDATE ".$this->prefix."settings SET optvalue='".$sValue."' WHERE opt='".$attr."'";
-
 
55
        $rq =& $this->db->query($query);
-
 
56
        if (PEAR::isError($this->db)) {
-
 
57
            $result["ERR"] = 1;
-
 
58
            $result["ERRINFO"] = $this->db->getMessage();
-
 
59
        } else {
-
 
60
            $result["ERR"] = 0;
-
 
61
        }
-
 
62
-
 
63
        return $result;
-
 
64
    }
-
 
65
-
 
66
    // Создание настройки
-
 
67
    function addOption($attr, $value) {
-
 
68
        $result = array();
-
 
69
        $sValue = $this->secure->checkStr($value);
-
 
70
-
 
71
        $query = "INSERT INTO ".$this->prefix."settings SET opt='".$attr."', optvalue='".$sValue."'";
-
 
72
        $rq =& $this->db->query($query);
-
 
73
        if (PEAR::isError($this->db)) {
-
 
74
            $result["ERR"] = 1;
-
 
75
            $result["ERRINFO"] = $this->db->getMessage();
-
 
76
        } else {
-
 
77
            $result["ERR"] = 0;
-
 
78
        }
-
 
79
-
 
80
        return $result;
-
 
81
    }
-
 
82
-
 
83
43
    // Получение и отображение списка дистрибутивов
84
    // Получение и отображение списка дистрибутивов
44
    function showDistributionList($name, $info = "", $format = 'html') {
85
    function showDistributionList($name, $info = "", $format = 'html') {
45
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
86
        $query = "SELECT * FROM ".$this->prefix."distribution ORDER BY dist_id ASC";
46
        $rq =& $this->db->query($query);
87
        $rq =& $this->db->query($query);
47
        switch ($format) {
88
        switch ($format) {
Строка 243... Строка 284...
243
    // sourses.list
284
    // sourses.list
244
    function showSourcesList() {
285
    function showSourcesList() {
245
       //TODO Написать генератор sources.list
286
       //TODO Написать генератор sources.list
246
    }
287
    }
247
   
288
   
-
 
289
    // Проверка пароля (из формы авторизации)
-
 
290
    function checkSign($word) {
-
 
291
        $result = array();
-
 
292
-
 
293
        $sHash = $this->secure->encryptStr($word);
-
 
294
        $pwd   = $this->getOption("passwd");
-
 
295
        if ($sHash == $pwd["OptValue"]) {
-
 
296
            $result["ERR"] = 0;
-
 
297
            $result["Location"] = "manager.php";
-
 
298
            setcookie($this->cookie, $sHash);
-
 
299
        } else {
-
 
300
            $result["ERR"] = 1;
-
 
301
            $result["ERRINFO"] = "Password not valid";
-
 
302
            $result["Location"] = "sign.php?error=1";
-
 
303
        }
-
 
304
-
 
305
        return $result;
-
 
306
    }
-
 
307
248
    // Аутентификация пользователя
308
    // Проверка пароля (из cookies)
249
    function checkUser($user, $hash) {
309
    function checkCookieSign($hash) {
-
 
310
        $result = array();
-
 
311
-
 
312
        $pwd = $this->getOption("passwd");
-
 
313
        if ($hash == $pwd["OptValue"]) {
-
 
314
            $result["ERR"] = 0;
-
 
315
        } else {
-
 
316
            $result["ERR"] = 1;
-
 
317
            $result["ERRINFO"] = "Hash not valid";
-
 
318
            $result["Location"] = "sign.php";
-
 
319
        }
-
 
320
-
 
321
        return $result;
-
 
322
    }
-
 
323
250
        //TODO Написать функцию
324
    // Обновление пароля
-
 
325
    function updatePassword($word1, $word2) {
-
 
326
        $result = array();
-
 
327
-
 
328
        if ($word1 == $word2) {
-
 
329
            $sWord = $this->secure->encryptStr($word1);
-
 
330
            $r = $this->setOption("passwd", $sWord);
-
 
331
            $result = $r;
-
 
332
        } else {
-
 
333
            $result["ERR"] = 1;
-
 
334
            $result["ERRINFO"] = "Passwords is mismatch";
-
 
335
        }
-
 
336
-
 
337
        return $result;
251
    }
338
    }
252
339
253
}
340
}
254
341
255
?>
342
?>
256
343