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_htmlpurify4guest extends ProtectorFilterAbstract
23: {
24: var $purifier;
25:
26: var $method;
27:
28: function execute()
29: {
30: $xoops = Xoops::getInstance();
31:
32: if ($xoops->isUser()) {
33: return true;
34: }
35:
36: // use HTMLPurifier inside Protector
37: //require_once $xoops->path('lib/HTMLPurifier/HTMLPurifier.auto.php');
38: $config = HTMLPurifier_Config::createDefault();
39: $config->set('Cache', 'SerializerPath', \XoopsBaseConfig::get('lib-path'));
40: $config->set('Core', 'Encoding', XoopsLocale::getCharset());
41: //$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
42: $this->purifier = new HTMLPurifier($config);
43: $this->method = 'purify';
44:
45: $_POST = $this->purify_recursive($_POST);
46: return true;
47: }
48:
49: function purify_recursive($data)
50: {
51: if (is_array($data)) {
52: return array_map(array($this, 'purify_recursive'), $data);
53: } else {
54: return strlen($data) > 32 ? call_user_func(array($this->purifier, $this->method), $data) : $data;
55: }
56: }
57: }
58: