1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 08:47:45 +02:00

Updates related to message.php

git-svn-id: file:///svn/phpbb/trunk@548 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen
2001-07-03 22:53:31 +00:00
parent bed1d3ab9a
commit 9c235fca0e
4 changed files with 78 additions and 179 deletions

View File

@@ -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,41 +74,12 @@ 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'];
break;
case SQL_CONNECT:
$msg_title = $lang['General_Error'];
$msg_text = $lang['Error_database_connect'];
break;
case SQL_QUERY:
if($msg_text == "")
{
$msg_text = $lang['An_error_occured'];
}
case CRITICAL_MESSAGE:
if($msg_title == "")
{
$msg_title = $lang['General_Error'];
$msg_title = $lang['Critical_Information'];
}
break;
case SESSION_CREATE:
$msg_title = $lang['General_Error'];
$msg_text = $lang['Error_session'];
break;
case GENERAL_ERROR:
if($msg_text == "")
@@ -115,13 +90,38 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "",
{
$msg_title = $lang['General_Error'];
}
case CRITICAL_ERROR:
if($msg_text == "")
{
$msg_text = $lang['A_critical_error'];
}
if($msg_title == "")
{
$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;
}
}

View File

@@ -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'] = "";
}