コード例 #1
0
ファイル: 2.0.3-b7.php プロジェクト: bossrabbit/piwik
 static function update()
 {
     $errors = array();
     try {
         $checker = new DoNotTrackHeaderChecker();
         // enable DoNotTrack check in PrivacyManager if DoNotTrack plugin was enabled
         if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('DoNotTrack')) {
             $checker->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) {
         try {
             \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($plugin);
         } catch (\Exception $e) {
         }
         $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));
     }
 }
コード例 #2
0
ファイル: API.php プロジェクト: piwik/piwik
 /**
  * @internal
  */
 public function setAnonymizeIpSettings($anonymizeIPEnable, $maskLength, $useAnonymizedIpForVisitEnrichment)
 {
     Piwik::checkUserHasSuperUserAccess();
     if ($anonymizeIPEnable == '1') {
         IPAnonymizer::activate();
     } else {
         if ($anonymizeIPEnable == '0') {
             IPAnonymizer::deactivate();
         } else {
             // pass
         }
     }
     $privacyConfig = new Config();
     $privacyConfig->ipAddressMaskLength = (int) $maskLength;
     $privacyConfig->useAnonymizedIpForVisitEnrichment = (bool) $useAnonymizedIpForVisitEnrichment;
     return true;
 }
コード例 #3
0
ファイル: Controller.php プロジェクト: emersonmatsumoto/piwik
 public function saveSettings()
 {
     Piwik::checkUserHasSuperUserAccess();
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $this->checkTokenInUrl();
         switch (Common::getRequestVar('form')) {
             case "formMaskLength":
                 $enable = Common::getRequestVar("anonymizeIPEnable", 0);
                 if ($enable == 1) {
                     IPAnonymizer::activate();
                 } else {
                     if ($enable == 0) {
                         IPAnonymizer::deactivate();
                     } else {
                         // pass
                     }
                 }
                 $privacyConfig = new Config();
                 $privacyConfig->ipAddressMaskLength = Common::getRequestVar("maskLength", 1);
                 $privacyConfig->useAnonymizedIpForVisitEnrichment = Common::getRequestVar("useAnonymizedIpForVisitEnrichment", 1);
                 break;
             case "formDeleteSettings":
                 $this->checkDataPurgeAdminSettingsIsEnabled();
                 $settings = $this->getPurgeSettingsFromRequest();
                 PrivacyManager::savePurgeDataSettings($settings);
                 break;
             default:
                 //do nothing
                 break;
         }
     }
     $notification = new Notification(Piwik::translate('General_YourChangesHaveBeenSaved'));
     $notification->context = Notification::CONTEXT_SUCCESS;
     Notification\Manager::notify('PrivacyManager_ChangesHaveBeenSaved', $notification);
     $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
 }
コード例 #4
0
ファイル: Tracker.php プロジェクト: Abine/piwik
 public static function setTestEnvironment($args = null, $requestMethod = null)
 {
     if (is_null($args)) {
         $postData = self::getRequestsArrayFromBulkRequest(self::getRawBulkRequest());
         $args = $_GET + $postData;
     }
     if (is_null($requestMethod) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
         $requestMethod = $_SERVER['REQUEST_METHOD'];
     } else {
         if (is_null($requestMethod)) {
             $requestMethod = 'GET';
         }
     }
     // Do not run scheduled tasks during tests
     self::updateTrackerConfig('scheduled_tasks_min_interval', 0);
     // if nothing found in _GET/_POST and we're doing a POST, assume bulk request. in which case,
     // we have to bypass authentication
     if (empty($args) && $requestMethod == 'POST') {
         self::updateTrackerConfig('tracking_requests_require_authentication', 0);
     }
     // Tests can force the use of 3rd party cookie for ID visitor
     if (Common::getRequestVar('forceUseThirdPartyCookie', false, null, $args) == 1) {
         self::updateTrackerConfig('use_third_party_id_cookie', 1);
     }
     // Tests using window_look_back_for_visitor
     if (Common::getRequestVar('forceLargeWindowLookBackForVisitor', false, null, $args) == 1 || strpos(json_encode($args, true), '"forceLargeWindowLookBackForVisitor":"1"') !== false) {
         self::updateTrackerConfig('window_look_back_for_visitor', 2678400);
     }
     // Tests can force the enabling of IP anonymization
     if (Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) {
         self::connectDatabaseIfNotConnected();
         $privacyConfig = new PrivacyManagerConfig();
         $privacyConfig->ipAddressMaskLength = 2;
         \Piwik\Plugins\PrivacyManager\IPAnonymizer::activate();
     }
     // Custom IP to use for this visitor
     $customIp = Common::getRequestVar('cip', false, null, $args);
     if (!empty($customIp)) {
         self::setForceIp($customIp);
     }
     // Custom server date time to use
     $customDatetime = Common::getRequestVar('cdt', false, null, $args);
     if (!empty($customDatetime)) {
         self::setForceDateTime($customDatetime);
     }
     $pluginsDisabled = array('Provider');
     // Disable provider plugin, because it is so slow to do many reverse ip lookups
     self::setPluginsNotToLoad($pluginsDisabled);
 }
コード例 #5
0
ファイル: Tracker.php プロジェクト: FluentDevelopment/piwik
 public static function setTestEnvironment($args = null, $requestMethod = null)
 {
     if (is_null($args)) {
         $requests = new Requests();
         $args = $requests->getRequestsArrayFromBulkRequest($requests->getRawBulkRequest());
         $args = $_GET + $args;
     }
     if (is_null($requestMethod) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
         $requestMethod = $_SERVER['REQUEST_METHOD'];
     } elseif (is_null($requestMethod)) {
         $requestMethod = 'GET';
     }
     // Do not run scheduled tasks during tests
     if (!defined('DEBUG_FORCE_SCHEDULED_TASKS')) {
         TrackerConfig::setConfigValue('scheduled_tasks_min_interval', 0);
     }
     // if nothing found in _GET/_POST and we're doing a POST, assume bulk request. in which case,
     // we have to bypass authentication
     if (empty($args) && $requestMethod == 'POST') {
         TrackerConfig::setConfigValue('tracking_requests_require_authentication', 0);
     }
     // Tests can force the use of 3rd party cookie for ID visitor
     if (Common::getRequestVar('forceEnableFingerprintingAcrossWebsites', false, null, $args) == 1) {
         TrackerConfig::setConfigValue('enable_fingerprinting_across_websites', 1);
     }
     // Tests can force the use of 3rd party cookie for ID visitor
     if (Common::getRequestVar('forceUseThirdPartyCookie', false, null, $args) == 1) {
         TrackerConfig::setConfigValue('use_third_party_id_cookie', 1);
     }
     // Tests using window_look_back_for_visitor
     if (Common::getRequestVar('forceLargeWindowLookBackForVisitor', false, null, $args) == 1 || strpos(json_encode($args, true), '"forceLargeWindowLookBackForVisitor":"1"') !== false) {
         TrackerConfig::setConfigValue('window_look_back_for_visitor', 2678400);
     }
     // Tests can force the enabling of IP anonymization
     if (Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) {
         self::getDatabase();
         // make sure db is initialized
         $privacyConfig = new PrivacyManagerConfig();
         $privacyConfig->ipAddressMaskLength = 2;
         \Piwik\Plugins\PrivacyManager\IPAnonymizer::activate();
         \Piwik\Tracker\Cache::deleteTrackerCache();
         Filesystem::clearPhpCaches();
     }
     $pluginsDisabled = array('Provider');
     // Disable provider plugin, because it is so slow to do many reverse ip lookups
     PluginManager::getInstance()->setTrackerPluginsNotToLoad($pluginsDisabled);
 }
コード例 #6
0
 protected function handlePluginState($state = 0)
 {
     if ($state == 1) {
         IPAnonymizer::activate();
     } else {
         if ($state == 0) {
             IPAnonymizer::deactivate();
         } else {
             // pass
         }
     }
 }
コード例 #7
0
ファイル: PrivacyManager.php プロジェクト: dorelljames/piwik
 /**
  * Process the submit on the Installation "default settings" form.
  *
  * @param FormDefaultSettings $form
  */
 public function installationFormSubmit(FormDefaultSettings $form)
 {
     $doNotTrack = (bool) $form->getSubmitValue('do_not_track');
     $dntChecker = new DoNotTrackHeaderChecker();
     if ($doNotTrack) {
         $dntChecker->activate();
     } else {
         $dntChecker->deactivate();
     }
     $anonymiseIp = (bool) $form->getSubmitValue('anonymise_ip');
     if ($anonymiseIp) {
         IPAnonymizer::activate();
     } else {
         IPAnonymizer::deactivate();
     }
 }
コード例 #8
0
 public static function setTestEnvironment($args = null, $requestMethod = null)
 {
     if (is_null($args)) {
         $args = $_GET + $_POST;
     }
     if (is_null($requestMethod)) {
         $requestMethod = $_SERVER['REQUEST_METHOD'];
     }
     // Do not run scheduled tasks during tests
     self::updateTrackerConfig('scheduled_tasks_min_interval', 0);
     // if nothing found in _GET/_POST and we're doing a POST, assume bulk request. in which case,
     // we have to bypass authentication
     if (empty($args) && $requestMethod == 'POST') {
         self::updateTrackerConfig('tracking_requests_require_authentication', 0);
     }
     // Tests can force the use of 3rd party cookie for ID visitor
     if (Common::getRequestVar('forceUseThirdPartyCookie', false, null, $args) == 1) {
         self::updateTrackerConfig('use_third_party_id_cookie', 1);
     }
     // Tests using window_look_back_for_visitor
     if (Common::getRequestVar('forceLargeWindowLookBackForVisitor', false, null, $args) == 1) {
         self::updateTrackerConfig('window_look_back_for_visitor', 2678400);
     }
     // Tests can force the enabling of IP anonymization
     $forceIpAnonymization = false;
     if (Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) {
         self::updateTrackerConfig('ip_address_mask_length', 2);
         self::connectDatabaseIfNotConnected();
         \Piwik\Plugins\PrivacyManager\IPAnonymizer::activate();
         $forceIpAnonymization = true;
     }
     // Custom IP to use for this visitor
     $customIp = Common::getRequestVar('cip', false, null, $args);
     if (!empty($customIp)) {
         self::setForceIp($customIp);
     }
     // Custom server date time to use
     $customDatetime = Common::getRequestVar('cdt', false, null, $args);
     if (!empty($customDatetime)) {
         self::setForceDateTime($customDatetime);
     }
     // Custom visitor id
     $customVisitorId = Common::getRequestVar('cid', false, null, $args);
     if (!empty($customVisitorId)) {
         self::setForceVisitorId($customVisitorId);
     }
     $pluginsDisabled = array('Provider');
     // Disable provider plugin, because it is so slow to do many reverse ip lookups
     self::setPluginsNotToLoad($pluginsDisabled);
 }