PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 4.13.5
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v4.13.5
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 / config / global.php
matomo / app / config Last commit date
environment 5 years ago global.ini.php 3 years ago global.php 4 years ago
global.php
240 lines
1 <?php
2
3 use Psr\Container\ContainerInterface;
4 use Matomo\Cache\Eager;
5 use Piwik\SettingsServer;
6
7 return [
8
9 'path.root' => PIWIK_DOCUMENT_ROOT,
10
11 'path.misc.user' => 'misc/user/',
12
13 'path.tmp' => function (ContainerInterface $c) {
14 $root = PIWIK_USER_PATH;
15
16 // TODO remove that special case and instead have plugins override 'path.tmp' to add the instance id
17 if ($c->has('ini.General.instance_id')) {
18 $instanceId = $c->get('ini.General.instance_id');
19 $instanceId = $instanceId ? '/' . $instanceId : '';
20 } else {
21 $instanceId = '';
22 }
23
24 /** @var Piwik\Config\ $config */
25 $config = $c->get('Piwik\Config');
26 $general = $config->General;
27 $tmp = empty($general['tmp_path']) ? '/tmp' : $general['tmp_path'];
28
29 return $root . $tmp . $instanceId;
30 },
31
32 'path.tmp.templates' => DI\string('{path.tmp}/templates_c'),
33
34 'path.cache' => DI\string('{path.tmp}/cache/tracker/'),
35
36 'view.clearcompiledtemplates.enable' => true,
37
38 'twig.cache' => DI\string('{path.tmp.templates}'),
39
40 'Matomo\Cache\Eager' => function (ContainerInterface $c) {
41 $backend = $c->get('Matomo\Cache\Backend');
42 $cacheId = $c->get('cache.eager.cache_id');
43
44 if (SettingsServer::isTrackerApiRequest()) {
45 $eventToPersist = 'Tracker.end';
46 $cacheId .= 'tracker';
47 } else {
48 $eventToPersist = 'Request.dispatch.end';
49 $cacheId .= 'ui';
50 }
51
52 $cache = new Eager($backend, $cacheId);
53 \Piwik\Piwik::addAction($eventToPersist, function () use ($cache) {
54 $cache->persistCacheIfNeeded(43200);
55 });
56
57 return $cache;
58 },
59 'Matomo\Cache\Backend' => function (ContainerInterface $c) {
60 // If Piwik is not installed yet, it's possible the tmp/ folder is not writable
61 // we prevent failing with an unclear message eg. coming from doctrine-cache
62 // by forcing to use a cache backend which always works ie. array
63 if (!\Piwik\SettingsPiwik::isMatomoInstalled()) {
64 $backend = 'array';
65 } else {
66 try {
67 $backend = $c->get('ini.Cache.backend');
68 } catch (\DI\NotFoundException $ex) {
69 $backend = 'chained'; // happens if global.ini.php is not available
70 }
71 }
72
73 return \Piwik\Cache::buildBackend($backend);
74 },
75 'cache.eager.cache_id' => function () {
76 return 'eagercache-' . str_replace(['.', '-'], '', \Piwik\Version::VERSION) . '-';
77 },
78
79 'entities.idNames' => DI\add(['idGoal', 'idDimension']),
80
81 'Psr\Log\LoggerInterface' => DI\create('Psr\Log\NullLogger'),
82
83 'Piwik\Translation\Loader\LoaderInterface' => DI\autowire('Piwik\Translation\Loader\LoaderCache')
84 ->constructorParameter('loader', DI\get('Piwik\Translation\Loader\JsonFileLoader')),
85
86 'DeviceDetector\Cache\Cache' => DI\autowire('Piwik\DeviceDetector\DeviceDetectorCache')->constructor(86400),
87
88 'observers.global' => [],
89
90 /**
91 * By setting this option to false, the check that the DB schema version matches the version of the source code will
92 * be no longer performed. Thus it allows you to execute for example a newer version of Matomo with an older Matomo
93 * database version. Please note disabling this setting is not recommended because often an older DB version is not
94 * compatible with newer source code.
95 * If you disable this setting, make sure to execute the updates after updating the source code. The setting can be
96 * useful if you want to update Matomo without any outage when you know the current source code update will still
97 * run fine for a short time while in the background the database updates are running.
98 */
99 'EnableDbVersionCheck' => true,
100
101 'fileintegrity.ignore' => DI\add([
102 '*.htaccess',
103 '*web.config',
104 'bootstrap.php',
105 'favicon.ico',
106 'robots.txt',
107 '.bowerrc',
108 '.lfsconfig',
109 '.phpstorm.meta.php',
110 'config/config.ini.php',
111 'config/config.php',
112 'config/common.ini.php',
113 'config/*.config.ini.php',
114 'config/manifest.inc.php',
115 'misc/*.dat',
116 'misc/*.dat.gz',
117 'misc/*.mmdb',
118 'misc/*.mmdb.gz',
119 'misc/*.bin',
120 'misc/user/*png',
121 'misc/user/*svg',
122 'misc/user/*js',
123 'misc/user/*/config.ini.php',
124 'misc/package',
125 'misc/package/WebAppGallery/*.xml',
126 'misc/package/WebAppGallery/install.sql',
127 'plugins/ImageGraph/fonts/unifont.ttf',
128 'plugins/*/config/tracker.php',
129 'plugins/*/config/config.php',
130 'vendor/autoload.php',
131 'vendor/composer/autoload_real.php',
132 'vendor/szymach/c-pchart/app/*',
133 'tmp/*',
134 // Search engine sites verification
135 'google*.html',
136 'BingSiteAuth.xml',
137 'yandex*.html',
138 // common files on shared hosters
139 'php.ini',
140 '.user.ini',
141 'error_log',
142 // Files below are not expected but they used to be present in older Piwik versions and may be still here
143 // As they are not going to cause any trouble we won't report them as 'File to delete'
144 '*.coveralls.yml',
145 '*.scrutinizer.yml',
146 '*.gitignore',
147 '*.gitkeep',
148 '*.gitmodules',
149 '*.gitattributes',
150 '*.bower.json',
151 '*.travis.yml',
152 ]),
153
154 'Piwik\EventDispatcher' => DI\autowire()->constructorParameter('observers', DI\get('observers.global')),
155
156 'login.allowlist.ips' => function (ContainerInterface $c) {
157 /** @var Piwik\Config\ $config */
158 $config = $c->get('Piwik\Config');
159 $general = $config->General;
160
161 $ips = [];
162 if (!empty($general['login_allowlist_ip']) && is_array($general['login_allowlist_ip'])) {
163 $ips = $general['login_allowlist_ip'];
164 } elseif (!empty($general['login_whitelist_ip']) && is_array($general['login_whitelist_ip'])) {
165 // for BC
166 $ips = $general['login_whitelist_ip'];
167 }
168
169 $ipsResolved = [];
170
171 foreach ($ips as $ip) {
172 $ip = trim($ip);
173 if (filter_var($ip, FILTER_VALIDATE_IP) || \Matomo\Network\IPUtils::getIPRangeBounds($ip) !== null) {
174 $ipsResolved[] = $ip;
175 } else {
176 $lazyCache = \Piwik\Cache::getLazyCache();
177 $cacheKey = 'DNS.' . md5($ip);
178
179 $resolvedIps = $lazyCache->fetch($cacheKey);
180
181 if (!is_array($resolvedIps)) {
182 $resolvedIps = [];
183
184 $ipFromHost = @gethostbyname($ip);
185 if (!empty($ipFromHost) && $ipFromHost !== $ip) {
186 $resolvedIps[] = $ipFromHost;
187 }
188
189 if (function_exists('dns_get_record')) {
190 $entry = @dns_get_record($ip, DNS_AAAA);
191
192 if (
193 !empty($entry['0']['ipv6'])
194 && filter_var($entry['0']['ipv6'], FILTER_VALIDATE_IP)
195 ) {
196 $resolvedIps[] = $entry['0']['ipv6'];
197 }
198 }
199
200 $lazyCache->save($cacheKey, $resolvedIps, 30);
201 }
202
203 $ipsResolved = array_merge($ipsResolved, $resolvedIps);
204 }
205 }
206
207 return $ipsResolved;
208 },
209
210 /**
211 * This defines a list of hostnames Matomo's Http class will deny requests to. Wildcards (*) can be used in the
212 * beginning to match any subdomain level or in the end to match any tlds
213 */
214 'http.blocklist.hosts' => [
215 '*.amazonaws.com',
216 ],
217
218 'Piwik\Tracker\VisitorRecognizer' => DI\autowire()
219 ->constructorParameter('trustCookiesOnly', DI\get('ini.Tracker.trust_visitors_cookies'))
220 ->constructorParameter('visitStandardLength', DI\get('ini.Tracker.visit_standard_length'))
221 ->constructorParameter('lookbackNSecondsCustom', DI\get('ini.Tracker.window_look_back_for_visitor')),
222
223 'Piwik\Tracker\Settings' => DI\autowire()
224 ->constructorParameter(
225 'isSameFingerprintsAcrossWebsites',
226 DI\get('ini.Tracker.enable_fingerprinting_across_websites')
227 ),
228
229 'archiving.performance.logger' => null,
230
231 \Piwik\CronArchive\Performance\Logger::class => DI\autowire()
232 ->constructorParameter('logger', DI\get('archiving.performance.logger')),
233
234 \Piwik\Concurrency\LockBackend::class => \DI\get(\Piwik\Concurrency\LockBackend\MySqlLockBackend::class),
235
236 \Piwik\Segment\SegmentsList::class => function () {
237 return \Piwik\Segment\SegmentsList::get();
238 }
239 ];
240