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
  #62  
Old 08-29-2004, 06:28 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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?
Reply With Quote
  #64  
Old 08-30-2004, 03:05 AM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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();
?>
Reply With Quote
  #65  
Old 08-30-2004, 03:08 AM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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

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
Reply With Quote
  #68  
Old 01-01-2005, 07:11 PM
Jim Mayhugh's Avatar
Jim Mayhugh Jim Mayhugh is offline
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #69  
Old 02-28-2005, 08:55 PM
Delphiprogrammi Delphiprogrammi is offline
 
Join Date: Feb 2004
Location: Landen(Belgium)
Posts: 1,335
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 ?
Reply With Quote
  #70  
Old 03-01-2005, 01:10 PM
Delphiprogrammi Delphiprogrammi is offline
 
Join Date: Feb 2004
Location: Landen(Belgium)
Posts: 1,335
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #71  
Old 03-14-2005, 02:38 PM
Polo's Avatar
Polo Polo is offline
 
Join Date: Jun 2004
Posts: 893
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
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 09:09 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.05197 seconds
  • Memory Usage 2,393KB
  • 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
  • (3)bbcode_code
  • (5)bbcode_php
  • (4)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
  • (3)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