Repository navigation
Expand file tree
/
Copy pathConfiguration.php
More file actions
52 lines (42 loc) · 1.52 KB
/
Copy pathConfiguration.php
File metadata and controls
52 lines (42 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\Provider;
use Piwik\Config;
class Configuration
{
public const KEY_SKIP_REVERSE_DNS_LOOKUP = 'skip_reverse_dns_lookup';
public const DEFAULT_SKIP_REVERSE_DNS_LOOKUP = 1;
/**
* Whether the DNS reverse lookup should be skipped when the configured location provider
* doesn't return any ISP or organisation information for a visitor's IP.
*
* The lookup is a blocking, uncached DNS request within the tracking request, which can add
* several seconds to it whenever no PTR record exists or the resolver is slow to answer, so
* it is skipped by default. Set `skip_reverse_dns_lookup = 0` in the `[Provider]` section of
* `config/config.ini.php` to perform the lookup anyway.
*
* @return bool
*/
public function shouldSkipReverseDnsLookup()
{
$value = $this->getConfigValue(self::KEY_SKIP_REVERSE_DNS_LOOKUP, self::DEFAULT_SKIP_REVERSE_DNS_LOOKUP);
if ($value === '' || $value === null) {
$value = self::DEFAULT_SKIP_REVERSE_DNS_LOOKUP;
}
return (bool) $value;
}
private function getConfigValue($name, $default)
{
$providerConfig = Config::getInstance()->Provider;
if (is_array($providerConfig) && array_key_exists($name, $providerConfig)) {
return $providerConfig[$name];
}
return $default;
}
}