1 | <?php |
||
10 | class Secure |
||
11 | { |
||
12 | /** |
||
13 | * Hash a string |
||
14 | * |
||
15 | * @param string $val String to hash |
||
16 | * |
||
17 | * @return string |
||
18 | */ |
||
19 | public static function hash($val) |
||
20 | { |
||
21 | return hash('sha256', md5($val)); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Securize a string for some types with filter_var. |
||
26 | * |
||
27 | * @param mixed $data String to securize |
||
28 | * @param string $type Type of filter |
||
29 | * |
||
30 | * @return mixed |
||
31 | * |
||
32 | * @throws Exception If the type is unknown |
||
33 | */ |
||
34 | public static function securiseKnownTypes($data, $type) |
||
54 | |||
55 | /** |
||
56 | * Securize a variable |
||
57 | * |
||
58 | * @param mixed $data The variable to securize |
||
59 | * @param string $type The type of datas |
||
60 | * @param boolean $htmlentities If use htmlentities function |
||
61 | * to more securize |
||
62 | * |
||
63 | * @return mixed |
||
64 | * |
||
65 | * @throws Exception If a error with a type of data |
||
66 | */ |
||
67 | public static function securise($data, $type, $htmlentities) |
||
106 | |||
107 | /** |
||
108 | * Get the sqlSecure function declared in bfw config file |
||
109 | * |
||
110 | * @return boolean|string |
||
111 | */ |
||
112 | public static function getSqlSecureMethod() |
||
123 | |||
124 | /** |
||
125 | * Securize an array key's value for a declared type. |
||
126 | * |
||
127 | * @param array $array The array where is the key |
||
128 | * @param string $key The key where is the value to securize |
||
129 | * @param string $type The type of data |
||
130 | * @param boolean $htmlentities If use htmlentities function |
||
131 | * to more securize |
||
132 | * |
||
133 | * @return mixed |
||
134 | * |
||
135 | * @throws Exception If the key not exist in array |
||
136 | */ |
||
137 | public static function getSecurisedKeyInArray(&$array, $key, $type, $htmlentities = false) |
||
146 | |||
147 | /** |
||
148 | * Get a securized value for a key in $_POST array |
||
149 | * |
||
150 | * @param string $key The key where is the value to securize |
||
151 | * @param string $type The type of data |
||
152 | * @param boolean $htmlentities If use htmlentities function |
||
153 | * to more securize |
||
154 | * |
||
155 | * @return mixed |
||
156 | */ |
||
157 | public static function getSecurisedPostKey($key, $type, $htmlentities = false) |
||
162 | |||
163 | /** |
||
164 | * Get a securized value for a key in $_GET array |
||
165 | * |
||
166 | * @param string $key The key where is the value to securize |
||
167 | * @param string $type The type of data |
||
168 | * @param boolean $htmlentities If use htmlentities function |
||
169 | * to more securize |
||
170 | * |
||
171 | * @return mixed |
||
172 | */ |
||
173 | public static function getSecurisedGetKey($key, $type, $htmlentities = false) |
||
178 | } |
||
179 |