function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images;
global $userdata, $user_ip, $session_length;
global $starttime;
//-- mod : categories hierarchy ------------------------------------------------
//-- add
global $config, $user, $censored_words, $icons, $navigation, $themes, $smilies;
//-- fin mod : categories hierarchy --------------------------------------------
//-- mod : Fix message_die for multiple errors ---------------------------------
// note : this one is Markus Petrux's "Fix message_die for multiple errors" mod
//-- delete
// if(defined('HAS_DIED'))
// {
// die("message_die() was called multiple times. This isn't supposed to happen. Was message_die() used in page_tail.php?");
// }
//
// define(HAS_DIED, 1);
//-- add
static $msg_history;
if( !isset($msg_history) )
{
$msg_history = array();
}
$msg_history[] = array(
'msg_code' => $msg_code,
'msg_text' => $msg_text,
'msg_title' => $msg_title,
'err_line' => $err_line,
'err_file' => $err_file,
'sql' => $sql,
);
// already died
if ( defined('HAS_DIED') )
{
//
// This message is printed at the end of the report.
// Of course, you can change it to suit your own needs.

//
$custom_error_message = 'Please, contact the %swebmaster%s. Thank you.';
if ( !empty($config) && !empty($config->data['board_email']) )
{
$custom_error_message = sprintf($custom_error_message, '<a href="mailto:' . $config->data['board_email'] . '">', '</a>');
}
else
{
$custom_error_message = sprintf($custom_error_message, '', '');
}
echo "<html>\n<body>\n<b>Critical Error!</b><br />\nmessage_die() was called multiple times.<br /> <hr />";
for( $i = 0; $i < count($msg_history); $i++ )
{
echo '<b>Error #' . ($i+1) . "</b>\n<br />\n";
if( !empty($msg_history[$i]['msg_title']) )
{
echo '<b>' . $msg_history[$i]['msg_title'] . "</b>\n<br />\n";
}
echo $msg_history[$i]['msg_text'] . "\n<br /><br />\n";
if( !empty($msg_history[$i]['err_line']) )
{
echo '<b>Line :</b> ' . $msg_history[$i]['err_line'] . '<br /><b>File :</b> ' . $msg_history[$i]['err_file'] . "</b>\n<br />\n";
}
if( !empty($msg_history[$i]['sql']) )
{
echo '<b>SQL :</b> ' . $msg_history[$i]['sql'] . "\n<br />\n";
}
echo " <hr />\n<br />";
}
echo " <br /><hr />\n" . $custom_error_message . '<hr /><br clear="all">';
die("</body>\n</html>");
}
// let's notice an error occured
define('HAS_DIED', true);
//-- fin mod : Fix message_die for multiple errors -----------------------------
$sql_store = $sql;
//
// Get SQL error if we are debugging. Do this as soon as possible to prevent
// subsequent queries from overwriting the status of sql_error()
//
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_store != '' )
{
$debug_text .= "<br /><br />$sql_store";
}
if ( $err_line != '' && $err_file != '' )
{
$debug_text .= '</br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);
}
}
if( empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) )
{
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
}
//
// If the header hasn't been output then do it
//
if ( !defined('HEADER_INC') && $msg_code != CRITICAL_ERROR )
{
if ( empty($lang) )
{
if ( !empty($board_config['default_lang']) )
{
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx);
}
else
{
include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
}
}
if ( empty($template) )
{
//-- mod : categories hierarchy ------------------------------------------------
//-- delete
// $template = new Template($phpbb_root_path . 'templates/' . $board_config['board_template']);
//-- add
$template = new template_class($phpbb_root_path . 'templates/' . $board_config['board_template']);
//-- fin mod : categories hierarchy --------------------------------------------
}
if ( empty($theme) )
{
$theme = setup_style($board_config['default_style']);
}