function _get_region in GeoIP API 7
Same name and namespace in other branches
- 6 lib/geoip.inc \_get_region()
1 call to _get_region()
- geoip_region_by_addr in lib/
geoip.inc
File
- lib/
geoip.inc, line 493
Code
function _get_region($gi, $ipnum) {
if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
$seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV0;
if ($seek_region >= 1000) {
$country_code = "US";
$region = chr(($seek_region - 1000) / 26 + 65) . chr(($seek_region - 1000) % 26 + 65);
}
else {
$country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
$region = "";
}
return array(
$country_code,
$region,
);
}
else {
if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
$seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV1;
//print $seek_region;
if ($seek_region < US_OFFSET) {
$country_code = "";
$region = "";
}
else {
if ($seek_region < CANADA_OFFSET) {
$country_code = "US";
$region = chr(($seek_region - US_OFFSET) / 26 + 65) . chr(($seek_region - US_OFFSET) % 26 + 65);
}
else {
if ($seek_region < WORLD_OFFSET) {
$country_code = "CA";
$region = chr(($seek_region - CANADA_OFFSET) / 26 + 65) . chr(($seek_region - CANADA_OFFSET) % 26 + 65);
}
else {
$country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
$region = "";
}
}
}
return array(
$country_code,
$region,
);
}
}
}