function geoip_country_code in GeoIP API 5
Same name and namespace in other branches
- 6 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.
File
- ./
geoip.module, line 141 - 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);
return $cc;
}