View Single Post
Old 12-07-2005, 10:16   #4
punky
Inactive
 
Join Date: Jun 2003
Age: 45
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: php? detecting ip of NTL user?

Quote:
Originally Posted by philip.j.fry
Isn't that VB rather than PHP?
I thought it was ASP.
__________________

The most robust way of doing it that I have seen is this:

PHP Code:
function getip() {
if (isSet(
$_SERVER)) {
 if (isSet(
$_SERVER["HTTP_X_FORWARDED_FOR"])) {
  
$realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
 } elseif (isSet(
$_SERVER["HTTP_CLIENT_IP"])) {
  
$realip = $_SERVER["HTTP_CLIENT_IP"];
 } else {
  
$realip = $_SERVER["REMOTE_ADDR"];
 }

} else {
 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' );
 }
}
return 
$realip;
} 
From here:

http://board.php-princess.net/index....=ST&f=10&t=14# second post down, by pootergeist. Haven't tried it, looks pretty good though.
punky is offline   Reply With Quote