Phpcms the method of obtaining IP, today do the Yellow pages, because just start phpcms, so the system is somewhat puzzled, there is a comment function to save the comments of IP, Baidu, unexpectedly did not say search, after my hard search, haha found, the original in the system common function, To invoke the method that gets the IP, you must first refer to the system public method:
Pc_base::load_app_func (' Global '); Then this reference can be $ip =ip ();
Found the way to make statements, haha, and thinkphp framework to get IP in the same way, with the method of writing:
/**
* GET request IP
*
* @return IP Address
*/
function IP () {
if (getenv (' http_client_ip ') && strcasecmp (getenv (' http_client_ip '), ' unknown ')) {
$ip = getenv (' http_client_ip ');
} elseif (getenv (' http_x_forwarded_for ') && strcasecmp (getenv (' http_x_forwarded_for '), ' unknown ')) {
$ip = getenv (' http_x_forwarded_for ');
} elseif (getenv (' remote_addr ') && strcasecmp (getenv (' remote_addr '), ' unknown ')) {
$ip = getenv (' remote_addr ');
} elseif (Isset ($_server[' remote_addr ')) && $_server[' remote_addr '] && strcasecmp ($_server[' Remote_ ADDR '], ' unknown ') {
$ip = $_server[' remote_addr '];
}
Return Preg_match ('/[\d\.] {7,15}/', $ip, $matches)? $matches [0]: ';
}
OK, let's say here, just start phpcms can refer to, haha!