vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Custom HTTP Error Pages (https://vborg.vbsupport.ru/showthread.php?t=98243)

JJR512 10-11-2005 10:00 PM

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

exceem 10-12-2005 07:28 PM

Ive been waiting for somethign similar to this

thanks :)

Andreas 10-12-2005 07:39 PM

Quote:

This hack asks you to make one modification to your includes\adminfunctions_template.php file, to group its templates together. However, this is not absolutely necessary;
You are right, this edit is not necessary at all ;)

Hook template_groups
PHP Code:

$only['http_error'] = 'HTTP Errors'

Another suggestion:
Use phrases for the Text, so users can easily use it with other Languages too.

dsotmoon 10-12-2005 08:11 PM

wow, works great, i didnt make the file edit though

akanevsky 10-12-2005 08:19 PM

'e' should be a TYPE_UINT.

Itworx4me 10-12-2005 09:25 PM

Quote:

Originally Posted by KirbyDE
You are right, this edit is not necessary at all ;)

Hook template_groups
PHP Code:

$only['http_errors'] = 'HTTP Errors'

Another suggestion:
Use phrases for the Text, so users can easily use it with other Languages too.


Ok using your code above doesn't work. I have tested this and it doesn't group the templates.

Thanks,
Itworx4me

Omega Prime 10-12-2005 10:53 PM

Worked like a charm. Thanks :)

[high]* Omega Prime clicks Install[/high]

Andreas 10-12-2005 11:13 PM

It does work, just leave out the s I added accidently ;)

COBRAws 10-12-2005 11:54 PM

been waiting for this 3.5 port too

Thank you sir

--EDiT--
Phrases please, that would be very nice.

Avalon111 10-13-2005 06:18 AM

great work! i love it!!!

JJR512 10-13-2005 01:53 PM

Quote:

Originally Posted by KirbyDE
You are right, this edit is not necessary at all ;)

Hook template_groups
PHP Code:

$only['http_error'] = 'HTTP Errors'

Another suggestion:
Use phrases for the Text, so users can easily use it with other Languages too.

Just create a new plugin with that code as the code to that hook?

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.

Andreas 10-13-2005 02:09 PM

Phrase with Variable:
Code:

Hello {1}, how are you?
Template using this Phrase:
Code:

<phrase 1="$bbuserinfo[username]">$vbphrase[hello_x_how_are_you]</phrase>
Yes, just make a plugin with this Code and the Templates will be grouped.

JJR512 10-13-2005 03:24 PM

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.

JJR512 10-13-2005 03:26 PM

Quote:

Originally Posted by KirbyDE
Phrase with Variable:
Code:

Hello {1}, how are you?
Template using this Phrase:
Code:

<phrase 1="$bbuserinfo[username]">$vbphrase[hello_x_how_are_you]</phrase>
Yes, just make a plugin with this Code and the Templates will be grouped.

Can you use {1} more than once in a phrase; for example, have the phrase be:
Code:

Hello, {1}! How are you today, {1}?
And the template would still be exactly the same as in your current example?

JJR512 10-13-2005 03:31 PM

Quote:

Originally Posted by Dark Visor
'e' should be a TYPE_UINT.

I think this is probably going just slightly beyond what I know about. How would I make this change, and why is it important? For my education and future reference.

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?

JJR512 10-13-2005 03:33 PM

Wait, I think I answered my own question...

In the httperror.php file, the line
Code:

        'e'        => TYPE_STR
should be
Code:

        'e'        => TYPE_UINT
Is that correct?

(But in the other hack I mentioned, where $p is some text, leave it set to TYPE_STR, right?)

Snake 10-13-2005 06:11 PM

Great, thanks for the hack.

akanevsky 10-13-2005 06:21 PM

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

JJR512 10-13-2005 07:27 PM

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.

Avalon111 10-14-2005 05:09 AM

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?

JJR512 10-14-2005 12:28 PM

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.

Avalon111 10-14-2005 01:14 PM

Quote:

Originally Posted by JJR512
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?

in my screenshot before you see a user called koschel. i have been talking with him when he was display with showing http error message in who is online. he told me that he has no http error on his screen he was watching the who is online page.

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:

Originally Posted by JJR512
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.

I will try that when i get home today. thank you very much for your help!

Avalon111 10-14-2005 02:08 PM

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?

Andreas 10-14-2005 02:16 PM

Moved to Extensions :)

JJR512 10-14-2005 02:51 PM

Quote:

Originally Posted by Avalon111
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?

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.

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.

Avalon111 10-14-2005 04:41 PM

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

Originally Posted by JJR512
It could be that vBulletin is being tricked into thinking the user is on the error page when he isn't.

Yes i believe thats my problem. i have visited the Who is online quite rarely befoe i installed you modification. i am sure this issue was allready there before.

Avalon111 10-14-2005 05:12 PM

update!

when i remove the changes in the .htaccess the problem is gone!

JJR512 10-14-2005 05:43 PM

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]);
and
Code:

        $error['title'] = construct_phrase($vbphrase['error_title_$e']);
But neither worked.

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?

JJR512 10-14-2005 08:16 PM

Please disregard the previous question. The problem was that I hadn't told the script to use the new phrases.

akanevsky 10-14-2005 08:38 PM

Quote:

$error['title'] = construct_phrase($vbphrase['error_title_' . $e]);
Is wrong. Try:

Code:

$error['title'] = construct_phrase($vbphrase["error_title_$e"]);
Or if that doesn't work,

Code:

$errorvar = 'error_title_' . $e;
$error['title'] = construct_phrase($vbphrase["$errorvar"]);


JJR512 10-14-2005 09:32 PM

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];


JJR512 10-14-2005 09:41 PM

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.

Andreas 10-15-2005 04:45 AM

Quote:

Originally Posted by Dark Visor
Quote:

$error['title'] = construct_phrase($vbphrase['error_title_' . $e]);
Is wrong. Try:

Code:

$error['title'] = construct_phrase($vbphrase["error_title_$e"]);

Hmm, why should it be wrong?

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

JJR512 10-17-2005 03:40 PM

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

JJR512 10-17-2005 05:10 PM

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.

oglsmm 10-26-2005 02:39 PM

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.

Snake 10-26-2005 06:45 PM

Same here!

Delphiprogrammi 10-26-2005 09:00 PM

installed no problem found so far

Snake 10-26-2005 09:04 PM

It's working all fine now. Thanks again. :)

JJR512 10-27-2005 12:09 PM

Quote:

Originally Posted by Aftermath
It's working all fine now. Thanks again. :)

Did you do anything to fix the problem?


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
  • Page Generation 0.01987 seconds
  • Memory Usage 1,840KB
  • 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
  • (13)bbcode_code_printable
  • (3)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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