/** * Error and message handler, call with trigger_error if reqd. * Mostly borrowed from phpBB includes/functions.php. */ public static function msg_handler($errno, $msg_text, $errfile, $errline) { global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text, $quickinstall_path; global $user; // Do not display notices if we suppress them via @ if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) { return; } // Message handler is stripping text. In case we need it, we are possible to define long text... if (isset($msg_long_text) && $msg_long_text && !$msg_text) { $msg_text = $msg_long_text; } if (!defined('E_DEPRECATED')) { define('E_DEPRECATED', 8192); } switch ($errno) { case E_NOTICE: case E_WARNING: // Check the error reporting level and return if the error level does not match // If DEBUG is defined the default level is E_ALL if (($errno & (defined('DEBUG') ? E_ALL : error_reporting())) == 0) { return; } // remove complete path to installation, with the risk of changing backslashes meant to be there $errfile = str_replace(array(phpbb_functions::phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile); $msg_text = str_replace(array(phpbb_functions::phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); $error_name = $errno === E_WARNING ? 'PHP Warning' : 'PHP Notice'; echo '<b>[QI Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n"; return; break; case E_USER_ERROR: case E_USER_WARNING: case E_USER_NOTICE: if (!empty($user) && !empty($user->lang)) { $msg_text = !empty($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text; $msg_title = !isset($msg_title) ? $user->lang['GENERAL_ERROR'] : (!empty($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title); $l_return_index = sprintf($user->lang['GO_QI_MAIN'], '<a href="' . qi::url('main') . '">', '</a> • '); $l_return_index .= sprintf($user->lang['GO_QI_SETTINGS'], '<a href="' . qi::url('settings') . '">', '</a>'); } else { $msg_title = 'General Error'; $l_return_index = '<a href="' . qi::url('main') . '">Go to QuickInstall main page</a> • '; $l_return_index .= '<a href="' . qi::url('settings') . '">Go to settings</a> • '; } $backtrace = phpbb_functions::get_backtrace(); if ($backtrace) { $msg_text .= '<br /><br />BACKTRACE<br />' . $backtrace; } phpbb_functions::send_status_line(503, 'Service Unavailable'); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">'; echo '<head>'; echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'; echo '<title>' . $msg_title . '</title>'; echo '<link href="' . $quickinstall_path . 'style/style.css" rel="stylesheet" type="text/css" media="screen" />'; echo '</head>'; echo '<body id="errorpage">'; echo '<div id="wrap">'; echo ' <div id="page-header">'; echo ' ' . $l_return_index; echo ' </div>'; echo ' <div id="page-body">'; echo ' <div id="acp">'; echo ' <div class="panel">'; echo ' <span class="corners-top"><span></span></span>'; echo ' <div id="content">'; echo ' <h1>' . $msg_title . '</h1>'; echo ' <div>' . $msg_text . '</div>'; echo ' </div>'; echo ' <div style="padding-left: 10px;">'; echo ' ' . $l_return_index; echo ' </div>'; echo ' <span class="corners-bottom"><span></span></span>'; echo ' </div>'; echo ' </div>'; echo ' </div>'; echo ' <div id="page-footer">'; echo ' <a href="https://www.phpbb.com/customise/db/official_tool/phpbb3_quickinstall/">phpBB QuickInstall</a> {QI_VERSION} for phpBB 3.0, 3.1 and 3.2 © <a href="https://www.phpbb.com/">phpBB Limited</a><br />'; echo ' Powered by phpBB® Forum Software © <a href="https://www.phpbb.com/">phpBB Limited</a>'; echo ' </div>'; echo '</div>'; echo '</body>'; echo '</html>'; // As a pre-caution... some setups display a blank page if the flush() is not there. ob_get_level() > 0 ? @ob_flush() : @flush(); // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here. exit; break; } // If we notice an error not handled here we pass this back to PHP by returning false // This may not work for all php versions return false; }
function gen_error_msg($msg_text, $msg_title = 'General error', $msg_explain = '', $update_profiles = false) { global $quickinstall_path, $user; $settings_url = qi::url('settings'); if ($update_profiles) { $settings_form = '<div style="margin: 10px 0 0 0; text-align: center;"><p><form action="" method="post"><input class="button2" type="submit" name="update_all" value="' . $user->lang['UPDATE_PROFILES'] . '" /></form></p></div>'; } else { $settings_form = ''; } if (!empty($user) && !empty($user->lang)) { $l_return_index = sprintf($user->lang['GO_QI_MAIN'], '<a href="' . qi::url('main') . '">', '</a> • '); $l_return_index .= sprintf($user->lang['GO_QI_SETTINGS'], '<a href="' . qi::url('settings') . '">', '</a>'); } else { $l_return_index = '<a href="' . qi::url('main') . '">Go to QuickInstall main page</a> • '; $l_return_index .= '<a href="' . qi::url('settings') . '">Go to settings</a> • '; } $qi_version = QI_VERSION; phpbb_functions::send_status_line(503, 'Service Unavailable'); echo <<<ERROR_PAGE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> \t<head> \t\t<meta http-equiv="content-type" content="text/html; charset=utf-8" /> \t\t<title>{$msg_title}</title> \t\t<link href="{$quickinstall_path}style/style.css" rel="stylesheet" type="text/css" media="screen" /> \t</head> \t<body id="errorpage"> \t\t<div id="wrap"> \t\t\t<div id="page-header"> \t\t\t\t{$l_return_index} \t\t\t</div> \t\t\t<div id="page-body"> \t\t\t\t<div id="acp"> \t\t\t\t\t<div class="panel"> \t\t\t\t\t\t<span class="corners-top"><span></span></span> \t\t\t\t\t\t<div id="content"> \t\t\t\t\t\t\t<h1 style="margin-bottom: 10px; text-align: center;">{$msg_title}</h1> \t\t\t\t\t\t\t<div style="font-weight: bold;">{$msg_explain}<br /><br /></div> \t\t\t\t\t\t\t<div>{$msg_text}</div> \t\t\t\t\t\t{$settings_form} \t\t\t\t\t\t</div> \t\t\t\t\t\t<div style="padding-left: 10px;"> \t\t\t\t\t\t\t{$l_return_index} \t\t\t\t\t\t</div> \t\t\t\t\t\t<span class="corners-bottom"><span></span></span> \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t</div> \t\t\t<div id="page-footer"> \t\t\t\t<a href="https://www.phpbb.com/customise/db/official_tool/phpbb3_quickinstall/">phpBB QuickInstall</a> {$qi_version} for phpBB 3.0, 3.1 and 3.2 © <a href="https://www.phpbb.com/">phpBB Limited</a><br /> \t\t\t\tPowered by phpBB® Forum Software © <a href="https://www.phpbb.com/">phpBB Limited</a> \t\t\t</div> \t\t</div> \t</body> </html> ERROR_PAGE; exit; }