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