1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: /**
13: * Protector
14: *
15: * @copyright XOOPS Project (http://xoops.org)
16: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17: * @package protector
18: * @author trabis <lusopoemas@gmail.com>
19: * @version $Id$
20: */
21:
22: class protector_postcommon_post_htmlpurify4everyone extends ProtectorFilterAbstract
23: {
24: var $purifier;
25:
26: var $method;
27:
28: function execute()
29: {
30: $xoops = Xoops::getInstance();
31: // use HTMLPurifier inside Protector
32: //require_once $xoops->path('lib/HTMLPurifier/HTMLPurifier.auto.php');
33: $config = HTMLPurifier_Config::createDefault();
34: $config->set('Cache', 'SerializerPath', \XoopsBaseConfig::get('lib-path'));
35: $config->set('Core', 'Encoding', XoopsLocale::getCharset());
36: //$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
37: $this->purifier = new HTMLPurifier($config);
38: $this->method = 'purify';
39: $_POST = $this->purify_recursive($_POST);
40: }
41:
42: function purify_recursive($data)
43: {
44: if (is_array($data)) {
45: return array_map(array($this, 'purify_recursive'), $data);
46: } else {
47: return strlen($data) > 32 ? call_user_func(array($this->purifier, $this->method), $data) : $data;
48: }
49: }
50: }
51: