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)

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 :)


All times are GMT. The time now is 12:15 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.02042 seconds
  • Memory Usage 1,850KB
  • 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
  • (3)bbcode_code_printable
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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