Re: Questions about $_SERVER

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

 



Sorry, forgot to include the mailing list email when I replied to this originally...

On Aug 28, 2010, at 8:28 PM, tedd wrote:

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?

I hope that makes better sense.

Cheers,

tedd


I really don't understand what you mean by "remote script" -- most requests are made by clients. REMOTE_ADDR is the IP address of the *client* - i.e. the requesting system. It may or may not be a script. And it may or may not have an accessible hostname.

Is this a situation where you are establishing a service that is to be called by other servers, i.e, some form of API? If not, and if it is a case of a browser client calling a PHP script on your server, most browser clients aren't running on very useful hostnames for the outside world anyway. E.g. the hostname of my mac is "paladin.local" but it obviously can't be called by the outside world by that name. Maybe tell us what you are trying to accomplish by knowing the hostname of the calling machine? Maybe there's another way.

Are you trying to set up two-way communication between the two servers? Normally, communication is established without regard for the calling machine's hostname, because it's going through the connection established by the web server. PHP just returns info along that connection to the calling machine. It seems you would only need to know the requesting system's hostname if you were going to establish some other channel of communication with it, i.e., if your original script was somehow going to call back the calling machine, webbytedd.com to do some other kind of activity. If that *is* what you're doing, I can probably guarantee there's a better way to do it.

However, if what you're after is *authenticating* that the requester is who they say they are, there are ways to do that as well without knowing the requesting host's name (and better than knowing the requesting host's name, you can establish authenticity and access control for a particular script which is much better than just establishing blanket authority for a particular hostname).

However, I'm really reaching here with trying to understand what you want to accomplish by knowing the requesting machine's hostname.

So, please, explain what you are trying to do and maybe we can help with that.

Tamara


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