[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package VC 5 * @version $Id$ 6 * @copyright (c) 2008 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 */ 10 11 /** 12 * @ignore 13 */ 14 if (!defined('IN_PHPBB')) 15 { 16 exit; 17 } 18 19 /** 20 * A small class for 3.0.x (no autoloader in 3.0.x) 21 * 22 * @package VC 23 */ 24 class phpbb_captcha_factory 25 { 26 /** 27 * return an instance of class $name in file $name_plugin.php 28 */ 29 function &get_instance($name) 30 { 31 global $phpbb_root_path, $phpEx; 32 33 $name = basename($name); 34 if (!class_exists($name)) 35 { 36 include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx); 37 } 38 $instance = call_user_func(array($name, 'get_instance')); 39 return $instance; 40 } 41 42 /** 43 * Call the garbage collector 44 */ 45 function garbage_collect($name) 46 { 47 global $phpbb_root_path, $phpEx; 48 49 $name = basename($name); 50 if (!class_exists($name)) 51 { 52 include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx); 53 } 54 call_user_func(array($name, 'garbage_collect'), 0); 55 } 56 57 /** 58 * return a list of all discovered CAPTCHA plugins 59 */ 60 function get_captcha_types() 61 { 62 global $phpbb_root_path, $phpEx; 63 64 $captchas = array( 65 'available' => array(), 66 'unavailable' => array(), 67 ); 68 69 $dp = @opendir($phpbb_root_path . 'includes/captcha/plugins'); 70 71 if ($dp) 72 { 73 while (($file = readdir($dp)) !== false) 74 { 75 if ((preg_match('#_plugin\.' . $phpEx . '$#', $file))) 76 { 77 $name = preg_replace('#^(.*?)_plugin\.' . $phpEx . '$#', '\1', $file); 78 if (!class_exists($name)) 79 { 80 include($phpbb_root_path . "includes/captcha/plugins/$file"); 81 } 82 83 if (call_user_func(array($name, 'is_available'))) 84 { 85 $captchas['available'][$name] = call_user_func(array($name, 'get_name')); 86 } 87 else 88 { 89 $captchas['unavailable'][$name] = call_user_func(array($name, 'get_name')); 90 } 91 } 92 } 93 closedir($dp); 94 } 95 96 return $captchas; 97 } 98 } 99 100 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Oct 2 15:03:47 2013 | Cross-referenced by PHPXref 0.7.1 |