This is a PHP extension I wrote for the libGeoIP library from MaxMind that provides a nice and easy class for doing GeoIP. It allows you to find things like what country is from. It also contains information that makes it possible to do things like maps showing where hits are coming from.
It was written to solve three major problems with the current geoip module which is already in PECL.
- not object oriented
- does not allow custom directories
- throws warnings/notices at the most dumb times, like when a record is not found in the database, instead of just sitting down shutting up and returning an empty result.
So I present to you this new extension, geoipo. Both geoip and geoipo can be installed and used at the same time if you need. geoipo also provides a PHP compatibility script you can use as a crutch if you want to migrate to this module but do not have time to really update all your projects properly.
Quick Example
PHP Code:<?php
$geo = new GeoIP('squirrelshaterobots.com');
print_r($geo->getRecord());
/*
[bob@mckay ~]$ php demo.php
stdClass Object
(
[ContinentCode] => NA
[CountryCode] => US
[CountryCode3] => USA
[CountryName] => United States
[RegionCode] => MI
[RegionName] => Michigan
[City] => East Lansing
[PostalCode] => 48823
[Latitude] => 42.762699127197
[Longitude] => -84.44270324707
[TimeZone] => America/New_York
)
*/
?>
