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:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-09-22 04:06:24 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-09-22 04:06:24 +0400
commitaebff1e38c23bf2fe217c5c9bc24c65d779efcbc (patch)
tree5fce0847bb2a8b68c5430bc61beb88bf246b21a2 /plugins
parentc120944911a2333d0b61c3be5c2a480a29d68d55 (diff)
Remove &date= query parameter from maxmind URLs if present.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/UserCountry/GeoIPAutoUpdater.php39
1 files changed, 31 insertions, 8 deletions
diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php
index 5ad460d5b2..cb7deb50a7 100755
--- a/plugins/UserCountry/GeoIPAutoUpdater.php
+++ b/plugins/UserCountry/GeoIPAutoUpdater.php
@@ -105,6 +105,8 @@ class GeoIPAutoUpdater
$zippedOutputPath = GeoIp::getPathForGeoIpDatabase($zippedFilename);
+ $url = self::removeDateFromUrl($url);
+
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
@@ -285,12 +287,18 @@ class GeoIPAutoUpdater
*/
public static function setUpdaterOptionsFromUrl()
{
- self::setUpdaterOptions(array(
- 'loc' => Common::getRequestVar('loc_db', false, 'string'),
- 'isp' => Common::getRequestVar('isp_db', false, 'string'),
- 'org' => Common::getRequestVar('org_db', false, 'string'),
- 'period' => Common::getRequestVar('period', false, 'string'),
- ));
+ $options = array(
+ 'loc' => Common::getRequestVar('loc_db', false, 'string'),
+ 'isp' => Common::getRequestVar('isp_db', false, 'string'),
+ 'org' => Common::getRequestVar('org_db', false, 'string'),
+ 'period' => Common::getRequestVar('period', false, 'string'),
+ );
+
+ foreach (self::$urlOptions as $optionKey => $optionName) {
+ $options[$optionKey] = Common::unsanitizeInputValue($options[$optionKey]); // URLs should not be sanitized
+ }
+
+ self::setUpdaterOptions($options);
}
/**
@@ -313,7 +321,10 @@ class GeoIPAutoUpdater
continue;
}
- Piwik_SetOption($optionName, $url = $options[$optionKey]);
+ $url = $options[$optionKey];
+ $url = self::removeDateFromUrl($url);
+
+ Piwik_SetOption($optionName, $url);
}
// set period option
@@ -590,4 +601,16 @@ class GeoIPAutoUpdater
$timestamp = Piwik_GetOption(self::LAST_RUN_TIME_OPTION_NAME);
return $timestamp === false ? false : Date::factory((int)$timestamp);
}
-}
+
+ /**
+ * Removes the &date=... query parameter if present in the URL. This query parameter
+ * is in MaxMind URLs by default and will force the download of an old database.
+ *
+ * @param string $url
+ * @return string
+ */
+ private static function removeDateFromUrl($url)
+ {
+ return preg_replace("/&date=[^&#]*/", '', $url);
+ }
+} \ No newline at end of file