Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

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
  #22  
Old 05-12-2004, 12:34 PM
Dankinit Dankinit is offline
 
Join Date: Dec 2001
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
Where would I have to give the path for that at? Do you remember?
This is very useful for anybody writing custom hacks outside of their vb3 base directory and storing css as file:

https://vborg.vbsupport.ru/showthread.php?t=63520
Reply With Quote
  #23  
Old 05-12-2004, 07:19 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AlexanderT
Cool. I have updated the instruction accordingly. <base> is an empty tag, or a standalone tag, that doesn't use a </base> endtag. The /> at the end is sufficient to make the code xhtml 1.0-valid.
Nice to see my tip actually worked
Reply With Quote
  #24  
Old 05-12-2004, 07:35 PM
AlexanderT's Avatar
AlexanderT AlexanderT is offline
 
Join Date: Mar 2003
Posts: 294
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MrNase
Nice to see my tip actually worked
Yup, merci for it
Reply With Quote
  #25  
Old 05-12-2004, 09:19 PM
Synicide Synicide is offline
 
Join Date: Dec 2002
Location: Providence, RI
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow, this is awesome. Saves me a LOT of work.

[high]* Synicide clicks install![/high]
Reply With Quote
  #26  
Old 05-13-2004, 09:39 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Synicide
Wow, this is awesome. Saves me a LOT of work.

[high]* Synicide clicks install![/high]
I love the skin on your site. Did you do that?
Reply With Quote
  #27  
Old 05-13-2004, 12:57 PM
Synicide Synicide is offline
 
Join Date: Dec 2002
Location: Providence, RI
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
I love the skin on your site. Did you do that?
Yep, that's homemade.
Reply With Quote
  #28  
Old 05-13-2004, 02:33 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Synicide
Yep, that's homemade.
Have you thought about releasing it at all?
Reply With Quote
  #29  
Old 05-13-2004, 03:01 PM
Natch's Avatar
Natch Natch is offline
 
Join Date: Nov 2002
Location: Australia
Posts: 851
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AlexanderT
Cool. I have updated the instruction accordingly. <base> is an empty tag, or a standalone tag, that doesn't use a </base> endtag. The /> at the end is sufficient to make the code xhtml 1.0-valid.
One useful bit of info try
Code:
<base href="$vboptions[bburl]" />
and it should work across all boards you could include that code in your template

Also a switch($_SERVER['REDIRECT_STATUS']) would probably be a nicer way to code this ... rather than all those else if's

Just a personal preference thing

[high]* Natch clicks install just the same
[/high]

Great idea!
Reply With Quote
  #30  
Old 05-13-2004, 03:27 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Natch
One useful bit of info try
Code:
<base href="$vboptions[bburl]" />
and it should work across all boards you could include that code in your template

Also a switch($_SERVER['REDIRECT_STATUS']) would probably be a nicer way to code this ... rather than all those else if's

Just a personal preference thing

[high]* Natch clicks install just the same
[/high]

Great idea!
The $vboptions[bburl] doesn't work for stylesheets as files. I just tested it. You have to have the absolute path for the home page to work right.

How would you set up the switch code?
Reply With Quote
  #31  
Old 05-13-2004, 03:30 PM
Natch's Avatar
Natch Natch is offline
 
Join Date: Nov 2002
Location: Australia
Posts: 851
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As I mentioned in the post above, this code can be more efficient (and easier to add new error codes) witha switch statement:

Find:
PHP Code:
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=\"$vboptions[bburl]/$vboptions[contactuslink]\">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=\"$vboptions[bburl]/$vboptions[contactuslink]\">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=\"$vboptions[bburl]/$vboptions[contactuslink]\">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=\"$vboptions[bburl]/$vboptions[contactuslink]\">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=\"$vboptions[bburl]/$vboptions[contactuslink]\">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=\"$vboptions[bburl]/$vboptions[contactuslink]\">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=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if this problem persists.";        

Replace with:
PHP Code:
if(!isset($_SERVER['REDIRECT_STATUS']))
{
        
$error['title'] = "Unknown Error";
        
$error['description'] = "We are currently unable to handle this error.";
        
$error['contact'] = "Please <a href=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if this problem persists.";        
}
else switch(
$_SERVER['REDIRECT_STATUS'])
{
    case(
"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=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if you believe that the mistake is on our part.";
    break;
    case(
"403"):
        
$error['title'] = "403 Forbidden";
        
$error['description'] = "You don't have permission to access this document on this server.";
        
$error['contact'] = "Please <a href=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if you think that there is a mistake.";
    break;
    case(
"401"):
        
$error['title'] = "401 Unauthorized";
        
$error['description'] = "The URL you are requesting requires proper authentication.";
        
$error['contact'] = "Please <a href=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if you think that there is a mistake.";
    break;
    case(
"500"):
        
$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.";
    break;
    case(
"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=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if this problem persists.";
    break;
    default:
        
$error['title'] = "Unknown Error: " $_SERVER['REDIRECT_STATUS'];
        
$error['description'] = "We are currently unable to handle this error.";
        
$error['contact'] = "Please <a href=\"$vboptions[bburl]/$vboptions[contactuslink]\">contact</a> us if this problem persists.";        

Also (to follow all those W3C tips about the TITLE tags) ...

In the ERROR_SHELL template, find:
HTML Code:
<title>$vboptions[bbtitle]</title>
Replace with:
HTML Code:
<title>$error[title] - $vboptions[bbtitle]</title>
UPDATED: thanks Boofo for the heads up about the missing break;
Reply With Quote
Reply


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 04:16 PM.


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.05466 seconds
  • Memory Usage 2,373KB
  • 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
  • (2)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_php
  • (8)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