-
Notifications
You must be signed in to change notification settings - Fork 7
/
Tasks.php
49 lines (42 loc) · 1.18 KB
/
Tasks.php
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
<?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;
class Tasks extends \Piwik\Plugin\Tasks
{
/**
* @var SystemSettings
*/
private $systemSettings;
/**
* @var BlockedIpRanges
*/
private $blockedIpRanges;
public function __construct(SystemSettings $systemSettings, BlockedIpRanges $blockedIpRanges)
{
$this->systemSettings = $systemSettings;
$this->blockedIpRanges = $blockedIpRanges;
}
public function schedule()
{
$this->daily('updateBlockedIpRanges');
}
/**
* To test execute the following command:
* `./console core:run-scheduled-tasks --force "Piwik\Plugins\TrackingSpamPrevention\Tasks.updateBlockedIpRanges"`
*
*/
public function updateBlockedIpRanges()
{
if ($this->systemSettings->block_clouds->getValue()) {
$this->blockedIpRanges->updateBlockedIpRanges();
} else {
// we also unset any banned IP every 24 hours
$this->blockedIpRanges->unsetAllIpRanges();
}
}
}