XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
postcommon_post_htmlpurify4everyone.php
Go to the documentation of this file.
1 <?php
2 
4  var $purifier ;
5  var $method ;
6 
7  function execute()
8  {
9  // HTMLPurifier runs with PHP5 only
10  if( version_compare( PHP_VERSION , '5.0.0' ) < 0 ) {
11  die( 'Turn postcommon_post_htmlpurify4everyone.php off because this filter cannot run with PHP4' ) ;
12  }
13 
14  if( file_exists( XOOPS_ROOT_PATH.'/class/icms.htmlpurifier.php' ) ) {
15  // use HTMLPurifier inside ImpressCMS
16  if( ! class_exists( 'icms_HTMLPurifier' ) ) {
17  require_once ICMS_ROOT_PATH.'/class/icms.htmlpurifier.php' ;
18  }
19 // $pure =& icms_HTMLPurifier::getPurifierInstance() ;
20 // $_POST = $pure->icms_html_purifier( $_POST , 'protector' ) ;
21  $this->purifier =& icms_HTMLPurifier::getPurifierInstance() ;
22  $this->method = 'icms_html_purifier' ;
23 
24  } else {
25  // use HTMLPurifier inside Protector
26  require_once dirname(dirname(__FILE__)).'/library/HTMLPurifier.auto.php' ;
28  $config->set('Cache', 'SerializerPath', XOOPS_TRUST_PATH.'/modules/protector/configs');
29  $config->set('Core', 'Encoding', _CHARSET);
30  //$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
31  $this->purifier = new HTMLPurifier($config);
32  $this->method = 'purify' ;
33  }
34 
35  $_POST = $this->purify_recursive( $_POST ) ;
36  }
37 
38 
39  function purify_recursive( $data )
40  {
41  if( is_array( $data ) ) {
42  return array_map( array( $this , 'purify_recursive' ) , $data ) ;
43  } else {
44  return strlen( $data ) > 32 ? call_user_func( array( $this->purifier , $this->method ) , $data ) : $data ;
45  }
46  }
47 
48 }
49 
50 ?>