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]
|