Skip to content

Instantly share code, notes, and snippets.

@techskilled
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techskilled/394d3b5b1175ff2a3cb8 to your computer and use it in GitHub Desktop.
Save techskilled/394d3b5b1175ff2a3cb8 to your computer and use it in GitHub Desktop.
Create a WordPress Database Error Page
<?php
// INFORM GOOGLE SITES TEMP DOWN
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && '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' );
$temp = mysql_error();
$url = curPageURL();
// GET THE PAGE URL
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; }
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
// EMAIL WEBMASTER
mail( 'me@example.com', 'MySql Down', 'MySql seems to be down : '.$temp.'. Current URL is : '.$url);
?>
<html>
<head>
<title>Website Title is currently down</title>
</head>
<body>
<div style="margin: 120px auto 0; width:590px;">
<h1>Website Title is currently down</h1>
<p>We are working on it please check in 10 minutes.</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment