ISN (International Social Networking Services - Interactive Apps and Websites)



Intelligent 404 Handler


 

 
<?php 
/* 
Errors in Client 
400 Bad syntax 
401 Unauthorized 
402 Not Used (Payment Granted) 
403 Forbidden 
404 Not Found 
 
Errors in Server 
500 Internal Error 
501 Not Implemented 
502 Overloaded 
503 Gateway Timeout 
To call the scripts add the following to your .htaccess file. 
 
ErrorDocument 404 /track.php 
 
*/ 
//choose the record either of the following statements 
//depending on what your host provides 
$file404 = $_SERVER['REDIRECT_ERROR_NOTES']."\n"; 
//or 
$file404 = $_SERVER['REDIRECT_URL'] . "\n"; 
$filename = '/var/users/mysite/htdocs/history404.txt'; 
 
if (file_exists($filename)) 
    $filecontents = file($filename); 
    $add = (!in_array($file404, $filecontents)); 
else $add = true; 
 
if ($add) 
    $fp = fopen($filename, 'a'); 
    $write = fputs($fp, $file404); 
    fclose($fp); 
    $body = ''; 
    $reportvars = array('REDIRECT_ERROR_NOTES','HTTP_HOST', 'HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_FROM', 
        'REDIRECT_URL', 'REDIRECT_REQUEST_METHOD', 'REDIRECT_STATUS','REQUEST_URI','QUERY_STRING', 
        'REMOTE_ADDR', 'REMOTE_PORT'); 
    foreach($reportvars as $key) $body .= "$key: {$_SERVER[$key]}\n"; 
    mail('webmaster@mysite.com','404:' . $_SERVER['REDIRECT_URL'],$body); 
 
$revbits = explode('.',strrev($_SERVER['REDIRECT_URL'])); 
 
$pages['html'] = array('html','htm','php','txt'); 
$pages['special'] = array('css', 'js'); 
 
$ext = strrev($revbits[0]); 
if (in_array($ext, $pages['html'])) 
    // or show a make a comment form 
    header('Location: /index.php'); 
elseif (in_array($ext, $pages['special'])) 
    //output nothing 
    echo ''; 
else 
    //throw a large image onto the screen so it's easy to hunt down. 
    //change the width and height to a more discreet dimension when live 
    //although if the img has height and width attributes that will overrule 
    //the width and height here 
    $width = 50; 
    $height = 50; 
 
    $image  = ImageCreate($width,$height); 
    $blob = ImageColorAllocate($image,27,48,107); 
 
    if (function_exists("imagegif")) { 
        header ("Content-type: image/gif"); 
        imagegif ($image); 
    } 
    elseif (function_exists("imagejpeg")) { 
        header ("Content-type: image/jpeg"); 
        imagejpeg ($image, "", 0.5); 
    } 
    elseif (function_exists("imagepng")) { 
        header ("Content-type: image/png"); 
        imagepng ($image); 
    } 
    elseif (function_exists("imagewbmp")) { 
        header ("Content-type: image/vnd.wap.wbmp"); 
        imagewbmp ($image); 
    } 
    else 
        // or whatever action should be taken if you don't have GD installed. 
        die("No image support in this PHP server"); 
 
    ImageDestroy($image); 
?>
sdds
By continuing to use this site, you agree to the use of cookies to personalize content and advertisements, to provide social media functionality, to analyze our traffic using Google services like Analytics and Adsense.

Google Adsense and its partners may use your data for advertising personalization and cookies may be used for personalized and non-personalized advertising. How does Google use my data?
Please use the following button to see the list of Google partners as well as all the details regarding cookies.
See detailsI Accept
These cookies are mandatory for the operation of isn-services.com, if you do not accept them please quit this site.
You have the right to refuse cookies and leave the site or to change the parameters.