2009-06-04 13:30:01 +00:00
|
|
|
<?php
|
2009-06-02 14:12:23 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package VC
|
2009-06-04 13:30:01 +00:00
|
|
|
* @version $Id$
|
2009-06-02 14:12:23 +00:00
|
|
|
* @copyright (c) 2008 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2009-06-07 11:34:01 +00:00
|
|
|
/**
|
|
|
|
* A small class for 3.0.x (no autoloader in 3.0.x)
|
|
|
|
*
|
|
|
|
* @package VC
|
|
|
|
*/
|
2009-06-02 14:12:23 +00:00
|
|
|
class phpbb_captcha_factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* return an instance of class $name in file $name_plugin.php
|
|
|
|
*/
|
2009-06-13 14:09:51 +00:00
|
|
|
function &get_instance($name)
|
2009-06-02 14:12:23 +00:00
|
|
|
{
|
|
|
|
global $phpbb_root_path, $phpEx;
|
2009-06-07 11:34:01 +00:00
|
|
|
|
2009-06-02 14:12:23 +00:00
|
|
|
$name = basename($name);
|
|
|
|
if (!class_exists($name))
|
|
|
|
{
|
|
|
|
include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx);
|
|
|
|
}
|
2009-10-15 10:52:41 +00:00
|
|
|
$instance = call_user_func(array($name, 'get_instance'));
|
2009-06-13 14:09:51 +00:00
|
|
|
return $instance;
|
2009-06-02 14:12:23 +00:00
|
|
|
}
|
2009-06-07 11:34:01 +00:00
|
|
|
|
2009-06-02 14:12:23 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
2009-06-07 11:34:01 +00:00
|
|
|
|
2009-06-02 14:12:23 +00:00
|
|
|
/**
|
|
|
|
* return a list of all discovered CAPTCHA plugins
|
|
|
|
*/
|
|
|
|
function get_captcha_types()
|
|
|
|
{
|
|
|
|
global $phpbb_root_path, $phpEx;
|
2009-06-07 11:34:01 +00:00
|
|
|
|
|
|
|
$captchas = array(
|
|
|
|
'available' => array(),
|
|
|
|
'unavailable' => array(),
|
|
|
|
);
|
|
|
|
|
2009-06-02 14:12:23 +00:00
|
|
|
$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");
|
|
|
|
}
|
2009-06-07 11:34:01 +00:00
|
|
|
|
2009-06-02 14:12:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-06-04 13:30:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|