function geoip_instance in GeoIP API 6
Same name and namespace in other branches
- 5 geoip.module \geoip_instance()
- 7.2 geoip.module \geoip_instance()
- 7 geoip.module \geoip_instance()
Singleton wrapper around geoip_open().
2 calls to geoip_instance()
- geoip_city in ./
geoip.module - API function to return the city data for a given IP.
- geoip_country_code in ./
geoip.module - API function to return the country code for a given IP. Defaults to using the current user's IP if not specified. This function works with both the country and city level databases.
File
- ./
geoip.module, line 119 - API for using the MaxMind GeoLite Country database.
Code
function geoip_instance() {
$data_file = geoip_data_file();
if (!$data_file || !file_exists($data_file)) {
return FALSE;
}
// geoip.inc is common to both database types
_geoip_load_lib();
$instance = geoip_open($data_file, GEOIP_STANDARD);
// conditionally load the geoipcity include file
if ($instance->databaseType == GEOIP_CITY_EDITION_REV1) {
_geoip_load_lib('geoipcity.inc');
}
return $instance;
}