diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/message.php | 64 | ||||
-rw-r--r-- | phpBB/includes/sessions.php | 104 |
2 files changed, 49 insertions, 119 deletions
diff --git a/phpBB/includes/message.php b/phpBB/includes/message.php index 58a0df3db1..afb915dd29 100644 --- a/phpBB/includes/message.php +++ b/phpBB/includes/message.php @@ -22,11 +22,12 @@ * ***************************************************************************/ -function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", $err_file = "") +function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", $err_file = "", $sql = "") { global $db, $template, $board_config, $theme, $lang, $phpEx; global $userdata, $user_ip, $session_length; + global $starttime; if(empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) ) { @@ -58,7 +59,10 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", { $theme = setuptheme(1); } - include('includes/page_header.'.$phpEx); + if($msg_code != CRITICAL_ERROR) + { + include('includes/page_header.'.$phpEx); + } } switch($msg_code) @@ -70,27 +74,14 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", } break; - case BANNED: - $msg_title = $lang['Information']; - $msg_text = $lang['You_been_banned']; - break; - - case NO_POSTS: - $msg_title = $lang['Information']; - $msg_text = $lang['No_topics_post_one']; - break; - - case LOGIN_FAILED: - $msg_title = $lang['Information']; - $msg_text = $lang['Error_login']; + case CRITICAL_MESSAGE: + if($msg_title == "") + { + $msg_title = $lang['Critical_Information']; + } break; - case SQL_CONNECT: - $msg_title = $lang['General_Error']; - $msg_text = $lang['Error_database_connect']; - break; - - case SQL_QUERY: + case GENERAL_ERROR: if($msg_text == "") { $msg_text = $lang['An_error_occured']; @@ -99,29 +90,38 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", { $msg_title = $lang['General_Error']; } - break; - - case SESSION_CREATE: - $msg_title = $lang['General_Error']; - $msg_text = $lang['Error_session']; - break; - case GENERAL_ERROR: + case CRITICAL_ERROR: if($msg_text == "") { - $msg_text = $lang['An_error_occured']; + $msg_text = $lang['A_critical_error']; } if($msg_title == "") { - $msg_title = $lang['General_Error']; + $msg_title = $lang['Critical_Error']; } break; } - if(DEBUG) + if(DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) ) { + $sql_error = $db->sql_error(); + + $debug_text = ""; + if($sql_error['message'] != "") + { + $debug_text .= "<br /><br />SQL Error : " . $sql_error['code'] . " " . $sql_error['message']; + } + if($sql != "") + { + $debug_text .= "<br /><br />$sql"; + } if($err_line != "" && $err_file != "") { - $msg_text .= "<br /><br /><u>DEBUG INFO</u></br /><br>Line : " . $err_line . "<br />File : " . $err_file; + $debug_text .= "</br /><br />Line : " . $err_line . "<br />File : " . $err_file; + } + if($debug_text != "") + { + $msg_text = $msg_text . "<br /><br /><b><u>DEBUG MODE</u></b>" . $debug_text; } } diff --git a/phpBB/includes/sessions.php b/phpBB/includes/sessions.php index 92e0e50f20..336e5ecebe 100644 --- a/phpBB/includes/sessions.php +++ b/phpBB/includes/sessions.php @@ -30,7 +30,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0, $autologin = 0) { - global $db; + global $db, $lang; global $cookiename, $cookiedomain, $cookiepath, $cookiesecure, $cookielife; global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID; @@ -57,7 +57,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0 $result = $db->sql_query($sql); if (!$result) { - error_die(SQL_QUERY, "Couldn't obtain ban information.", __LINE__, __FILE__); + message_die(CRITICAL_ERROR, "Couldn't obtain ban information.", __LINE__, __FILE__, $sql); } $ban_info = $db->sql_fetchrow($result); @@ -67,7 +67,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0 // if($ban_info['ban_ip'] || $ban_info['ban_userid']) { - error_die(AUTH_BANNED); + message_die(CRITICAL_MESSAGE, $lang['You_been_banned']); } else { @@ -106,8 +106,8 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0 if(!$result || !$db->sql_affectedrows()) { mt_srand( (double) microtime() * 1000000); -// $session_id = md5(mt_rand(uniqid)); // This is a superior but more intensive creation method - $session_id = mt_rand(); + $session_id = md5(mt_rand()); // This is a superior but more intensive creation method +// $session_id = mt_rand(); $sql_insert = "INSERT INTO ".SESSIONS_TABLE." (session_id, session_user_id, session_start, session_time, session_last_visit, session_ip, session_page, session_logged_in) @@ -116,14 +116,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0 $result = $db->sql_query($sql_insert); if(!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error creating new session : session_begin", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error creating new session : session_begin", __LINE__, __FILE__, $sql); } $sessiondata['sessionid'] = $session_id; @@ -143,14 +136,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0 $result = $db->sql_query($sql_auto); if(!$result) { - if(DEBUG) - { - error_die(GENERAL_ERROR, "Couldn't update users autologin key : session_begin", __LINE__, __FILE__); - } - else - { - error_die(SQL_QUERY, "Error creating new session", __LINE__ , __FILE__); - } + message_die(CRITICAL_ERROR, "Couldn't update users autologin key : session_begin", __LINE__, __FILE__, $sql); } $sessiondata['autologinid'] = $autologin_key; } @@ -175,7 +161,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0 // function session_pagestart($user_ip, $thispage_id, $session_length) { - global $db; + global $db, $lang; global $cookiename, $cookiedomain, $cookiepath, $cookiesecure, $cookielife; global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID; @@ -201,14 +187,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) $result = $db->sql_query($sql); if(!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error clearing sessions table : session_pagestart", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error clearing sessions table : session_pagestart", __LINE__, __FILE__, $sql); } // @@ -236,14 +215,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) $result = $db->sql_query($sql); if (!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error doing DB query userdata row fetch : session_pagestart", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch : session_pagestart", __LINE__, __FILE__, $sql); } $userdata = $db->sql_fetchrow($result); @@ -269,14 +241,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) $result = $db->sql_query($sql); if(!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error updating sessions table : session_pagestart", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error updating sessions table : session_pagestart", __LINE__, __FILE__, $sql); } else { @@ -319,14 +284,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) $result = $db->sql_query($sql); if (!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error doing DB query userdata row fetch (non-session) : session_pagestart", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch (non-session) : session_pagestart", __LINE__, __FILE__, $sql); } $userdata = $db->sql_fetchrow($result); @@ -357,14 +315,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) $result_id = session_begin($user_id, $user_ip, $thispage_id, $session_length, $login, $autologin); if(!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error creating ".$userdata['user_id']." session : session_pagestart", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error creating user session : session_pagestart", __LINE__, __FILE__, $sql); } else { @@ -376,14 +327,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) $result = $db->sql_query($sql); if (!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Error doing DB query userdata row fetch : session_pagestart new user", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch : session_pagestart new user", __LINE__, __FILE__, $sql); } $userdata = $db->sql_fetchrow($result); @@ -401,7 +345,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length) function session_end($session_id, $user_id) { - global $db; + global $db, $lang; global $cookiename, $cookiedomain, $cookiepath, $cookiesecure, $cookielife; global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID; @@ -424,14 +368,7 @@ function session_end($session_id, $user_id) $result = $db->sql_query($sql, $db); if (!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Couldn't delete user session : session_end", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Couldn't delete user session : session_end", __LINE__, __FILE__, $sql); } if($sessiondata['autologinid']) @@ -442,14 +379,7 @@ function session_end($session_id, $user_id) $result = $db->sql_query($sql, $db); if (!$result) { - if(DEBUG) - { - error_die(SQL_QUERY, "Couldn't reset user autologin key : session_end", __LINE__, __FILE__); - } - else - { - error_die(SESSION_CREATE); - } + message_die(CRITICAL_ERROR, "Couldn't reset user autologin key : session_end", __LINE__, __FILE__, $sql); } $sessiondata['autologinid'] = ""; } |