Piwik\Plugins\UserCountry\LocationProvider\GeoIp\ServerBased::getLocation PHP Метод

getLocation() публичный Метод

This function will return different results based on the data used and based on how the GeoIP module is configured. If a region database is used, it may return the country code, region code, city name, area code, latitude, longitude and postal code of the visitor. Alternatively, only the country code may be returned for another database. If your HTTP server is not configured to include all GeoIP information, some information will not be available to Piwik.
public getLocation ( array $info ) : array
$info array Must have an 'ip' field.
Результат array
    public function getLocation($info)
    {
        $ip = $this->getIpFromInfo($info);
        // geoip modules that are built into servers can't use a forced IP. in this case we try
        // to fallback to another version.
        $myIP = IP::getIpFromHeader();
        if (!self::isSameOrAnonymizedIp($ip, $myIP) && (!isset($info['disable_fallbacks']) || !$info['disable_fallbacks'])) {
            Common::printDebug("The request is for IP address: " . $info['ip'] . " but your IP is: {$myIP}. GeoIP Server Module (apache/nginx) does not support this use case... ");
            $fallbacks = array(Pecl::ID, Php::ID);
            foreach ($fallbacks as $fallbackProviderId) {
                $otherProvider = LocationProvider::getProviderById($fallbackProviderId);
                if ($otherProvider) {
                    Common::printDebug("Used {$fallbackProviderId} to detect this visitor IP");
                    return $otherProvider->getLocation($info);
                }
            }
            Common::printDebug("FAILED to lookup the geo location of this IP address, as no fallback location providers is configured. We recommend to configure Geolocation PECL module to fix this error.");
            return false;
        }
        $result = array();
        foreach (self::$geoIpServerVars as $resultKey => $geoipVarName) {
            if (!empty($_SERVER[$geoipVarName])) {
                $result[$resultKey] = $_SERVER[$geoipVarName];
            }
            $geoipVarNameV6 = $geoipVarName . '_V6';
            if (!empty($_SERVER[$geoipVarNameV6])) {
                $result[$resultKey] = $_SERVER[$geoipVarNameV6];
            }
        }
        foreach (self::$geoIpUtfServerVars as $resultKey => $geoipVarName) {
            if (!empty($_SERVER[$geoipVarName])) {
                $result[$resultKey] = utf8_encode($_SERVER[$geoipVarName]);
            }
        }
        $this->completeLocationResult($result);
        return $result;
    }