Re: Re: help - to get client IP

From: Date: Mon, 11 Feb 2002 14:21:45 +0000
Subject: Re: Re: help - to get client IP
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-16798@lists.php.net to get a copy of this message
Yet a more complete solution ripped off from this list (posted by gaouzief) would be <?php if($HTTP_X_FORWARDED_FOR) { $ip = $HTTP_X_FORWARDED_FOR; } elseif($HTTP_VIA) { $ip = $HTTP_VIA; } elseif($REMOTE_ADDR) { $ip = $REMOTE_ADDR; } else { $ip = "unknown"; } ?> Bogdan Jonathan Underfoot wrote: > This is what I use, I think I got it off the online documentation. I use it > to track users and it checks for proxys. > > if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != "") > {$IP = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]; > $proxy = $HTTP_SERVER_VARS["REMOTE_ADDR"]; > $host = @gethostbyaddr($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]);} > > else > {$IP = $HTTP_SERVER_VARS["REMOTE_ADDR"]; > $host = @gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]);} > > -Jonathan > > ----- Original Message ----- > From: "Jeroen Timmers" <maillist@start4me.nl> > To: <mlists123@yahoo.com> > Cc: "[PHP-DB]" <php-db@lists.php.net> > Sent: Monday, February 11, 2002 7:43 AM > Subject: [PHP-DB] Re: [PHP] help - to get client IP > > > Someone please help me of how I could get the client IP using PHP, when i > > use $remote_addr it gives me the server IP, Kindly help how I could get > the > > IP of clients who are connected to my server or website. > > > > $ip = gethostbyname($REMOTE_HOST); > > > > the you got the IP of the remote user. > > > > Jeroen Timmers > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#16798) next »