1: <?php
2:
3:
4: 5: 6:
7: class ProtectorFilterAbstract
8: {
9: public $protector;
10:
11: 12: 13:
14: public function __construct()
15: {
16: $this->protector = Protector::getInstance();
17: $lang = empty($GLOBALS['xoopsConfig']['language']) ? @$this->protector->_conf['default_lang'] : $GLOBALS['xoopsConfig']['language'];
18: @include_once dirname(__DIR__) . '/language/' . $lang . '/main.php';
19: if (!defined('_MD_PROTECTOR_YOUAREBADIP')) {
20: include_once dirname(__DIR__) . '/language/english/main.php';
21: }
22: }
23:
24: 25: 26: 27:
28: public function isMobile()
29: {
30: if (class_exists('Wizin_User')) {
31:
32: $user =& Wizin_User::getSingleton();
33:
34: return $user->bIsMobile;
35: } elseif (defined('HYP_K_TAI_RENDER') && HYP_K_TAI_RENDER) {
36:
37: return true;
38: } else {
39: return false;
40: }
41: }
42: }
43:
44:
45: 46: 47:
48: class ProtectorFilterHandler
49: {
50: public $protector;
51: public $filters_base = '';
52:
53: 54: 55:
56: protected function __construct()
57: {
58: $this->protector = Protector::getInstance();
59: $this->filters_base = dirname(__DIR__) . '/filters_enabled';
60: }
61:
62: 63: 64:
65: public static function getInstance()
66: {
67: static $instance;
68: if (!isset($instance)) {
69: $instance = new ProtectorFilterHandler();
70: }
71:
72: return $instance;
73: }
74:
75:
76: 77: 78: 79: 80:
81: public function execute($type)
82: {
83: $ret = 0;
84:
85: $dh = opendir($this->filters_base);
86: while (($file = readdir($dh)) !== false) {
87: if (strncmp($file, $type . '_', strlen($type) + 1) === 0) {
88: include_once $this->filters_base . '/' . $file;
89: $plugin_name = 'protector_' . substr($file, 0, -4);
90: if (function_exists($plugin_name)) {
91:
92: $ret |= call_user_func($plugin_name);
93: } elseif (class_exists($plugin_name)) {
94:
95: $plugin_obj = new $plugin_name();
96: $ret |= $plugin_obj->execute();
97: }
98: }
99: }
100: closedir($dh);
101:
102: return $ret;
103: }
104: }
105: