HTTP_REFERER problem
| From: | motion_4u | Date: | Wed, 12 Jan 2005 05:24:00 +0000 |
| Subject: | HTTP_REFERER problem | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-22895@lists.php.net to get a copy of this message | ||
Hello,
My name is Sam.
I'm working with PHP almost 5 years and here and there I always stumble on an options,
which PHP still didn't solve or missing.
My last battle took about 6 month until I could explain a problem about the sessions, which
didn't work properly to some on the bug.php.net page.
The below problem is a new one and after I have received a not adequate answer, I have decided to
send it to you.
It is a rare problem and a big problem for some one who needs it.
I'm pasting it here below:
----------------------------------------------------------------------------------
I see that there is a misunderstanding issue regarding the HTTP_REFERER.
It is not a bug, it is only a very important missing option.
Here, there is something very important, which has been neglected.
Not only the browser calls a page. the server does it too!
For example, what is the value of the HTTP_REFERER of an included in
another one?
There are many situations that a PHP file is included in another PHP
file before it is parsed and sent to the browser. In this case the
HTTP_REFERER is very well known by the SEVER or better to say by PHP!
An included file MUST update the header with the URL of the caller,
which is already there.
It might seem something not important but if someone would like to make
sure that only one file is allowed to call and include another php file
on the server, the only way to verify it is to call the HTTP_REFERER
and check who called this file. Incase that it happens on the server
the HTTP_REFERER must contain the URL of the referrer which it is not the case.
Example:
A PHP file [referrer.php] retrieves a hidden value by including another php file
In this case, lets name it [hiddenphpfile.php].
The [hiddenphpfile.php] returns a hidden value back only if the referrer is known.
In this case the referrer file we call as [referrer.php].
The problem is that php doesn't add the value of the $referrer into the Global variable
HTTP_REFERER since it is only programmed to retrieve the referrer from the browser.
[FILE 1: hiddenphpfile.php]
$referrer=getenv('HTTP_REFERER');
// !!! here $referrer gets no value !!!
if($referrer==" referrer.php")
{
return (" $SomeHiddenValue");
}
--------------------------------------------------
[FILE 2: referrer.php]
$ref=include "refer.php";
echo $ref;
--------------------------------------------------
Expected result:
----------------
When a php file included within another one, the HTTP_REFERER should retrieve the URL of the
referrer from the server and not from the browser.
I would be very glad to receive your comment.
Best Regards
Sam