Overview
Unless otherwise stated all functions return boolean false when something unexpected happens. This could be a missing database, or no record found for the host you wanted to look up. Functions which return objects, if any of the objects have missing data the properties that are missing will also be boolean false.
Static Methods
These are functions you can call off the GeoIP class without creating an object instance.
- static string GeoIP::getDatabaseFile ( int dbid );
- Returns the full file path to the database specified. This does not reflect if the file actually exists or not, only that this is where the library will attempt to look when it comes time to open it. You should check that it exists if you really need to know (see GeoIP::hasDatabase).
- static string GeoIP::getDatabaseInfo ( int dbid );
- Returns the version and copyright information the database specified. Returns boolean false if the database was not found.
- static string GeoIP::getRegionName ( string ccode, string rcode );
- Returns the full region name as specified by the country code (2 or 3 char) and region code (2char). Returns boolean false if no record is found.
- static string GeoIP::getTimeZone ( string ccode, string rcode );
- Returns the full time zone name as specified by the country code (2 or 3 char) and region code (2char). Returns boolean false if no time zone data is found.
- static boolean GeoIP::hasDatabase ( int dbid );
- Returns true or false based on if the database you specified is actually available on the system.
- static void GeoIP::init ( optional string custompath );
- Sets up the library for use. The only time you will need to use this manually is if you want to set a custom directory for the databases. You should use this before using other functions if you are going to do it.
- static array GeoIP::listCountryCodes ( optional int codelen default 2 );
- Returns a list of all the countries codes as an associative array. Array keys will be the 2 or 3 character country code (as specified by the optional codelen) and the array value will be the full country name.
- static array GeoIP::listDatabases ( void );
- Returns a list containing objects of all the databases libGeoIP COULD use, their file path, if they are available, and their description.
Instance Properties
These properties are only accessable on an object instance of GeoIP.
- public string GeoIP->host
- Stores the host name or IP address that is currently being used for GeoIP lookups. You can reuse an object to look up a different host by changing this value.
Instance Methods
These functions are only accessable on an object instance of GeoIP.
- public constructor GeoIP->__construct ( optional string host );
- Creates your object when you make a new one. The argument is optional and if set, will set the default host for this object for GeoIP lookups in the host property.
- public string GeoIP->getContinentCode ( void );
- Returns a 2 character string noting the continent that the specified host is from (e.g. NA for North America). Returns boolean false if no record is found.
- public string GeoIP->getCountryCode ( optional int codelen );
- Returns a 2 or 3 character country code for the current host. Default is 2 unless 3 is specified (e.g. US or USA for United States). Returns boolean false if no record is found.
- public string GeoIP->getCountryName ( void );
- Returns the full name for the country of the current host. Returns boolean false if no record is found.
- public int GeoIP->getID ( void );
- Returns an integer ID for the country of the current host. Returns boolean false if no record is found.
- public string GeoIP->getISP ( void );
- Returns the Internet Service Provider of the current host. Requires GeoIPISP.dat (not free). Returns boolean false if no record is found.
- public object GeoIP->getRecord ( void );
- Returns an object containing all the record data available for the specified host. Any missing data will be set to boolean false. Returns boolean false if no record is found.
- ContinentCode
- CountryCode
- CountryCode3
- CountryName
- RegionCode
- RegionName
- City
- PostalCode
- Latitude
- Longitude
- TimeZone
- Returns an object containing all the record data available for the specified host. Any missing data will be set to boolean false. Returns boolean false if no record is found.
- public object GeoIP->getRegion ( void );
- Returns an object containing all the region data available for the specified host. Any missing data will be set to boolean false. Returns boolean false if no record is found.
- CountryCode
- RegionCode
- RegionName
- TimeZone
- Returns an object containing all the region data available for the specified host. Any missing data will be set to boolean false. Returns boolean false if no record is found.
