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)

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?


All times are GMT. The time now is 10:16 PM.

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.01878 seconds
  • Memory Usage 1,748KB
  • 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
  • (6)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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