Show DevBest 404 page & notifier

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
As I was working on my site again, I made a little 404 page (matching my theme on my website). I edited so it isn't using my classes anymore, if something isn't working, please say so, I'll fix it. Thanks to for anoying me while working on this.

404.php:
PHP:
<?php
$url = 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] .'';
 
if (isset($url) && $_SESSION['error404'] != $url && !strpos($_SERVER['REQUEST_URI'], 'favicon.ico'))
{
mysql_query("INSERT INTO page_errors(url, request_uri, http_referer, ip, date) VALUES ('".$url."', '".$_SERVER['REQUEST_URI']."', '".$_SERVER['HTTP_REFERER']."', '".$$_SERVER['REMOTE_ADDR']."', '".date("d-m-Y H:i")."')");
$_SESSION['error404'] = $url;
}
?>
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>404 - Webpage not found!</title>
<style>
body,html {
margin: 120px 0px 0px 0px;
padding: 0;
background-color: #16499A;
background-image: url('bg');
background-size: 1280px 292px;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: 100% 100%;
font-family: 'SegoeWP-Light';
font-size: 14px;
color: white;
text-align: center;
}
 
@font-face {
font-family: 'SegoeWP-Light';
src: url('SegoeWP-Light.ttf');
}
 
#wrapper {
margin: 0 auto 0 auto;
width: 700px;
 
}
 
#content {
width: 700px;
text-align: left;
}
 
#main {
width: 100%;
height: auto;
font-size: 40px;
font-family: 'SegoeWP-Light';
}
 
h1 {
font-size: 100px;
font-family: 'SegoeWP-Light';
margin-bottom: 25px;
}
</style>
</head>
 
<body>
<div id="wrapper">
 
<div id="content">
<div id="main">
<h1>:(</h1>
We are sorry, but this page couldn't be found. The webmaster has been notified!
</div>
</div>
 
</div>
</body>
</html>

Database:
Code:
CREATE TABLE IF NOT EXISTS `page_errors` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(40) NOT NULL,
  `request_uri` varchar(25) NOT NULL,
  `http_referer` varchar(40) NOT NULL,
  `ip` varchar(18) NOT NULL,
  `date` varchar(20) NOT NULL
  PRIMARY KEY (`id`),
) ENGINE=MyISAM  DEFAULT CHARSET=latin1

Add this to your .htaccess:
Code:
ErrorDocument 404 /404.php

SegoeWP-Light .ttf file:


bg.png file:


Hope you like it.
Preview:
 

CosmoTrigger

Member
Dec 30, 2012
60
7
This is really nice, it reminds me of the windows 8 blue screen.

windows-8-blue-screen-of-death-offical.png
 

TesoMayn

Boredom, it vexes me.
Oct 30, 2011
1,482
1,482
I wrote this in MySQLi, both OOP and Procedural.

OOP
PHP:
<?php
$_SESSION['error404'] = false;
$mysqli = new mysqli('localhost',  'root',  '');
$mysqli->select_db("database");
$url = 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] .'';
 
if (isset($url) && $_SESSION['error404'] != $url && !strpos($_SERVER['REQUEST_URI'], 'favicon.ico')) {
$mysqli->query("INSERT INTO page_errors(url, request_uri, http_referer, ip, date) VALUES ('".$url."', '".$_SERVER['REQUEST_URI']."', '".htmlentities($_SERVER['HTTP_REFERER'])."', '".$_SERVER['REMOTE_ADDR']."', '".date("d-m-Y H:i")."')");
$_SESSION['error404'] = $url;
}
?>

Procedural:
PHP:
<?php
$_SESSION['error404'] = false;
$link = mysqli_connect('localhost',  'root',  '');
mysqli_select_db($link, "database");
$url = 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] .'';
 
if (isset($url) && $_SESSION['error404'] != $url && !strpos($_SERVER['REQUEST_URI'], 'favicon.ico')) {
mysqli_query($link,  "INSERT INTO page_errors(url, request_uri, http_referer, ip, date) VALUES ('".$url."', '".$_SERVER['REQUEST_URI']."', '".htmlentities($_SERVER['HTTP_REFERER'])."', '".$_SERVER['REMOTE_ADDR']."', '".date("d-m-Y H:i")."')");
$_SESSION['error404'] = $url;
}
?>
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,398
962
Storing error document information in MySQL... why? Already gets stored in raw access logs and error logs. Simple cURL script can probably make that page_errors table close to 1GB in about 10-15 minutes.
 

Causem

Member
Aug 8, 2012
95
6
all my 404 pages in the past
Code:
.htaccess =
ErrorDocument 404 /404.php
Code:
404.php =
<html>
<head>
<title>Error 404 - Page not found</title>
</head>
<body>
<h1>Error 404 page not found</h1>
</body>
</html>
You made it look so complicated....
 

Users who are viewing this thread

Top