PHP 中的 GeoIP 和 IP 到国家/地区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13424336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GeoIP and IP to Country in PHP
提问by David Tkachuk
Possible Duplicate:
How to get the page visitors Country with PHP?
可能的重复:
如何使用 PHP 获取页面访问者国家/地区?
I've been searching everywhere, and I can't seem to find anything. I need a free PHP GeoIP/Ip to country.
我到处寻找,似乎什么也找不到。我需要一个免费的 PHP GeoIP/Ip 到国家。
All I can find is that it gives me the country and small form of the country. I also would like to have information of possible street or coords, city, and maybe host information?
我所能找到的就是它给了我国家和国家的小形式。我还想知道可能的街道或坐标、城市的信息,也许还有主机信息?
I need this because I am creating a PHP CMS (for myself and clients) and I want to track ips.
我需要这个,因为我正在创建一个 PHP CMS(为我自己和客户)并且我想跟踪 ips。
I don't really want an API, I want it like a database. Any ideas ?
我真的不想要一个 API,我想要它就像一个数据库。有任何想法吗 ?
回答by Anthony Hatzopoulos
MaxMind GeoLite database: http://dev.maxmind.com/geoip/geoliteORpay for the full version: http://www.maxmind.com/en/geolocation_landing
MaxMind GeoLite 数据库:http://dev.maxmind.com/geoip/geolite或支付完整版:http: //www.maxmind.com/en/geolocation_landing
They also have php libraries to go with it: http://dev.maxmind.com/geoip/downloadable
他们还有 php 库可以使用:http: //dev.maxmind.com/geoip/downloadable
As for PHP, checkout GeoIP libraryand Example geoip_record_by_name()
至于 PHP,请查看GeoIP 库和示例 geoip_record_by_name()
For a database, you could make your own database overtime... and fill it with cached collected data but I doubt that would be as accurate as MaxMind's data.
对于数据库,您可以使自己的数据库超时……并用缓存的收集数据填充它,但我怀疑这是否与 MaxMind 的数据一样准确。
There are manyother methods you could use and couple them with a custom database or even combine it with the GeoLite db: geoplugin, ipinfodb
还有很多其他的方法可以使用与他们夫妇有一个自定义的数据库,甚至与GEOLITE上DB结合起来:geoplugin,ipinfodb
回答by Stefan Koenen
Google is your best friend :).
谷歌是你最好的朋友:)。
you should be able to make it yourself with this information (API):
您应该能够使用此信息 (API) 自己制作:

