PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 4.15.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v4.15.2
5.13.0 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 / config / global.php
matomo / app / config Last commit date
environment 5 years ago global.ini.php 3 years ago global.php 3 years ago
global.php
258 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 /**
80 * A list of API query parameters that map to entity IDs, for example, `idGoal` for goals.
81 *
82 * If your plugin introduces new entities that can be fetched or manipulated by ID through
83 * API requests, you should add the query parameters that represent the new entity's IDs
84 * to this array.
85 */
86 'entities.idNames' => DI\add(['idGoal', 'idDimension']),
87
88 /**
89 * If your plugin uses custom query parameters in API requests (that is, query parameters not used
90 * by a core plugin), and you want to be able to use those query parameters in system tests, you
91 * will need to add them, via DI, to this array. Otherwise, in system tests, they will be
92 * silently ignored.
93 *
94 * Note: if the query parameter has been added to `'entities.idNames'`, it does not need to be added
95 * here as well.
96 */
97 'DocumentationGenerator.customParameters' => [],
98
99 'Psr\Log\LoggerInterface' => DI\create('Psr\Log\NullLogger'),
100
101 'Piwik\Translation\Loader\LoaderInterface' => DI\autowire('Piwik\Translation\Loader\LoaderCache')
102 ->constructorParameter('loader', DI\get('Piwik\Translation\Loader\JsonFileLoader')),
103
104 'DeviceDetector\Cache\Cache' => DI\autowire('Piwik\DeviceDetector\DeviceDetectorCache')->constructor(86400),
105
106 'observers.global' => [],
107
108 /**
109 * By setting this option to false, the check that the DB schema version matches the version of the source code will
110 * be no longer performed. Thus it allows you to execute for example a newer version of Matomo with an older Matomo
111 * database version. Please note disabling this setting is not recommended because often an older DB version is not
112 * compatible with newer source code.
113 * If you disable this setting, make sure to execute the updates after updating the source code. The setting can be
114 * useful if you want to update Matomo without any outage when you know the current source code update will still
115 * run fine for a short time while in the background the database updates are running.
116 */
117 'EnableDbVersionCheck' => true,
118
119 'fileintegrity.ignore' => DI\add([
120 '*.htaccess',
121 '*web.config',
122 'bootstrap.php',
123 'favicon.ico',
124 'robots.txt',
125 '.bowerrc',
126 '.lfsconfig',
127 '.phpstorm.meta.php',
128 'config/config.ini.php',
129 'config/config.php',
130 'config/common.ini.php',
131 'config/*.config.ini.php',
132 'config/manifest.inc.php',
133 'misc/*.dat',
134 'misc/*.dat.gz',
135 'misc/*.mmdb',
136 'misc/*.mmdb.gz',
137 'misc/*.bin',
138 'misc/user/*png',
139 'misc/user/*svg',
140 'misc/user/*js',
141 'misc/user/*/config.ini.php',
142 'misc/package',
143 'misc/package/WebAppGallery/*.xml',
144 'misc/package/WebAppGallery/install.sql',
145 'plugins/ImageGraph/fonts/unifont.ttf',
146 'plugins/*/config/tracker.php',
147 'plugins/*/config/config.php',
148 'vendor/autoload.php',
149 'vendor/composer/autoload_real.php',
150 'vendor/szymach/c-pchart/app/*',
151 'tmp/*',
152 // Search engine sites verification
153 'google*.html',
154 'BingSiteAuth.xml',
155 'yandex*.html',
156 // common files on shared hosters
157 'php.ini',
158 '.user.ini',
159 'error_log',
160 // Files below are not expected but they used to be present in older Piwik versions and may be still here
161 // As they are not going to cause any trouble we won't report them as 'File to delete'
162 '*.coveralls.yml',
163 '*.scrutinizer.yml',
164 '*.gitignore',
165 '*.gitkeep',
166 '*.gitmodules',
167 '*.gitattributes',
168 '*.bower.json',
169 '*.travis.yml',
170 ]),
171
172 'Piwik\EventDispatcher' => DI\autowire()->constructorParameter('observers', DI\get('observers.global')),
173
174 'login.allowlist.ips' => function (ContainerInterface $c) {
175 /** @var Piwik\Config\ $config */
176 $config = $c->get('Piwik\Config');
177 $general = $config->General;
178
179 $ips = [];
180 if (!empty($general['login_allowlist_ip']) && is_array($general['login_allowlist_ip'])) {
181 $ips = $general['login_allowlist_ip'];
182 } elseif (!empty($general['login_whitelist_ip']) && is_array($general['login_whitelist_ip'])) {
183 // for BC
184 $ips = $general['login_whitelist_ip'];
185 }
186
187 $ipsResolved = [];
188
189 foreach ($ips as $ip) {
190 $ip = trim($ip);
191 if (filter_var($ip, FILTER_VALIDATE_IP) || \Matomo\Network\IPUtils::getIPRangeBounds($ip) !== null) {
192 $ipsResolved[] = $ip;
193 } else {
194 $lazyCache = \Piwik\Cache::getLazyCache();
195 $cacheKey = 'DNS.' . md5($ip);
196
197 $resolvedIps = $lazyCache->fetch($cacheKey);
198
199 if (!is_array($resolvedIps)) {
200 $resolvedIps = [];
201
202 $ipFromHost = @gethostbyname($ip);
203 if (!empty($ipFromHost) && $ipFromHost !== $ip) {
204 $resolvedIps[] = $ipFromHost;
205 }
206
207 if (function_exists('dns_get_record')) {
208 $entry = @dns_get_record($ip, DNS_AAAA);
209
210 if (
211 !empty($entry['0']['ipv6'])
212 && filter_var($entry['0']['ipv6'], FILTER_VALIDATE_IP)
213 ) {
214 $resolvedIps[] = $entry['0']['ipv6'];
215 }
216 }
217
218 $lazyCache->save($cacheKey, $resolvedIps, 30);
219 }
220
221 $ipsResolved = array_merge($ipsResolved, $resolvedIps);
222 }
223 }
224
225 return $ipsResolved;
226 },
227
228 /**
229 * This defines a list of hostnames Matomo's Http class will deny requests to. Wildcards (*) can be used in the
230 * beginning to match any subdomain level or in the end to match any tlds
231 */
232 'http.blocklist.hosts' => [
233 '*.amazonaws.com',
234 ],
235
236 'Piwik\Tracker\VisitorRecognizer' => DI\autowire()
237 ->constructorParameter('trustCookiesOnly', DI\get('ini.Tracker.trust_visitors_cookies'))
238 ->constructorParameter('visitStandardLength', DI\get('ini.Tracker.visit_standard_length'))
239 ->constructorParameter('lookbackNSecondsCustom', DI\get('ini.Tracker.window_look_back_for_visitor')),
240
241 'Piwik\Tracker\Settings' => DI\autowire()
242 ->constructorParameter(
243 'isSameFingerprintsAcrossWebsites',
244 DI\get('ini.Tracker.enable_fingerprinting_across_websites')
245 ),
246
247 'archiving.performance.logger' => null,
248
249 \Piwik\CronArchive\Performance\Logger::class => DI\autowire()
250 ->constructorParameter('logger', DI\get('archiving.performance.logger')),
251
252 \Piwik\Concurrency\LockBackend::class => \DI\get(\Piwik\Concurrency\LockBackend\MySqlLockBackend::class),
253
254 \Piwik\Segment\SegmentsList::class => function () {
255 return \Piwik\Segment\SegmentsList::get();
256 }
257 ];
258