logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Does anybody know about a php driven error system for Apache
Author
asdfgqw



Joined: 21 Jan 2007
Posts: 12

PostPosted: Wed 24 Jan '07 18:28    Post subject: Does anybody know about a php driven error system for Apache Reply with quote

I mean the 403 and 404 etc. stuff.

I canĀ“t remember the source, but i can remember that someone wrote about the existence of a php driven error pages system for Apache. Does something like that exists?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 25 Jan '07 11:15    Post subject: Reply with quote

ErrorDocument 403 /403.php
ErrorDocument 404 /404.php

Wink

What should be done inside the php error pages?
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Thu 25 Jan '07 17:29    Post subject: Reply with quote

I have one:

Code:
ErrorDocument 400 /error/?code=400
ErrorDocument 401 /error/?code=401
ErrorDocument 403 /error/?code=403
ErrorDocument 404 /error/?code=404
ErrorDocument 500 /error/?code=500
ErrorDocument 502 /error/?code=502
ErrorDocument 503 /error/?code=503
ErrorDocument 504 /error/?code=504


index.php inside apache's error folder
Code:
<?php
   /**************************************\
   | Apache Error Pages                   |
   | By Jorge Schrauwen 2005              |
   | http://www.blackdot.be               |
   | ------------------------------------ |
   | Usage:                               |
   | ErrorDocument 400 /error/?code=400   |
   | Make sure you correct the path to    |
   | the file, and update the status code |
   \**************************************/
   if(isset($_GET['code'])){
      if($_GET['code'] == 400){
         $title = 'Error 400 - Bad Request!';
         $message = 'The server didn\'t understand the request.';
      }elseif($_GET['code'] == 401){
         $title = 'Error 401 - Unauthorized!';
         $message = 'You are not unauthorized to view the page requested.';
      }elseif($_GET['code'] == 403){
         $title = 'Error 403 - Access Forbidden!';
         $message = 'Access for this request was denied.';
      }elseif($_GET['code'] == 404){
         $title = 'Error 404 - Not Found!';
         $message = 'The server couldn\'t find <em>'.$_SERVER['REQUEST_URI'].'</em> you where looking for.';
      }elseif($_GET['code'] == 500){
         $title = 'Error 500 - Internal Server Error!';
         $message = 'The server encountered an unexpected condition which prevented it from fulfilling the request.';
      }elseif($_GET['code'] == 502){
         $title = 'Error 502 - Bad Gateway!';
         $message = 'The server, while acting as a gateway or proxy, received an invalid response from the upstream server.';
      }elseif($_GET['code'] == 503){
         $title = 'Error 504 - Service Temporarily Unavailable!';
         $message = 'The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.';
      }elseif($_GET['code'] == 504){
         $title = 'Error 504 - Gateway Timeout!';
         $message = 'The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.';
      }elseif($_GET['code'] == 'jrun'){
         $title = 'Error while processing jrun request!';
         $message = 'The jrun server made and error processing the request.';
      }
   }
?>
<!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>
<title><?php echo $title; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
   body{
      background-color: #FAFAFA;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #000000;
   }
   a{
      color: #0000CC;
      text-decoration: none;
   }
   a:hover{
      color: #FF3300;
      text-decoration: none;
   }
   button{
      background-color: #3F97EE;
      border: 1px solid #277CD7;
      padding: 0px 5px;
      color: #fff;
   }
   #bar{
      position: absolute;
      top: 10px;
      bottom: 10px;
      left: 10px;
      width: 150px;
      background-color: #78b5f2;
   }
   #header{
      position: absolute;
      top: 10px;
      right: 10px;
      left: 170px;
      height: 20px;
      font-weight: bold;
      font-size: 15px;
   }
   #message{
      position: absolute;
      top: 40px;
      right: 10px;
      left: 170px;
      bottom: 40px;
   }
   #message #desc{
      color: #FF0000;
   }
   #footer{
      position: absolute;
      right: 10px;
      left: 170px;
      bottom: 10px;
      height: 20px;
   }
</style>
<script type="text/javascript">
function fixie(){
   if (navigator.appName.indexOf("Microsoft")!=-1) {
      var wHeight = document.documentElement.clientHeight;;
      document.getElementById('bar').style.height = (wHeight-20) + 'px';
   }
}
</script>
</head>

<body onload="fixie()">
<div id="bar">&nbsp;</div>
<div id="header"><?php echo $title; ?></div>
<div id="message">
   <span id="desc"><?php echo $message; ?></span>
   <br />
   <br />
   You can go back from where you came or try again later.<br />
   <button onclick="javascript:history.back()">Back</button>&nbsp;<button onclick="javascript:location.reload()">Reload</button>
</div>
<div id="footer"><?php echo $_SERVER['SERVER_SIGNATURE']; ?></div>
</body>
</html>
Back to top
asdfgqw



Joined: 21 Jan 2007
Posts: 12

PostPosted: Sat 27 Jan '07 12:49    Post subject: Reply with quote

Thanks Jorge, that is exactly what i wanted. Wink
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Sat 27 Jan '07 16:19    Post subject: Reply with quote

Thats what i'm using on my VPS server Smile pretty easy to maintain or update with new errors
Back to top


Reply to topic   Topic: Does anybody know about a php driven error system for Apache View previous topic :: View next topic
Post new topic   Forum Index -> Apache