1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20:
21:
22:
23: class ProtectorFilterAbstract
24: {
25: var $protector = null;
26:
27: var $errors = array();
28:
29: function ProtectorFilterAbstract()
30: {
31: $xoops = Xoops::getInstance();
32: $language = $xoops->getConfig('language');
33: $this->protector = Protector::getInstance();
34: $lang = !$language ? @$this->protector->_conf['default_lang'] : $language;
35: @include_once dirname(__DIR__) . '/language/' . $lang . '/main.php';
36: if (!defined('_MD_PROTECTOR_YOUAREBADIP')) {
37: include_once dirname(__DIR__) . '/language/english/main.php';
38: }
39: }
40:
41: function isMobile()
42: {
43: if (class_exists('Wizin_User')) {
44:
45: $user = Wizin_User::getSingleton();
46: return $user->bIsMobile;
47: } else {
48: if (defined('HYP_K_TAI_RENDER') && HYP_K_TAI_RENDER) {
49:
50: return true;
51: } else {
52: return false;
53: }
54: }
55: }
56: }
57:
58:
59: class ProtectorFilterHandler
60: {
61: var $protector = null;
62:
63: var $filters_base = '';
64:
65: function ProtectorFilterHandler()
66: {
67: $this->protector = Protector::getInstance();
68: $this->filters_base = dirname(__DIR__) . '/filters_enabled';
69: }
70:
71: static function getInstance()
72: {
73: static $instance;
74: if (!isset($instance)) {
75: $instance = new ProtectorFilterHandler();
76: }
77: return $instance;
78: }
79:
80:
81: 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: } else {
94: if (class_exists($plugin_name)) {
95:
96: $plugin_obj = new $plugin_name();
97: $ret |= $plugin_obj->execute();
98: }
99: }
100: }
101: }
102: closedir($dh);
103:
104: return $ret;
105: }
106: }
107: