XOOPS  2.6.0
xcaptcha.php
Go to the documentation of this file.
1 <?php
19 class Xcaptcha extends XoopsCaptcha
20 {
22 
23  public $config = array();
24 
25  public $plugin_List = array();
26 
27  public $plugin_config = array();
28 
30 
31  public function __construct()
32  {
33  $this->captchaHandler = XoopsCaptcha::getInstance();
34  $this->config = $this->loadConfig();
35  $this->plugin_List = $this->getPluginList();
36  $this->plugin_config = $this->loadConfigPlugin();
37  $this->xcaptcha_path_plugin = \XoopsBaseConfig::get('root-path') . '/modules/xcaptcha/plugins';
38  }
39 
40  static function getInstance()
41  {
42  static $instance;
43  if (!isset($instance)) {
44  $class = __CLASS__;
45  $instance = new $class();
46  }
47  return $instance;
48  }
49 
50  public function loadConfig($name = 'config')
51  {
52  return $this->captchaHandler->loadConfig($name);
53  }
54 
55  public function loadBasicConfig($filename = null)
56  {
57  return $this->captchaHandler->loadBasicConfig($filename);
58  }
59 
60  public function readConfig($file = 'config')
61  {
62  return $this->captchaHandler->readConfig($file);
63  }
64 
65  public function writeConfig($file = 'config', $data)
66  {
67  return $this->captchaHandler->writeConfig($file, $data);
68  }
69 
70  public function getPluginList()
71  {
72  $ret = array();
73 
74  foreach (glob($this->captchaHandler->path_basic . '/config.*.php') as $filename) {
75  $plugin_List = preg_replace('/(config\.)(.*)(\.php)/', '$2', basename($filename));
76  $ret[$plugin_List] = $plugin_List;
77  }
78  return $ret;
79  }
80 
81  public function loadConfigPlugin()
82  {
83  $config = array();
84  foreach ($this->plugin_List as $key) {
85  $config = $this->loadConfig($key);
86  }
87  return $config;
88  }
89 
90  public function VerifyData()
91  {
93  $config = array();
94  $_POST['disabled'] = $system->CleanVars($_POST, 'disabled', false, 'boolean');
95  $_POST['mode'] = $system->CleanVars($_POST, 'mode', 'image', 'string');
96  $_POST['name'] = $system->CleanVars($_POST, 'name', 'xoopscaptcha', 'string');
97  $_POST['skipmember'] = $system->CleanVars($_POST, 'skipmember', false, 'boolean');
98  $_POST['maxattempts'] = $system->CleanVars($_POST, 'maxattempts', 10, 'int');
99  foreach (array_keys($this->config) as $key) {
100  $config[$key] = $_POST[$key];
101  }
102  return $config;
103  }
104 
105  public function loadPluginHandler($name = null)
106  {
107  $name = empty($name) ? 'text' : $name;
108  $class = 'Xcaptcha' . ucfirst($name);
109  $this->Pluginhandler = null;
110  if (XoopsLoad::fileExists($file = $this->xcaptcha_path_plugin . '/' . $name . '.php')) {
111  require_once $file;
112  $this->Pluginhandler = new $class($this);
113  }
114  return $this->Pluginhandler;
115  }
116 }
static getInstance()
$plugin_List
Definition: xcaptcha.php:25
static getInstance()
Definition: system.php:46
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
writeConfig($file= 'config', $data)
Definition: xcaptcha.php:65
$xcaptcha_path_plugin
Definition: xcaptcha.php:29
$captchaHandler
Definition: xcaptcha.php:21
static getInstance()
Definition: xcaptcha.php:40
getPluginList()
Definition: xcaptcha.php:70
static fileExists($file)
Definition: xoopsload.php:506
static get($name)
loadBasicConfig($filename=null)
Definition: xcaptcha.php:55
loadConfigPlugin()
Definition: xcaptcha.php:81
readConfig($file= 'config')
Definition: xcaptcha.php:60
loadConfig($name= 'config')
Definition: xcaptcha.php:50
VerifyData()
Definition: xcaptcha.php:90
loadPluginHandler($name=null)
Definition: xcaptcha.php:105
$plugin_config
Definition: xcaptcha.php:27
__construct()
Definition: xcaptcha.php:31