<!--
  -- Unfortunately, Microsoft has added a clever new
  -- "feature" to Internet Explorer.  If the text in
  -- an error's message is "too small", specifically
  -- less than 512 bytes, Internet Explorer returns
  -- its own error message.  Yes, you can turn that
  -- off, but *surprise* it's pretty tricky to find
  -- buried as a switch called "smart error
  -- messages"  That means, of course, that many of
  -- Resin's error messages are censored by default.
  -- And, of course, you'll be shocked to learn that
  -- IIS always returns error messages that are long
  -- enough to make Internet Explorer happy.  The
  -- workaround is pretty simple: pad the error
  -- message with a big comment to push it over the
  -- five hundred and twelve byte minimum.  Of course,
  -- that's exactly what you're reading right now.
//-->
<?php

    
/*
        COPYLEFT
            Wolfram Schlich <wolfram@schlich.org>
            Manuel Wildauer <manuel@wildauer.net>
        
        README
            Insert something like this into your httpd.conf:
            --8<--
            Alias /ERROR/ "/data/www/errdocs/"
            ErrorDocument 401 /ERROR/error.php?err_num=401
            ErrorDocument 403 /ERROR/error.php?err_num=403
            ErrorDocument 404 /ERROR/error.php?err_num=404
            ErrorDocument 500 /ERROR/error.php?err_num=500
            --8<--
    */

    
$err_str = array(
        
401 => 'unauthorized',
        
403 => 'forbidden',
        
404 => 'not found',
        
500 => 'internal server error'
    
);
    
$err_num || $err_num '75 6E 6B 6E 6F 77 6E';
    
$err_str[$err_num] || $err_str[$err_num] = 'unknown error';

    
srand((double) microtime() * 1000000);

    function 
random_bla() {
        
$bla = array(
            
'why not?',
            
'kAbLaMM...frzfzzdf',
            
'kNoCk kNoCk, nE0',
            
'D\'OH!',
            
'follow the white rabbit...',
            
'mit windows waer das nicht passiert!',
            
'BUG();',
            
'zero by division',
            
'he\'s dead jim',
            
'what? you mean this is random_bla();?'
        
);
        
$random_bla $bla[rand(0sizeof($bla) - 1)];
        return 
$random_bla;
    }

    function 
random_url() {
        
$url = array(
            
'http://localhost/',
            
'about:mozilla',
            
'http://www.disney.com',
            
'http://www.microsoft.com/piracy',
            
'file://c:',
            
'http://www.whitehouse.gov',
            
'javascript:location.reload();'
        
);
        
$random_url $url[rand(0sizeof($url) - 1)];
        return 
$random_url;
    }

    function 
random_color() {
        
$colorparts = array(
            
'a',
            
'0',
            
'1',
            
'b',
            
'2',
            
'3',
            
'c',
            
'4',
            
'5',
            
'd',
            
'6',
            
'7',
            
'e',
            
'8',
            
'9',
            
'f',
        );
        
$random_color '#';
        for (
$i 0$i 6$i++) {
            
$random_color .= $colorparts[rand(0sizeof($colorparts) - 1)];
        }
        return 
$random_color;
    }

    print(
'
        <html>
            <head>
                <title>ERROR '
.$err_num.'</title>
            </head>
            <style type="text/css">
            <!--
                body, h1, hr, p, a {
                    font-family:monospace;
                    color:'
.random_color().';
                    background-color:'
.random_color().';
                }
                b {
                    color:'
.random_color().';
                }
                a {
                    font-weight:bold;
                    color:'
.random_color().';
                }
            //-->
            </style>
            <body>
                <h1>'
.random_bla().'</h1>
                <hr>
                <p>
                    the indian says: white man trying to get information, but:<br>
                    <b>'
.$REQUEST_URI.': '.$err_str[$err_num].'</b>, hugh!
                </p>
                &laquo;
                <a href="javascript:history.back();">backward</a>
                |
                <a href="javascript:location.reload();">try again</a>
                |
                <a href="'
.random_url().'">forward</a>
                &raquo;
            </body>
        </html>
    '
);

?>