update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,9 +18,14 @@ use Piwik\Tracker\Cache;
use ReflectionClass;
/**
* @see plugins/UserCountry/LocationProvider/Default.php
* @see plugins/UserCountry/functions.php
*/
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/LocationProvider/Default.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
/**
* @see plugins/UserCountry/LocationProvider/DefaultProvider.php
*/
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/LocationProvider/DefaultProvider.php';
/**
* @see plugins/UserCountry/LocationProvider/GeoIp.php
@ -30,8 +35,8 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/LocationProvider/GeoIp.p
/**
* The base class of all LocationProviders.
*
* LocationProviders attempt to determine a visitor's location using other
* visitor info. All LocationProviders require a visitor's IP address, some
* LocationProviders attempt to determine a visitor's location using
* visit information. All LocationProviders require a visitor's IP address, some
* require more, such as the browser language.
*/
abstract class LocationProvider
@ -272,7 +277,7 @@ abstract class LocationProvider
*
* This function should not be called by the Tracker.
*
* @return \Piwik\Plugins\UserCountry\LocationProvider
* @return \Piwik\Plugins\UserCountry\LocationProvider|null
*/
public static function getCurrentProvider()
{
@ -289,7 +294,7 @@ abstract class LocationProvider
public static function setCurrentProvider($providerId)
{
$provider = self::getProviderById($providerId);
if ($provider === false) {
if (empty($provider)) {
throw new Exception(
"Invalid provider ID '$providerId'. The provider either does not exist or is not available");
}
@ -302,17 +307,24 @@ abstract class LocationProvider
* Returns a provider instance by ID or false if the ID is invalid or unavailable.
*
* @param string $providerId
* @return \Piwik\Plugins\UserCountry\LocationProvider|false
* @return \Piwik\Plugins\UserCountry\LocationProvider|null
*/
public static function getProviderById($providerId)
{
foreach (self::getAvailableProviders() as $provider) {
$info = $provider->getInfo();
if ($info['id'] == $providerId) {
if ($provider->getId() == $providerId) {
return $provider;
}
}
return false;
return null;
}
public function getId()
{
$info = $this->getInfo();
return $info['id'];
}
/**
@ -340,7 +352,7 @@ abstract class LocationProvider
&& !empty($location[self::CONTINENT_CODE_KEY])
) {
$continentCode = strtolower($location[self::CONTINENT_CODE_KEY]);
$location[self::CONTINENT_NAME_KEY] = Piwik::translate('UserCountry_continent_' . $continentCode);
$location[self::CONTINENT_NAME_KEY] = continentTranslate($continentCode);
}
// fill in country name if country code is present
@ -348,7 +360,7 @@ abstract class LocationProvider
&& !empty($location[self::COUNTRY_CODE_KEY])
) {
$countryCode = strtolower($location[self::COUNTRY_CODE_KEY]);
$location[self::COUNTRY_NAME_KEY] = Piwik::translate('UserCountry_country_' . $countryCode);
$location[self::COUNTRY_NAME_KEY] = countryTranslate($countryCode);
}
// deal w/ improper latitude/longitude & round proper values
@ -437,22 +449,19 @@ abstract class LocationProvider
/**
* Returns an IP address from an array that was passed into getLocation. This
* will return an IPv4 address or false if the address is IPv6 (IPv6 is not
* supported yet).
* will return an IPv4 address or IPv6 address.
*
* @param array $info Must have 'ip' key.
* @return string|bool
* @return string|null
*/
protected function getIpFromInfo($info)
{
$ip = $info['ip'];
if (IP::isMappedIPv4($ip)) {
return IP::getIPv4FromMappedIPv6($ip);
} else if (IP::isIPv6($ip)) // IPv6 is not supported (yet)
{
return false;
$ip = \Piwik\Network\IP::fromStringIP($info['ip']);
if ($ip instanceof \Piwik\Network\IPv6 && $ip->isMappedIPv4()) {
return $ip->toIPv4String();
} else {
return $ip;
return $ip->toString();
}
}
}