Re: Best way to get the remote IP address?
| From: | gaouzief | Date: | Tue, 22 Jan 2002 10:20:55 +0000 |
| Subject: | Re: Best way to get the remote IP address? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81523@lists.php.net to get a copy of this message | ||
here is a piece o fcode that looks up user ip from env vars recursively
<?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";
}
?>
22/01/2002 04:57:50, Jimmy <jimmy@spacedisk.com> wrote:
>> either $HTTP_SERVER_VARS['REMOTE_ADDR'] or simply $REMOTE_ADDR (if you use
>> $REMOTE_ADDR in functions make sure you do a global on it first) - I
>> personally use $REMOTE_ADDR, but you should read the docs for details...
>
>using $REMOTE_ADDR directly is fine as long as the
>"register_global" setting is off.
>
>otherwise, it's wiser to use getenv('REMOTE_ADDR') instead of
>$REMOTE_ADDR directly.
>
>--
>Jimmy
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Failure doesn't mean you'll never make it. It just means it may take longer.
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>