XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
ProtectorFilter.php
Go to the documentation of this file.
1 <?php
2 
3 // Abstract of each filter classes
5  var $protector = null ;
6 
8  {
9  $this->protector =& Protector::getInstance() ;
10  $lang = empty( $GLOBALS['xoopsConfig']['language'] ) ? @$this->protector->_conf['default_lang'] : $GLOBALS['xoopsConfig']['language'] ;
11  @include_once dirname(dirname(__FILE__)).'/language/'.$lang.'/main.php' ;
12  if( ! defined( '_MD_PROTECTOR_YOUAREBADIP' ) ) {
13  include_once dirname(dirname(__FILE__)).'/language/english/main.php' ;
14  }
15  }
16 
17  function isMobile()
18  {
19  if( class_exists( 'Wizin_User' ) ) {
20  // WizMobile (gusagi)
21  $user =& Wizin_User::getSingleton();
22  return $user->bIsMobile ;
23  } else if( defined( 'HYP_K_TAI_RENDER' ) && HYP_K_TAI_RENDER ) {
24  // hyp_common ktai-renderer (nao-pon)
25  return true ;
26  } else {
27  return false ;
28  }
29  }
30 }
31 
32 
33 // Filter Handler class (singleton)
35  var $protector = null ;
36  var $filters_base = '' ;
37 
39  {
40  $this->protector =& Protector::getInstance() ;
41  $this->filters_base = dirname(dirname(__FILE__)).'/filters_enabled' ;
42  }
43 
44  function &getInstance()
45  {
46  static $instance ;
47  if( ! isset( $instance ) ) {
48  $instance = new ProtectorFilterHandler() ;
49  }
50  return $instance ;
51  }
52 
53  // return: false : execute default action
54  function execute( $type )
55  {
56  $ret = 0 ;
57 
58  $dh = opendir( $this->filters_base ) ;
59  while( ( $file = readdir( $dh ) ) !== false ) {
60  if( strncmp( $file , $type.'_' , strlen( $type ) + 1 ) === 0 ) {
61  include_once $this->filters_base.'/'.$file ;
62  $plugin_name = 'protector_'.substr($file,0,-4) ;
63  if( function_exists( $plugin_name ) ) {
64  // old way
65  $ret |= call_user_func( $plugin_name ) ;
66  } else if( class_exists( $plugin_name ) ) {
67  // newer way
68  $plugin_obj = new $plugin_name() ; //old code is -> $plugin_obj =& new $plugin_name() ; //hack by Trabis
69  $ret |= $plugin_obj->execute() ;
70  }
71  }
72  }
73  closedir( $dh ) ;
74 
75  return $ret ;
76  }
77 }
78 
79 ?>