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