-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsample_region.php
More file actions
20 lines (15 loc) · 819 Bytes
/
sample_region.php
File metadata and controls
20 lines (15 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/php -q
<?php
// This code demonstrates how to lookup the country and region by IP Address
// It is designed to work with GeoIP Region available from MaxMind
include("geoip.inc");
include("geoipregionvars.php");
$gi = geoip_open("/usr/local/share/GeoIP/GeoIPRegion.dat",GEOIP_STANDARD);
list ($countrycode,$region) = geoip_region_by_addr($gi,"24.24.24.24");
print $countrycode . " " . $region . " " . $GEOIP_REGION_NAME[$countrycode][$region] . "\n";
list ($countrycode,$region) = geoip_region_by_addr($gi,"80.24.24.24");
print $countrycode . " " . $region . " " . $GEOIP_REGION_NAME[$countrycode][$region] . "\n";
list ($countrycode,$region) = geoip_region_by_addr($gi,"199.243.137.184");
print $countrycode . " " . $region . " " . $GEOIP_REGION_NAME[$countrycode][$region] . "\n";
geoip_close($gi);
?>