![]() |
Custom HTTP Error Pages
This is a re-write of a hack I made for vBulletin 2.x.
What this hack does is use vBulletin to generate HTTP error pages (such as the 404 - Not Found error). For those of you trying to get an all-vB-based-site, this addition will help complete your quest. Also for anyone who wants a nicer looking HTTP error message than the standard blah. Note: Your website needs to be on a server that uses a .htaccess file, a file located in your root public directory. This may only be servers using the Apache HTTP server, I'm not sure if any other HTTP server, like Microsoft IIS, uses that or not. Some more notes on this are included in the instructions.txt file. There are no vB files to modify. There is one file to upload, and one product to install, which will install several new templates and two plugins. The plugins are for Who's Online display. The templates contain the actual messages. No existing templates are modified. Special thanks to KirbyDE for showing me how to group templates using a plugin rather than a code modification. :) This hack has now been re-written to use phrases. If you have a previous version, here's what you can do to upgrade. 1. Upload the new httperror.php file. 2. Add the product-jjr512_httperr.xml, overwriting the existing. (All old non-used templates should be removed automatically. This version uses only two templates: HTTP_ERROR and http_error_bit.) |
Ive been waiting for somethign similar to this
thanks :) |
Quote:
Hook template_groups PHP Code:
Use phrases for the Text, so users can easily use it with other Languages too. |
wow, works great, i didnt make the file edit though
|
'e' should be a TYPE_UINT.
|
Quote:
Ok using your code above doesn't work. I have tested this and it doesn't group the templates. Thanks, Itworx4me |
Worked like a charm. Thanks :)
[high]* Omega Prime clicks Install[/high] |
It does work, just leave out the s I added accidently ;)
|
been waiting for this 3.5 port too
Thank you sir --EDiT-- Phrases please, that would be very nice. |
great work! i love it!!!
|
Quote:
Also, regarding the templates vs. phrases issue: I originally thought to use phrases. But then I discovered you can't use variables, such as $vboptions[hometitle] in phrases. Is there a way to use variables like that in phrases? If so, I can re-write the hack. But when I put in that variable in a phrase I was testing, it just came out on the page literally, dollar sign and everything. |
Phrase with Variable:
Code:
Hello {1}, how are you? Code:
<phrase 1="$bbuserinfo[username]">$vbphrase[hello_x_how_are_you]</phrase> |
I have updated the hack to include the new plugin provided by KirbyDE. The instructions have been updated. No vBulletin file modifications are necessary. (I copied that file mod from some other hacks that group templates the same way. Now I know it's not necessary to do it like that, and I'll probably create plugins like this for other hacks I've installed and return that file to its stock form.)
Due to the small change in method, the hack is now 2.0.1. This version does not include any phrases as KirbyDE has suggested. It will take me a short while to get all that done and tested, at which point we will probably have 2.1.0. If you have already installed 2.0.0, and are going to upgrade to 2.0.1, simply do this: Removed the modification to your adminfunctions_template.php file, and add the product again, making sure to overwrite the existing version. |
Quote:
Code:
Hello, {1}! How are you today, {1}? |
Quote:
I have another hack I may release soon that's also going to be using a variable through the URL in the same way that $e is used here. However, in this other hack, the value of the variable, $p, will be some text, like file.php?p=something. What should I define that as and how? |
Wait, I think I answered my own question...
In the httperror.php file, the line Code:
'e' => TYPE_STR Code:
'e' => TYPE_UINT (But in the other hack I mentioned, where $p is some text, leave it set to TYPE_STR, right?) |
Great, thanks for the hack.
|
Yes, that is correct.
You might want to read my tutorial, it describes what are the clean variable types in vBulletin. :) Basically, since you are passing an integer through the "e" variable, you should force the integer type on it, but it's just for security's sake :) |
Updated to 2.0.2 based on code change suggested by Dark Visor.
If you have 2.0.1, make the change as described in post# 16 above and upload the modified httperror.php file. If you have 2.0.0, basically do what is in post# 13 above (undo the modification to adminfunctions_template.php, then re-add the product, overwriting the existing version), PLUS upload the new httperror.php file. |
i have noticed that members who are not viewing a error page are listed as viewing error page in Who is online.
i have been talking with one member who has told me that. could that be caused by this modification? |
I've gone to your board and saw one or two people apparently on an error page, just as you've said. But I have no way to know what they're really doing. Have you spoken to the people and confirmed that they definitely did not ever see an error page?
I've looked at my own board, and didn't see anyone on an error page. As far as I can tell, I'm using the exact same code in the two plugins to add a new online location as many other hacks use. It's still possible there's something wrong, but I don't know what it could be yet. If you're absolutely, positively sure these people haven't really been seeing error pages, try disableing the two plugins (in the Plugin Manager in the AdminCP, uncheck the active status of the plugins "Cutom Error Page (Online Location Process)" and "Cutom Error Page (Online Location Unknown)", then watch for a while and see what happens. |
Quote:
Today i have opened the who is online and my location was displayed as HTTP Error Page (see the screenshot my name is infinityloop). i have tried to refresh without any changes. Quote:
|
i have tried to deactivated the plugins. i have opened the Who is online and watched it for about 15 minutes. i have been using "reload this page" to update it. after such a reload i was suddenly displayed with location: unknown viewing forums/httperror.php?e=404
using reload had no effect! i think the problem is caused by vbulletin or my host. not by this modification! My Host is using a loadbalancer thats why i have to use $_SERVER['HTTP_X_REMOTECLIENT_IP'] instead off $_SERVER['REMOTE_ADDR'] could that cause my problem? anyone knows how vbulletin is determing the location of the users? |
Moved to Extensions :)
|
Quote:
Since you've deactivated the plugin, you can see that the user is actually looking at the error page. But you say the user says he hasn't seen the error page. So I don't know what the problem is. It could be that vBulletin is being tricked into thinking the user is on the error page when he isn't. But I don't know anything about how vBulletin determines where a user is, so I don't know how that could be, or how to prevent it. Is anyone else experiencing a similar issue after installing this hack? Let us know. |
[QUOTE=JJR512]Those settings, the $_SERVER..., I don't know anything about those, I don't even know where they are or what they're for. Sorry. I also don't know anything about loadbalancing.[QUOTE]
my host told me that i have to use $_SERVER['HTTP_X_REMOTECLIENT_IP'] in all php scripts to determin the ip adresses of the visitors. otherwise vbulletin shows the ip from the loadbalancing server as ip fron the users. i had to edit the includes\class_core.php Quote:
|
update!
when i remove the changes in the .htaccess the problem is gone! |
Kirby (or anyone else): Can you use a variable as part of a phrase name?
I have created a bunch of phrases called error_title_400, _401, _403, etc. Rather than creating a long if...else...else...else... statement to call each phrase by its full name, I'd like to just use one statement to call the phrase, using the value of $e as part of the name. I have tried both Code:
$error['title'] = construct_phrase($vbphrase['error_title_' . $e]); Code:
$error['title'] = construct_phrase($vbphrase['error_title_$e']); I also tried both without the contruct_phrase function being used (when is it appropriate to use that function and when shouldn't it be used?). Is there a way to do this? |
Please disregard the previous question. The problem was that I hadn't told the script to use the new phrases.
|
Quote:
Code:
$error['title'] = construct_phrase($vbphrase["error_title_$e"]); Code:
$errorvar = 'error_title_' . $e; |
The first thing I originally tried, which is the bit of code you said is wrong, does actually work.
Well, let me rephrase that. It works without using the construct_phrase function. This is what I'm using, and it works, and is about to be uploaded: Code:
$error['title'] = $vbphrase['error_title_' . $e]; |
The hack is now updated to use phrases for, I believe, all text displayed.
If you have an earlier version, upgrade instructions are now in the hack description above. |
Quote:
@JJR512 Wasn't the previous version a product as well? Then you don't have to worry about old templates or such; product management will take care of that. The User just has to reimport the XML :) |
I didn't realize that. So when you import a product, using the overwrite, it will also remove any templates with that product's name that are not in the new version of the product? Wow. Great stuff! :)
|
Note: The product file has been updated to correct the "refresh" and "back" messages be actual links that will refresh the page or go back to the previous page. The links were accidentally converted to text when I was converting the original templates into phrases.
If you had the 2.1.0 version, you only need to re-add the product file, overwriting the previous version. For any other earlier version, download the new httperrors211.zip file and follow the same instructions already posted for upgrading to 2.1.0. |
I also am getting a lot of people reported as "Viewing HTTP Error" on the Who's Online page, when i know they are not seeing an error. I don't have anything in my .httaccess file either.
|
Same here!
|
installed no problem found so far
|
It's working all fine now. Thanks again. :)
|
Quote:
|
All times are GMT. The time now is 04:46 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|