note 5985 deleted from function.getenv by philip
| From: | philip@php.net | Date: | Mon, 09 Jun 2003 21:02:37 +0000 |
| Subject: | note 5985 deleted from function.getenv by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-50058@lists.php.net to get a copy of this message | ||
Note Submitter: c.k.karssen@student.tudelft.nl
----
Get the RIGHT IP adress of the current user
When you use REMOTE_ADDR for getting the IP of the current user,
sometimes you get the IP of the ISP Cache server.
When this happens, the HTTP_X_FORWARDED_FOR is also set, it
contains the IP of the user.
So with this script, you always get the right IP:
if (getenv(HTTP_X_FORWARDED_FOR)){
$ip=getenv(HTTP_X_FORWARDED_FOR);
}
else {
$ip=getenv(REMOTE_ADDR);
}
For comments please mail me.
Klemens Karssen