Created
October 2, 2012 07:15
-
-
Save Darkflib/3816994 to your computer and use it in GitHub Desktop.
GeoIP example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
teamplayr.com: | |
This host is located in: NA | |
This host is located in: US | |
Array | |
( | |
[continent_code] => NA | |
[country_code] => US | |
[country_code3] => USA | |
[country_name] => United States | |
[region] => TX | |
[city] => San Antonio | |
[postal_code] => 78218 | |
[latitude] => 29.488899230957 | |
[longitude] => -98.398696899414 | |
[dma_code] => 641 | |
[area_code] => 210 | |
) | |
America/Chicago | |
monitor1.technomonk.net: | |
uk4.technomonk.net: | |
This host is located in: EU | |
This host is located in: GB | |
Array | |
( | |
[continent_code] => EU | |
[country_code] => GB | |
[country_code3] => GBR | |
[country_name] => United Kingdom | |
[region] => H9 | |
[city] => London | |
[postal_code] => | |
[latitude] => 51.500198364258 | |
[longitude] => -0.1262000054121 | |
[dma_code] => 0 | |
[area_code] => 0 | |
) | |
Europe/London | |
www.magrathea-telecom.co.uk: | |
This host is located in: EU | |
This host is located in: GB | |
Array | |
( | |
[continent_code] => EU | |
[country_code] => GB | |
[country_code3] => GBR | |
[country_name] => United Kingdom | |
[region] => | |
[city] => | |
[postal_code] => | |
[latitude] => 54 | |
[longitude] => -2 | |
[dma_code] => 0 | |
[area_code] => 0 | |
) | |
Europe/London | |
www.sysdom.com: | |
This host is located in: NA | |
This host is located in: US | |
Array | |
( | |
[continent_code] => NA | |
[country_code] => US | |
[country_code3] => USA | |
[country_name] => United States | |
[region] => CA | |
[city] => Brea | |
[postal_code] => 92821 | |
[latitude] => 33.926898956299 | |
[longitude] => -117.86119842529 | |
[dma_code] => 803 | |
[area_code] => 714 | |
) | |
America/Los_Angeles | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$hosts=array('teamplayr.com','www.google.com','www.yahoo.co.uk','www.synety.com'); | |
foreach ($hosts as $host) { | |
echo $host.":\n"; | |
$continent = geoip_continent_code_by_name($host); | |
if ($continent) { | |
echo 'This host is located in: ' . $continent."\n"; | |
} | |
$country = geoip_country_code_by_name($host); | |
if ($country) { | |
echo 'This host is located in: ' . $country."\n"; | |
} | |
$record = geoip_record_by_name($host); | |
if ($record) { | |
print_r($record); | |
if ($record['region']!='') { | |
$tz=geoip_time_zone_by_country_and_region ( $record['country_code'], $record['region']); | |
} else { | |
$tz=geoip_time_zone_by_country_and_region ( $record['country_code']); | |
} | |
print_r($tz); | |
} | |
echo "\n\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment