Marook-Online
* 06.Feb.2012, 15:15 UTC+1
Welcome, Guest. Please login or register.
Username:
Password:

News: Back again Wink
Main Menu
  Navigation
   Downloads
     Tools
     Music Discs
     SMF Mods
     Trainer & Patches
     EgoShare Uploader
   Guestbook
   NoPaste
   User Map
   Gallery
  
   Malware Scan
   Hacker Blacklist
   Find Abusemail
Top Downloads
Support Me !
Help me by donating a small amount!



Advanced search

Google


Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read
05-Nov-2007 15:26
Marook
Administrator
*****
Offline Offline

Joined: 01-Jan-2005
Posts: 224


Hi,

i started PHP with a simple small script to catch server errors. First we need to edit (or create) a .htaccess file in our wwwroot. Fill it with the following

Code:
# Customized error messages.
ErrorDocument 404 /error/index.php  #change the path to your needs

This will intruct the webserver to call our index.php when an error 404 occours.

Now lets code our index.php

Code
GeSHi (php):
  1. <?php
  2. $TPL_FILE = "error.tpl";
  3.  
  4. // Get the status 404,403,500... ?
  5. $err = $_SERVER['REDIRECT_STATUS'];
  6.  
  7. // for debugging reasons uncomment this
  8. // echo phpinfo();
  9.  
  10. $handle = fopen($TPL_FILE, "r");
  11. $tpl = fread($handle, filesize($TPL_FILE));
  12. fclose($handle);
  13.  
  14. // Depending on the error, save some errormessages
  15. switch ($err) {
  16. case '404':
  17. $errshort = "error 404: file not found!";
  18. $message = "The requested file could not found on this server!";
  19. break;
  20. case '403';
  21. $errshort = "error 403: forbidden!";
  22. $message = "Access denied - you are not allowed to access this site!";
  23. break;
  24. case '500';
  25. $errshort = "error 500: internal server error!";
  26. $message = "The requested file could not processed by its preprocessor!";
  27. break;
  28. default:
  29. break;
  30. }
  31.  
  32. // Now replace the above saved messages with its placeholders in the template
  33.  $tpl = str_replace("%MESSAGE%",$message,$tpl);
  34.  $tpl = str_replace("%ERRSHORT%",$errshort,$tpl);
  35.  
  36. // Send a correct header to the browser
  37.  header('STATUS: {$err}');
  38.  
  39. // Output of the template
  40. echo $tpl;
  41. ?>
Created by GeSHI 1.0.7.20

Just create a normal HTML file called error.tpl and use the two placeholders for a shortmessage and a long one.

That's it Smiley Save it and try http://yourdomain/site_does_not_exist and see it works...
Logged
 

Pages: [1]   Go Up
Jump to:  

Theme by webtechnica.net

MHD v2.1 © 2oo8 by Marook
32116 hacking attempts defended!