Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/UserCountry/LocationProvider/GeoIp/Php.php')
-rwxr-xr-xplugins/UserCountry/LocationProvider/GeoIp/Php.php41
1 files changed, 7 insertions, 34 deletions
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Php.php b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
index 33b763e502..2a3fda9dee 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/Php.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
@@ -95,7 +95,6 @@ class Php extends GeoIp
public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
- $isIPv6 = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
$result = array();
@@ -105,11 +104,7 @@ class Php extends GeoIp
case GEOIP_CITY_EDITION_REV0: // city database type
case GEOIP_CITY_EDITION_REV1:
case GEOIP_CITYCOMBINED_EDITION:
- if ($isIPv6) {
- $location = geoip_record_by_addr_v6($locationGeoIp, $ip);
- } else {
- $location = geoip_record_by_addr($locationGeoIp, $ip);
- }
+ $location = geoip_record_by_addr($locationGeoIp, $ip);
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location->country_code;
$result[self::REGION_CODE_KEY] = $location->region;
@@ -122,46 +117,28 @@ class Php extends GeoIp
break;
case GEOIP_REGION_EDITION_REV0: // region database type
case GEOIP_REGION_EDITION_REV1:
- if ($isIPv6) {
- // NOTE: geoip_region_by_addr_v6 does not exist (yet?), so we
- // return the country code and an empty region code
- $location = array(geoip_country_code_by_addr_v6($locationGeoIp, $ip), '');
- } else {
- $location = geoip_region_by_addr($locationGeoIp, $ip);
- }
+ $location = geoip_region_by_addr($locationGeoIp, $ip);
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location[0];
$result[self::REGION_CODE_KEY] = $location[1];
}
break;
case GEOIP_COUNTRY_EDITION: // country database type
- if ($isIPv6) {
- $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr_v6($locationGeoIp, $ip);
- } else {
- $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
- }
+ $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
break;
default: // unknown database type, log warning and fallback to country edition
Log::warning("Found unrecognized database type: %s", $locationGeoIp->databaseType);
- if ($isIPv6) {
- $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr_v6($locationGeoIp, $ip);
- } else {
- $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
- }
+ $result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
break;
}
}
- // NOTE: ISP & ORG require commercial dbs to test. The code has been tested manually,
+ // NOTE: ISP & ORG require commercial dbs to test. this code has been tested manually,
// but not by system tests.
$ispGeoIp = $this->getGeoIpInstance($key = 'isp');
if ($ispGeoIp) {
- if ($isIPv6) {
- $isp = geoip_name_by_addr_v6($ispGeoIp, $ip);
- } else {
- $isp = geoip_org_by_addr($ispGeoIp, $ip);
- }
+ $isp = geoip_org_by_addr($ispGeoIp, $ip);
if (!empty($isp)) {
$result[self::ISP_KEY] = utf8_encode($isp);
}
@@ -169,11 +146,7 @@ class Php extends GeoIp
$orgGeoIp = $this->getGeoIpInstance($key = 'org');
if ($orgGeoIp) {
- if ($isIPv6) {
- $org = geoip_name_by_addr_v6($orgGeoIp, $ip);
- } else {
- $org = geoip_org_by_addr($orgGeoIp, $ip);
- }
+ $org = geoip_org_by_addr($orgGeoIp, $ip);
if (!empty($org)) {
$result[self::ORG_KEY] = utf8_encode($org);
}