Skip to content

Instantly share code, notes, and snippets.

@bitbonsai
Created September 7, 2012 08:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitbonsai/3664344 to your computer and use it in GitHub Desktop.
Save bitbonsai/3664344 to your computer and use it in GitHub Desktop.
Proactive 404
<?php
$http = str_replace('HTTP/1.1','http://',$_SERVER['SERVER_PROTOCOL']);
$datetime = date('Y-m-d H:i:s');
$to = $config['webmaster'];
$subject = '404 at '. $config['url'];
$headers = 'From: site@'.$config['url']."\r\n";
$message = <<< MAIL
Date/Time: {$datetime}
The following URL fell on 404: $http{$_SERVER["SERVER_NAME"]}{$_SERVER["REQUEST_URI"]}
Redirect Url: {$_SERVER["REDIRECT_URL"]}
Referrer: {$_SERVER["HTTP_REFERER"]}
User Agent: {$_SERVER["HTTP_USER_AGENT"]}
Accept-Encoding: {$_SERVER["HTTP_ACCEPT_ENCODING"]}
Cookie: {$_ENV["HTTP_COOKIE"]}
Please fix it.
Sincerely- 404 Robot
MAIL;
@mail($to, $subject, $message, $headers);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment