aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/captcha/captcha_factory.php
diff options
context:
space:
mode:
authorHenry Sudhof <kellanved@phpbb.com>2008-09-19 13:17:30 +0000
committerHenry Sudhof <kellanved@phpbb.com>2008-09-19 13:17:30 +0000
commit461be11e8d0f5d4bd879cf95bd1472dbe985e0b6 (patch)
treed170e1a09d717a49bf676ef1f2ed9edbfa1be0db /phpBB/includes/captcha/captcha_factory.php
parent5349280538df70d63c5e6f91e7f4e6ecad01d23d (diff)
downloadforums-461be11e8d0f5d4bd879cf95bd1472dbe985e0b6.tar
forums-461be11e8d0f5d4bd879cf95bd1472dbe985e0b6.tar.gz
forums-461be11e8d0f5d4bd879cf95bd1472dbe985e0b6.tar.bz2
forums-461be11e8d0f5d4bd879cf95bd1472dbe985e0b6.tar.xz
forums-461be11e8d0f5d4bd879cf95bd1472dbe985e0b6.zip
Okay, that is pretty raw, but better to have it in place than trying to play catch-up. Introducing an early stage of CAPTCHA modules.
git-svn-id: file:///svn/phpbb/trunk@8889 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/captcha/captcha_factory.php')
-rwxr-xr-xphpBB/includes/captcha/captcha_factory.php90
1 files changed, 90 insertions, 0 deletions
diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php
new file mode 100755
index 0000000000..dfbe605917
--- /dev/null
+++ b/phpBB/includes/captcha/captcha_factory.php
@@ -0,0 +1,90 @@
+<?
+/**
+*
+* @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;
+}
+
+if (!interface_exists('phpbb_captcha_plugin'))
+{
+ include(PHPBB_ROOT_PATH . "includes/captcha/captcha_plugin." . PHP_EXT);
+}
+
+/** A small class until we get the autoloader done */
+class phpbb_captcha_factory
+{
+ /**
+ * return an instance of class $name in file $name_plugin.php
+ */
+ public static function get_instance($name)
+ {
+ $name = basename($name);
+ if (!class_exists($name))
+ {
+ include(PHPBB_ROOT_PATH . "includes/captcha/plugins/{$name}_plugin." . PHP_EXT);
+ }
+ return call_user_func(array($name, 'get_instance'));
+ }
+
+ /**
+ * Call the garbage collector
+ */
+ public static function garbage_collect($name)
+ {
+ $name = basename($name);
+ if (!class_exists($name))
+ {
+ include(PHPBB_ROOT_PATH . "includes/captcha/plugins/{$name}_plugin." . PHP_EXT);
+ }
+ call_user_func(array($name, 'garbage_collect'), 0);
+ }
+
+ /**
+ * return a list of all discovered CAPTCHA plugins
+ */
+ public static function get_captcha_types()
+ {
+ $captchas = array();
+ $captchas['available'] = array();
+ $captchas['unavailable'] = array();
+
+ $dp = @opendir(PHPBB_ROOT_PATH . 'includes/captcha/plugins');
+
+ if ($dp)
+ {
+ while (($file = readdir($dp)) !== false)
+ {
+ if ((preg_match('#_plugin\.' . PHP_EXT . '$#', $file)))
+ {
+ $name = preg_replace('#^(.*?)_plugin\.' . PHP_EXT . '$#', '\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