You are here

function geoip_ip_address in GeoIP API 6

Same name and namespace in other branches
  1. 5 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.

2 calls to geoip_ip_address()
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 105
API for using the MaxMind GeoLite Country database.

Code

function geoip_ip_address() {
  if (variable_get('geoip_debug', FALSE) && !empty($_GET['geoip_debug'])) {
    $ip = $_GET['geoip_debug'];
    drupal_set_message(t('GeoIP is in debug mode. Using IP: %ip', array(
      '%ip' => $ip,
    )));
  }
  else {
    $ip = ip_address();
  }
  return $ip;
}