You are here

function geoip_ip_address in GeoIP API 7

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

Helper function to get the current ip address

Return value

string

2 calls to geoip_ip_address()
geoip_city in ./geoip.module
API function to return the city data for a given IP. Defaults to using the current user's IP if not specified. This function only works with the city level database and will return false in all other cases.
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 69
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;
}