Редакция 459 | Редакция 475 | К новейшей редакции | Весь файл | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 459 | Редакция 463 | ||
---|---|---|---|
Строка 13... | Строка 13... | ||
13 | 13 | ||
14 | class Security extends Core { |
14 | class Security extends Core { |
15 | public function __construct() { |
15 | public function __construct() { |
16 | }
|
16 | }
|
17 | 17 | ||
- | 18 | /**
|
|
- | 19 | * Проверка на валидность целочисленных значений
|
|
- | 20 | *
|
|
- | 21 | * @author Alexander Wolf
|
|
- | 22 | * @category Security
|
|
- | 23 | *
|
|
- | 24 | * @param int $value
|
|
- | 25 | * @return int
|
|
- | 26 | */
|
|
18 | public function checkInt($value) { |
27 | public function checkInt($value) { |
19 | return abs(intval($value)); |
28 | return abs(intval($value)); |
20 | }
|
29 | }
|
21 | 30 | ||
- | 31 | /**
|
|
- | 32 | * Обработка строковых переменных
|
|
- | 33 | *
|
|
- | 34 | * @author Alexander Wolf
|
|
- | 35 | * @category Security
|
|
- | 36 | *
|
|
- | 37 | * @param string $value
|
|
- | 38 | * @param byte $mode
|
|
- | 39 | * @return string
|
|
- | 40 | */
|
|
22 | public function checkStr($value, $mode = 0) { |
41 | public function checkStr($value, $mode = 0) { |
23 | // mode - 0 -> wrap; mode - 1 -> strip;
|
42 | // mode - 0 -> wrap; mode - 1 -> strip;
|
24 | if ($mode == 0) { |
43 | if ($mode == 0) { |
25 | $result = mysql_real_escape_string($value); |
44 | $result = mysql_real_escape_string($value); |
26 | } else { |
45 | } else { |
27 | $result = stripslashes($value); |
46 | $result = stripslashes($value); |
28 | }
|
47 | }
|
29 | return $result; |
48 | return $result; |
30 | }
|
49 | }
|
31 | 50 | ||
- | 51 | /**
|
|
32 | // генерация хеша пароля
|
52 | * генерация хеша пароля
|
- | 53 | *
|
|
- | 54 | * @author Alexander Wolf
|
|
- | 55 | * @category Security
|
|
- | 56 | *
|
|
- | 57 | * @param string $string
|
|
- | 58 | * @return string
|
|
- | 59 | */
|
|
33 | public function encryptStr($string) { |
60 | public function encryptStr($string) { |
34 | return md5(md5($string)."-CN-ANT-NG-".sha1($string)); |
61 | return md5(md5($string)."-CN-ANT-NG-".sha1($string)); |
35 | }
|
62 | }
|
36 | 63 | ||
37 | }
|
64 | }
|