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