aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/captcha
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-02-22 15:29:18 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-02-22 15:29:18 +0000
commit794c5749696c9fa2595ed3a1d7c836a0d984e11c (patch)
tree37aab2f0f965ddcaeb1d26af753095f59a6e025c /phpBB/includes/captcha
parent7aced345c5a2871f6eddfe316297b4ff9a0ebb76 (diff)
downloadforums-794c5749696c9fa2595ed3a1d7c836a0d984e11c.tar
forums-794c5749696c9fa2595ed3a1d7c836a0d984e11c.tar.gz
forums-794c5749696c9fa2595ed3a1d7c836a0d984e11c.tar.bz2
forums-794c5749696c9fa2595ed3a1d7c836a0d984e11c.tar.xz
forums-794c5749696c9fa2595ed3a1d7c836a0d984e11c.zip
remove global and change $user-> to phpbb::$user->
git-svn-id: file:///svn/phpbb/trunk@9334 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/captcha')
-rw-r--r--phpBB/includes/captcha/plugins/captcha_abstract.php39
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php6
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php4
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php6
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php25
5 files changed, 20 insertions, 60 deletions
diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php
index 7cc3bf8abb..adbb06e7db 100644
--- a/phpBB/includes/captcha/plugins/captcha_abstract.php
+++ b/phpBB/includes/captcha/plugins/captcha_abstract.php
@@ -32,8 +32,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function init($type)
{
- global $db, $user;
-
// read input
$this->confirm_id = request_var('confirm_id', '');
$this->confirm_code = request_var('confirm_code', '');
@@ -48,8 +46,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function execute_demo()
{
- global $user;
-
$this->code = gen_rand_string(mt_rand(5, 8));
$this->seed = hexdec(substr(unique_id(), 4, 10));
@@ -76,8 +72,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function get_template()
{
- global $user, $template;
-
$template->set_filenames(array(
'captcha' => 'captcha_default.html')
);
@@ -92,8 +86,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function get_demo_template($id)
{
- global $user, $template;
-
$template->set_filenames(array(
'captcha_demo' => 'captcha_default_acp_demo.html')
);
@@ -121,8 +113,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
static function garbage_collect($type)
{
- global $db;
-
$sql = 'SELECT DISTINCT c.session_id
FROM ' . CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
@@ -161,13 +151,11 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function validate()
{
- global $db, $user;
-
$this->confirm_code = request_var('confirm_code', '');
if (!$this->confirm_id)
{
- $error = $user->lang['CONFIRM_CODE_WRONG'];
+ $error = phpbb::$user->lang['CONFIRM_CODE_WRONG'];
}
else
{
@@ -178,7 +166,7 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
}
else
{
- $error = $user->lang['CONFIRM_CODE_WRONG'];
+ $error = phpbb::$user->lang['CONFIRM_CODE_WRONG'];
}
}
@@ -200,10 +188,8 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
*/
protected function generate_code()
{
- global $db, $user;
-
$this->code = gen_rand_string(mt_rand(5, 8));
- $this->confirm_id = md5(unique_id($user->ip));
+ $this->confirm_id = md5(unique_id(phpbb::$user->ip));
$this->seed = hexdec(substr(unique_id(), 4, 10));
$this->solved = false;
// compute $seed % 0x7fffffff
@@ -211,7 +197,7 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'confirm_id' => (string) $this->confirm_id,
- 'session_id' => (string) $user->session_id,
+ 'session_id' => (string) phpbb::$user->session_id,
'confirm_type' => (int) $this->type,
'code' => (string) $this->code,
'seed' => (int) $this->seed)
@@ -224,11 +210,10 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
*/
protected function load_code()
{
- global $db, $user;
$sql = 'SELECT code, seed
FROM ' . CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
- AND session_id = '" . $db->sql_escape($user->session_id) . "'
+ AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
@@ -245,8 +230,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
protected function check_code()
{
- global $db;
-
if (empty($this->code))
{
if (!$this->load_code())
@@ -259,22 +242,18 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
protected function delete_code()
{
- global $db, $user;
-
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
- AND session_id = '" . $db->sql_escape($user->session_id) . "'
+ AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type;
$db->sql_query($sql);
}
function get_attempt_count()
{
- global $db, $user;
-
$sql = 'SELECT COUNT(session_id) AS attempts
FROM ' . CONFIRM_TABLE . "
- WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
+ WHERE session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type;
$result = $db->sql_query($sql);
$attempts = (int) $db->sql_fetchfield('attempts');
@@ -286,10 +265,8 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function reset()
{
- global $db, $user;
-
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
- WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
+ WHERE session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . (int) $this->type;
$db->sql_query($sql);
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
index 8711c9bb14..bb4d550903 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
@@ -50,8 +50,6 @@ class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_pl
function acp_page($id, &$module)
{
- global $db, $template, $user;
-
$captcha_vars = array(
'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID',
'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID',
@@ -77,11 +75,11 @@ class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_pl
set_config($captcha_var, $value);
}
}
- trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
+ trigger_error(phpbb::$user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
}
else if ($submit)
{
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
+ trigger_error(phpbb::$user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
}
else
{
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 6b1629f8ad..1dbebcdbd6 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
@@ -50,9 +50,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha implements phpbb_captc
function acp_page($id, &$module)
{
- global $db, $template, $user;
-
- trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
+ trigger_error(phpbb::$user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
}
}
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
index ac09e4f3c7..f76c42338e 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
@@ -37,8 +37,6 @@ class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_
static function get_name()
{
- global $user;
-
return 'CAPTCHA_NO_GD';
}
@@ -50,9 +48,7 @@ class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_
function acp_page($id, &$module)
{
- global $user;
-
- trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
+ trigger_error(phpbb::$user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
}
}
diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
index ddb52ba8e8..e70500e797 100644
--- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
@@ -2,7 +2,7 @@
/**
*
* @package VC
-* @version $Id: constants.php 8818 2008-09-04 14:06:43Z acydburn $
+* @version $Id$
* @copyright (c) 2006 2008 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
@@ -28,9 +28,7 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
function init($type)
{
- global $db, $user;
-
- $user->add_lang('recaptcha');
+ phpbb::$user->add_lang('recaptcha');
parent::init($type);
$this->challenge = request_var('recaptcha_challenge_field', '');
@@ -44,8 +42,7 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
static function is_available()
{
- global $user;
- $user->add_lang('recaptcha');
+ phpbb::$user->add_lang('recaptcha');
return (isset(phpbb::$config['recaptcha_pubkey']) && !empty(phpbb::$config['recaptcha_pubkey']));
}
@@ -61,8 +58,6 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
function acp_page($id, &$module)
{
- global $db, $template, $user;
-
$captcha_vars = array(
'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY',
'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY',
@@ -86,11 +81,11 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
set_config($captcha_var, $value);
}
}
- trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
+ trigger_error(phpbb::$user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
}
else if ($submit)
{
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
+ trigger_error(phpbb::$user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
}
else
{
@@ -122,8 +117,6 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
function get_template()
{
- global $user, $template;
-
$template->set_filenames(array(
'captcha' => 'captcha_recaptcha.html')
);
@@ -260,17 +253,15 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
*/
protected function recaptcha_check_answer($extra_params = array())
{
- global $user;
-
// discard spam submissions
if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0)
{
- return $user->lang['RECAPTCHA_INCORRECT'];
+ return phpbb::$user->lang['RECAPTCHA_INCORRECT'];
}
$response = $this->_recaptcha_http_post(self::recaptcha_verify_server, '/verify', array(
'privatekey' => phpbb::$config['recaptcha_privkey'],
- 'remoteip' => $user->ip,
+ 'remoteip' => phpbb::$user->ip,
'challenge' => $this->challenge,
'response' => $this->response,
) + $extra_params
@@ -287,7 +278,7 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
{
if ($answers[1] === 'incorrect-captcha-sol')
{
- return $user->lang['RECAPTCHA_INCORRECT'];
+ return phpbb::$user->lang['RECAPTCHA_INCORRECT'];
}
}
}