Log in

View Full Version : How to use print_standard_error() in init.php?


HuangA
03-14-2005, 01:12 PM
Hi all;
I am on a cPanel box, and I have my forum installed on forums.domain.com, but as we all know, for cPanel boxes, forums.domain is exactly the same as domain.com/forums. Some clever visitors of mine figured that out and started to use that point of presence to access the forum instead. Generally speaking, this does not cause a major problem as it accesses the same DB etc. However, whenever the user tries to login, they get this ugly die('POST requests from foreign hosts are not allowed.'); output with no page decoration what so ever. This poses as a problem for me as I do not wish to have ugly 'debug-look-alike' pages like that sitting around for my visitor...

I did some code probing and found that the message is thrown in init.php; which means any posting request (IE: login, post, reply, edit profile ... etc.) will all throw them the message. I've gone ahead and drafted a quick phrase named "baddomain" as follow
We cannot allow POST requests from this remote location. This is placed in to prevent people from hacking / creating extra work load from external locations. The reason you are seeing this message is most likely because of an error in linking on our part, please do not take this message offensively. Please try your action again by doing so <a href="$vboptions[bburl]/index.php?$session[sessionurl]">here</a>!
... and modified the die('POST requests from foreign hosts are not allowed.'); to ...
require_once('./includes/functions.php');
eval(print_standard_error('error_baddomain'));
die('');

However, I am guessing there might be some other templating stuff that I am missing out as simply doing so does not return anything at all. I get a blank screen with no output what-so-ever. So, if anyone is familiar with coding such, I'd be greatly appreciated if you can tell me how to make use of the function print_standard_error() in init.php so it outputs the error page as it would in any other vb page.

Thanks in advance!

Zachery
03-14-2005, 02:21 PM
Hi all;
I am on a cPanel box, and I have my forum installed on forums.domain.com, but as we all know, for cPanel boxes, forums.domain is exactly the same as domain.com/forums. Some clever visitors of mine figured that out and started to use that point of presence to access the forum instead. Generally speaking, this does not cause a major problem as it accesses the same DB etc. However, whenever the user tries to login, they get this ugly die('POST requests from foreign hosts are not allowed.'); output with no page decoration what so ever. This poses as a problem for me as I do not wish to have ugly 'debug-look-alike' pages like that sitting around for my visitor...

I did some code probing and found that the message is thrown in init.php; which means any posting request (IE: login, post, reply, edit profile ... etc.) will all throw them the message. I've gone ahead and drafted a quick phrase named "baddomain" as follow
We cannot allow POST requests from this remote location. This is placed in to prevent people from hacking / creating extra work load from external locations. The reason you are seeing this message is most likely because of an error in linking on our part, please do not take this message offensively. Please try your action again by doing so <a href="$vboptions[bburl]/index.php?$session[sessionurl]">here</a>!
... and modified the die('POST requests from foreign hosts are not allowed.'); to ...
require_once('./includes/functions.php');
eval(print_standard_error('error_baddomain'));
die('');

However, I am guessing there might be some other templating stuff that I am missing out as simply doing so does not return anything at all. I get a blank screen with no output what-so-ever. So, if anyone is familiar with coding such, I'd be greatly appreciated if you can tell me how to make use of the function print_standard_error() in init.php so it outputs the error page as it would in any other vb page.

Thanks in advance!
I don't believe print_stadnard_error is avaible in that file.

HuangA
03-14-2005, 04:57 PM
Yes, it is not available by default; hence why I had to come here to ask and leave that post of mine unanswered on .com ;)

Ultimately, I'd like to some how use that function to throw a more user friendly error message for the visitors, and as things stand right now, I don't see it happening. Do you have any experience with making it work? Hm.. idea flash... I wonder if I can just create a custom page using vbulletin's skinning system etc. and redirect it there instead... I'll give that a try now I guess...

thanks :)

There we go, I took out the line where it said die('POST....'); and replaced it with header("HTTP/1.0 301 Moved Permanently"); and header("Location http://url/baddomain.php"); where baddomain.php is just a page presenting the error message, and everything works great now :D