Geo IP Location


It should be noted that this extension has now been superseded by the GeoIP2 API that MaxMind now produces. There is a pure-PHP set of classes and a C library and extension you can optionally install. The code can be found in various projects on MaxMind's GitHub page:
2013-12-26 19:43:46
If you still want to use legacy binaries but also need IPv6 support this should help: 

In order to support IPv6->Country code easily and without unnecessary files based on the integration above:

Grab a copy of the latest legacy IPv6 data (I'm assuming you already have IPv4 binary):

Decompress and move it to a dir accessible to your web server:

gunzip GeoIPv6.dat
mv GeoIPv6.dat /etc/usr/share/GeoIP/GeoIPv6.dat
Grab a copy of from the Maxmind git dir ( and save it somewhere you can access wherever you'll need to run geoip.

If you have php5-geoip installed as I did, remove it with sudo apt-get remove php5-geoip; purge as necessary.

With the above done you can now test incoming IP address for v4 or v6 and get appropriate results.



//set an IPv6 address for testing

test if $ip is v4 or v6 and assign appropriate .dat file in $gi
run appropriate function geoip_country_code_by_addr() vs geoip_country_code_by_addr_v6()   
if((strpos($ip":") === false)) {
$gi geoip_open("/usr/share/GeoIP/GeoIP1.dat",GEOIP_STANDARD);
$country geoip_country_code_by_addr($gi$ip);
else {
$gi geoip_open("/usr/share/GeoIP/GeoIPv6.dat",GEOIP_STANDARD);
$country geoip_country_code_by_addr_v6($gi$ip);
$ip "<br>" $country;
This is specifically for Countrybut can easily be replicated for City data.
2015-05-08 09:00:26

    Поддержать сайт на родительском проекте КГБ