aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/message.php104
1 files changed, 76 insertions, 28 deletions
diff --git a/phpBB/includes/message.php b/phpBB/includes/message.php
index afb915dd29..1a0e1126d7 100644
--- a/phpBB/includes/message.php
+++ b/phpBB/includes/message.php
@@ -22,28 +22,47 @@
*
***************************************************************************/
+//
+// This function gets called to output any message or error
+// that doesn't require additional output from the calling
+// page.
+//
+// $msg_code takes one of four constant values:
+//
+// GENERAL_MESSAGE -> Use for any simple text message, eg.
+// results of an operation, authorisation failures, etc.
+//
+// GENERAL ERROR -> Use for any error which occurs _AFTER_
+// the common.php include and session code, ie. most errors
+// in pages/functions
+//
+// CRITICAL_MESSAGE -> Only currently used to announce a user
+// has been banned, can be used where session results cannot
+// be relied upon to exist
+//
+// CRITICAL_ERROR -> Used whenever a DB connection cannot be
+// guaranteed and/or sessions have failed. Shouldn't be used
+// in general pages/functions (it results in a simple echo'd
+// statement, no templates are used)
+//
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 ) )
+ if( empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) )
{
- //
- // Start session management
- //
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
- //
- // End session management
- //
}
-
- if(!defined("HEADER_INC"))
+
+ //
+ // If the header hasn't been output then do it
+ //
+ if( !defined("HEADER_INC") && $msg_code != CRITICAL_ERROR )
{
- if(!empty($board_config['default_lang']))
+ if( !empty($board_config['default_lang']) )
{
include('language/lang_' . $board_config['default_lang'] . '.'.$phpEx);
}
@@ -51,18 +70,21 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "",
{
include('language/lang_english.'.$phpEx);
}
- if(!$template)
+
+ if( empty($template) )
{
$template = new Template("templates/Default");
}
- if(!$theme)
+
+ if( empty($theme) )
{
$theme = setuptheme(1);
}
- if($msg_code != CRITICAL_ERROR)
- {
- include('includes/page_header.'.$phpEx);
- }
+
+ //
+ // Load the Page Header
+ //
+ include('includes/page_header.'.$phpEx);
}
switch($msg_code)
@@ -86,57 +108,83 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "",
{
$msg_text = $lang['An_error_occured'];
}
+
if($msg_title == "")
{
$msg_title = $lang['General_Error'];
}
case CRITICAL_ERROR:
+ //
+ // Critical errors mean we cannot rely on _ANY_ DB information being
+ // available so we're going to dump out a simple echo'd statement
+ //
+ include('language/lang_english.'.$phpEx);
+
if($msg_text == "")
{
$msg_text = $lang['A_critical_error'];
}
+
if($msg_title == "")
{
- $msg_title = $lang['Critical_Error'];
+ $msg_title = "phpBB : <b>" . $lang['Critical_Error'] . "</b>";
}
break;
}
+
+ //
+ // Add on DEBUG info if we've enabled debug mode and this is an error. This
+ // prevents debug info being output for general messages should DEBUG be
+ // set TRUE by accident (preventing confusion for the end user!)
+ //
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 != "")
{
$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;
}
}
- $template->set_filenames(array(
- "message_body" => "message_body.tpl")
- );
- $template->assign_vars(array(
- "MESSAGE_TITLE" => $msg_title,
- "MESSAGE_TEXT" => $msg_text)
- );
- $template->pparse("message_body");
+ if( $msg_code != CRITICAL_ERROR )
+ {
+ $template->set_filenames(array(
+ "message_body" => "message_body.tpl")
+ );
+ $template->assign_vars(array(
+ "MESSAGE_TITLE" => $msg_title,
+ "MESSAGE_TEXT" => $msg_text)
+ );
+ $template->pparse("message_body");
+
+ include('includes/page_tail.'.$phpEx);
+ }
+ else
+ {
+ echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>";
+ }
- include('includes/page_tail.'.$phpEx);
+ exit;
- exit();
}
?> \ No newline at end of file