Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine where posted or remote script is coming from 1

Status
Not open for further replies.

tyhand

Programmer
Joined
Jul 3, 2002
Messages
186
Location
US
Hi all,

I have a website, herein called website "A", that has
a CGI script that posts (action = "post") to a PHP script
on another website, herein called website "B".

How can I tell from within the PHP script in website
"B" that the CGI script is actually coming from
website "A"?

Is there a function call for this? I've been browsing
php.net but haven't found any references. Any an all help,
ideas or references is greatly appreciated. Thanks. Peace!

T Y H A N D
 
in the $_SERVER array there should be a $_SERVER[HTTP_REFERER] value .. which is where the call originated.



______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
However with $_SERVER['HTTP_REFERER'] there are ways to "fake" these values as they are passed with the HTTP request.
If you administer server A and server B I would institute a scheme that sends an encrypted parameter with the request. Only if server B correctly decrypts the passed item it will proceed to take the posted values and process them.
 
$_SERVER['HTTP_REFERER'] is an arbitrary value that is reported in an HTTP header provided by the client software. As DRJ478 has said, it can be forged. Also that value is only reported when the client software has been configured to do so -- otherwise, the value is not present at all. Also, if client software goes directly to a URL, it wasn't referred there, so the value will be blank anyway.

But in any regard, $_SERVER['HTTP_REFERER'] doesn't tell you anything about from where the client software is connecting. It tells you, when present and not forged, the URL of the page which sent the client software to your site, not from where the client software is connecting.

If you need to know from where the client software is coming, use $_SERVER['REMOTE_ADDR']. It tells you the IP address with which the client software connected.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top