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