blob: 0f16e137ecdc8c82d2dac42ca9f2a61e3b77c8fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
<?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;
}
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(
'available' => array(),
'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;
}
}
?>
|