You do not need an IP library, update-free.
Taobao IP Library: http://ip.taobao.com
Thanks for the 5 floor reminder.
/** * Get user real IP */function GetIP () { static $realip; if (Isset ($_server)) {&NB Sp if (Isset ($_server["Http_x_forwarded_for")) { $realip = $_s erver["Http_x_forwarded_for"]; } else if (Isset ($_server["Http_client_ip")) { $rea Lip = $_server["Http_client_ip"]; } else { $realip = $_server["REMOTE_ADDR"]; & nbsp } } else { if (getenv ("Http_x_forwarded_for")) { &nbs P $realip = getenv ("Http_x_forwarded_for"); } else if (getenv ("Http_client_ip")) { $realip = Get Env ("Http_client_ip"); } else { $realip = getenv ("Remote_ADDR "); } { return $realip; /** * get IP location * Taobao IP interface * @Return: array */function getcity ($ip) {$url = " Http://ip.taobao.com/service/getIpInfo.php?ip= ". $ip; $ip =json_decode (file_get_contents ($url)); if ((string) $ip->code== ' 1 ') { return false; } $data = (array) $ip->data; return $data; }