diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-01-11 02:48:50 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-01-11 02:54:13 +0400 |
commit | fb5454b703d00d50fb90fb7ddd0aa58656728093 (patch) | |
tree | fc5626edf1701b9c35baa1c5965a5dc5487067ba /core | |
parent | 15853da8b03f0ab7a858a2335e9dbd62b7db4116 (diff) |
Fixes #4493, move DoNotTrack & AnonymizeIP logic to PrivacyManager plugin. Includes modification to EventDipatcher to allow generic callbacks in getListHooksRegistered method.
Diffstat (limited to 'core')
-rw-r--r-- | core/EventDispatcher.php | 2 | ||||
-rw-r--r-- | core/Nonce.php | 21 | ||||
-rw-r--r-- | core/Tracker/Cache.php | 2 | ||||
-rw-r--r-- | core/Updates/2.0.3-b7.php | 66 | ||||
-rw-r--r-- | core/Version.php | 2 |
5 files changed, 90 insertions, 3 deletions
diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php index 670269862a..a66cd35fba 100644 --- a/core/EventDispatcher.php +++ b/core/EventDispatcher.php @@ -82,7 +82,7 @@ class EventDispatcher extends Singleton if (isset($hooks[$eventName])) { list($pluginFunction, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($hooks[$eventName]); - $callbacks[$callbackGroup][] = array($plugin, $pluginFunction); + $callbacks[$callbackGroup][] = is_string($pluginFunction) ? array($plugin, $pluginFunction) : $pluginFunction; } } diff --git a/core/Nonce.php b/core/Nonce.php index 55567e8841..0fc84c3f6b 100644 --- a/core/Nonce.php +++ b/core/Nonce.php @@ -154,4 +154,25 @@ class Nonce return $origins; } + + /** + * Verifies and discards a nonce. + * + * @param string $nonceName The nonce's unique ID. See {@link getNonce()}. + * @param string|null $nonce The nonce from the client. If `null`, the value from the + * **nonce** query parameter is used. + * @throws Exception if the nonce is invalid. See {@link verifyNonce()}. + */ + static public function checkNonce($nonceName, $nonce = null) + { + if ($nonce === null) { + $nonce = Common::getRequestVar('nonce', null, 'string'); + } + + if (!self::verifyNonce($nonceName, $nonce)) { + throw new \Exception(Piwik::translate('General_ExceptionNonceMismatch')); + } + + self::discardNonce($nonceName); + } }
\ No newline at end of file diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php index 3b23d55442..aacb91c86b 100644 --- a/core/Tracker/Cache.php +++ b/core/Tracker/Cache.php @@ -204,4 +204,4 @@ class Cache { self::getInstance()->deleteAll(); } -} +}
\ No newline at end of file diff --git a/core/Updates/2.0.3-b7.php b/core/Updates/2.0.3-b7.php new file mode 100644 index 0000000000..06669b4a47 --- /dev/null +++ b/core/Updates/2.0.3-b7.php @@ -0,0 +1,66 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik + * @package Piwik + */ + +namespace Piwik\Updates; + +use Piwik\Common; +use Piwik\Site; +use Piwik\Updater; +use Piwik\Updates; +use Piwik\Filesystem; + +use Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker; +use Piwik\Plugins\PrivacyManager\IPAnonymizer; + +/** + * @package Updates + */ +class Updates_2_0_3_b7 extends Updates +{ + static function update() + { + $errors = array(); + + try { + // enable DoNotTrack check in PrivacyManager if DoNotTrack plugin was enabled + if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('DoNotTrack')) { + DoNotTrackHeaderChecker::activate(); + } + + // enable IP anonymization if AnonymizeIP plugin was enabled + if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('AnonymizeIP')) { + IPAnonymizer::activate(); + } + } catch (Exception $ex) { + // pass + } + + // disable & delete old plugins + $oldPlugins = array('DoNotTrack', 'AnonymizeIP'); + foreach ($oldPlugins as $plugin) { + \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($plugin); + + $dir = PIWIK_INCLUDE_PATH . "/plugins/$plugin"; + + if (file_exists($dir)) { + Filesystem::unlinkRecursive($dir, true); + } + + if (file_exists($dir)) { + $errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n"; + } + + } + if(!empty($errors)) { + throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors)); + } + } +} diff --git a/core/Version.php b/core/Version.php index 11dc4bd1b7..b872741b6a 100644 --- a/core/Version.php +++ b/core/Version.php @@ -24,5 +24,5 @@ final class Version * The current Piwik version. * @var string */ - const VERSION = '2.0.3-b6'; + const VERSION = '2.0.3-b7'; } |