Re: RE: [PHP] HTTP_X_FORWARDED_FOR?
| From: | sebbe at popmail dot com | Date: | Thu, 10 Jan 2002 18:36:43 +0000 |
| Subject: | Re: RE: [PHP] HTTP_X_FORWARDED_FOR? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-80060@lists.php.net to get a copy of this message | ||
> > Okay, thanks. 'Cause I mean, the REMOTE_ADDR is still there. So you
> > mean that the HTTP_X_FORWARDED_FOR isn't working while I'm working
> localhost?
>
> REMOTE_ADDR contains the IP of the computer that requested your page.
>
> If it was a proxy doing the request, you'll have the proxy's IP in this
> variable, and the IP of the computer that requested the page from the proxy
> will be in HTTP_X_FORWARDED_FOR.
>
Thanks, never really knew that.
> This means the best way to grab an IP is with a a function like this:
>
> <?php
> function getIP () {
> if (getenv(HTTP_X_FORWARDED_FOR)) {
>
> $ip = getenv(HTTP_X_FORWARDED_FOR);
> } else {
> $ip = getenv(REMOTE_ADDR);
> }
> return $ip;
> }
> ?>
>
Yeah, that's what I do. ;)
> I'm unsure what happens with multiple proxies, and I'd be interested to know
> - do you get an array of HTTP_X_FORWARDED_FORs? Do you just get the first or
> the last?
Have no idea...
>
> Cheers
> Jon
>
>
....................................
Get your own free email account from
http://www.popmail.com