ip's behind proxy-server

From: Date: Sat, 05 Jul 2003 15:43:19 +0000
Subject: ip's behind proxy-server
Groups: php.general 
Request: Send a blank email to php-general+get-154062@lists.php.net to get a copy of this message
I've a problem: I need to block accounts with the same ip, but if it's a proxy-server you get only the proxy-server ip's. I downloaded somewhere this script: <?php $proxy=""; $IP = ""; if (isSet($_SERVER)) { if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) { $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; $proxy = $_SERVER["REMOTE_ADDR"]; } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) { $IP = $_SERVER["HTTP_CLIENT_IP"]; } else { $IP = $_SERVER["REMOTE_ADDR"]; } } else { if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) { $IP = getenv( 'HTTP_X_FORWARDED_FOR' ); $proxy = getenv( 'REMOTE_ADDR' ); } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) { $IP = getenv( 'HTTP_CLIENT_IP' ); } else { $IP = getenv( 'REMOTE_ADDR' ); } } if (strstr($IP, ',')) { $ips = explode(',', $IP); $IP = $ips[0]; } $RemoteInfo[0]=$IP; $RemoteInfo[1]=$proxy; print "Client-ip: " . $RemoteInfo[0] . "<BR>Proxy-ip: " . $RemoteInfo[1]; ?> But that doesn't seems to work, it will only give your proxy-server ip's, and doesn't give the real client-ip. Does someone know how to recieve the real client-ip, and not the proxy-server ip. Thanx Paul

« previous php.general (#154062) next »