oops, that's what you get for not testing more thoroughly ...

git-svn-id: file:///svn/phpbb/trunk@2644 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-06-22 15:17:26 +00:00
parent c3be8488ed
commit 3a233ee6bb

View file

@ -31,9 +31,7 @@ class session {
$current_time = time(); $current_time = time();
$session_browser = ( !empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : $HTTP_ENV_VARS['HTTP_USER_AGENT']; $session_browser = ( !empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : $HTTP_ENV_VARS['HTTP_USER_AGENT'];
$this_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF']; $this_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF'];
$this_query = ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? explode('&', $HTTP_SERVER_VARS['QUERY_STRING']) : explode('&', $HTTP_ENV_VARS['QUERY_STRING']); $this_page .= '&' . ( ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? $HTTP_SERVER_VARS['QUERY_STRING'] : $HTTP_ENV_VARS['QUERY_STRING'] );
array_shift($this_query);
$this_page = $this_page . '&' . implode('&', $this_query);
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data']) ) if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data']) )
{ {
@ -53,7 +51,7 @@ class session {
// //
if ( !empty($board_config['limit_load']) && file_exists('/proc/loadavg') ) if ( !empty($board_config['limit_load']) && file_exists('/proc/loadavg') )
{ {
if ( $load = file('/proc/loadvg') ) if ( $load = file('/proc/loadavg') )
{ {
$load = explode(' ', $load[0]); $load = explode(' ', $load[0]);
@ -138,19 +136,30 @@ class session {
$user_id = ( isset($sessiondata['userid']) ) ? $sessiondata['userid'] : ANONYMOUS; $user_id = ( isset($sessiondata['userid']) ) ? $sessiondata['userid'] : ANONYMOUS;
// //
// Limit 5 minute sessions // Limit connections (for MySQL) or 5 minute sessions (for other DB's)
// //
$sql = "SELECT COUNT(*) AS sessions switch ( DB_LAYER )
FROM " . SESSIONS_TABLE . " {
WHERE session_time >= " . ( $current_time - 3600 ); case 'mysql':
case 'mysql4':
$sql = "SELECT COUNT(*) AS sessions
FROM " . SESSIONS_TABLE . "
WHERE session_time >= " . ( $current_time - 3600 );
break;
default:
$sql = "SELECT COUNT(*) AS sessions
FROM " . SESSIONS_TABLE . "
WHERE session_time >= " . ( $current_time - 3600 );
break;
}
if ( !($result = $db->sql_query($sql)) ) if ( !($result = $db->sql_query($sql)) )
{ {
message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, 'Could not obtain connection information', '', __LINE__, __FILE__, $sql);
} }
$row = $db->sql_fetchrow[$result]; $row = $db->sql_fetchrow[$result];
if ( intval($board_config['active_sessions']) && $row['sessions'] >= $board_config['active_sessions'] ) if ( intval($board_config['active_sessions']) && $row['sessions'] >= intval($board_config['active_sessions']) )
{ {
message_die(GENERAL_MESSAGE, 'Board_unavailable', 'Information'); message_die(GENERAL_MESSAGE, 'Board_unavailable', 'Information');
} }
@ -179,11 +188,11 @@ class session {
$sql = "SELECT ban_ip, ban_userid, ban_email $sql = "SELECT ban_ip, ban_userid, ban_email
FROM " . BANLIST_TABLE . " FROM " . BANLIST_TABLE . "
WHERE ban_ip IN ( WHERE ban_ip IN (
'" . $user_ip_parts[1] . ".', '" . $user_ip_parts[0] . ".',
'" . $user_ip_parts[1] . "." . $user_ip_parts[2] . ".', '" . $user_ip_parts[0] . "." . $user_ip_parts[1] . ".',
'" . $user_ip_parts[1] . "." . $user_ip_parts[2] . "." . $user_ip_parts[3] . ".', '" . $user_ip_parts[0] . "." . $user_ip_parts[1] . "." . $user_ip_parts[2] . ".',
'" . $user_ip_parts[1] . "." . $user_ip_parts[2] . "." . $user_ip_parts[3] . "." . $user_ip_parts[4] . "') '" . $user_ip_parts[0] . "." . $user_ip_parts[1] . "." . $user_ip_parts[2] . "." . $user_ip_parts[3] . "')
OR ban_userid = $user_id"; OR ban_userid = " . $this->userdata['user_id'];
if ( $user_id != ANONYMOUS ) if ( $user_id != ANONYMOUS )
{ {
$sql .= " OR ban_email LIKE '" . str_replace('\\\'', '\\\'\\\'', $this->userdata['user_email']) . "' $sql .= " OR ban_email LIKE '" . str_replace('\\\'', '\\\'\\\'', $this->userdata['user_email']) . "'
@ -375,9 +384,10 @@ class session {
// //
$style = ( !$board_config['override_user_style'] && $this->userdata['user_id'] != ANONYMOUS && $this->userdata['user_style'] > 0 )? $this->userdata['user_style'] : $board_config['default_style']; $style = ( !$board_config['override_user_style'] && $this->userdata['user_id'] != ANONYMOUS && $this->userdata['user_style'] > 0 )? $this->userdata['user_style'] : $board_config['default_style'];
$sql = "SELECT * $sql = "SELECT s.style_name, s.template_name, c.css_data, c.css_extra_data
FROM " . THEMES_TABLE . " FROM " . STYLES_TABLE . " s, " . STYLES_CSS_TABLE . " c
WHERE themes_id = $style"; WHERE s.style_id = $style
AND c.theme_id = s.style_id";
if ( !($result = $db->sql_query($sql)) ) if ( !($result = $db->sql_query($sql)) )
{ {
message_die(CRITICAL_ERROR, 'Could not query database for theme info'); message_die(CRITICAL_ERROR, 'Could not query database for theme info');
@ -388,6 +398,11 @@ class session {
message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]"); message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
} }
//
// Unserialize the extra data
//
$theme['css_extra_data'] = unserialize($theme['css_extra_data']);
$template_path = 'templates/' ; $template_path = 'templates/' ;
$template_name = $theme['template_name'] ; $template_name = $theme['template_name'] ;
@ -405,7 +420,7 @@ class session {
$img_lang = ( file_exists($current_template_path . '/images/lang_' . $board_config['default_lang']) ) ? $board_config['default_lang'] : 'english'; $img_lang = ( file_exists($current_template_path . '/images/lang_' . $board_config['default_lang']) ) ? $board_config['default_lang'] : 'english';
while( list($key, $value) = @each($images) ) while ( list($key, $value) = @each($images) )
{ {
if ( !is_array($value) ) if ( !is_array($value) )
{ {
@ -433,7 +448,7 @@ class auth {
global $db; global $db;
$sql = "SELECT ag.forum_id, ag.auth_allow_deny, ao.auth_option $sql = "SELECT ag.forum_id, ag.auth_allow_deny, ao.auth_option
FROM phpbb_user_group ug, phpbb_auth_groups ag, phpbb_auth_options ao FROM " . USER_GROUP_TABLE . " ug, " . ACL_GROUPS_TABLE . " ag, " . ACL_OPTIONS_TABLE . " ao
WHERE ug.user_id = " . $userdata['user_id'] . " WHERE ug.user_id = " . $userdata['user_id'] . "
AND ag.group_id = ug.group_id AND ag.group_id = ug.group_id
AND ao.auth_option_id = ag.auth_option_id"; AND ao.auth_option_id = ag.auth_option_id";
@ -454,7 +469,7 @@ class auth {
$db->sql_freeresult($result); $db->sql_freeresult($result);
$sql = "SELECT au.forum_id, au.auth_allow_deny, ao.auth_option $sql = "SELECT au.forum_id, au.auth_allow_deny, ao.auth_option
FROM phpbb_auth_users au, phpbb_auth_options ao FROM " . ACL_USERS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao
WHERE au.user_id = " . $userdata['user_id'] . " WHERE au.user_id = " . $userdata['user_id'] . "
AND ao.auth_option_id = au.auth_option_id"; AND ao.auth_option_id = au.auth_option_id";
if ( !($result = $db->sql_query($sql)) ) if ( !($result = $db->sql_query($sql)) )
@ -566,9 +581,13 @@ class auth {
// //
// Centralised login? May stay, may not ... depends if needed // Centralised login? May stay, may not ... depends if needed
// //
function login($username, $password) function login($username, $password, $autologin = false)
{ {
global $SID, $db, $board_config, $lang, $user_ip, $phpEx; global $SID, $db, $board_config, $lang, $user_ip;
global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
$this_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF'];
$this_page .= '&' . ( ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? $HTTP_SERVER_VARS['QUERY_STRING'] : $HTTP_ENV_VARS['QUERY_STRING'] );
$result = false; $result = false;
@ -584,8 +603,8 @@ function login($username, $password)
{ {
if ( $row['user_level'] != ADMIN && $board_config['board_disable'] ) if ( $row['user_level'] != ADMIN && $board_config['board_disable'] )
{ {
header($header_location . "index.$phpEx$SID"); // header($header_location . "index.$phpEx$SID");
exit; // exit;
} }
if ( $board_config['ldap_enable'] && extension_loaded('ldap') ) if ( $board_config['ldap_enable'] && extension_loaded('ldap') )
@ -602,7 +621,7 @@ function login($username, $password)
{ {
if ( md5($password) == $row['user_password'] && $row['user_active'] ) if ( md5($password) == $row['user_password'] && $row['user_active'] )
{ {
$autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? md5($password) : ''; $autologin = ( isset($autologin) ) ? md5($password) : '';
$user_ip_parts = explode('.', $user_ip); $user_ip_parts = explode('.', $user_ip);
@ -640,7 +659,7 @@ function login($username, $password)
// Update the session // Update the session
// //
$sql = "UPDATE " . SESSIONS_TABLE . " $sql = "UPDATE " . SESSIONS_TABLE . "
SET session_user_id = " . $row['user_id'] . ", session_start = $current_time, session_time = $current_time, session_browser = '$session_browser', session_page = '' SET session_user_id = " . $row['user_id'] . ", session_start = $current_time, session_time = $current_time, session_browser = '$session_browser', session_page = '$this_page'
WHERE session_id = '" . $userdata['session_id'] . "'"; WHERE session_id = '" . $userdata['session_id'] . "'";
if ( !$db->sql_query($sql) ) if ( !$db->sql_query($sql) )
{ {
@ -662,14 +681,4 @@ function login($username, $password)
} }
//
//
// This routine is dead instead we just set a URL$SID for
// appropriate URLs rather than this append stuff
//
function append_sid($url, $non_html_amp = false)
{
return $url;
}
?> ?>