| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/usr/bin/php -q
- <?php
- // This code demonstrates how to lookup the country, region, city,
- // postal code, latitude, and longitude by IP Address.
- // It is designed to work with GeoIP/GeoLite City
- // Note that you must download the New Format of GeoIP City (GEO-133).
- // The old format (GEO-132) will not work.
- include("geoipcity.inc");
- include("geoipregionvars.php");
- // uncomment for Shared Memory support
- // geoip_load_shared_mem("/usr/local/share/GeoIP/GeoIPCity.dat");
- // $gi = geoip_open("/usr/local/share/GeoIP/GeoIPCity.dat",GEOIP_SHARED_MEMORY);
- define("DIR_LOCALISE", getcwd() . "/");
- $gi = geoip_open(DIR_LOCALISE."GeoLiteCity.dat",GEOIP_STANDARD);
- $record = geoip_record_by_addr($gi,"93.17.95.144");
-
- print '<?xml version="1.0" encoding="UTF-8"?>';
- print "<root>";
- print "<continent_code>" . $record->continent_code . "</continent_code>";
- print "<country_code>" . $record->country_code . "</country_code>";
- print "<country_code3>" . $record->country_code3 . "</country_code3>";
- print "<country_name>" . $record->country_name . "</country_name>";
- print "<region>" . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "</region>";
- print "<city>" . $record->city . "</city>";
- print "<postal_code>" . $record->postal_code . "</postal_code>";
- print "<latitude>" . $record->latitude . "</latitude>";
- print "<longitude>" . $record->longitude . "</longitude>";
- print "<dma_code>" . $record->dma_code . "</dma_code>";
- print "<area_code>" . $record->area_code . "</area_code>";
- print "</root>";
-
- geoip_close($gi);
- ?>
|