6 * @copyright (c) 2008 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
20 * A small class for 3.0.x (no autoloader in 3.0.x)
24 class phpbb_captcha_factory
27 * return an instance of class $name in file $name_plugin.php
29 function &get_instance($name)
31 global $phpbb_root_path, $phpEx;
33 $name = basename($name);
34 if (!class_exists($name))
36 include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx);
38 $instance = call_user_func(array($name, 'get_instance'));
43 * Call the garbage collector
45 function garbage_collect($name)
47 global $phpbb_root_path, $phpEx;
49 $name = basename($name);
50 if (!class_exists($name))
52 include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx);
54 call_user_func(array($name, 'garbage_collect'), 0);
58 * return a list of all discovered CAPTCHA plugins
60 function get_captcha_types()
62 global $phpbb_root_path, $phpEx;
65 'available' => array(),
66 'unavailable' => array(),
69 $dp = @opendir($phpbb_root_path . 'includes/captcha/plugins');
73 while (($file = readdir($dp)) !== false)
75 if ((preg_match('#_plugin\.' . $phpEx . '$#', $file)))
77 $name = preg_replace('#^(.*?)_plugin\.' . $phpEx . '$#', '\1', $file);
78 if (!class_exists($name))
80 include($phpbb_root_path . "includes/captcha/plugins/$file");
83 if (call_user_func(array($name, 'is_available')))
85 $captchas['available'][$name] = call_user_func(array($name, 'get_name'));
89 $captchas['unavailable'][$name] = call_user_func(array($name, 'get_name'));