update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -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
|
||||
|
|
@ -104,7 +104,7 @@ class DefaultProvider extends LocationProvider
|
|||
$desc = Piwik::translate('UserCountry_DefaultLocationProviderDesc1') . ' '
|
||||
. Piwik::translate('UserCountry_DefaultLocationProviderDesc2',
|
||||
array('<strong>', '<em>', '</em>', '</strong>'))
|
||||
. '<p><em><a href="http://piwik.org/faq/how-to/#faq_163" target="_blank">'
|
||||
. '<p><em><a href="http://piwik.org/faq/how-to/#faq_163" rel="noreferrer" target="_blank">'
|
||||
. Piwik::translate('UserCountry_HowToInstallGeoIPDatabases')
|
||||
. '</em></a></p>';
|
||||
return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc, 'order' => 1);
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -90,7 +90,7 @@ class Pecl extends GeoIp
|
|||
// get isp data if the isp database is available
|
||||
if (self::isISPDatabaseAvailable()) {
|
||||
$isp = @geoip_isp_by_name($ip);
|
||||
if ($ip !== false) {
|
||||
if ($isp !== false) {
|
||||
$result[self::ISP_KEY] = utf8_encode($isp);
|
||||
}
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ class Pecl extends GeoIp
|
|||
$desc = Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Pecl1') . '<br/><br/>'
|
||||
. Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Pecl2');
|
||||
$installDocs = '<em>'
|
||||
. '<a target="_blank" href="http://piwik.org/faq/how-to/#faq_164">'
|
||||
. '<a rel="noreferrer" target="_blank" href="http://piwik.org/faq/how-to/#faq_164">'
|
||||
. Piwik::translate('UserCountry_HowToInstallGeoIpPecl')
|
||||
. '</a>'
|
||||
. '</em>';
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
|
||||
|
||||
|
||||
use Piwik\Log;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
|
||||
|
|
@ -96,6 +95,7 @@ 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,7 +105,11 @@ class Php extends GeoIp
|
|||
case GEOIP_CITY_EDITION_REV0: // city database type
|
||||
case GEOIP_CITY_EDITION_REV1:
|
||||
case GEOIP_CITYCOMBINED_EDITION:
|
||||
$location = geoip_record_by_addr($locationGeoIp, $ip);
|
||||
if ($isIPv6) {
|
||||
$location = geoip_record_by_addr_v6($locationGeoIp, $ip);
|
||||
} else {
|
||||
$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;
|
||||
|
|
@ -118,28 +122,46 @@ class Php extends GeoIp
|
|||
break;
|
||||
case GEOIP_REGION_EDITION_REV0: // region database type
|
||||
case GEOIP_REGION_EDITION_REV1:
|
||||
$location = geoip_region_by_addr($locationGeoIp, $ip);
|
||||
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);
|
||||
}
|
||||
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
|
||||
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
default: // unknown database type, log warning and fallback to country edition
|
||||
Log::warning("Found unrecognized database type: %s", $locationGeoIp->databaseType);
|
||||
|
||||
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: ISP & ORG require commercial dbs to test. this code has been tested manually,
|
||||
// but not by integration tests.
|
||||
// NOTE: ISP & ORG require commercial dbs to test. The code has been tested manually,
|
||||
// but not by system tests.
|
||||
$ispGeoIp = $this->getGeoIpInstance($key = 'isp');
|
||||
if ($ispGeoIp) {
|
||||
$isp = geoip_org_by_addr($ispGeoIp, $ip);
|
||||
if ($isIPv6) {
|
||||
$isp = geoip_name_by_addr_v6($ispGeoIp, $ip);
|
||||
} else {
|
||||
$isp = geoip_org_by_addr($ispGeoIp, $ip);
|
||||
}
|
||||
if (!empty($isp)) {
|
||||
$result[self::ISP_KEY] = utf8_encode($isp);
|
||||
}
|
||||
|
|
@ -147,7 +169,11 @@ class Php extends GeoIp
|
|||
|
||||
$orgGeoIp = $this->getGeoIpInstance($key = 'org');
|
||||
if ($orgGeoIp) {
|
||||
$org = geoip_org_by_addr($orgGeoIp, $ip);
|
||||
if ($isIPv6) {
|
||||
$org = geoip_name_by_addr_v6($orgGeoIp, $ip);
|
||||
} else {
|
||||
$org = geoip_org_by_addr($orgGeoIp, $ip);
|
||||
}
|
||||
if (!empty($org)) {
|
||||
$result[self::ORG_KEY] = utf8_encode($org);
|
||||
}
|
||||
|
|
@ -298,7 +324,7 @@ class Php extends GeoIp
|
|||
$desc = Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Php1') . '<br/><br/>'
|
||||
. Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Php2',
|
||||
array('<strong><em>', '</em></strong>', '<strong><em>', '</em></strong>'));
|
||||
$installDocs = '<em><a target="_blank" href="http://piwik.org/faq/how-to/#faq_163">'
|
||||
$installDocs = '<em><a rel="noreferrer" target="_blank" href="http://piwik.org/faq/how-to/#faq_163">'
|
||||
. Piwik::translate('UserCountry_HowToInstallGeoIPDatabases')
|
||||
. '</em></a>';
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -12,8 +12,8 @@ namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
|
|||
use Piwik\Common;
|
||||
use Piwik\IP;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\UserCountry\LocationProvider;
|
||||
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
|
||||
use Piwik\Plugins\UserCountry\LocationProvider;
|
||||
|
||||
/**
|
||||
* A LocationProvider that uses an GeoIP module installed in an HTTP Server.
|
||||
|
|
@ -28,6 +28,7 @@ class ServerBased extends GeoIp
|
|||
const TITLE = 'GeoIP (%s)';
|
||||
const TEST_SERVER_VAR = 'GEOIP_ADDR';
|
||||
const TEST_SERVER_VAR_ALT = 'GEOIP_COUNTRY_CODE';
|
||||
const TEST_SERVER_VAR_ALT_IPV6 = 'GEOIP_COUNTRY_CODE_V6';
|
||||
|
||||
private static $geoIpServerVars = array(
|
||||
parent::COUNTRY_CODE_KEY => 'GEOIP_COUNTRY_CODE',
|
||||
|
|
@ -96,6 +97,11 @@ class ServerBased extends GeoIp
|
|||
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])) {
|
||||
|
|
@ -150,25 +156,27 @@ class ServerBased extends GeoIp
|
|||
}
|
||||
|
||||
$available = !empty($_SERVER[self::TEST_SERVER_VAR])
|
||||
|| !empty($_SERVER[self::TEST_SERVER_VAR_ALT]);
|
||||
|| !empty($_SERVER[self::TEST_SERVER_VAR_ALT])
|
||||
|| !empty($_SERVER[self::TEST_SERVER_VAR_ALT_IPV6])
|
||||
;
|
||||
|
||||
if ($available) {
|
||||
return true;
|
||||
} else // if not available return message w/ extra info
|
||||
{
|
||||
if (!function_exists('apache_get_modules')) {
|
||||
return Piwik::translate('General_Note') . ': ' . Piwik::translate('UserCountry_AssumingNonApache');
|
||||
}
|
||||
|
||||
$message = "<strong><em>" . Piwik::translate('General_Note') . ': '
|
||||
. Piwik::translate('UserCountry_FoundApacheModules')
|
||||
. "</em></strong>:<br/><br/>\n<ul style=\"list-style:disc;margin-left:24px\">\n";
|
||||
foreach (apache_get_modules() as $name) {
|
||||
$message .= "<li>$name</li>\n";
|
||||
}
|
||||
$message .= "</ul>";
|
||||
return $message;
|
||||
}
|
||||
|
||||
// if not available return message w/ extra info
|
||||
if (!function_exists('apache_get_modules')) {
|
||||
return Piwik::translate('General_Note') . ': ' . Piwik::translate('UserCountry_AssumingNonApache');
|
||||
}
|
||||
|
||||
$message = "<strong><em>" . Piwik::translate('General_Note') . ': '
|
||||
. Piwik::translate('UserCountry_FoundApacheModules')
|
||||
. "</em></strong>:<br/><br/>\n<ul style=\"list-style:disc;margin-left:24px\">\n";
|
||||
foreach (apache_get_modules() as $name) {
|
||||
$message .= "<li>$name</li>\n";
|
||||
}
|
||||
$message .= "</ul>";
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -180,6 +188,7 @@ class ServerBased extends GeoIp
|
|||
{
|
||||
if (empty($_SERVER[self::TEST_SERVER_VAR])
|
||||
&& empty($_SERVER[self::TEST_SERVER_VAR_ALT])
|
||||
&& empty($_SERVER[self::TEST_SERVER_VAR_ALT_IPV6])
|
||||
) {
|
||||
return Piwik::translate("UserCountry_CannotFindGeoIPServerVar", self::TEST_SERVER_VAR . ' $_SERVER');
|
||||
}
|
||||
|
|
@ -214,10 +223,10 @@ class ServerBased extends GeoIp
|
|||
. Piwik::translate('UserCountry_GeoIpLocationProviderDesc_ServerBased2',
|
||||
array('<strong><em>', '</em></strong>', '<strong><em>', '</em></strong>'));
|
||||
$installDocs =
|
||||
'<em><a target="_blank" href="http://piwik.org/faq/how-to/#faq_165">'
|
||||
'<em><a rel="noreferrer" target="_blank" href="http://piwik.org/faq/how-to/#faq_165">'
|
||||
. Piwik::translate('UserCountry_HowToInstallApacheModule')
|
||||
. '</a></em><br/><em>'
|
||||
. '<a target="_blank" href="http://piwik.org/faq/how-to/#faq_166">'
|
||||
. '<a rel="noreferrer" target="_blank" href="http://piwik.org/faq/how-to/#faq_166">'
|
||||
. Piwik::translate('UserCountry_HowToInstallNginxModule')
|
||||
. '</a></em>';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue