[Edit] Get The Location From The Ip
examplevar_dump(ip2location('91.110.223.84'));will return: array(13) { ["Ip"]=> string(13) "91.110.223.84" ["Status"]=> string(2) "OK" ["CountryCode"]=> string(2) "GB" ["CountryName"]=> string(14) "United Kingdom" ["RegionCode"]=> string(2) "P3" ["RegionName"]=> string(12) "Warwickshire" ["City"]=> string(8) "Nuneaton" ["ZipPostalCode"]=> string(0) "" ["Latitude"]=> string(7) "52.5167" ["Longitude"]=> string(7) "-1.4667" ["TimezoneName"]=> string(13) "Europe/London" ["Gmtoffset"]=> string(4) "3600" ["Isdst"]=> string(1) "1" } /** * Return true if $ip is a valid ip */ function isIp($ip){ if(preg_match("^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}^", $ip)) return true; else return false; } /** * Return the geolocation of user ip */ function ip2location( $ip = null){ if( $ip == null ) $ip = IP; if( isIp( $ip ) ){ $location = file_get_contents( "http://ipinfodb.com/ip_query.php?ip={$ip}&output=json&timezone=true" ); return json_decode($location, true); } } |
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
© Advanced Web Core. All rights reserved