Reply to Re: get client IP problem - REMOTE_ADDR

Your name:

Reply:


Posted by Philip Hallstrom on 03/31/05 18:14

On 2005-03-31, Tony Wong <tonywonghs@yahoo.com> wrote:
> Hi, I have a problem with my server A that retrieving proxy server IP
> instead of client machine IP. Below is the code,
>
> $IPaddress=$REMOTE_ADDR;
> print $IPaddress . "<br>";
>
>
> But I have no problem with the same code in my server B to retrieve
> client IP. Would there be a bug of php version?
>
> Server A : PHP version 4.3.2
> Server B : PHP version 4.3.10
>
> I tried the following code too but no clue,
>
> if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
> $realip = getenv( 'HTTP_X_FORWARDED_FOR' );
> } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
> $realip = getenv( 'HTTP_CLIENT_IP' );
> } else {
> $realip = getenv( 'REMOTE_ADDR' );
> }

Try doing:

print_r($_SERVER);

and then looking for what you *know* to be the client IP, then just use
that if it exists.

Good luck!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация