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)

AlexanderT 05-10-2004 09:00 PM

Custom error-handler based on vBulletin templates
 
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

Boofo 05-11-2004 05:46 PM

Ahhh, a new toy for me to play with. Thank you very much, sir. ;)

[high]* Boofo clicks the install button continuously![/high]

sabret00the 05-11-2004 05:52 PM

beautiful :)

Intex 05-11-2004 06:28 PM

Nice work. I'll add to my install list :cool:.

Boofo 05-11-2004 06:39 PM

I'm having a strange problem with my style background not showing as well as the alt1 and alt2 variables. :(

Preech 05-11-2004 07:39 PM

I can't get this to work. I know it has something to do with how I'm doing the htaccess file.

FleaBag 05-11-2004 08:33 PM

Same here. When I install it every page get's a 500 error. Everything is in my root folder, I commented out the chmod line but to no avail.

Boofo 05-11-2004 08:38 PM

Quote:

Originally Posted by Boofo
I'm having a strange problem with my style background not showing as well as the alt1 and alt2 variables. :(

If the error.php file is accessed from my forums directory, it looks like it is supposed to. If it is accessed from my home page, that is where I have the problem with the background of my styles not showing and making the page look wierd. Anyone have any ideas how to fix this? ;)

Dankinit 05-11-2004 08:40 PM

You might want to take out custom code in that error.php and re-release it...

Also a side note to anybody installing it, if you haven't put absolute paths to your navbar links, you'll see they point to incorrect files.

Dankinit 05-11-2004 08:42 PM

Quote:

Originally Posted by Boofo
If the error.php file is accessed from my forums directory, it looks like it is supposed to. If it is accessed from my home page, that is where I have the problem with the background of my styles not showing and making the page look wierd. Anyone have any ideas how to fix this? ;)

Sounds like it's looking in the wrong place for the css file. I think i had to hack my board to give it an absolute path for the css file...can't remember though, it was awhile ago. ;)

Boofo 05-11-2004 08:47 PM

Quote:

Originally Posted by Dankinit
Sounds like it's looking in the wrong place for the css file. I think i had to hack my board to give it an absolute path for the css file...can't remember though, it was awhile ago. ;)

Where would I have to give the path for that at? Do you remember? ;)

What's wierd is that my home page doesn't have a problem with it.

GamerJunk.net 05-12-2004 03:59 AM

Good hack, but my host already lets me make my own error pages so I could easily do this without the hack.

Great job though!

MrNase 05-12-2004 04:04 AM

I don't know if it validates but placing

Code:

        <base href="http://www.sportboard.de" />
above </header> makes all links have an absolut path :)

test.html goes to http://www.sportboard.de/test.html and even a relative link to a stylesheet should change.

Pure magic ;)

colicab-d 05-12-2004 04:11 AM

oooh now this is handy :) thnx very much :)

AlexanderT 05-12-2004 05:16 AM

Ok, I updated the hack with improved instruction. Please download again.

@Boofo: Error.php is now copied to your forums path; please re-download the hack. I assume you store CSS stylesheets as files, this is why it didn't work correctly for you.

@Preech/FleaBag: Check the new instruction. Perhaps you need to ask your webhost for assistance.

@Dankinit: Ok, I moved the custom error handling specific to my site to /example/. I included it first place to help people further customizing their error responses.

Greets
Alex

Phalynx 05-12-2004 06:50 AM

*install*

Boofo 05-12-2004 08:48 AM

Quote:

Originally Posted by AlexanderT
Ok, I updated the hack with improved instruction. Please download again.

@Boofo: Error.php is now copied to your forums path; please re-download the hack. I assume you store CSS stylesheets as files, this is why it didn't work correctly for you.

Greets
Alex

Didn't chnage anything. I still get the same thing on the home page. If I select NO for stylesheets as files, it works fine. But I like to have them as files. :(

AlexanderT 05-12-2004 09:44 AM

Boofo did you read the new instruction? Earlier you said yourself that "if the error.php file is accessed from my forums directory, it looks like it is supposed to" ?!

Edit: Ahh I think i understand your problem now. I must think again if it is at all possible to support external style sheets like in your case then. Perhaps if you copy the style sheets to your root path, but that would be a pain. Lemme think about it.

Edit2: Could you add <base href="http://www.yoursite.com/yourforum/" /> to the <head> section of the ERROR_SHELL template and see if it does any difference?

Greets

Boofo 05-12-2004 10:15 AM

Quote:

Originally Posted by AlexanderT
Edit2: Could you add <base href="http://www.yoursite.com/yourforum/"> to the <head> section of the ERROR_SHELL template and see if it does any difference?

Greets

That fixed it! Thank you, sir. ;)

Do I need to put a closing </base> anywhere with that?

AlexanderT 05-12-2004 10:48 AM

Quote:

Originally Posted by Boofo
That fixed it! Thank you, sir. ;)
Do I need to put a closing </base> anywhere with that?

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.

Dankinit 05-12-2004 11:34 AM

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

MrNase 05-12-2004 06:19 PM

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

AlexanderT 05-12-2004 06:35 PM

Quote:

Originally Posted by MrNase
Nice to see my tip actually worked :)

Yup, merci for it :)

Synicide 05-12-2004 08:19 PM

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

[high]* Synicide clicks install![/high]

Boofo 05-13-2004 08:39 AM

Quote:

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

[high]* Synicide clicks install![/high]

I love the skin on your site. Did you do that? ;)

Synicide 05-13-2004 11:57 AM

Quote:

Originally Posted by Boofo
I love the skin on your site. Did you do that? ;)

Yep, that's homemade. :D

Boofo 05-13-2004 01:33 PM

Quote:

Originally Posted by Synicide
Yep, that's homemade. :D

Have you thought about releasing it at all? ;)

Natch 05-13-2004 02:01 PM

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!

Boofo 05-13-2004 02:27 PM

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?

Natch 05-13-2004 02:30 PM

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;

Natch 05-13-2004 02:33 PM

Quote:

Originally Posted by Boofo
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. ;)

You're right ... then you could use $vboptions[homeurl]/forums/ but that defeats the purpose of having one template for all ...
Quote:

Originally Posted by Boofo
How would you set up the switch code?

I knoew you would ask :D see above :)

Natch 05-13-2004 02:35 PM

I believe that Zachery has posted code that gives an absolute path to the link href statement to call stylesheets - that's why I didn't notice it not working ... it did for me :)

Boofo 05-13-2004 02:58 PM

Witrh Zach's code, I don't need the Base code in the template anymore. Thank you, sir. ;)

Boofo 05-13-2004 03:08 PM

Quote:

Originally Posted by Natch
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.";
    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>

Shouldn't there be a break before the default line?

paulomt1 05-13-2004 04:12 PM

Where I can add the 'AllowOverride FileInfo' entry?

Problem already resolved, thanks

Synicide 05-13-2004 07:41 PM

Quote:

Originally Posted by Boofo
Have you thought about releasing it at all? ;)

I dunno dude, I kind of like my one of a kind styles. But hey, if I ever feel like coming up with a more generic version of it... I guess I could release it, you think it'd be a good idea?

Boofo 05-13-2004 08:30 PM

Quote:

Originally Posted by Synicide
I dunno dude, I kind of like my one of a kind styles. But hey, if I ever feel like coming up with a more generic version of it... I guess I could release it, you think it'd be a good idea?

I think that would be an excellent idea. ;)

ImportPassion 05-19-2004 01:17 AM

i wasn't using the sendmessage.php, so the link was messed up for contact. that should be an option.

also, it's funny, when you do click the contact us link, it takes u to the contact page and after you send it, it takes u back to the 404 page. ;)

Natch 05-19-2004 01:23 AM

Quote:

Originally Posted by Boofo
Shouldn't there be a break before the default line?

Yup - I''ll modify my post to reflect that :) (good debugging)

Boofo 05-19-2004 01:37 AM

Quote:

Originally Posted by Natch
Yup - I''ll modify my post to reflect that :) (good debugging)

Always willing to help a friend out. ;)


All times are GMT. The time now is 07:08 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.03204 seconds
  • Memory Usage 1,955KB
  • 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
  • (4)bbcode_html_printable
  • (4)bbcode_php_printable
  • (21)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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