1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | class Protector_postcommon_post_htmlpurify4everyone extends ProtectorFilterAbstract |
7: | { |
8: | public $purifier; |
9: | public $method; |
10: | |
11: | public function execute() |
12: | { |
13: | |
14: | if (version_compare(PHP_VERSION, '5.0.0') < 0) { |
15: | die('Turn postcommon_post_htmlpurify4everyone.php off because this filter cannot run with PHP4'); |
16: | } |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | require_once dirname(__DIR__) . '/library/HTMLPurifier.auto.php'; |
32: | $config = HTMLPurifier_Config::createDefault(); |
33: | $config->set('Cache', 'SerializerPath', XOOPS_VAR_PATH . '/configs/protector'); |
34: | $config->set('Core', 'Encoding', _CHARSET); |
35: | |
36: | $this->purifier = new HTMLPurifier($config); |
37: | $this->method = 'purify'; |
38: | |
39: | |
40: | $_POST = $this->purify_recursive($_POST); |
41: | } |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | public function purify_recursive($data) |
49: | { |
50: | if (is_array($data)) { |
51: | return array_map(array($this, 'purify_recursive'), $data); |
52: | } else { |
53: | return strlen($data) > 32 ? call_user_func(array($this->purifier, $this->method), $data) : $data; |
54: | } |
55: | } |
56: | } |
57: | |