PHP gets IP information, PHP gets IP
Php/** * Get client IP * @param integer $type return type 0:string,1:long * @return String|long*/functionGetclientip ($type= 0) { $ip=NULL; if(isset($_server[' Http_x_forwarded_for '])) { $arr=Explode(',',$_server[' Http_x_forwarded_for ']); $pos=Array_search(' Unknown ',$arr); if(false!==$pos)unset($arr[$pos]); $ip=Trim($arr[0]); }ElseIf(isset($_server[' Http_client_ip '])) { $ip=$_server[' Http_client_ip ']; }ElseIf(isset($_server[' REMOTE_ADDR '])) { $ip=$_server[' REMOTE_ADDR ']; } $long=sprintf("%u",Ip2long($ip)); $ip=$long?Array($ip,$long) :Array(' 0.0.0.0 ', 0); return $ip[$type];}/** * Get IP information * @param string|long $IP IP address * @return Array*/functionGetipinfo ($ip){ if(Is_long($ip)) { $ip=Long2ip($ip); } $api= ' http://ip.taobao.com/service/getIpInfo.php '; $ret=file_get_contents($api. '? ip= '.$ip); $ret= Json_decode ($ret,true); if($ret[' code '] = = 0) { return $ret[' Data ']; } return Array();}
http://www.bkjia.com/PHPjc/968597.html www.bkjia.com true http://www.bkjia.com/PHPjc/968597.html techarticle PHP Get IP information, PHP get IP, PHP/* * * Get client IP * @param integer $type return type 0:string,1:long * @return String|long */function g Etclientip ($type = 0) {$ip ...