/**
  * Checks for DoNotTrack headers and if found, sets `$exclude` to `true`.
  */
 public function checkHeaderInTracker(&$exclude)
 {
     if ($exclude) {
         Common::printDebug("Visit is already excluded, no need to check DoNotTrack support.");
         return;
     }
     if (!$this->isActive()) {
         Common::printDebug("DoNotTrack support is not enabled, skip check");
         return;
     }
     if (isset($_SERVER['HTTP_X_DO_NOT_TRACK']) && $_SERVER['HTTP_X_DO_NOT_TRACK'] === '1' || isset($_SERVER['HTTP_DNT']) && substr($_SERVER['HTTP_DNT'], 0, 1) === '1') {
         $request = new Request($_REQUEST);
         $ua = $request->getUserAgent();
         if (strpos($ua, 'MSIE') !== false || strpos($ua, 'Trident') !== false) {
             Common::printDebug("INTERNET EXPLORER enable DoNotTrack by default; so Piwik ignores DNT IE browsers...");
             return;
         }
         Common::printDebug("DoNotTrack header found!");
         $exclude = true;
         $trackingCookie = IgnoreCookie::getTrackingCookie();
         $trackingCookie->delete();
         // this is an optional supplement to the site's tracking status resource at:
         //     /.well-known/dnt
         // per Tracking Preference Expression (draft)
         header('Tk: 1');
     } else {
         Common::printDebug("DoNotTrack header not found");
     }
 }
 /**
  * Checks for DoNotTrack headers and if found, sets `$exclude` to `true`.
  */
 public function checkHeaderInTracker(&$exclude)
 {
     if ($exclude) {
         Common::printDebug("Visit is already excluded, no need to check DoNotTrack support.");
         return;
     }
     $exclude = $this->isDoNotTrackFound();
     if ($exclude) {
         IgnoreCookie::deleteThirdPartyCookieUIDIfExists();
         // this is an optional supplement to the site's tracking status resource at:
         //     /.well-known/dnt
         // per Tracking Preference Expression
         //Tracking Perference Expression has been updated to require Tk: N rather than Tk: 1
         Common::sendHeader('Tk: N');
     }
 }
 /**
  * Checks for DoNotTrack headers and if found, sets `$exclude` to `true`.
  */
 public function checkHeaderInTracker(&$exclude)
 {
     if ($exclude) {
         Common::printDebug("Visit is already excluded, no need to check DoNotTrack support.");
         return;
     }
     $exclude = $this->isDoNotTrackFound();
     if ($exclude) {
         $trackingCookie = IgnoreCookie::getTrackingCookie();
         $trackingCookie->delete();
         // this is an optional supplement to the site's tracking status resource at:
         //     /.well-known/dnt
         // per Tracking Preference Expression (draft)
         header('Tk: 1');
     }
 }
 /**
  * Checks for DoNotTrack headers and if found, sets `$exclude` to `true`.
  */
 public function checkHeaderInTracker(&$exclude)
 {
     if (!$this->isActiveInTracker() || $exclude) {
         return;
     }
     if (isset($_SERVER['HTTP_X_DO_NOT_TRACK']) && $_SERVER['HTTP_X_DO_NOT_TRACK'] === '1' || isset($_SERVER['HTTP_DNT']) && substr($_SERVER['HTTP_DNT'], 0, 1) === '1') {
         $request = new Request($_REQUEST);
         $ua = $request->getUserAgent();
         if (strpos($ua, 'MSIE 10') !== false || strpos($ua, 'Trident/7') !== false) {
             Common::printDebug("INTERNET EXPLORER 10 and 11 enable DoNotTrack by default; so Piwik ignores DNT for all IE10 + IE11 browsers...");
             return;
         }
         $exclude = true;
         Common::printDebug("DoNotTrack found.");
         $trackingCookie = IgnoreCookie::getTrackingCookie();
         $trackingCookie->delete();
         // this is an optional supplement to the site's tracking status resource at:
         //     /.well-known/dnt
         // per Tracking Preference Expression (draft)
         header('Tk: 1');
     }
 }
Beispiel #5
0
 /**
  * Shows the "Track Visits" checkbox.
  */
 public function optOut()
 {
     $trackVisits = !IgnoreCookie::isIgnoreCookieFound();
     $nonce = Common::getRequestVar('nonce', false);
     $language = Common::getRequestVar('language', '');
     if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
         Nonce::discardNonce('Piwik_OptOut');
         IgnoreCookie::setIgnoreCookie();
         $trackVisits = !$trackVisits;
     }
     $view = new View('@CoreAdminHome/optOut');
     $view->trackVisits = $trackVisits;
     $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
     $view->language = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     return $view->render();
 }
Beispiel #6
0
 public function setIgnoreCookie()
 {
     Piwik::checkUserHasSomeViewAccess();
     Piwik::checkUserIsNotAnonymous();
     $salt = Common::getRequestVar('ignoreSalt', false, 'string');
     if ($salt !== $this->getIgnoreCookieSalt()) {
         throw new Exception("Not authorized");
     }
     IgnoreCookie::setIgnoreCookie();
     Piwik::redirectToModule('UsersManager', 'userSettings', array('token_auth' => false));
 }
 /**
  * Looks for the ignore cookie that users can set in the Piwik admin screen.
  * @return bool
  */
 protected function isIgnoreCookieFound()
 {
     if (IgnoreCookie::isIgnoreCookieFound()) {
         Common::printDebug('Piwik ignore cookie was found, visit not tracked.');
         return true;
     }
     return false;
 }
 /**
  * @return View
  * @throws \Exception
  */
 public function getOptOutView()
 {
     if ($this->view) {
         return $this->view;
     }
     $trackVisits = !IgnoreCookie::isIgnoreCookieFound();
     $dntFound = $this->getDoNotTrackHeaderChecker()->isDoNotTrackFound();
     $setCookieInNewWindow = Common::getRequestVar('setCookieInNewWindow', false, 'int');
     if ($setCookieInNewWindow) {
         $reloadUrl = Url::getCurrentQueryStringWithParametersModified(array('showConfirmOnly' => 1, 'setCookieInNewWindow' => 0));
     } else {
         $reloadUrl = false;
         $nonce = Common::getRequestVar('nonce', false);
         if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
             Nonce::discardNonce('Piwik_OptOut');
             IgnoreCookie::setIgnoreCookie();
             $trackVisits = !$trackVisits;
         }
     }
     $language = Common::getRequestVar('language', '');
     $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     $this->addQueryParameters(array('module' => 'CoreAdminHome', 'action' => 'optOut', 'language' => $lang, 'setCookieInNewWindow' => 1), false);
     $this->view = new View("@CoreAdminHome/optOut");
     $this->view->setXFrameOptions('allow');
     $this->view->dntFound = $dntFound;
     $this->view->trackVisits = $trackVisits;
     $this->view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
     $this->view->language = $lang;
     $this->view->showConfirmOnly = Common::getRequestVar('showConfirmOnly', false, 'int');
     $this->view->reloadUrl = $reloadUrl;
     $this->view->javascripts = $this->getJavascripts();
     $this->view->stylesheets = $this->getStylesheets();
     $this->view->title = $this->getTitle();
     $this->view->queryParameters = $this->getQueryParameters();
     return $this->view;
 }
Beispiel #9
0
 /**
  * Shows the "Track Visits" checkbox.
  */
 public function optOut()
 {
     $trackVisits = !IgnoreCookie::isIgnoreCookieFound();
     $nonce = Common::getRequestVar('nonce', false);
     $language = Common::getRequestVar('language', '');
     if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
         Nonce::discardNonce('Piwik_OptOut');
         IgnoreCookie::setIgnoreCookie();
         $trackVisits = !$trackVisits;
     }
     $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     // should not use self::renderTemplate since that uses setBasicVariablesView. this will cause
     // an error when setBasicVariablesAdminView is called, and MenuTop is requested (the idSite query
     // parameter is required)
     $view = new View("@CoreAdminHome/optOut");
     $view->setXFrameOptions('allow');
     $view->trackVisits = $trackVisits;
     $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
     $view->language = $lang;
     return $view->render();
 }
Beispiel #10
0
 public function setIgnoreCookie()
 {
     Piwik::checkUserHasSomeViewAccess();
     Piwik::checkUserIsNotAnonymous();
     $this->checkTokenInUrl();
     IgnoreCookie::setIgnoreCookie();
     Piwik::redirectToModule('UsersManager', 'userSettings', array('token_auth' => false));
 }
Beispiel #11
0
    /**
     * Shows the "Track Visits" checkbox.
     */
    public function optOut()
    {
        $trackVisits = !IgnoreCookie::isIgnoreCookieFound();

        $dntChecker = new DoNotTrackHeaderChecker();
        $dntFound = $dntChecker->isDoNotTrackFound();

        $setCookieInNewWindow = Common::getRequestVar('setCookieInNewWindow', false, 'int');
        if ($setCookieInNewWindow) {
            $reloadUrl = Url::getCurrentQueryStringWithParametersModified(array(
                'showConfirmOnly' => 1,
                'setCookieInNewWindow' => 0,
            ));
        } else {
            $reloadUrl = false;

            $nonce = Common::getRequestVar('nonce', false);
            if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
                Nonce::discardNonce('Piwik_OptOut');
                IgnoreCookie::setIgnoreCookie();
                $trackVisits = !$trackVisits;
            }
        }

        $language = Common::getRequestVar('language', '');
        $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language)
            ? $language
            : LanguagesManager::getLanguageCodeForCurrentUser();

        // should not use self::renderTemplate since that uses setBasicVariablesView. this will cause
        // an error when setBasicVariablesAdminView is called, and MenuTop is requested (the idSite query
        // parameter is required)
        $view = new View("@CoreAdminHome/optOut");
        $view->setXFrameOptions('allow');
        $view->dntFound = $dntFound;
        $view->trackVisits = $trackVisits;
        $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
        $view->language = $lang;
        $view->isSafari = $this->isUserAgentSafari();
        $view->showConfirmOnly = Common::getRequestVar('showConfirmOnly', false, 'int');
        $view->reloadUrl = $reloadUrl;
        return $view->render();
    }
Beispiel #12
0
 /**
  * Shows the "Track Visits" checkbox.
  */
 public function optOut()
 {
     $trackVisits = !IgnoreCookie::isIgnoreCookieFound();
     $nonce = Common::getRequestVar('nonce', false);
     $language = Common::getRequestVar('language', '');
     if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
         Nonce::discardNonce('Piwik_OptOut');
         IgnoreCookie::setIgnoreCookie();
         $trackVisits = !$trackVisits;
     }
     $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     return $this->renderTemplate('optOut', array('trackVisits' => $trackVisits, 'nonce' => Nonce::getNonce('Piwik_OptOut', 3600), 'language' => $lang));
 }