function geoip_country_code in GeoIP API 6
Same name and namespace in other branches
- 5 geoip.module \geoip_country_code()
- 7.2 geoip.module \geoip_country_code()
- 7 geoip.module \geoip_country_code()
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.
Related topics
3 calls to geoip_country_code()
- geoip_json_country in ./
geoip.module - Callback handler that returns JSON data of the country.
- geoip_language_detect_language in geoip_language/
geoip_language.module - Return the language object mapped to the current GeoIP detected country.
- page_cache_fastpath in geoip_language/
geoip_language.fastpath.inc - @file description
File
- ./
geoip.module, line 191 - API for using the MaxMind GeoLite Country database.
Code
function geoip_country_code($ip = NULL) {
$ip = $ip ? $ip : geoip_ip_address();
$gi = geoip_instance();
if (!$gi) {
return FALSE;
}
$cc = geoip_country_code_by_addr($gi, $ip);
geoip_close($gi);
if (variable_get('geoip_debug', FALSE) && !empty($_GET['geoip_debug'])) {
drupal_set_message(t('GeoIP reports country: %cc', array(
'%cc' => $cc,
)));
}
return $cc;
}