aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/captcha/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/captcha/plugins')
-rw-r--r--phpBB/includes/captcha/plugins/captcha_abstract.php24
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php24
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php13
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php15
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php56
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php20
6 files changed, 61 insertions, 91 deletions
diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php
index 21cacd730c..7fd88feeb5 100644
--- a/phpBB/includes/captcha/plugins/captcha_abstract.php
+++ b/phpBB/includes/captcha/plugins/captcha_abstract.php
@@ -2,9 +2,8 @@
/**
*
* @package VC
-* @version $Id$
* @copyright (c) 2006, 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
*
*/
@@ -22,7 +21,7 @@ if (!defined('IN_PHPBB'))
*
* @package VC
*/
-class phpbb_default_captcha
+class phpbb_captcha_plugins_captcha_abstract
{
var $confirm_id;
var $confirm_code;
@@ -207,7 +206,6 @@ class phpbb_default_captcha
{
if ($this->check_code())
{
- // $this->delete_code(); commented out to allow posting.php to repeat the question
$this->solved = true;
}
else
@@ -329,17 +327,6 @@ class phpbb_default_captcha
return (strcasecmp($this->code, $this->confirm_code) === 0);
}
- function delete_code()
- {
- global $db, $user;
-
- $sql = 'DELETE FROM ' . CONFIRM_TABLE . "
- WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'
- AND session_id = '" . $db->sql_escape($user->session_id) . "'
- AND confirm_type = " . $this->type;
- $db->sql_query($sql);
- }
-
function get_attempt_count()
{
return $this->attempts;
@@ -377,4 +364,9 @@ class phpbb_default_captcha
}
-?> \ No newline at end of file
+/**
+* Old class name for legacy use. The new class name is auto loadable.
+*/
+class phpbb_default_captcha extends phpbb_captcha_plugins_captcha_abstract
+{
+}
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
index 6e899adc16..4ad34f2a26 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
@@ -2,9 +2,8 @@
/**
*
* @package VC
-* @version $Id$
* @copyright (c) 2006, 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
*
*/
@@ -19,7 +18,7 @@ if (!defined('IN_PHPBB'))
/**
* Placeholder for autoload
*/
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
}
@@ -50,13 +49,13 @@ class phpbb_captcha_gd extends phpbb_default_captcha
}
}
- function &get_instance()
+ static public function get_instance()
{
- $instance =& new phpbb_captcha_gd();
+ $instance = new phpbb_captcha_gd();
return $instance;
}
- function is_available()
+ static public function is_available()
{
global $phpbb_root_path, $phpEx;
@@ -81,7 +80,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha
return true;
}
- function get_name()
+ static public function get_name()
{
return 'CAPTCHA_GD';
}
@@ -152,14 +151,19 @@ class phpbb_captcha_gd extends phpbb_default_captcha
global $config;
$config_old = $config;
+
+ $config = new phpbb_config(array());
+ foreach ($config_old as $key => $value)
+ {
+ $config->set($key, $value);
+ }
+
foreach ($this->captcha_vars as $captcha_var => $template_var)
{
- $config[$captcha_var] = request_var($captcha_var, (int) $config[$captcha_var]);
+ $config->set($captcha_var, request_var($captcha_var, (int) $config[$captcha_var]));
}
parent::execute_demo();
$config = $config_old;
}
}
-
-?> \ No newline at end of file
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
index 2f55d15efd..26383c76a8 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
@@ -2,9 +2,8 @@
/**
*
* @package VC
-* @version $Id$
* @copyright (c) 2006, 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
*
*/
@@ -19,7 +18,7 @@ if (!defined('IN_PHPBB'))
/**
* Placeholder for autoload
*/
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
}
@@ -40,12 +39,12 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha
}
}
- function get_instance()
+ static public function get_instance()
{
return new phpbb_captcha_gd_wave();
}
- function is_available()
+ static public function is_available()
{
global $phpbb_root_path, $phpEx;
@@ -62,7 +61,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha
return can_load_dll('gd');
}
- function get_name()
+ static public function get_name()
{
return 'CAPTCHA_GD_3D';
}
@@ -79,5 +78,3 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha
trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
}
}
-
-?> \ No newline at end of file
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
index ac30ed4297..c5ef8c78b0 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
@@ -2,9 +2,8 @@
/**
*
* @package VC
-* @version $Id$
* @copyright (c) 2006, 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
*
*/
@@ -19,7 +18,7 @@ if (!defined('IN_PHPBB'))
/**
* Placeholder for autoload
*/
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
}
@@ -40,18 +39,18 @@ class phpbb_captcha_nogd extends phpbb_default_captcha
}
}
- function &get_instance()
+ static public function get_instance()
{
- $instance =& new phpbb_captcha_nogd();
+ $instance = new phpbb_captcha_nogd();
return $instance;
}
- function is_available()
+ static public function is_available()
{
return true;
}
- function get_name()
+ static public function get_name()
{
return 'CAPTCHA_NO_GD';
}
@@ -68,5 +67,3 @@ class phpbb_captcha_nogd extends phpbb_default_captcha
trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
}
}
-
-?> \ No newline at end of file
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
index 45f76bd676..ec7636f511 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
@@ -2,9 +2,8 @@
/**
*
* @package VC
-* @version $Id$
* @copyright (c) 2006, 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
*
*/
@@ -87,7 +86,7 @@ class phpbb_captcha_qa
}
$db->sql_freeresult($result);
}
-
+
// okay, if there is a confirm_id, we try to load that confirm's state. If not, we try to find one
if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer()))
{
@@ -99,9 +98,9 @@ class phpbb_captcha_qa
/**
* API function
*/
- function &get_instance()
+ static public function get_instance()
{
- $instance =& new phpbb_captcha_qa();
+ $instance = new phpbb_captcha_qa();
return $instance;
}
@@ -109,11 +108,11 @@ class phpbb_captcha_qa
/**
* See if the captcha has created its tables.
*/
- function is_installed()
+ static public function is_installed()
{
global $db, $phpbb_root_path, $phpEx;
- if (!class_exists('phpbb_db_tools'))
+ if (!class_exists('phpbb_db_tools', false))
{
include("$phpbb_root_path/includes/db/db_tools.$phpEx");
}
@@ -125,14 +124,14 @@ class phpbb_captcha_qa
/**
* API function - for the captcha to be available, it must have installed itself and there has to be at least one question in the board's default lang
*/
- function is_available()
+ static public function is_available()
{
global $config, $db, $phpbb_root_path, $phpEx, $user;
// load language file for pretty display in the ACP dropdown
$user->add_lang('captcha_qa');
- if (!phpbb_captcha_qa::is_installed())
+ if (!self::is_installed())
{
return false;
}
@@ -158,7 +157,7 @@ class phpbb_captcha_qa
/**
* API function
*/
- function get_name()
+ static public function get_name()
{
return 'CAPTCHA_QA';
}
@@ -365,12 +364,12 @@ class phpbb_captcha_qa
global $config, $db, $user;
$error = '';
-
+
if (!sizeof($this->question_ids))
{
return false;
}
-
+
if (!$this->confirm_id)
{
$error = $user->lang['CONFIRM_QUESTION_WRONG'];
@@ -379,7 +378,6 @@ class phpbb_captcha_qa
{
if ($this->check_answer())
{
- // $this->delete_code(); commented out to allow posting.php to repeat the question
$this->solved = true;
}
else
@@ -434,7 +432,7 @@ class phpbb_captcha_qa
function reselect_question()
{
global $db, $user;
-
+
if (!sizeof($this->question_ids))
{
return false;
@@ -482,8 +480,8 @@ class phpbb_captcha_qa
global $db, $user;
$sql = 'SELECT confirm_id
- FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
- WHERE
+ FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
+ WHERE
session_id = '" . $db->sql_escape($user->session_id) . "'
AND lang_iso = '" . $db->sql_escape($this->question_lang) . "'
AND confirm_type = " . $this->type;
@@ -505,7 +503,7 @@ class phpbb_captcha_qa
function load_answer()
{
global $db, $user;
-
+
if (!strlen($this->confirm_id) || !sizeof($this->question_ids))
{
return false;
@@ -567,20 +565,6 @@ class phpbb_captcha_qa
}
/**
- * API function - clean the entry
- */
- function delete_code()
- {
- global $db, $user;
-
- $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
- WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'
- AND session_id = '" . $db->sql_escape($user->session_id) . "'
- AND confirm_type = " . $this->type;
- $db->sql_query($sql);
- }
-
- /**
* API function
*/
function get_attempt_count()
@@ -628,7 +612,7 @@ class phpbb_captcha_qa
$user->add_lang('acp/board');
$user->add_lang('captcha_qa');
- if (!$this->is_installed())
+ if (!self::is_installed())
{
$this->install();
}
@@ -990,9 +974,9 @@ class phpbb_captcha_qa
return $langs;
}
-
-
-
+
+
+
/**
* See if there is a question other than the one we have
*/
@@ -1018,5 +1002,3 @@ class phpbb_captcha_qa
}
}
}
-
-?> \ No newline at end of file
diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
index 0b0270f568..83d40bbba7 100644
--- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
@@ -2,9 +2,8 @@
/**
*
* @package VC
-* @version $Id$
* @copyright (c) 2006, 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
*
*/
@@ -16,7 +15,7 @@ if (!defined('IN_PHPBB'))
exit;
}
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
// we need the classic captcha code for tracking solutions and attempts
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
@@ -41,7 +40,8 @@ class phpbb_recaptcha extends phpbb_default_captcha
// PHP4 Constructor
function phpbb_recaptcha()
{
- $this->recaptcha_server = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? $this->recaptcha_server_secure : $this->recaptcha_server;
+ global $request;
+ $this->recaptcha_server = $request->is_secure() ? $this->recaptcha_server_secure : $this->recaptcha_server;
}
function init($type)
@@ -54,13 +54,13 @@ class phpbb_recaptcha extends phpbb_default_captcha
$this->response = request_var('recaptcha_response_field', '');
}
- function &get_instance()
+ static public function get_instance()
{
- $instance =& new phpbb_recaptcha();
+ $instance = new phpbb_recaptcha();
return $instance;
}
- function is_available()
+ static public function is_available()
{
global $config, $user;
$user->add_lang('captcha_recaptcha');
@@ -75,7 +75,7 @@ class phpbb_recaptcha extends phpbb_default_captcha
return true;
}
- function get_name()
+ static public function get_name()
{
return 'CAPTCHA_RECAPTCHA';
}
@@ -163,7 +163,7 @@ class phpbb_recaptcha extends phpbb_default_captcha
'RECAPTCHA_SERVER' => $this->recaptcha_server,
'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '',
'RECAPTCHA_ERRORGET' => '',
- 'S_RECAPTCHA_AVAILABLE' => $this->is_available(),
+ 'S_RECAPTCHA_AVAILABLE' => self::is_available(),
'S_CONFIRM_CODE' => true,
'S_TYPE' => $this->type,
'L_CONFIRM_EXPLAIN' => $explain,
@@ -341,5 +341,3 @@ class phpbb_recaptcha extends phpbb_default_captcha
return $req;
}
}
-
-?> \ No newline at end of file