A better version would be:

if (getenv(HTTP_X_FORWARDED_FOR)) {

        $ip=getenv(HTTP_X_FORWARDED_FOR); 
} else { 
        $ip=getenv(REMOTE_ADDR); 
}       

This checks for proxy forwarding as well, if you just use REMOTE_ADDR you
might end up with a proxy, not the real IP.

Cheers
Jon


-----Original Message-----
From: Andreas Gietl [mailto:[EMAIL PROTECTED]]
Sent: 19 September 2001 11:15
To: Andrew Semark; [EMAIL PROTECTED]
Subject: Re: [PHP] Getting IP address


On Wednesday 19 September 2001 11:37, Andrew Semark wrote:

$addr = getenv('REMOTE_ADDR');

> Can anybody tell me how to get the IP address of the remote machine
looking
> at the web page.  I have two versions of PHP 4 On the box with version
> 4.0.1 I can use $HTTP_SERVER_VARS["REMOTE_ADDR"], but on the other server
> running 4.0.0 this don't work. Is there another way of doing this as it's
> not possible to upgrade this server.


**********************************************************************
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or confidentiality'

**********************************************************************

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to