Редакция 475 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
309 | alex-w | 1 | <?php |
2 | /** |
||
3 | * |
||
554 | alex-w | 4 | * Codename: ant-ng - generator of sources.list for apt-distributives |
309 | alex-w | 5 | * http://alex-w.org.ru/p/antng/ |
6 | * |
||
7 | * Copyright (c) 2009 Alexander Wolf |
||
8 | * Dual licensed under the MIT and GNU LGPL licenses. |
||
9 | * http://alex-w.org.ru/p/antng/license |
||
10 | * |
||
11 | */ |
||
12 | |||
314 | alex-w | 13 | class Security extends Core { |
368 | alex-w | 14 | public function __construct() { |
309 | alex-w | 15 | } |
16 | |||
463 | alex-w | 17 | /** |
18 | * Проверка на валидность целочисленных значений |
||
19 | * |
||
20 | * @author Alexander Wolf |
||
21 | * @category Security |
||
22 | * |
||
23 | * @param int $value |
||
24 | * @return int |
||
25 | */ |
||
368 | alex-w | 26 | public function checkInt($value) { |
309 | alex-w | 27 | return abs(intval($value)); |
28 | } |
||
29 | |||
463 | alex-w | 30 | /** |
31 | * Обработка строковых переменных |
||
32 | * |
||
33 | * @author Alexander Wolf |
||
34 | * @category Security |
||
35 | * |
||
36 | * @param string $value |
||
37 | * @param byte $mode |
||
38 | * @return string |
||
39 | */ |
||
368 | alex-w | 40 | public function checkStr($value, $mode = 0) { |
309 | alex-w | 41 | // mode - 0 -> wrap; mode - 1 -> strip; |
42 | if ($mode == 0) { |
||
43 | $result = mysql_real_escape_string($value); |
||
44 | } else { |
||
45 | $result = stripslashes($value); |
||
46 | } |
||
47 | return $result; |
||
48 | } |
||
358 | alex-w | 49 | |
463 | alex-w | 50 | /** |
51 | * генерация хеша пароля |
||
52 | * |
||
53 | * @author Alexander Wolf |
||
54 | * @category Security |
||
55 | * |
||
56 | * @param string $string |
||
57 | * @return string |
||
58 | */ |
||
368 | alex-w | 59 | public function encryptStr($string) { |
358 | alex-w | 60 | return md5(md5($string)."-CN-ANT-NG-".sha1($string)); |
61 | } |
||
62 | |||
309 | alex-w | 63 | } |
64 | |||
65 | ?> |