-
-
Save franz-josef-kaiser/bacf75dfe94c968a9626 to your computer and use it in GitHub Desktop.
File to replace the default DB Error message »Unable to connect to database«.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Tells the Search Engine that the site is temporary unavailable. | |
* Preserves page rank and sends a mail to the owner. | |
* @TODO Fill in the mail address inside `$mail_address`. | |
* | |
* There're still some cases where this file won't get triggered. | |
* @link http://core.trac.wordpress.org/ticket/10883 | |
*/ | |
$protocol = $_SERVER["SERVER_PROTOCOL"]; | |
if ( | |
'HTTP/1.1' != $protocol | |
AND 'HTTP/1.0' != $protocol | |
) | |
$protocol = 'HTTP/1.0'; | |
header( "{$protocol} 503 Service Unavailable", true, 503 ); | |
header( 'Content-Type: text/html; charset=utf-8' ); | |
header( 'Retry-After: 600' ); | |
// Get Variables | |
$temp = mysql_error(); | |
$url = current_page_URL(); | |
// Get Page URL | |
function current_page_URL() | |
{ | |
$url = 'http'; | |
if ( function_exists( 'is_ssl()' ) ) | |
{ | |
is_ssl() AND $url .= 's'; | |
} | |
elseif ( isset( $_SERVER['HTTPS'] ) ) | |
{ | |
'on' == $_SERVER['HTTPS'] AND $url .= 's'; | |
} | |
$url .= "://{$_SERVER['SERVER_NAME']}"; | |
if ( '80' != $_SERVER['SERVER_PORT'] ) | |
return "{$url}:{$_SERVER['SERVER_PORT']}{$_SERVER['REQUEST_URI']}"; | |
return "{$url}{$_SERVER['REQUEST_URI']}"; | |
} | |
$mail_address = '24-7@gmx.net'; | |
$headers = "From: {$mail_address}\r\n"; | |
$headers .= "Reply-To: {$mail_address}\r\n"; | |
$headers .= sprintf( 'X-Mailer: PHP/%s', phpversion() ); | |
$headers .= "content-type: text/html"; | |
// Send The Alert | |
@mail( | |
$mail_address | |
,'SQL Error on the Website' | |
,sprintf( | |
'This is an automated message. There is a SQL error: %s - The affected URL is: %' | |
,$temp | |
,$url | |
) | |
,$headers | |
); | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"><![endif]--> | |
<title>The website is down</title> | |
<link href="http://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css"> | |
<style> | |
html, body { margin:0; padding:0; font-size: 100%; } | |
body { background: #073642; font-family: Verdana, sans-serif; line-height: 1.3; color: #eee8d5; } | |
#container { height: 225px; margin: 20% auto 0; width: 575px; } | |
.jAnimConsole { height: 1.2em; width: 100%; font-family: "Source Code Pro", sans-serif; color: #dc322f; } | |
.inserChar { padding: 0; margin: 0; font-size: 1em; line-height: 1; } | |
h1 { font-size: 2.5em; font-weight: normal; padding: 0 0 0 .1em; } | |
p { margin: 0 0 10px 5px; font-size: 1em; color: #2aa198; } | |
a { color: #dc322f; } | |
hr { border-color: #2aa198; } | |
h1, p, a { text-rendering: optimizeLegibility; } | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<div class="hello-container"> | |
<h1 class="jAnimConsole" data-list="Hello;Bonjour;Hola;Ciao;Hallo;Привет;您好"></h1> | |
</div> | |
<h1>We're Having Database Issues.</h1> | |
<p> | |
This may be temporary, so try again shortly. | |
<br /> | |
An email has been sent automatically to one of our staff. | |
</p> | |
<?php | |
if ( | |
defined( 'WP_ADMIN' ) | |
OR defined( 'WP_INSTALLING' ) | |
) | |
isset( $GLOBALS['wpdb'] ) AND print "<hr /><p>{$GLOBALS['wpdb']->error}</p>"; | |
?> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
( function() { | |
var | |
dataName | |
,inserChar | |
,inserClass | |
,jAnimConsole | |
,separator | |
; | |
inserChar = '∣'; | |
separator = ';'; | |
dataName = "list"; | |
inserClass = "inserChar"; | |
jAnimConsole = function() | |
{ | |
var | |
blinkAnim | |
,currentChar | |
,currentWord | |
,htmlInser | |
,list | |
,out | |
,printWord | |
,timeBwtLetters | |
,timeBwtWords | |
; | |
out = $( this ); | |
list = $( this ).data( dataName ).split( separator ); | |
htmlInser = "<span class=" + inserClass + ">" + inserChar + "</span>"; | |
out.html( htmlInser ); | |
blinkAnim = function() | |
{ | |
$( "." + inserClass ).delay( 1000 ).hide( 100 ).delay( 1000 ).show( 100 ); | |
$( "." + inserClass ).queue( function( next ) | |
{ | |
next(); | |
blinkAnim(); | |
} ); | |
}; | |
currentWord = 0; | |
currentChar = 1; | |
timeBwtLetters = 50; | |
timeBwtWords = 2500; | |
printWord = function() | |
{ | |
var substr; | |
substr = list[ currentWord ].substr( 0, currentChar++ ); | |
out.html( "" + substr + htmlInser ); | |
// Prints the letters, char by char | |
if ( currentChar <= list[ currentWord ].length ) | |
{ | |
return setTimeout(printWord, timeBwtLetters); | |
} | |
// Adds the new word | |
else | |
{ | |
setTimeout( blinkAnim, timeBwtLetters ); | |
currentWord = ( currentWord + 1 ) % list.length; | |
currentChar = 1; | |
return setTimeout( printWord, timeBwtWords ); | |
} | |
}; | |
setTimeout( printWord, 0 ); | |
}; | |
$( ".jAnimConsole" ).each( jAnimConsole ); | |
} ).call( this ); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* DB Error (plain version) | |
* Tells the Search Engine that the site is temporary unavailable. | |
* Preserves page rank and sends a mail to the owner. | |
* @TODO Fill in the mail address inside `$mail_address`. | |
* | |
* There're still some cases where this file won't get triggered. | |
* @link http://core.trac.wordpress.org/ticket/10883 | |
*/ | |
$protocol = $_SERVER["SERVER_PROTOCOL"]; | |
if ( | |
'HTTP/1.1' != $protocol | |
AND 'HTTP/1.0' != $protocol | |
) | |
$protocol = 'HTTP/1.0'; | |
header( "{$protocol} 503 Service Unavailable", true, 503 ); | |
header( 'Content-Type: text/html; charset=utf-8' ); | |
header( 'Retry-After: 600' ); | |
// Get Variables | |
$temp = mysql_error(); | |
$url = current_page_URL(); | |
// Get Page URL | |
function current_page_URL() | |
{ | |
$url = 'http'; | |
if ( function_exists( 'is_ssl()' ) ) | |
{ | |
is_ssl() AND $url .= 's'; | |
} | |
elseif ( isset( $_SERVER['HTTPS'] ) ) | |
{ | |
'on' == $_SERVER['HTTPS'] AND $url .= 's'; | |
} | |
$url .= "://{$_SERVER['SERVER_NAME']}"; | |
if ( '80' != $_SERVER['SERVER_PORT'] ) | |
return "{$url}:{$_SERVER['SERVER_PORT']}{$_SERVER['REQUEST_URI']}"; | |
return "{$url}{$_SERVER['REQUEST_URI']}"; | |
} | |
$mail_address = 'YOU@example.com'; | |
$headers = "From: {$mail_address}\r\n"; | |
$headers .= "Reply-To: {$mail_address}\r\n"; | |
$headers .= sprintf( 'X-Mailer: PHP/%s', phpversion() ); | |
$headers .= "content-type: text/html"; | |
// Send The Alert | |
@mail( | |
$mail_address | |
,'SQL Error on the Website' | |
,sprintf( | |
'This is an automated message. There is a SQL error: %s - The affected URL is: %' | |
,$temp | |
,$url | |
) | |
,$headers | |
); | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"><![endif]--> | |
<title>The website is down</title> | |
<style> | |
html, body { margin:0; padding:0; font-size: 100%; } | |
body { background: #FFF; font-family: Verdana, sans-serif; line-height: 1.3; } | |
#container { height: 225px; margin: 20% auto 0; width: 575px; } | |
h1 { font-size: 2.5em; font-weight: normal; } | |
p { margin: 0 0 10px 5px; font-size: 1em; } | |
a { color: #dc322f; } | |
hr { border-color: #313131; } | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<h1>We're Having Database Issues.</h1> | |
This may be temporary, so try again shortly. | |
<br /> | |
An email has been sent automatically to one of our staff. | |
</p> | |
<?php | |
if ( | |
defined( 'WP_ADMIN' ) | |
OR defined( 'WP_INSTALLING' ) | |
) | |
isset( $GLOBALS['wpdb'] ) AND print "<hr /><p>{$GLOBALS['wpdb']->error}</p>"; | |
?> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should it not be Ooops not Ups?