-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathConfiguration.php
More file actions
172 lines (152 loc) · 4.66 KB
/
Copy pathConfiguration.php
File metadata and controls
172 lines (152 loc) · 4.66 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?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\TrackingSpamPrevention;
use Piwik\Config;
use Piwik\Container\StaticContainer;
class Configuration
{
public const DEFAULT_RANGE_THROW_EXCEPTION = 0;
/** @deprecated since 5.1.0, the allow list was moved to the `ip_allow_list` system setting */
public const DEFAULT_RANGE_ALLOW_LIST = [''];
public const DEFAULT_GEOIP_MATCH_PROVIDERS = [
'alicloud',
'alibaba cloud',
'kwaifong group limited',
'contabo',
'digitalocean',
'digital ocean',
'leaseweb',
'hostroyale technologies',
'ucloud information',
'secure internet llc',
'inios oy',
'fnk llc',
'dedipath-llc',
'mirholding b.v.',
'datacamp limited',
'voxility llp',
'lucidacloud',
'cloud computing corporation',
'gigabit hosting',
'hetzner online',
'm247 europe srl',
'incognet llc',
'ponynet',
'as40676',
'nforce entertainment b.v.',
'trabia srl',
'latitude-sh',
'dataforest gmbh',
'31173 services ab',
'advin services llc',
'wholesale services provider',
'netminders',
'altushost b.v.',
'amazon-02',
'akamai connected cloud',
'uab cherry servers',
'datema bilisim ticaret anonim sirketi',
'alibaba us technology co., ltd.',
'netcup gmbh',
'jinx co., limited',
'fd-298-8796',
'cloudsingularity',
'weserve b.v.',
'amarutu technology ltd',
'limestonenetworks',
'versija sia',
'oy crea nova hosting solution ltd',
'owl limited',
'tzulo',
'serverastra kft',
'ionos se',
'as-globaltelehost',
'estnoc oy',
'as-colocrossing',
'greenhost bv',
'keminet shpk',
'worldstream b.v.',
'aeza international ltd',
'asline limited',
'packethub s.a.',
'gorillaservers',
'as-vultr',
'nl-811-40021',
'cheapy-host',
'jsc selectel',
'gb network solutions sdn. bhd.',
'latitude.sh',
'limestone networks, inc',
'scaleway',
'm247 europe',
'tencent',
'fdcservers',
'ace data centers',
'egihosting',
'hangzhou alibaba advertising',
'sharktech',
'dmit cloud services',
];
public const KEY_RANGE_THROW_EXCEPTION = 'block_cloud_sync_throw_exception_on_error';
/** @deprecated since 5.1.0, the allow list was moved to the `ip_allow_list` system setting */
public const KEY_RANGE_ALLOW_LIST = 'iprange_allowlist';
/** @deprecated since 5.2.0, the list was moved to the `organisation_block_list` system setting */
public const KEY_GEOIP_MATCH_PROVIDERS = 'block_geoip_organisations';
public function install()
{
$config = $this->getConfig();
$default = $config->TrackingSpamPrevention;
if (empty($default)) {
$default = array();
}
if (empty($default[self::KEY_RANGE_THROW_EXCEPTION])) {
$default[self::KEY_RANGE_THROW_EXCEPTION] = self::DEFAULT_RANGE_THROW_EXCEPTION;
}
$config->TrackingSpamPrevention = $default;
$config->forceSave();
}
public function uninstall()
{
$config = $this->getConfig();
$config->TrackingSpamPrevention = array();
$config->forceSave();
}
/**
* @return bool
*/
public function shouldThrowExceptionOnIpRangeSync()
{
$value = $this->getConfigValue(self::KEY_RANGE_THROW_EXCEPTION, self::DEFAULT_RANGE_THROW_EXCEPTION);
if ($value === false || $value === '' || $value === null) {
$value = self::KEY_RANGE_THROW_EXCEPTION;
}
return (bool) $value;
}
/**
* @deprecated since 5.1.0, use SystemSettings::getAllowedIpRanges() instead. The allow list was moved from the
* config file to the `ip_allow_list` system setting.
* @return array
*/
public function getIpRangesAlwaysAllowed()
{
return StaticContainer::get(SystemSettings::class)->getAllowedIpRanges();
}
private function getConfig()
{
return Config::getInstance();
}
private function getConfigValue($name, $default)
{
$config = $this->getConfig();
$attribution = $config->TrackingSpamPrevention;
if (isset($attribution[$name])) {
return $attribution[$name];
}
return $default;
}
}