PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.0.3
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.0.3
5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Tracker / Settings.php
matomo / app / core / Tracker Last commit date
Db 2 years ago Handler 2 years ago Visit 2 years ago Action.php 2 years ago ActionPageview.php 2 years ago Cache.php 2 years ago Db.php 2 years ago Failures.php 2 years ago FingerprintSalt.php 2 years ago GoalManager.php 2 years ago Handler.php 2 years ago IgnoreCookie.php 2 years ago LogTable.php 2 years ago Model.php 2 years ago PageUrl.php 2 years ago Request.php 2 years ago RequestProcessor.php 2 years ago RequestSet.php 2 years ago Response.php 2 years ago ScheduledTasksRunner.php 2 years ago Settings.php 2 years ago TableLogAction.php 2 years ago TrackerCodeGenerator.php 2 years ago TrackerConfig.php 2 years ago Visit.php 2 years ago VisitExcluded.php 2 years ago VisitInterface.php 2 years ago Visitor.php 2 years ago VisitorNotFoundInDb.php 2 years ago VisitorRecognizer.php 2 years ago
Settings.php
118 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 *
9 */
10 namespace Piwik\Tracker;
11
12 use Piwik\Config;
13 use Piwik\Container\StaticContainer;
14 use Piwik\Date;
15 use Piwik\Tracker;
16 use Piwik\DeviceDetector\DeviceDetectorFactory;
17 use Piwik\SettingsPiwik;
18 class Settings
19 {
20 const OS_BOT = 'BOT';
21 /**
22 * If `true`, the config ID for a visitor will be the same no matter what site is being tracked.
23 * If `false, the config ID will be different.
24 *
25 * @var bool
26 */
27 private $isSameFingerprintsAcrossWebsites;
28 public function __construct($isSameFingerprintsAcrossWebsites)
29 {
30 $this->isSameFingerprintsAcrossWebsites = $isSameFingerprintsAcrossWebsites;
31 }
32 public function getConfigId(\Piwik\Tracker\Request $request, $ipAddress)
33 {
34 list($plugin_Flash, $plugin_Java, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Silverlight, $plugin_Cookie) = $request->getPlugins();
35 $userAgent = $request->getUserAgent();
36 $deviceDetector = StaticContainer::get(DeviceDetectorFactory::class)->makeInstance($userAgent, $request->getClientHints());
37 $aBrowserInfo = $deviceDetector->getClient();
38 if (empty($aBrowserInfo['type']) || 'browser' !== $aBrowserInfo['type']) {
39 // for now only track browsers
40 unset($aBrowserInfo);
41 }
42 $browserName = !empty($aBrowserInfo['short_name']) ? $aBrowserInfo['short_name'] : 'UNK';
43 $browserVersion = !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : '';
44 if ($deviceDetector->isBot()) {
45 $os = self::OS_BOT;
46 } else {
47 $os = $deviceDetector->getOS();
48 $os = empty($os['short_name']) ? 'UNK' : $os['short_name'];
49 }
50 $client = $deviceDetector->getClient();
51 if (!empty($client['name']) && $client['name'] === 'Internet Explorer') {
52 // we assume cookies are disabled... when in tracker cookies are disabled, this ensures when upgrading to this version
53 // that no fingerprint changes in the 30min window during the upgrade...
54 // We don't include it anymore as it otherwise may cause new visits to be created when switching between
55 // cookies disabled and enabled in IE11 or older. Before Matomo 3.13.7 when cookies were disabled, then
56 // this value was set to 0. For people with cookies enabled the fingerprint is not as relevant as the visitorId
57 // is used to identify a visitor
58 $plugin_Cookie = '0';
59 }
60 $browserLang = substr($request->getBrowserLanguage(), 0, 20);
61 // limit the length of this string to match db
62 $trackerConfig = Config::getInstance()->Tracker;
63 $fingerprintSalt = '';
64 // fingerprint salt won't work when across multiple sites since all sites could have different timezones
65 // also cant add fingerprint salt for a specific day when we dont create new visit after midnight
66 if (!$this->isSameFingerprintsAcrossWebsites && !empty($trackerConfig['create_new_visit_after_midnight'])) {
67 $cache = \Piwik\Tracker\Cache::getCacheWebsiteAttributes($request->getIdSite());
68 $date = Date::factory((int) $request->getCurrentTimestamp());
69 $fingerprintSaltKey = new \Piwik\Tracker\FingerprintSalt();
70 $dateString = $fingerprintSaltKey->getDateString($date, $cache['timezone']);
71 if (!empty($cache[\Piwik\Tracker\FingerprintSalt::OPTION_PREFIX . $dateString])) {
72 $fingerprintSalt = $cache[\Piwik\Tracker\FingerprintSalt::OPTION_PREFIX . $dateString];
73 } else {
74 // we query the DB directly for requests older than 2-3 days...
75 $fingerprintSalt = $fingerprintSaltKey->getSalt($dateString, $request->getIdSite());
76 }
77 $fingerprintSalt .= $dateString;
78 if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE) {
79 $fingerprintSalt = '';
80 // use fixed value so they don't change randomly in tests
81 }
82 }
83 return $this->getConfigHash($request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Silverlight, $plugin_Cookie, $ipAddress, $browserLang, $fingerprintSalt);
84 }
85 /**
86 * Returns a 64-bit hash that attempts to identify a user.
87 * Maintaining some privacy by default, eg. prevents the merging of several Piwik serve together for matching across instances..
88 *
89 * @param $os
90 * @param $browserName
91 * @param $browserVersion
92 * @param $plugin_Flash
93 * @param $plugin_Java
94 * @param $plugin_Quicktime
95 * @param $plugin_RealPlayer
96 * @param $plugin_PDF
97 * @param $plugin_WindowsMedia
98 * @param $plugin_Silverlight
99 * @param $plugin_Cookie
100 * @param $ip
101 * @param $browserLang
102 * @param $fingerprintHash
103 * @return string
104 */
105 protected function getConfigHash(\Piwik\Tracker\Request $request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang, $fingerprintHash)
106 {
107 // prevent the config hash from being the same, across different Piwik instances
108 // (limits ability of different Piwik instances to cross-match users)
109 $salt = SettingsPiwik::getSalt();
110 $configString = $os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . '0' . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . '0' . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang . $salt . $fingerprintHash;
111 if (!$this->isSameFingerprintsAcrossWebsites) {
112 $configString .= $request->getIdSite();
113 }
114 $hash = md5($configString, $raw_output = true);
115 return substr($hash, 0, Tracker::LENGTH_BINARY_ID);
116 }
117 }
118