1 | <?php |
||
11 | class Sanitise |
||
12 | { |
||
13 | |||
14 | private $is_valid = null; |
||
15 | private $_sanitised = null; |
||
16 | private $filters; |
||
17 | private $input; |
||
18 | private $output; |
||
19 | private $strings; |
||
20 | private $urlService; |
||
21 | |||
22 | function __construct() |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * Removes URLs from strings |
||
32 | * |
||
33 | * @param array|string $data |
||
34 | * @return array|string|string[]|null |
||
35 | */ |
||
36 | public function removeUrl($data) |
||
60 | |||
61 | /** |
||
62 | * @param $data |
||
63 | * @param string $toEncoding |
||
64 | * @param string $fromEncoding |
||
65 | * @return array|false|string|string[]|null |
||
66 | */ |
||
67 | public function cleanse($data, $toEncoding = 'utf-8', $fromEncoding = 'auto') |
||
88 | |||
89 | /** |
||
90 | * @param $string |
||
91 | * @param string $delimiter |
||
92 | * @return string |
||
93 | */ |
||
94 | public function cleanseCsv($string, $delimiter = "|") |
||
98 | |||
99 | /** |
||
100 | * @param $data |
||
101 | * @param string $type |
||
102 | * @param int $stringLength |
||
103 | * @return mixed|string |
||
104 | */ |
||
105 | 4 | public function disinfect($data, $type = 'special_chars', $stringLength = -1) |
|
167 | |||
168 | |||
169 | /** |
||
170 | * @param $str |
||
171 | * @return mixed|string |
||
172 | */ |
||
173 | 4 | public function decodeHtmlEntity($str) |
|
174 | { |
||
175 | 4 | $ret = html_entity_decode($str, ENT_COMPAT, 'UTF-8'); |
|
176 | 4 | $p2 = -1; |
|
177 | 4 | for (; ;) { |
|
178 | 4 | $p = strpos($ret, '&#', $p2 + 1); |
|
179 | 4 | if ($p === false) { |
|
180 | 4 | break; |
|
181 | } |
||
182 | $p2 = strpos($ret, ';', $p); |
||
183 | if ($p2 === false) { |
||
184 | break; |
||
185 | } |
||
186 | |||
187 | if (substr($ret, $p + 2, 1) == 'x') { |
||
188 | $char = hexdec(substr($ret, $p + 3, $p2 - $p - 3)); |
||
189 | } else { |
||
190 | $char = intval(substr($ret, $p + 2, $p2 - $p - 2)); |
||
191 | } |
||
192 | |||
193 | $newchar = iconv( |
||
194 | 'UCS-4', 'UTF-8', |
||
195 | chr(($char >> 24) & 0xFF) . chr(($char >> 16) & 0xFF) . chr(($char >> 8) & 0xFF) . chr($char & 0xFF) |
||
196 | ); |
||
197 | |||
198 | $ret = substr_replace($ret, $newchar, $p, 1 + $p2 - $p); |
||
199 | 4 | $p2 = $p + strlen($newchar); |
|
200 | } |
||
201 | 4 | return $ret; |
|
202 | } |
||
203 | |||
204 | |||
205 | /** |
||
206 | * @return null |
||
207 | */ |
||
208 | public function isSanitised() |
||
212 | |||
213 | /** |
||
214 | * Returns true if the data is valid |
||
215 | * @return null |
||
216 | */ |
||
217 | public function isValid() |
||
221 | |||
222 | 4 | function result() |
|
230 | |||
231 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.