Re: RE: [PHP] HTTP_X_FORWARDED_FOR?
| From: | TD - Sales International Holland B.V. | Date: | Fri, 11 Jan 2002 17:19:23 +0000 |
| Subject: | Re: RE: [PHP] HTTP_X_FORWARDED_FOR? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80183@lists.php.net to get a copy of this message | ||
On Thursday 10 January 2002 19:36, sebbe@popmail.com stuffed this into my
mailbox:
Please note that not all proxies will fill in HTTP_X_FORWARDED_FOR. Some will
obscure it others will not fill it in at all, either due to privacy or to
conseal things.
> > > 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