function smart_ip_get_current_visitor_location_data in Smart IP 7
Same name and namespace in other branches
- 6.2 smart_ip.module \smart_ip_get_current_visitor_location_data()
- 6 smart_ip.module \smart_ip_get_current_visitor_location_data()
- 7.2 smart_ip.module \smart_ip_get_current_visitor_location_data()
Get current visitor's location information
8 calls to smart_ip_get_current_visitor_location_data()
- device_geolocation_get_coordinates in modules/
device_geolocation/ device_geolocation.module - Get Visitor's coordinates.
- smart_ip_admin_settings_submit in includes/
smart_ip.admin.inc - Process Forms submitted by IP to Country administration page
- smart_ip_condition_in_city in ./
smart_ip.rules.inc - Condition implementation for IP address in city.
- smart_ip_condition_in_country in ./
smart_ip.rules.inc - Condition implementation for IP address in country.
- smart_ip_condition_in_region in ./
smart_ip.rules.inc - Condition implementation for IP address in region.
File
- ./
smart_ip.module, line 533 - Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address
Code
function smart_ip_get_current_visitor_location_data() {
$location = smart_ip_get_location(ip_address());
if (!isset($location['country']) && !isset($location['country_code']) && !isset($location['region']) && !isset($location['region_code']) && !isset($location['city']) && !isset($location['zip']) && !isset($location['latitude']) && !isset($location['longitude'])) {
// Use server's mod_geoip user's geolocation info as fallback
if (function_exists('apache_note')) {
if ($country = apache_note('GEOIP_COUNTRY_NAME')) {
$location['country'] = $country;
}
if ($country_code = apache_note('GEOIP_COUNTRY_CODE')) {
$location['country_code'] = $country_code;
}
if ($region = apache_note('GEOIP_REGION_NAME')) {
$location['region'] = $region;
}
if ($region_code = apache_note('GEOIP_REGION')) {
$location['region_code'] = $region_code;
}
if ($city = apache_note('GEOIP_CITY')) {
$location['city'] = $city;
}
if ($zip = apache_note('GEOIP_POSTAL_CODE')) {
$location['zip'] = $zip;
}
if ($latitude = apache_note('GEOIP_LATITUDE')) {
$location['latitude'] = $latitude;
}
if ($longitude = apache_note('GEOIP_LONGITUDE')) {
$location['longitude'] = $longitude;
}
}
else {
if (isset($_SERVER['GEOIP_COUNTRY_NAME'])) {
$location['country'] = $_SERVER['GEOIP_COUNTRY_NAME'];
}
if (isset($_SERVER['GEOIP_COUNTRY_CODE'])) {
$location['country_code'] = $_SERVER['GEOIP_COUNTRY_CODE'];
}
if (isset($_SERVER['GEOIP_REGION_NAME'])) {
$location['region'] = $_SERVER['GEOIP_REGION_NAME'];
}
if (isset($_SERVER['GEOIP_REGION'])) {
$location['region_code'] = $_SERVER['GEOIP_REGION'];
}
if (isset($_SERVER['GEOIP_CITY'])) {
$location['city'] = $_SERVER['GEOIP_CITY'];
}
if (isset($_SERVER['GEOIP_POSTAL_CODE'])) {
$location['zip'] = $_SERVER['GEOIP_POSTAL_CODE'];
}
if (isset($_SERVER['GEOIP_LATITUDE'])) {
$location['latitude'] = $_SERVER['GEOIP_LATITUDE'];
}
if (isset($_SERVER['GEOIP_LONGITUDE'])) {
$location['longitude'] = $_SERVER['GEOIP_LONGITUDE'];
}
}
}
return $location;
}