<?php
isset($_SERVER['HTTP_X_FORWARDED_FOR'])?$ip = $_SERVER['HTTP_X_FORWARDED_FOR']:$ip = $_SERVER['REMOTE_ADDR'];
     $ch = curl_init();
     curl_setopt($ch,CURLOPT_URL,"http://ip.taobao.com/service/getIpInfo.php?ip=$ip");
     curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
     curl_setopt($ch,CURLOPT_HEADER,0);
     $ip2=curl_exec($ch);
     $ip_js=json_decode($ip2,true);
     $dizhi=$ip_js['data']['country']." ".$ip_js['data']['region']." ".$ip_js['data']['city'];
?>