if (getenv (' http_client_ip ') && strcasecmp (getenv (' http_client_ip '), ' unknown ')
{
$PHP _ip = getenv (' http_client_ip ');
}
ElseIf (getenv (' http_x_forwarded_for ') && strcasecmp (getenv (' http_x_forwarded_for '), ' unknown ')
{
$PHP _ip = getenv (' http_x_forwarded_for ');
}
ElseIf (getenv (' remote_addr ') && strcasecmp (getenv (' remote_addr '), ' unknown ')
{
$PHP _ip = getenv (' remote_addr ');
}
ElseIf (Isset ($_server[' remote_addr ']) && $_server[' remote_addr '] && strcasecmp ($_server[' Remote_ ADDR '], ' unknown ')
{
$PHP _ip = $_server[' remote_addr '];
}
Preg_match ("/[d.") {7,15}/", $PHP _ip, $ipmatches);
$PHP _ip = $ipmatches [0]? $ipmatches [0]: ' Unknown ';
/**
The function getenv () is the GET environment variable. Environment variable: HTTP_CLIENT_IP is the IP that gets the client. But it's possible that someone else has access to your program through a proxy. Then you need to use the environment variables:
It's http_x_forwarded_for. including getenv (' REMOTE_ADDR ') $_server[' REMOTE_ADDR '] are all to obtain the IP of others. Anyway Touch luo. It's workpiece to meet the one that can get it.
*/