You are here

function geoip_instance in GeoIP API 5

Same name and namespace in other branches
  1. 6 geoip.module \geoip_instance()
  2. 7.2 geoip.module \geoip_instance()
  3. 7 geoip.module \geoip_instance()

Singleton wrapper around geoip_open().

2 calls to geoip_instance()
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.
_geoip_info in ./geoip.module
Fetch the geoip info for a given ip address

File

./geoip.module, line 158
API for using the MaxMind GeoLite Country database

Code

function geoip_instance() {
  $data_file = variable_get('geoip_data_file', drupal_get_path('module', 'geoip') . '/GeoIP.dat');
  if (!$data_file || !file_exists($data_file)) {
    drupal_set_message(t('Please <a href="!url">configure</a> the GeoIP data file location.', array(
      '!url' => url('admin/settings/geoip'),
    )));
    return FALSE;
  }
  include_once drupal_get_path('module', 'geoip') . '/lib/geoip.inc';
  $instance = geoip_open($data_file, GEOIP_STANDARD);
  return $instance;
}