View Full Version : How do I get the user's IP?
mouse
08-02-2002, 12:20 AM
^^^as titled :thumbsup:
HormonX
08-02-2002, 12:37 AM
this should be the easiest way of doing that ...
<? echo $HTTP_SERVER_VARS["REMOTE_ADDR"] ?>
HormonX
mouse
08-02-2002, 12:45 AM
$REMOTE_ADDR
is quite easy too, cheers anyhoo :thumbsup::D
bcarl314
08-02-2002, 01:22 PM
Can you get the IP address of a computer behind a proxy server?
SYP}{ER
08-02-2002, 03:26 PM
Not sure about the proxy thing, but a few other ways to get the IP
getenv ("REMOTE_ADDR");
or
$_SERVER["REMOTE_ADDR"];
:)
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;
}
You might need to amend the $_SERVER calls to $HTTP_SERVER_VARS (note: I'm pretty sure I copied that from php.net somepage so don't blame me if it works properly ;))
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.