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