コード例 #1
0
ファイル: geoip.inc.php プロジェクト: saleshero/geoip-api-php
function _maxmind_get_region($gi, $ipnum)
{
    if ($gi->databaseType == MAXMIND_REGION_EDITION_REV0) {
        $seek_region = _maxmind_seek_country($gi, $ipnum) - MAXMIND_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->MAXMIND_COUNTRY_CODES[$seek_region];
            $region = "";
        }
        return array($country_code, $region);
    } elseif ($gi->databaseType == MAXMIND_REGION_EDITION_REV1) {
        $seek_region = _maxmind_seek_country($gi, $ipnum) - MAXMIND_STATE_BEGIN_REV1;
        if ($seek_region < US_OFFSET) {
            $country_code = "";
            $region = "";
        } elseif ($seek_region < CANADA_OFFSET) {
            $country_code = "US";
            $region = chr(($seek_region - US_OFFSET) / 26 + 65) . chr(($seek_region - US_OFFSET) % 26 + 65);
        } elseif ($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->MAXMIND_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
            $region = "";
        }
        return array($country_code, $region);
    }
}
コード例 #2
0
function _maxmind_get_record($gi, $ipnum)
{
    $seek_country = _maxmind_seek_country($gi, $ipnum);
    if ($seek_country == $gi->databaseSegments) {
        return null;
    }
    return _maxmind_common_get_record($gi, $seek_country);
}