Exemple #1
0
/**
 * Show an error message for the connection problems.
 * It shows a complete page independent of language files or themes.
 * It is used only if there's no way to connect to the database.
 * It stops further execution of the script.
 */
function display_db_error()
{
    global $mbname, $modSettings, $maintenance;
    global $db_connection, $webmaster_email, $db_last_error, $db_error_send, $smcFunc;
    set_fatal_error_headers();
    // For our purposes, we're gonna want this on if at all possible.
    $modSettings['cache_enable'] = '1';
    if (($temp = cache_get_data('db_last_error', 600)) !== null) {
        $db_last_error = max($db_last_error, $temp);
    }
    if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) {
        // Avoid writing to the Settings.php file if at all possible; use shared memory instead.
        cache_put_data('db_last_error', time(), 600);
        if (($temp = cache_get_data('db_last_error', 600)) === null) {
            logLastDatabaseError();
        }
        // Language files aren't loaded yet :(.
        $db_error = @$smcFunc['db_error']($db_connection);
        @mail($webmaster_email, $mbname . ': SMF Database Error!', 'There has been a problem with the database!' . ($db_error == '' ? '' : "\n" . $smcFunc['db_title'] . ' reported:' . "\n" . $db_error) . "\n\n" . 'This is a notice email to let you know that SMF could not connect to the database, contact your host if this continues.');
    }
    // What to do?  Language files haven't and can't be loaded yet...
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="robots" content="noindex" />
		<title>Connection Problems</title>
	</head>
	<body>
		<h3>Connection Problems</h3>
		Sorry, SMF was unable to connect to the database.  This may be caused by the server being busy.  Please try again later.
	</body>
</html>';
    die;
}
Exemple #2
0
/**
 * Show an error message for the connection problems.
 *
 * What it does:
 * - It shows a complete page independent of language files or themes.
 * - It is used only if there's no way to connect to the database.
 * - It stops further execution of the script.
 */
function display_db_error()
{
    global $mbname, $modSettings, $maintenance;
    global $webmaster_email, $db_last_error, $db_error_send;
    $db = database();
    // Just check we're not in any buffers, just in case.
    while (@ob_get_level() > 0) {
        @ob_end_clean();
    }
    set_fatal_error_headers();
    // For our purposes, we're gonna want this on if at all possible.
    $modSettings['cache_enable'] = 1;
    if (($temp = cache_get_data('db_last_error', 600)) !== null) {
        $db_last_error = max($db_last_error, $temp);
    }
    if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) {
        cache_put_data('db_last_error', time(), 600);
        if (($temp = cache_get_data('db_last_error', 600)) === null) {
            logLastDatabaseError();
        }
        // Language files aren't loaded yet :(.
        $db_error = $db->last_error($db->connection());
        @mail($webmaster_email, $mbname . ': Database Error!', 'There has been a problem with the database!' . ($db_error == '' ? '' : "\n" . $db->db_title() . ' reported:' . "\n" . $db_error) . "\n\n" . 'This is a notice email to let you know that the system could not connect to the database, contact your host if this continues.');
    }
    // What to do?  Language files haven't and can't be loaded yet...
    echo '<!DOCTYPE html>
<html>
	<head>
		<meta name="robots" content="noindex" />
		<title>Connection Problems</title>
	</head>
	<body>
		<h3>Connection Problems</h3>
		Sorry, we were unable to connect to the database.  This may be caused by the server being busy.  Please try again later.
	</body>
</html>';
    die;
}