Re: [PHP] Best way to get the remote IP address?
Hi, Simply... test for HTTP_X_FORWARDED_FOR if it exists, then your client are behind a proxy server, the REMOTE_ADDR is the proxy IP, and HTTP_X_FORWARDED_FOR is the client IP (if not faked by the proxy). hope this helps, Antonio. On Mon, 21 Jan 2002, Bogdan Stancescu wrote: > I can't seem to find any references to HTTP_X_FORWARDED_FOR in the PDF PHP > documentation from January 2001, so you should probably best stick with > 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... > > Bogdan > > Alan McFarlane wrote: > > > I'm trying to get the remote IP address of a user in a (PHP) version and > > server-software independant way, but am having a few problems. > > > > Obviously, I've seen $HTTP_SERVER_VARS['REMOTE_ADDR'], but Ive also seen > > references to $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']. > > > > Is there any generic solution to this problem (and if so, what is it?) > > > > Cheers > > -- > > Alan McFarlane > > [EMAIL PROTECTED] > > ICQ: 20787656 > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Antonio S. Martins Jr. - System Analist | "Only The Shadow Knows | | WorldNet Internet Maringa - PR - Brasil | what evil lurks in the | | E-Mail: [EMAIL PROTECTED] | Heart of Men!" | | [EMAIL PROTECTED] | !!! Linux User: 52392 !!! | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ This e-mail message is 100% Microsoft free! /"\ \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL / \ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Best way to get the remote IP address?
here is a piece o fcode that looks up user ip from env vars recursively 22/01/2002 04:57:50, Jimmy <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Best way to get the remote IP address?
> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Best way to get the remote IP address?
> I can't seem to find any references to HTTP_X_FORWARDED_FOR in the PDF PHP > documentation from January 2001, so you should probably best stick with > 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... That's because it's probably not so much a PHP thing. X-Forwarded-For is normally used when going through a proxy. Say my internal IP is 192.168.1.15, and my proxy's official IP address is 132.248.10.2, then we'd have this: REMOTE_ADDR=132.248.10.2 X_FORWARDED_FOR=192.168.1.15 That way, even when going through a proxy, there's information about who originally submitted the request. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Best way to get the remote IP address?
I can't seem to find any references to HTTP_X_FORWARDED_FOR in the PDF PHP documentation from January 2001, so you should probably best stick with 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... Bogdan Alan McFarlane wrote: > I'm trying to get the remote IP address of a user in a (PHP) version and > server-software independant way, but am having a few problems. > > Obviously, I've seen $HTTP_SERVER_VARS['REMOTE_ADDR'], but Ive also seen > references to $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']. > > Is there any generic solution to this problem (and if so, what is it?) > > Cheers > -- > Alan McFarlane > [EMAIL PROTECTED] > ICQ: 20787656 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Best way to get the remote IP address?
I'm trying to get the remote IP address of a user in a (PHP) version and server-software independant way, but am having a few problems. Obviously, I've seen $HTTP_SERVER_VARS['REMOTE_ADDR'], but Ive also seen references to $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']. Is there any generic solution to this problem (and if so, what is it?) Cheers -- Alan McFarlane [EMAIL PROTECTED] ICQ: 20787656 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]