My best shot (very reliable) is bodged together and adapted from various
sources.
Try this :
$comes_from=array(HTTP_VIA
, HTTP_X_COMING_FROM
, HTTP_X_FORWARDED_FOR
, HTTP_X_FORWARDED
, HTTP_COMING_FROM
, HTTP_FORWARDED_FOR
, HTTP_FORWARDED);
// This array *should* hold most of the possible headers identifying the
remote IP address.
// Credit to [EMAIL PROTECTED] for the list of http headers.
foreach ($comes_from as $value) {
if (ereg("^([0-9]{1,3}\.){3,3}[0-9]{1,3}",$$value,$remote_temp)) {
$remote=$remote_temp[0];
// Fish out IP match if ereg returns a value
}}
if (! $remote) {
$remote=$REMOTE_ADDR;
}
And thats it. If your user has a *real* IP address you get $remote set to
value of $REMOTE_ADDR, else it fishes out any forwarded address from the
proxy and returns that ;-) Use gethostbyname to lookup the hostname from IP
address.
Cheers,
Neil Smith.
>----- Original Message -----
>From: "Jeroen Timmers" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Cc: "[PHP-DB]" <[EMAIL PROTECTED]>
>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
> >
> >
****** Message from InterScan E-Mail VirusWall NT ******
** No virus found in attached file noname.htm
This is a virus free message scanned by Zyberway
***************** End of message ***************
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php