mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-23 02:18:56 +00:00
[ticket/12479] Remove set_var, phpbb_email_hash, and phpbb_http_login
PHPBB-12479
This commit is contained in:
parent
f4cad55581
commit
3e0637ad2e
3 changed files with 5 additions and 136 deletions
|
@ -19,32 +19,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a variable to the given type.
|
||||
*
|
||||
* @deprecated 3.1 (To be removed 4.0.0)
|
||||
*/
|
||||
function set_var(&$result, $var, $type, $multibyte = false)
|
||||
{
|
||||
// no need for dependency injection here, if you have the object, call the method yourself!
|
||||
$type_cast_helper = new \phpbb\request\type_cast_helper();
|
||||
$type_cast_helper->set_var($result, $var, $type, $multibyte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashes an email address to a big integer
|
||||
*
|
||||
* @param string $email Email address
|
||||
*
|
||||
* @return string Unsigned Big Integer
|
||||
*
|
||||
* @deprecated 3.3.0-b2 (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_email_hash($email)
|
||||
{
|
||||
return sprintf('%u', crc32(strtolower($email))) . strlen($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the autoloaders added by the extensions.
|
||||
*
|
||||
|
@ -72,111 +46,6 @@ function phpbb_load_extensions_autoloaders($phpbb_root_path)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Login using http authenticate.
|
||||
*
|
||||
* @param array $param Parameter array, see $param_defaults array.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 3.2.10 (To be removed 4.0.0)
|
||||
*/
|
||||
function phpbb_http_login($param)
|
||||
{
|
||||
global $auth, $user, $request;
|
||||
global $config;
|
||||
|
||||
$param_defaults = array(
|
||||
'auth_message' => '',
|
||||
|
||||
'autologin' => false,
|
||||
'viewonline' => true,
|
||||
'admin' => false,
|
||||
);
|
||||
|
||||
// Overwrite default values with passed values
|
||||
$param = array_merge($param_defaults, $param);
|
||||
|
||||
// User is already logged in
|
||||
// We will not overwrite his session
|
||||
if (!empty($user->data['is_registered']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// $_SERVER keys to check
|
||||
$username_keys = array(
|
||||
'PHP_AUTH_USER',
|
||||
'Authorization',
|
||||
'REMOTE_USER', 'REDIRECT_REMOTE_USER',
|
||||
'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION',
|
||||
'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION',
|
||||
'AUTH_USER',
|
||||
);
|
||||
|
||||
$password_keys = array(
|
||||
'PHP_AUTH_PW',
|
||||
'REMOTE_PASSWORD',
|
||||
'AUTH_PASSWORD',
|
||||
);
|
||||
|
||||
$username = null;
|
||||
foreach ($username_keys as $k)
|
||||
{
|
||||
if ($request->is_set($k, \phpbb\request\request_interface::SERVER))
|
||||
{
|
||||
$username = html_entity_decode($request->server($k), ENT_COMPAT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$password = null;
|
||||
foreach ($password_keys as $k)
|
||||
{
|
||||
if ($request->is_set($k, \phpbb\request\request_interface::SERVER))
|
||||
{
|
||||
$password = html_entity_decode($request->server($k), ENT_COMPAT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Decode encoded information (IIS, CGI, FastCGI etc.)
|
||||
if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0)
|
||||
{
|
||||
list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2);
|
||||
}
|
||||
|
||||
if (!is_null($username) && !is_null($password))
|
||||
{
|
||||
set_var($username, $username, 'string', true);
|
||||
set_var($password, $password, 'string', true);
|
||||
|
||||
$auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']);
|
||||
|
||||
if ($auth_result['status'] == LOGIN_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS)
|
||||
{
|
||||
send_status_line(401, 'Unauthorized');
|
||||
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
}
|
||||
|
||||
// Prepend sitename to auth_message
|
||||
$param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message'];
|
||||
|
||||
// We should probably filter out non-ASCII characters - RFC2616
|
||||
$param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']);
|
||||
|
||||
header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"');
|
||||
send_status_line(401, 'Unauthorized');
|
||||
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts query string (GET) parameters in request into hidden fields.
|
||||
*
|
||||
|
|
|
@ -184,7 +184,7 @@ class request implements request_interface
|
|||
* @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
|
||||
* Specifies which super global should be used
|
||||
*
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link type_cast_helper_interface::set_var} to ensure that the type is the
|
||||
* the same as that of $default. If the variable is not set $default is returned.
|
||||
*/
|
||||
public function variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST)
|
||||
|
@ -208,7 +208,7 @@ class request implements request_interface
|
|||
* @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
|
||||
* Specifies which super global should be used
|
||||
*
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link type_cast_helper_interface::set_var} to ensure that the type is the
|
||||
* the same as that of $default. If the variable is not set $default is returned.
|
||||
*/
|
||||
public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST)
|
||||
|
@ -401,7 +401,7 @@ class request implements request_interface
|
|||
* Specifies which super global should be used
|
||||
* @param bool $trim Indicates whether trim() should be applied to string values.
|
||||
*
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link type_cast_helper_interface::set_var} to ensure that the type is the
|
||||
* the same as that of $default. If the variable is not set $default is returned.
|
||||
*/
|
||||
protected function _variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST, $trim = true)
|
||||
|
|
|
@ -59,7 +59,7 @@ interface request_interface
|
|||
* @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
|
||||
* Specifies which super global shall be changed
|
||||
*
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link type_cast_helper_interface::set_var} to ensure that the type is the
|
||||
* the same as that of $default. If the variable is not set $default is returned.
|
||||
*/
|
||||
public function variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST);
|
||||
|
@ -81,7 +81,7 @@ interface request_interface
|
|||
* @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
|
||||
* Specifies which super global shall be changed
|
||||
*
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link type_cast_helper_interface::set_var} to ensure that the type is the
|
||||
* the same as that of $default. If the variable is not set $default is returned.
|
||||
*/
|
||||
public function raw_variable($var_name, $default, $super_global = request_interface::REQUEST);
|
||||
|
|
Loading…
Add table
Reference in a new issue