aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-07-03 22:53:31 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-07-03 22:53:31 +0000
commit9c235fca0e22bfcc99a82c346f3da5c4ed6535ad (patch)
tree876482e24fec37b445458808309b8a02c1431921
parentbed1d3ab9adadeea484384b38849ec568ef5d4ed (diff)
downloadforums-9c235fca0e22bfcc99a82c346f3da5c4ed6535ad.tar
forums-9c235fca0e22bfcc99a82c346f3da5c4ed6535ad.tar.gz
forums-9c235fca0e22bfcc99a82c346f3da5c4ed6535ad.tar.bz2
forums-9c235fca0e22bfcc99a82c346f3da5c4ed6535ad.tar.xz
forums-9c235fca0e22bfcc99a82c346f3da5c4ed6535ad.zip
Updates related to message.php
git-svn-id: file:///svn/phpbb/trunk@548 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/includes/message.php64
-rw-r--r--phpBB/includes/sessions.php104
-rw-r--r--phpBB/viewforum.php22
-rw-r--r--phpBB/viewtopic.php61
4 files changed, 75 insertions, 176 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'] = "";
}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index cd8e3e37a4..97c9d885d4 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -62,12 +62,12 @@ if(isset($forum_id))
}
else
{
- error_die(GENERAL_ERROR, "You have reached this page in error, please go back and try again");
+ message_die(GENERAL_MESSAGE, "You have reached this page in error, please go back and try again");
}
if(!$result = $db->sql_query($sql))
{
- error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't obtain forums information.", "", __LINE__, __FILE__, $sql);
}
//
@@ -76,14 +76,9 @@ if(!$result = $db->sql_query($sql))
//
if(!$total_rows = $db->sql_numrows($result))
{
- error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again.");
+ message_die(GENERAL_MESSAGE, "The forum you selected does not exist, please go back and try again.");
}
-
$forum_row = $db->sql_fetchrow($result);
-if(!$forum_row)
-{
- error_die(SQL_QUERY, "Couldn't obtain rowset.", __LINE__, __FILE__);
-}
//
// Start auth check
@@ -128,7 +123,6 @@ if(empty($HTTP_POST_VARS['postdays']))
$topics_count = $forum_row['forum_topics'];
}
-
//
// Obtain list of moderators of this forum
//
@@ -140,7 +134,7 @@ $sql = "SELECT u.username, u.user_id
AND u.user_id = ug.user_id";
if(!$result_mods = $db->sql_query($sql))
{
- error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't obtain forums information.", "", __LINE__, __FILE__, $sql);
}
$total_mods = $db->sql_numrows($result_mods);
if($total_mods)
@@ -183,7 +177,7 @@ if(!empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']))
if(!$result = $db->sql_query($sql))
{
- error_die(SQL_QUERY, "Couldn't obtain limited topics count information.", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't obtain limited topics count information", "", __LINE__, __FILE__, $sql);
}
$topics_count = $db->sql_fetchfield("forum_topics", -1, $result);
@@ -225,7 +219,7 @@ $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as i
if(!$t_result = $db->sql_query($sql))
{
- error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
}
$total_topics = $db->sql_numrows($t_result);
@@ -444,9 +438,9 @@ else
// at some future point when if...else
// constructs are available
//
- message_die(NO_POSTS);
+ message_die(GENERAL_MESSAGE, $lang['No_topics_post_one']);
}
include('includes/page_tail.'.$phpEx);
-?>
+?> \ No newline at end of file
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 51cb796bce..cccd881a9d 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -151,40 +151,12 @@ else
if(!$result = $db->sql_query($sql))
{
- if(DEBUG)
- {
- $dberror = $db->sql_error();
- message_die(SQL_QUERY, "Couldn't obtain topic information<br><br><b>DEBUG INFO</b><br><br>Reason : " . $dberror['message'] . "<br>Query : $sql<br>File : " . __FILE__ . "<br>Line : " . __LINE__ . "<br>", "");
- }
- else
- {
- message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist']);
- }
+ message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist'], "", __LINE__, __FILE__, $sql);
}
if(!$total_rows = $db->sql_numrows($result))
{
- //
- // This should be considered temporary since
- // it should be moved to the templating file
- // when if...else constructs become available
- //
-/* if(isset($HTTP_GET_VARS['view']))
- {
- error_die(GENERAL_ERROR, $l_nomoretopics);
- }
- else
- { */
- if(DEBUG)
- {
- $error = $db->sql_error();
- message_die(GENERAL_ERROR, "The forum/topic you selected does not exist<br><br><b><u>DEBUG INFO</u></b><br><br>Reason : " . $error['message'] . "<br><br>Query : $sql<br><br>File : " . __FILE__ . "<br><br>Line : " . __LINE__ . "<br>", "");
- }
- else
- {
- message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist']);
- }
-// }
+ message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist'], "", __LINE__, __FILE__, $sql);
}
$forum_row = $db->sql_fetchrowset($result);
$forum_name = stripslashes($forum_row[0]['forum_name']);
@@ -307,7 +279,7 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website,
LIMIT $start, ".$board_config['posts_per_page'];
if(!$result = $db->sql_query($sql))
{
- message_die(SQL_QUERY, "Couldn't obtain post/user information.", "", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't obtain post/user information.", "", __LINE__, __FILE__, $sql);
}
if(!$total_posts = $db->sql_numrows($result))
{
@@ -316,14 +288,14 @@ if(!$total_posts = $db->sql_numrows($result))
// will appear in the templates file at some
// point
//
- message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__, $sql);
}
$sql = "SELECT *
FROM ".RANKS_TABLE."
ORDER BY rank_min";
if(!$ranks_result = $db->sql_query($sql))
{
- message_die(SQL_QUERY, "Couldn't obtain ranks information.", "", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't obtain ranks information.", "", __LINE__, __FILE__, $sql);
}
$postrow = $db->sql_fetchrowset($result);
$ranksrow = $db->sql_fetchrowset($ranksresult);
@@ -385,7 +357,7 @@ $sql = "UPDATE ".TOPICS_TABLE."
WHERE topic_id = $topic_id";
if(!$update_result = $db->sql_query($sql))
{
- message_die(SQL_QUERY, "Couldn't update topic views.", "", __LINE__, __FILE__);
+ message_die(GENERAL_ERROR, "Couldn't update topic views.", "", __LINE__, __FILE__, $sql);
}
//
@@ -399,15 +371,15 @@ for($x = 0; $x < $total_posts; $x++)
$post_date = create_date($board_config['default_dateformat'], $postrow[$x]['post_time'], $board_config['default_timezone']);
- $poster_posts = $postrow[$x]['user_posts'];
+ $poster_posts = ($postrow[$x]['user_id'] != ANONYMOUS) ? $lang['Posts'] . ": " . $postrow[$x]['user_posts'] : "";
- $poster_from = ($postrow[$x]['user_from']) ? "$l_from: ".$postrow[$x]['user_from'] : "";
+ $poster_from = ($postrow[$x]['user_from'] && $postrow[$x]['user_id'] != ANONYMOUS) ? $lang['From'] . ": " .$postrow[$x]['user_from'] : "";
- $poster_joined = create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']);
+ $poster_joined = ($postrow[$x]['user_id'] != ANONYMOUS) ? $lang['Joined'] . ": " . create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']) : "";
$poster_avatar = ($postrow[$x]['user_avatar'] != "" && $userdata['user_id'] != ANONYMOUS) ? "<img src=\"".$board_config['avatar_path']."/".$postrow[$x]['user_avatar']."\">" : "";
- if($postrow[$x]['user_rank'] == '')
+ if(empty($postrow[$x]['user_rank']) && $postrow[$x]['user_id'] != ANONYMOUS)
{
for($i = 0; $i < count($ranksrow); $i++)
{
@@ -418,14 +390,17 @@ for($x = 0; $x < $total_posts; $x++)
}
}
}
- else
+ else
{
- for($i = 0; $i < count($ranksrow); $i++)
+ if(!empty($postrow[$x]['user_rank']))
{
- if($postrow[$x]['user_rank'] == $ranksrow[$i]['rank_special'])
+ for($i = 0; $i < count($ranksrow); $i++)
{
- $poster_rank = $ranksrow[$i]['rank_title'];
- $rank_image = ($ranksrow[$i]['rank_image']) ? "<img src=\"".$ranksrow[$i]['rank_image']."\">" : "";
+ if($postrow[$x]['user_rank'] == $ranksrow[$i]['rank_special'])
+ {
+ $poster_rank = $ranksrow[$i]['rank_title'];
+ $rank_image = ($ranksrow[$i]['rank_image']) ? "<img src=\"".$ranksrow[$i]['rank_image']."\">" : "";
+ }
}
}
}