vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Custom error-handler based on vBulletin templates (https://vborg.vbsupport.ru/showthread.php?t=65013)

Intex 05-29-2004 08:15 AM

I followed the instructions and it doesn't appear to work for me. I'm using Apache2 on a Windows host.

I've created the .htaccess file and made sure that the Apache httpd.conf file is set to look for .htaccess files and also includes the 'AllowOverride FileInfo AuthConfig Limit' directive. Template was also included and error.php uploaded.

All I get is the usual Windows 404 Error saying page not found.

Any ideas?

Intex 06-01-2004 10:57 AM

* Bump *

Intex 06-03-2004 10:36 AM

* Bump @ AlexanderT *

AlexanderT 06-03-2004 11:04 AM

Intex, sorry for my late reply. I am not sure why it wouldn't work for you. But the again, I haven't really had experience with either Apache 2 or Windows hosts. Can you use .htaccess files in general (like for protection directories)?

Slapyo 06-03-2004 12:23 PM

can i use this error handler for the forums only, and then a different error handler for my site.

like put a .htaccess in ../

and put your .htaccess in ../forums/

just curious if this is possible or not, or if i should just make the whole site goto the forum error handler. thanks.

0zone 06-07-2004 11:51 PM

Installed, tested, working as expected.

Thanks for the hack. :)

[clicks install]

AlexanderT 06-08-2004 06:22 AM

Quote:

Originally Posted by Slapyo
like put a .htaccess in ../
and put your .htaccess in ../forums/

Yes that should work. Have you given it a try?

Slapyo 06-08-2004 03:23 PM

not yet, unfortunately i am in the middle of finals week so i won't be able to sit down and work on my site until next week some time.

Slapyo 06-28-2004 11:27 AM

after installing the hack, all i get is:

Quote:

Unknown Error
We are currently unable to handle this error.
Please contact us if this problem persists.
i tried requesting a file like asdf.html which i don't have on my server and it doesn't give the 404 error. it gives the unknown error. after looking at the code that means that $_SERVER['REDIRECT_STATUS'] isn't being set. everything is setup up according to the install. any ideas?

EDIT: figured it out. in my .htaccess, the link i gave to the error.php file included my URL in front of it ... http://www.mysite.com/forums/error.php ... soon as i changed it to what was shown in the instructions ... /forums/error.php ... it worked like a charm. thanks!

ImportPassion 06-28-2004 11:38 AM

how do we get this to use whatever skin somebody is using currently?

58sniper 06-29-2004 08:52 PM

Okay - I was so happy with this hack that I'm going to help improve it. Hopefully, you will find this usefull...

What this does is, for 404 and 500 errors, the server will send you an email notifying you of the error, and providing some information that will assist you in resolving it.

open error.php and find:
Code:

$error['title'] = "404 File Not Found";
                $error['description'] = "The web server cannot find the file you asked for. Check the URL to ensure that the path is correct.";
                $error['contact'] = "Please <a href=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if you believe that the mistake is on our part.";

under that, paste
Code:

$error_message = "An attempt to get a file (". $_SERVER['REQUEST_URI'] . ") failed. Please investigate!\r\n";
                if (isset($_SERVER['HTTP_REFERER'])){
                        $error_message .= "The user came from " . $_SERVER['HTTP_REFERER'] . "\r\n";
                        if (!preg_match ("/.*?domain.com.*?/i", $_SERVER['HTTP_REFERER'])) {
                                $error_message .= "You may wish to contact the administrator of that domain.\r\n";
                        }
                }
                $error_message .= "User agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
                $error_message .= "Remote Address: " . $_SERVER['REMOTE_ADDR'] . "\r\n";
                $error_message .= "Remote Port: " . $_SERVER['REMOTE_PORT'] . "\r\n";

find
Code:

$error['title'] = "500 Internal Server Error";
                $error['description'] = "We encountered an unexpected condition.";
                $error['contact'] = "Please <a href=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us to report this problem.";

and paste this under it
Code:

$error_message = "An attempt to get a file (". $_SERVER['REQUEST_URI'] . ") caused an error. Please investigate!\r\n";
                if (isset($_SERVER['HTTP_REFERER'])){
                        $error_message .= "The user came from " . $_SERVER['HTTP_REFERER'] . "\r\n";
                }


find
Code:

eval("print_output(\"".fetch_template('ERROR_SHELL')."\");");
and paste this ABOVE it

Code:

$error_headers = "";
        $error_headers .= "FROM:domain.com Error Manager <errors@domain.com>\n";
        $error_headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $error_headers .= "X-Mailer: PHP " . phpversion() . "\r\n";
        $error_headers .= "Importance: High\r\n";
        $error_headers .= "X-Priority: 5 (High)\r\n";
        $error_headers .= "Return-Path: <errors@domain.com>\r\n";

        if ((($_SERVER['REDIRECT_STATUS']=="404")&&($_SERVER['REQUEST_URI'] != "/error.php?eid=404"))||($_SERVER['REDIRECT_STATUS']=="500")){
                $error_subject = $eid . " error!";
                $error_mail = mail("webmaster <webmaster@domain.com>","$error_subject","$error_message","$error_headers");
        }

IMPORTANT! Now replace each of the instances of domain with your actual domain.

Save and upload the file and test by going to a non-existing page on your site. You should receive the email right after that.

ImportPassion 06-29-2004 09:53 PM

couple things with that.

missing the headers to do html mail or something.
the error_start and error_footer will never get appended to the body

58sniper 06-30-2004 12:22 AM

You are correct. I could have swore I removed the error_start and error_footer stuff before I posted that. I use that for something else.

Also, I've changed some of the hard coded email addresses to the $vboptions['webmasteremail'] variable.

Would it be easier (and allowed) for me to just attach the php file here? It's just the original error page with my stuff added.

Whatever is convenient (and doesn't break the rules).....

AlexanderT 06-30-2004 05:09 AM

Nice addition, 58sniper!

I'd be only worried to be flooded with e-mails (at least if you have a high traffic site). Although my site is relatively small, for June 2004 I had 3864 404-Document Not-Found-errors, in May even 5048 of these errors. Not because I am sloppy with html programming, but because people (or bots, in majority) were trying to access and spider outdated links.

58sniper 06-30-2004 10:53 PM

The biggest problem I've seen is the PowerPC version of IE. It apparently has poor support for images in CSS. I think I'm going to filter that.

What's the rule about modifying hacks? Do I just post the new file here or do I need to start a new thread and give props?

I ask because I'd like to switch all of the IF statements to a switch, and make a few more changes, and I think the new version would be beneficial.

Jolten 07-01-2004 05:47 AM

Great addition. Thanks.

58sniper 07-04-2004 10:27 PM

Okay - here we go. This is an 'extension' of this hack, which includes:

- Emailing of the webmaster for 404 and 500 errors.

- Changed all of the IF ELSE statements to a single SWITCH

- Used more vBulletin variables so that no code modification is required to implement this.

I've tested this for a couple of days, and haven't seen any problems. Let me know if you spot any.

To install, just drop this in your forum folder, overwriting the original (which, of course, you backed up).

58sniper 07-08-2004 10:21 PM

Updated with the following changes:

Subject of error email now indicates type of error.
Address of referring page (if it exists) is now a link.

This is a straight drop-in replacement for the above.

H2k 07-18-2004 11:15 AM

This hack was Wrorking With me B4 After We update our Server . it dont work

Can i know what this hack need from me to install any software or anything ..

Thankyou

58sniper 07-18-2004 09:38 PM

Quote:

Originally Posted by H2k
This hack was Wrorking With me B4 After We update our Server . it dont work

Can i know what this hack need from me to install any software or anything ..

Thankyou

What happens?

Slapyo 08-29-2004 05:28 PM

hmmm, can someone help me out here? here is my .htaccess and my error.php file. error.php is in the root directory along with the .htaccess file. however if you goto some random page the only thing i get to load up is a blank page. nothing is inserted. even if i goto just error.php it is still blank. but according to the code it should atleast give the very last error on the list. it also never actually goes to error.php ... if you want to goto asfdasdf.php that is still in the URL bar ... shouldn't it redirect to the error.php file?

.htaccess:
Code:

ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 401 /error.php
ErrorDocument 500 /error.php
ErrorDocument 503 /error.php

error.php:
PHP Code:

<?php
    
if(isset($_SERVER['REDIRECT_STATUS'])) {
        if (
$_SERVER['REDIRECT_STATUS']=="404") {
            
$error['title'] = "404 File Not Found";
            
$error['description'] = "The web server cannot find the file you asked for. Check the URL to ensure that the path is correct.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if you believe that the mistake is on our part.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="403") {
            
$error['title'] = "403 Forbidden";
            
$error['description'] = "You don't have permission to access this document on this server.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if you think that there is a mistake.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="401") {
            
$error['title'] = "401 Unauthorized";
            
$error['description'] = "The URL you are requesting requires proper authentication.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if you think that there is a mistake.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="500") {
            
$error['title'] = "500 Internal Server Error";
            
$error['description'] = "We encountered an unexpected condition.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us to report this problem.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="503") {
            
$error['title'] = "503 Service Unavailable";
            
$error['description'] = "We are currently unable to handle your request due to a temporary overloading or maintenance of the server.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if this problem persists.";
        } else {
            
$error['title'] = "Unknown Error: " $_SERVER['REDIRECT_STATUS'];
            
$error['description'] = "We are currently unable to handle this error.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if this problem persists.";
        }
    } else {
            
$error['title'] = "Unknown Error";
            
$error['description'] = "We are currently unable to handle this error.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if this problem persists.";
    }

    require_once(
"header.inc.php");
?>
                    <p><b><?=$error['title']?></b>
                        <br /><?=$error['description']?>
                        <br /><?=$error['contact']?></p>
<?
    require_once("footer.inc.php");
?>


58sniper 08-30-2004 12:07 AM

Quote:

Originally Posted by Slapyo
hmmm, can someone help me out here? here is my .htaccess and my error.php file. error.php is in the root directory along with the .htaccess file. however if you goto some random page the only thing i get to load up is a blank page. nothing is inserted. even if i goto just error.php it is still blank. but according to the code it should atleast give the very last error on the list. it also never actually goes to error.php ... if you want to goto asfdasdf.php that is still in the URL bar ... shouldn't it redirect to the error.php file?

no. The URL will stay the same.

Quote:

Originally Posted by Slapyo
.htaccess:
Code:

ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 401 /error.php
ErrorDocument 500 /error.php
ErrorDocument 503 /error.php


That looks fine

Quote:

Originally Posted by Slapyo
error.php:
PHP Code:

<?php
    
if(isset($_SERVER['REDIRECT_STATUS'])) {
        if (
$_SERVER['REDIRECT_STATUS']=="404") {
            
$error['title'] = "404 File Not Found";
            
$error['description'] = "The web server cannot find the file you asked for. Check the URL to ensure that the path is correct.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if you believe that the mistake is on our part.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="403") {
            
$error['title'] = "403 Forbidden";
            
$error['description'] = "You don't have permission to access this document on this server.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if you think that there is a mistake.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="401") {
            
$error['title'] = "401 Unauthorized";
            
$error['description'] = "The URL you are requesting requires proper authentication.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if you think that there is a mistake.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="500") {
            
$error['title'] = "500 Internal Server Error";
            
$error['description'] = "We encountered an unexpected condition.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us to report this problem.";
        } elseif (
$_SERVER['REDIRECT_STATUS']=="503") {
            
$error['title'] = "503 Service Unavailable";
            
$error['description'] = "We are currently unable to handle your request due to a temporary overloading or maintenance of the server.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if this problem persists.";
        } else {
            
$error['title'] = "Unknown Error: " $_SERVER['REDIRECT_STATUS'];
            
$error['description'] = "We are currently unable to handle this error.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if this problem persists.";
        }
    } else {
            
$error['title'] = "Unknown Error";
            
$error['description'] = "We are currently unable to handle this error.";
            
$error['contact'] = "Please <a href=\"http://www.veteransresources.org/forums/sendmessage.php\">contact</a> us if this problem persists.";
    }

    require_once(
"header.inc.php");
?>
                    <p><b><?=$error['title']?></b>
                        <br /><?=$error['description']?>
                        <br /><?=$error['contact']?></p>
<?
    require_once("footer.inc.php");
?>



Well, I can't see what header.inc.php or footer.inc.php include. So I can't really troubleshoot. Did you try just using the originally supplied code?

Slapyo 08-30-2004 02:05 AM

this is the original code, i just stripped out the part where it gives the redirect stuff. this way i could have it for any page in my site instead of just the forums.

header and footer basically just open the table and close the table. header also includes the menu.

header.inc.php:
PHP Code:

<?
    ob_start('ob_gzhandler');

    chdir("./forums/");
    require_once("./global.php");
    require_once("./includes/functions_forumlist.php");
    chdir("../");
    chdir("./chat/");
    require_once("./users.php");
    chdir("../");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">
    <head>
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="-1" />
        <meta http-equiv="Cache-Control" content="no-cache" />
        <!-- end no cache headers -->
        <meta name="generator" content="vBulletin 3.0.3" />
        <meta name="keywords" content="veterans,resources,help,support,vietnam,ptsd,agent orange,cancer,gulf war,iraq,afghanistan" />
        <meta name="description" content="This is a discussion forum where veterans help other veterans." />
        <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
        <link rel="shortcut icon" href="http://www.veteransresources.org/favicon.ico" type="image/x-icon" />
        <title>VeteransResources.org</title>
        <style type="text/css">
            body {
                margin: 0px 0px 0px 0px;
                background-color: #f0eedb;
            }
            .black {
                font-family: Verdana, Arial, Helvetica, sans-serif;
                font-size: 13px;
                color: #000000;
                padding-right: 10px;
                padding-left: 10px;
                padding-top: 10px;
                padding-bottom: 10px;
            }
            .black a:link, .black a:visited, .black a:active .black a:hover {
                font-family: Verdana, Arial, Helvetica, sans-serif;
                font-size: 13px;
                color: #000000;
                text-decoration: underline;
            }
            .white {
                font-family: Verdana, Arial, Helvetica, sans-serif;
                font-size: 11px;
                font-weight: bold;
                color: #ffffff;
                padding-right: 10px;
                padding-left: 10px;
            }
            .white a:link, .white a:visited, .white a:active, .white a:hover {
                font-family: Verdana, Arial, Helvetica, sans-serif;
                font-size: 11px;
                font-weight: bold;
                color: #ffffff;
                text-decoration: none;
            }
            .loginform {
                font-family: Verdana, Arial, Helvetica, sans-serif;
                font-size: 13px;
                color: #000000;
            }
            .maintable {
                height: 100%;
            }
        </style>
        <script language="javascript" type="text/javascript">
        <!--
            function openchat() {
                window.open('http://www.veteransresources.org/chat/member.php','chat','resizable=yes,scrollbars=no,width=650,height=500');
            }
        //-->
        </script>
    </head>
    <body>
        <table width="760" class="maintable" cellspacing="0" cellpadding="0" align="center" border="0">
            <tr>
                <td width="480" height="30" bgcolor="#2d356e" class="white"><a href="http://www.veteransresources.org">Home</a> | <a href="http://www.veteransresources.org/forums/">Message Board</a> | <? if ($bbuserinfo['userid']!=0) {?><a href="#" onclick="openchat();">Chat (<?=$zznumber?>)</a> | <?}?><a href="http://www.veteransresources.org/links.php">Links</a> | <a href="http://www.veteransresources.org/forums/sendmessage.php">Contact</a></td>
                <td width="280" height="30" align="right" bgcolor="#2d356e" class="white"><? echo date("F j, Y"); ?></td>
            </tr>
            <tr>
                <td width="760" height="100" colspan="2"><img src="images/logo.jpg" width="760" height="100" border="0" alt="VeteransResources.org" /></td>
            </tr>
            <tr>
                <td width="760" bgcolor="#ffffff" colspan="2" class="black" valign="top">

footer.inc.php:
PHP Code:

                </td>
            </tr>
            <tr>
                <td width="480" height="30" bgcolor="#2d356e" class="white"><a href="privacy.php">Privacy Policy</a></td>
                <td width="280" height="30" align="right" bgcolor="#2d356e" class="white">Copyright &copy; 2004 VeteransResources.org</td>
            </tr>
        </table>
    </body>
</html>
<?
    ob_end_flush();
?>


Slapyo 08-30-2004 02:08 AM

actually, i just goofed around with the error.php file and if i place the
PHP Code:

require_once("header.inc.php"); 

above the error code stuff it works. weird.

58sniper 10-01-2004 11:31 PM

Here's an update.

I added info to the email sent to the admin. It now indicates the style number for the user that generated the error. Why? Because one of the things that you'll need to know is what the user was attempting to do that triggered a 404 error. But adding the style, we can further track down missing files or incorrect path problems.

I couldn't find a variable that contained the actual style NAME without doing another query. So I just include the style ID number. We can quickly look up which style that corresponds to in the ACP.

Just replace the existing file with this one and let me know what you think.

AlexanderT 10-02-2004 10:13 AM

Quote:

Originally Posted by 58sniper
I couldn't find a variable that contained the actual style NAME without doing another query. So I just include the style ID number. We can quickly look up which style that corresponds to in the ACP..

Hi 58sniper,
take a look at $datastore['stylecache'], or $stylechoosercache

Jim Mayhugh 01-01-2005 07:11 PM

If your $error['contact'] message is the same for all errors, you can save some typing by placing it outside of the switch() statement once.

Here's a copy of my file with a few more error codes inserted.

Delphiprogrammi 02-28-2005 08:55 PM

hi people,

nice hack but it fails to work for me.i have a directory (within my root directory) called "errorpages" i upload error.php and asked my host to allow the "FileInfo" thingy there but i get include errors "Warning: main(./includes/init.php): failed to open stream: No such file or directory " if i add the correct path (eg "../includes/global.php") then vbulletin stop saying that the config file is not there but it is .... what can i do about this ?

Delphiprogrammi 03-01-2005 01:10 PM

hi,

i've asked my host to configure the "FileInfo" Directory for my httpdocs they replyed they did that (and apache seems to be restarted) however if i go directly to error.php it says "unknown error" (like it should) BUT if you type

www.mysite.com/whateverhere => this doesn't exist so a 404 file not found should come up but all i get is white browser window with the text "error.php" printed in it nothing else ??

htaccess file i use

Code:

ErrorDocument 400 error.php
ErrorDocument 401 error.php
ErrorDocument 403 error.php
ErrorDocument 404 error.php
ErrorDocument 500 error.php

the attachment is what internet explorer shows me what to do :confused:

Polo 03-14-2005 02:38 PM

Nice, thank you very much, I was originally going to use this mod but after following the link to this thread, I decided to use this method. To me it was easier and hassle free... again thank you :)

TCM 03-22-2005 05:42 AM

Installed it, it works perfectly. Tres cool. Thanks. :D

ChrisLM2001 04-13-2005 10:40 PM

Is anyone getting this hack to work in cpanel?

Got the server configured for AllowOverride FileInfo in httpd.conf. But when I go to test if it works, I just get the browser's default error page. The error log shows an error is there, but it refuses to call the error.php file. :(

I put this....

PHP Code:

ErrorDocument 403 /forums/error.php
ErrorDocument 404 
/forums/error.php
ErrorDocument 401 
/forums/error.php
ErrorDocument 500 
/forums/error.php
ErrorDocument 503 
/forums/error.php 

in my /public_html/ directory .htaccess file.

The error.php in the /forums directory.

Created the shell_error file too.

But something is wrong, as I can't get the error.php to show it contents.

Anyone with a workaround?

Chris


All times are GMT. The time now is 12:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02505 seconds
  • Memory Usage 1,921KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (6)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (32)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete