git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8636 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2008-06-09 17:05:52 +00:00
parent bd95c0dfa7
commit 406895a1ad
5 changed files with 39 additions and 11 deletions

View file

@ -118,7 +118,8 @@
<li>[Fix] Delete drafts and bookmarks when deleting an user. (#27585, thanks Schumi for the fix)</li> <li>[Fix] Delete drafts and bookmarks when deleting an user. (#27585, thanks Schumi for the fix)</li>
<li>[Fix] Set last_post_subject for new topics. (#23945)</li> <li>[Fix] Set last_post_subject for new topics. (#23945)</li>
<li>[Fix] Allow moving posts to invisible forums. (#27325)</li> <li>[Fix] Allow moving posts to invisible forums. (#27325)</li>
<li>[Fix] Don't allow promoting unapproved group members (#16124)</li> <li>[Fix] Don't allow promoting unapproved group members (#16124)</li>
<li>[Fix] Correctly fetch server name if using non-standard port (#27395)</li>
</ul> </ul>
<a name="v300"></a><h3>1.ii. Changes since 3.0.0</h3> <a name="v300"></a><h3>1.ii. Changes since 3.0.0</h3>

View file

@ -1778,7 +1778,7 @@ function generate_board_url($without_script_path = false)
if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80))) if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80)))
{ {
// HTTP HOST can carry a port number... // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true)
if (strpos($server_name, ':') === false) if (strpos($server_name, ':') === false)
{ {
$url .= ':' . $server_port; $url .= ':' . $server_port;
@ -2054,7 +2054,7 @@ function meta_refresh($time, $url)
$template->assign_vars(array( $template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />') 'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />')
); );
return $url; return $url;
} }
@ -3118,16 +3118,16 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
function obtain_guest_count($forum_id = 0) function obtain_guest_count($forum_id = 0)
{ {
global $db, $config; global $db, $config;
if ($forum_id) if ($forum_id)
{ {
$reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id;
} }
else else
{ {
$reading_sql = ''; $reading_sql = '';
} }
$time = (time() - (intval($config['load_online_time']) * 60)); $time = (time() - (intval($config['load_online_time']) * 60));
// Get number of online guests // Get number of online guests
@ -3153,7 +3153,7 @@ function obtain_guest_count($forum_id = 0)
$result = $db->sql_query($sql, 60); $result = $db->sql_query($sql, 60);
$guests_online = (int) $db->sql_fetchfield('num_guests'); $guests_online = (int) $db->sql_fetchfield('num_guests');
$db->sql_freeresult($result); $db->sql_freeresult($result);
return $guests_online; return $guests_online;
} }
@ -3185,16 +3185,16 @@ function obtain_users_online($forum_id = 0)
{ {
$online_users['guests_online'] = obtain_guest_count($forum_id); $online_users['guests_online'] = obtain_guest_count($forum_id);
} }
// a little discrete magic to cache this for 30 seconds // a little discrete magic to cache this for 30 seconds
$time = (time() - (intval($config['load_online_time']) * 60)); $time = (time() - (intval($config['load_online_time']) * 60));
$sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline $sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline
FROM ' . SESSIONS_TABLE . ' s FROM ' . SESSIONS_TABLE . ' s
WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) .
$reading_sql . $reading_sql .
' AND s.session_user_id <> ' . ANONYMOUS; ' AND s.session_user_id <> ' . ANONYMOUS;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
@ -3215,7 +3215,7 @@ function obtain_users_online($forum_id = 0)
} }
$online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online']; $online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online'];
$db->sql_freeresult($result); $db->sql_freeresult($result);
return $online_users; return $online_users;
} }

View file

@ -161,6 +161,13 @@ class session
$this->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : ''; $this->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
$this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; $this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$this->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); $this->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
// Since HTTP_HOST may carry a port definition, we need to remove it here...
if (strpos($this->host, ':') !== false)
{
$this->host = substr($this->host, 0, strpos($this->host, ':'));
}
$this->page = $this->extract_current_page($phpbb_root_path); $this->page = $this->extract_current_page($phpbb_root_path);
// if the forwarded for header shall be checked we have to validate its contents // if the forwarded for header shall be checked we have to validate its contents
@ -1311,8 +1318,10 @@ class session
{ {
return true; return true;
} }
$host = htmlspecialchars($this->host); $host = htmlspecialchars($this->host);
$ref = substr($this->referer, strpos($this->referer, '://') + 3); $ref = substr($this->referer, strpos($this->referer, '://') + 3);
if (!(stripos($ref , $host) === 0)) if (!(stripos($ref , $host) === 0))
{ {
return false; return false;
@ -1321,15 +1330,18 @@ class session
{ {
$ref = substr($ref, strlen($host)); $ref = substr($ref, strlen($host));
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
if ($server_port !== 80 && $server_port !== 443 && stripos($ref, ":$server_port") === 0) if ($server_port !== 80 && $server_port !== 443 && stripos($ref, ":$server_port") === 0)
{ {
$ref = substr($ref, strlen(":$server_port")); $ref = substr($ref, strlen(":$server_port"));
} }
if (!(stripos(rtrim($ref, '/'), rtrim($this->page['root_script_path'], '/')) === 0)) if (!(stripos(rtrim($ref, '/'), rtrim($this->page['root_script_path'], '/')) === 0))
{ {
return false; return false;
} }
} }
return true; return true;
} }

View file

@ -25,6 +25,8 @@ $user->session_begin();
$auth->acl($user->data); $auth->acl($user->data);
$user->setup('viewforum'); $user->setup('viewforum');
echo generate_board_url();
exit;
display_forums('', $config['load_moderators']); display_forums('', $config['load_moderators']);
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data // Set some stats, get posts count from forums data if we... hum... retrieve all forums data

View file

@ -1021,6 +1021,12 @@ class install_install extends module
// HTTP_HOST is having the correct browser url in most cases... // HTTP_HOST is having the correct browser url in most cases...
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
// HTTP HOST can carry a port number...
if (strpos($server_name, ':') !== false)
{
$server_name = substr($server_name, 0, strpos($server_name, ':'));
}
$data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true; $data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true;
$data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name; $data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name;
$data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT')); $data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'));
@ -1114,6 +1120,13 @@ class install_install extends module
// HTTP_HOST is having the correct browser url in most cases... // HTTP_HOST is having the correct browser url in most cases...
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
// HTTP HOST can carry a port number...
if (strpos($server_name, ':') !== false)
{
$server_name = substr($server_name, 0, strpos($server_name, ':'));
}
$cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name; $cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name;
// Try to come up with the best solution for cookie domain... // Try to come up with the best solution for cookie domain...