1 | <?php |
||
10 | class Secure |
||
11 | { |
||
12 | /** |
||
13 | * @const ERR_SECURE_UNKNOWN_TYPE Exception code if the data into the |
||
14 | * method secure() is not a predefined type. |
||
15 | */ |
||
16 | const ERR_SECURE_UNKNOWN_TYPE = 1207001; |
||
17 | |||
18 | /** |
||
19 | * @const ERR_SECURE_ARRAY_KEY_NOT_EXIST If the asked key not exist into |
||
20 | * the array to secure. |
||
21 | */ |
||
22 | const ERR_SECURE_ARRAY_KEY_NOT_EXIST = 1207002; |
||
23 | |||
24 | /** |
||
25 | * @const ERR_OBTAIN_KEY Exception code if the key asked not exist |
||
26 | */ |
||
27 | const ERR_OBTAIN_KEY = 1207003; |
||
28 | |||
29 | /** |
||
30 | * Hash a string |
||
31 | * |
||
32 | * @param string $val String to hash |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | public static function hash($val) |
||
40 | |||
41 | /** |
||
42 | * Securize a string for some types with filter_var function. |
||
43 | * |
||
44 | * @param mixed $data String to securize |
||
45 | * @param string $type Type of filter |
||
46 | * |
||
47 | * @return mixed |
||
48 | * |
||
49 | * @throws Exception If the type is unknown |
||
50 | */ |
||
51 | public static function securiseKnownTypes($data, $type) |
||
71 | |||
72 | /** |
||
73 | * Securise a variable |
||
74 | * |
||
75 | * @param mixed $data The variable to securise |
||
76 | * @param string $type The type of datas |
||
77 | * @param boolean $htmlentities If use htmlentities function |
||
78 | * to a better security |
||
79 | * |
||
80 | * @return mixed |
||
81 | * |
||
82 | * @throws Exception If an error with a type of data |
||
83 | */ |
||
84 | public static function securise($data, $type, $htmlentities) |
||
123 | |||
124 | /** |
||
125 | * Get the sqlSecure function declared in bfw config file |
||
126 | * |
||
127 | * @return boolean|string |
||
128 | */ |
||
129 | public static function getSqlSecureMethod() |
||
140 | |||
141 | /** |
||
142 | * Securise the value of an array key for a declared type. |
||
143 | * |
||
144 | * @param array &$array The array where is the key |
||
145 | * @param string $key The key where is the value to securize |
||
146 | * @param string $type The type of data |
||
147 | * @param boolean $htmlentities (default: false) If use htmlentities |
||
148 | * function to a better security |
||
149 | * |
||
150 | * @return mixed |
||
151 | * |
||
152 | * @throws Exception If the key not exist in array |
||
153 | */ |
||
154 | public static function getSecurisedKeyInArray( |
||
174 | |||
175 | /** |
||
176 | * Obtain many key from an array in one time |
||
177 | * |
||
178 | * @param array &$arraySrc The source array |
||
179 | * @param array $keysList The key list to obtain. |
||
180 | * For each item, the key is the name of the key in source array; And the |
||
181 | * value the type of the value. The value can also be an object. In this |
||
182 | * case, the properties "type" contain the value type, and the "htmlenties" |
||
183 | * property contain the boolean who indicate if secure system |
||
184 | * will use htmlentities. |
||
185 | * @param boolean $throwOnError (defaut true) If a key not exist, throw an |
||
186 | * exception. If false, the value will be null into returned array |
||
187 | * |
||
188 | * @return array |
||
189 | * |
||
190 | * @throws Exception If a key is not found and if $throwOnError is true |
||
191 | */ |
||
192 | public static function getSecurisedManyKeys( |
||
230 | } |
||
231 |