aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/captcha/captcha_factory.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-10-04 18:14:59 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-10-04 18:14:59 +0000
commit2e17e448deed073f8614bb555a8ef20c57291c2a (patch)
tree533007e53d3584d0887b0f639d0e673b1e15ea7a /phpBB/includes/captcha/captcha_factory.php
parentbf8ac19eaa8d74f9dfd6d597190f5664e7339382 (diff)
downloadforums-2e17e448deed073f8614bb555a8ef20c57291c2a.tar
forums-2e17e448deed073f8614bb555a8ef20c57291c2a.tar.gz
forums-2e17e448deed073f8614bb555a8ef20c57291c2a.tar.bz2
forums-2e17e448deed073f8614bb555a8ef20c57291c2a.tar.xz
forums-2e17e448deed073f8614bb555a8ef20c57291c2a.zip
Copy 3.0.x branch to trunk
git-svn-id: file:///svn/phpbb/trunk@10211 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/captcha/captcha_factory.php')
-rw-r--r--phpBB/includes/captcha/captcha_factory.php100
1 files changed, 100 insertions, 0 deletions
diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php
new file mode 100644
index 0000000000..73406a954f
--- /dev/null
+++ b/phpBB/includes/captcha/captcha_factory.php
@@ -0,0 +1,100 @@
+<?php
+/**
+*
+* @package VC
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* A small class for 3.0.x (no autoloader in 3.0.x)
+*
+* @package VC
+*/
+class phpbb_captcha_factory
+{
+ /**
+ * return an instance of class $name in file $name_plugin.php
+ */
+ function &get_instance($name)
+ {
+ global $phpbb_root_path, $phpEx;
+
+ $name = basename($name);
+ if (!class_exists($name))
+ {
+ include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx);
+ }
+ $instance =& call_user_func(array($name, 'get_instance'));
+ return $instance;
+ }
+
+ /**
+ * Call the garbage collector
+ */
+ function garbage_collect($name)
+ {
+ global $phpbb_root_path, $phpEx;
+
+ $name = basename($name);
+ if (!class_exists($name))
+ {
+ include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx);
+ }
+ call_user_func(array($name, 'garbage_collect'), 0);
+ }
+
+ /**
+ * return a list of all discovered CAPTCHA plugins
+ */
+ function get_captcha_types()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ $captchas = array(
+ 'available' => array(),
+ 'unavailable' => array(),
+ );
+
+ $dp = @opendir($phpbb_root_path . 'includes/captcha/plugins');
+
+ if ($dp)
+ {
+ while (($file = readdir($dp)) !== false)
+ {
+ if ((preg_match('#_plugin\.' . $phpEx . '$#', $file)))
+ {
+ $name = preg_replace('#^(.*?)_plugin\.' . $phpEx . '$#', '\1', $file);
+ if (!class_exists($name))
+ {
+ include($phpbb_root_path . "includes/captcha/plugins/$file");
+ }
+
+ if (call_user_func(array($name, 'is_available')))
+ {
+ $captchas['available'][$name] = call_user_func(array($name, 'get_name'));
+ }
+ else
+ {
+ $captchas['unavailable'][$name] = call_user_func(array($name, 'get_name'));
+ }
+ }
+ }
+ closedir($dp);
+ }
+
+ return $captchas;
+ }
+}
+
+?> \ No newline at end of file