From 4bdad7125a34e121f7857c34480d0527c1925384 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 13 Jul 2011 11:32:38 +0200 Subject: [ticket/9608] Remove use of references in captcha and other places References are not really needed in PHP due to copy-on-write. Since PHP5, objects are always passed around as identifiers, which means they are mutable. So it is no longer required to pass these by reference either. PHPBB3-9608 --- phpBB/includes/captcha/captcha_factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/captcha_factory.php') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index a3766f4054..c2ec8c5bda 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -26,7 +26,7 @@ class phpbb_captcha_factory /** * return an instance of class $name in file $name_plugin.php */ - function &get_instance($name) + function get_instance($name) { global $phpbb_root_path, $phpEx; -- cgit v1.2.1 From 61df8a87d19c062f5284f06047c1a9093c664cdf Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 22 Aug 2011 03:51:03 -0400 Subject: [feature/extension-manager] Allow extensions to define captcha plugins. The base class for captcha plugins has been renamed, but the old name continues to exist as an empty subclass of it for backwards compatability. PHPBB3-10323 --- phpBB/includes/captcha/captcha_factory.php | 43 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'phpBB/includes/captcha/captcha_factory.php') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index c2ec8c5bda..2779a23d34 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -59,38 +59,39 @@ class phpbb_captcha_factory */ function get_captcha_types() { - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_extension_manager; $captchas = array( 'available' => array(), 'unavailable' => array(), ); - $dp = @opendir($phpbb_root_path . 'includes/captcha/plugins'); + $finder = $phpbb_extension_manager->get_finder(); + $captcha_plugin_classes = $finder + ->directory('/captcha') + ->suffix('_plugin') + ->default_path('includes/captcha/plugins/') + ->default_directory('') + ->get_classes(); - if ($dp) + foreach ($captcha_plugin_classes as $class) { - while (($file = readdir($dp)) !== false) + // check if this class needs to be loaded in legacy mode + $old_class = preg_replace('/^phpbb_captcha_plugins_/', '', $class); + if (file_exists($phpbb_root_path . "includes/captcha/plugins/$old_class.$phpEx") && !class_exists($old_class)) { - 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"); - } + include($phpbb_root_path . "includes/captcha/plugins/$old_class.$phpEx"); + $class = preg_replace('/_plugin$/', '', $old_class); + } - 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')); - } - } + if (call_user_func(array($class, 'is_available'))) + { + $captchas['available'][$class] = call_user_func(array($class, 'get_name')); + } + else + { + $captchas['unavailable'][$class] = call_user_func(array($class, 'get_name')); } - closedir($dp); } return $captchas; -- cgit v1.2.1 From 0d296785b2364f894f34171d054341cc4979223f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 18 Nov 2011 16:42:53 +0100 Subject: [feature/extension-manager] Rename default methods to core methods on finder. There are now extension_ and core_ methods for all finder settings as well as a generic method which overwrites both. PHPBB3-10323 --- phpBB/includes/captcha/captcha_factory.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/captcha/captcha_factory.php') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index 2779a23d34..e039e92054 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -68,10 +68,9 @@ class phpbb_captcha_factory $finder = $phpbb_extension_manager->get_finder(); $captcha_plugin_classes = $finder - ->directory('/captcha') + ->extension_directory('/captcha') ->suffix('_plugin') - ->default_path('includes/captcha/plugins/') - ->default_directory('') + ->core_path('includes/captcha/plugins/') ->get_classes(); foreach ($captcha_plugin_classes as $class) -- cgit v1.2.1 From 7a04c9048c110f0bd21ea3e9e869e17b408d640e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 31 Dec 2011 13:32:52 +0000 Subject: [ticket/9916] Updating header license and removing Version $Id$ PHPBB3-9916 --- phpBB/includes/captcha/captcha_factory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes/captcha/captcha_factory.php') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index e039e92054..62fb90d3c5 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -2,9 +2,8 @@ /** * * @package VC -* @version $Id$ * @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From c8da69d9c26e0017f13abb2c954e52c4cd593fdc Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 5 Apr 2012 14:14:40 +0100 Subject: [ticket/10575] Fixing non-static access to static functions get_instance These changes should solve the strict standards error about accessing the non-static get_instance() in a non-static way. For that, I changed the get_instance methods to static methods. PHPBB3-10575 --- phpBB/includes/captcha/captcha_factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/captcha_factory.php') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index 62fb90d3c5..602c8d130a 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -25,7 +25,7 @@ class phpbb_captcha_factory /** * return an instance of class $name in file $name_plugin.php */ - function get_instance($name) + static function get_instance($name) { global $phpbb_root_path, $phpEx; -- cgit v1.2.1 From 2bf1c4eb32f1e668a215f1dabb42fe88e8a9cd11 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 5 Apr 2012 14:16:56 +0100 Subject: [ticket/10575] Adding public visibility to the methods. Added public visibility to the methods PHPBB3-10575 --- phpBB/includes/captcha/captcha_factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/captcha_factory.php') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index 602c8d130a..d57b333c69 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -25,7 +25,7 @@ class phpbb_captcha_factory /** * return an instance of class $name in file $name_plugin.php */ - static function get_instance($name) + public static function get_instance($name) { global $phpbb_root_path, $phpEx; -- cgit v1.2.1