RE: [PHP] Getting IP address

From: Date: Wed, 19 Sep 2001 11:13:59 +0000
Subject: RE: [PHP] Getting IP address
Groups: php.general 
Request: Send a blank email to php-general+get-67815@lists.php.net to get a copy of this message
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:a.gietl@e-admin.de] Sent: 19 September 2001 11:15 To: Andrew Semark; php-general@lists.php.net 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' **********************************************************************

« previous php.general (#67815) next »