mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 13:30:25 +02:00
remove global and change $user-> to phpbb::$user->
git-svn-id: file:///svn/phpbb/trunk@9334 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user