You are here

function _geoip_info in GeoIP API 5

Fetch the geoip info for a given ip address

File

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

Code

function _geoip_info($ip) {
  include_once drupal_get_path('module', 'geoip') . '/lib/geoip.inc';
  $gi = geoip_instance();
  if (!$gi) {
    return FALSE;
  }
  $info = array();
  $info['ip'] = $ip;
  $info['country_code'] = geoip_country_code_by_addr($gi, $ip);
  $info['country_name'] = geoip_country_name_by_addr($gi, $ip);
  geoip_close($gi);
  return $info;
}