You are here

function geoip_ip_address in GeoIP API 5

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

Helper function to get the current ip address

1 call to geoip_ip_address()
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.

File

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

Code

function geoip_ip_address() {
  if (variable_get('geoip_debug', FALSE) && $_GET['geoip_debug']) {
    $ip = $_GET['geoip_debug'];
    drupal_set_message('Using IP: ' . $ip . '.');
  }
  else {
    $ip = $_SERVER['REMOTE_ADDR'];
  }
  return $ip;
}