Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

Reply
 
Thread Tools
Custom error-handler based on vBulletin templates Details »»
Custom error-handler based on vBulletin templates
Version: 1.00, by AlexanderT AlexanderT is offline
Developer Last Online: Jul 2021 Show Printable Version Email this Page

Version: 3.0.0 Rating:
Released: 05-10-2004 Last Update: Never Installs: 34
 
No support by the author.

What this hack does?
---------------------------

UPDATE: Improved instruction.txt, fixed for those who use external style sheets

This hack adds a custom error-handler to your site using the vBulletin template engine to display the appropriate errors (e.g. 404 File not Found, 403 Forbidden, etc).

Demo
-------
Go to my site and enter some non-existing url. E.g. Random 404 Error. Or try to access my /cgi-bin path to receive a 403 error.

What to do?
----------------
queries to run: 0
templates changed: 0
templates added: 1 (ERROR_SHELL)
files changed: 1 (.htaccess)
files added: 1 (error.php)

Time needed to install
----------------------------
< 5 mins

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 06-29-2004, 09:52 PM
58sniper 58sniper is offline
 
Join Date: Sep 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #53  
Old 06-29-2004, 10:53 PM
ImportPassion ImportPassion is offline
 
Join Date: Mar 2002
Location: Gilbert, AZ
Posts: 605
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #54  
Old 06-30-2004, 01:22 AM
58sniper 58sniper is offline
 
Join Date: Sep 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).....
Reply With Quote
  #55  
Old 06-30-2004, 06:09 AM
AlexanderT's Avatar
AlexanderT AlexanderT is offline
 
Join Date: Mar 2003
Posts: 294
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #56  
Old 06-30-2004, 11:53 PM
58sniper 58sniper is offline
 
Join Date: Sep 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #57  
Old 07-01-2004, 06:47 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great addition. Thanks.
Reply With Quote
  #58  
Old 07-04-2004, 11:27 PM
58sniper 58sniper is offline
 
Join Date: Sep 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #59  
Old 07-08-2004, 11:21 PM
58sniper 58sniper is offline
 
Join Date: Sep 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #60  
Old 07-18-2004, 12:15 PM
H2k H2k is offline
 
Join Date: Apr 2004
Posts: 177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #61  
Old 07-18-2004, 10:38 PM
58sniper 58sniper is offline
 
Join Date: Sep 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:03 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07208 seconds
  • Memory Usage 2,303KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete