Let's use the following function to obtain the real IP address of the customer based on the judgment. Let's take a look at the php program code for obtaining the real IP address of the customer. Let's use the following function to obtain the real IP address of the customer based on the judgment. Let's take a look at the php program code for obtaining the real IP address of the customer.
Script ec (2); script
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 getenv () function is used to obtain environment variables. Environment variable: HTTP_CLIENT_IP is used to obtain the Client IP address. But it is possible that someone accesses your program through proxy. At this time, we need to use the environment variable:
HTTP_X_FORWARDED_FOR. Including getenv ('remote _ ADDR ') $ _ SERVER ['remote _ ADDR. Touch Luo anyway. When it comes to getting it, you will be done.
*/