Location detecting techniques for IP addresses

前端 未结 9 1167
甜味超标
甜味超标 2020-11-28 12:22

What are the location detecting techniques for IP addresses?
I know to look at the
$_SERVER[\'HTTP_ACCEPT_LANGUAGE\'] (not accurate but mostly useful to

相关标签:
9条回答
  • 2020-11-28 12:45

    U can use this function

     function ip_info(){
                return $data = json_decode(file_get_contents('http://ip-api.com/json/'),true);
            }
    

    Call the function

    $info = ip_info();
    var_dump($info);
    
    0 讨论(0)
  • 2020-11-28 12:46

    Instead of using third party API I would suggest you to use self hosted IP record. This post explain you more

    http://www.techsirius.com/2014/05/simple-geo-tracking-system.html

    Basically they are using maxmind's country city IP database record [http://dev.maxmind.com/geoip/geoip2/geolite2/] with few modifications. After that a sample query

    $ip =  $_SERVER['REMOTE_ADDR'];
    $long = sprintf('%u', ip2long($ip));
    $sql = "SELECT * FROM `geo_ips` WHERE '$long' BETWEEN `ip_start` AND `ip_end`";
    
    0 讨论(0)
  • 2020-11-28 12:47

    One way in which these databases are compiled is from whois information. For example, to determine the location of 69.59.196.211:

    fmark@home:~$ host 69.59.196.211 211.196.59.69.in-addr.arpa domain name pointer stackoverflow.com. fmark@home:~$ whois stackoverflow.com

    Whois Server Version 2.0

    Domain names in the .com and .net domains can now be registered with many different competing registrars.

     <SNIP>
    

    > Registrant: stackoverflow.com llc
    410 Clayton Ave El Cerrito, California 94530 United States

     <SNIP>
    

    Obviously this isn't hugely accurate, so more sophisticated techniques are allegedly used.

    0 讨论(0)
提交回复
热议问题