Re: Questions about $_SERVER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
At 12:15 AM +0200 8/29/10, Peter Lind wrote:
On 28 August 2010 23:45, tedd <tedd.sperling@xxxxxxxxx> wrote:

> So, I'm trying to figure out a compliment to $_SERVER['SERVER_NAME'] such as
 something like $_SERVER['REMOTE_NAME'].

 > Is there such a beast?

You're not making any sense. For the script on your local host to be
able to connect and communicate with the remote host, it would need to
know the name of the remote host. Hence, the local host already knows
the name and has no reason to ask the remote host for a name by which
to contact it.
 That's what I get from your description of the problem. You probably
want to clarify some things.

Regards
Peter

Peter:

Sorry for not making sense. But sometimes you have to confirm the players (both server and remote) in communications.

Try this -- place this script on your site:

<?php
print_r($_SERVER);
?>

You will note that:

[SERVER_NAME] => is the domain name of your site.

Also:

[SERVER_ADDR] => is the IP of your site. If you are on a shared host, then it will still be the IP of the main host.

Please note:

[REMOTE_ADDR] => is the IP of the remote server. It *will be* the IP of the remote main host regardless of if the requesting script is running on the remote main host OR is running under a remote shared host.

Here's an example:

My site http://webbytedd.com is running on a shared host.

The server address reported for this site is: 74.208.162.186

However, if I enter 74.208.162.186 into a browser, I do not arrive at webbytedd.com, but instead go to securelayer.com who is my host.

Now, if webbytedd.com was the requesting script, how could the original script know what domain name the request came from? As it is now, it can only know the main host ID, but not the domain name of the requesting script. Does that make my question any clearer?

So my questions basically is -- how can I discover the actual domain name of the remote script when it is running on a shared server?

Their is not existing variable (if you would) that your server, when connecting to a remote server, would be sending. So, to have the remote end be able to identify the initiating host identity, the initiating side would have to add some something to the headers or pass it along in the body of the request itself.

What type of service are you trying to create on your server? And what protocol would it be using to connect to the remote server? If you are using cURL, you could add something to the headers before you send the request. But, if you are using something like fopen or file_get_contents, you are stuck. You would not be able to modify the headers being sent in the request.

If you are in need of identifying the initial server from the second server, then I would suggest using cURL and adding something unique to the headers before you send the request to the remote server.

Hope that is clear as mud.


I hope that makes better sense.

Cheers,

tedd



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux