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