aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php127
1 files changed, 122 insertions, 5 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 396267432a..38f910974a 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -202,7 +202,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false)
function gen_rand_string($num_chars = 8)
{
$rand_str = unique_id();
- $rand_str = str_replace('0', 'Z', strtoupper(base_convert($rand_str, 16, 35)));
+ $rand_str = str_replace(array('0', 'O'), array('Z', 'Y'), strtoupper(base_convert($rand_str, 16, 34)));
return substr($rand_str, 0, $num_chars);
}
@@ -556,11 +556,11 @@ function _hash_crypt_private($password, $setting, &$itoa64)
*
* @param string $email Email address
*
-* @return string Big Integer
+* @return string Unsigned Big Integer
*/
function phpbb_email_hash($email)
{
- return crc32(strtolower($email)) . strlen($email);
+ return sprintf('%u', crc32(strtolower($email))) . strlen($email);
}
/**
@@ -2336,6 +2336,19 @@ function redirect($url, $return = false, $disable_cd_check = false)
// Relative uri
$pathinfo = pathinfo($url);
+ if (!$disable_cd_check && !file_exists($pathinfo['dirname']))
+ {
+ $url = str_replace('../', '', $url);
+ $pathinfo = pathinfo($url);
+
+ if (!file_exists($pathinfo['dirname']))
+ {
+ // fallback to "last known user page"
+ $url = generate_board_url() . '/' . $user->page['page'];
+ break;
+ }
+ }
+
// Is the uri pointing to the current directory?
if ($pathinfo['dirname'] == '.')
{
@@ -3531,7 +3544,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
}
}
- if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT'))
+ if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db))
{
// let's avoid loops
$db->sql_return_on_error(true);
@@ -3921,6 +3934,108 @@ function phpbb_optionset($bit, $set, $data)
}
/**
+* Login using http authenticate.
+*
+* @param array $param Parameter array, see $param_defaults array.
+*
+* @return void
+*/
+function phpbb_http_login($param)
+{
+ global $auth, $user;
+ 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 (isset($_SERVER[$k]))
+ {
+ $username = $_SERVER[$k];
+ break;
+ }
+ }
+
+ $password = null;
+ foreach ($password_keys as $k)
+ {
+ if (isset($_SERVER[$k]))
+ {
+ $password = $_SERVER[$k];
+ 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)
+ {
+ header('HTTP/1.0 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'] . '"');
+ header('HTTP/1.0 401 Unauthorized');
+
+ trigger_error('NOT_AUTHORISED');
+}
+
+/**
* Generate page header
*/
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
@@ -4139,8 +4254,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))),
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
+ 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false,
'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false,
- 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false,
+ 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_topics_new']) ? true : false,
+ 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false,
'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false,
'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme',