Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-06-23 16:09:06 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-06-24 22:22:02 +0300
commit12241c90dfb13d91b779f70ecc53eb1a643831dc (patch)
tree470bb74edb54e243a6c6b57b8e598375d4353459 /plugins/CoreAdminHome/Tasks.php
parentb1df4aa23693096e0c3cbb479b71b8cb1d4ddb4a (diff)
#7674 Auto-update the referrer spammer blacklist
The blacklist is updated weekly from github (stored in the option table).
Diffstat (limited to 'plugins/CoreAdminHome/Tasks.php')
-rw-r--r--plugins/CoreAdminHome/Tasks.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php
index 7a3ff406b5..84c8be3ff9 100644
--- a/plugins/CoreAdminHome/Tasks.php
+++ b/plugins/CoreAdminHome/Tasks.php
@@ -10,11 +10,13 @@ namespace Piwik\Plugins\CoreAdminHome;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Archive\ArchivePurger;
-use Piwik\Container\StaticContainer;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Date;
use Piwik\Db;
+use Piwik\Http;
+use Piwik\Option;
use Piwik\Plugins\CoreAdminHome\Tasks\ArchivesToPurgeDistributedList;
+use Piwik\Tracker\Visit\ReferrerSpamFilter;
use Psr\Log\LoggerInterface;
class Tasks extends \Piwik\Plugin\Tasks
@@ -45,13 +47,15 @@ class Tasks extends \Piwik\Plugin\Tasks
// lowest priority since tables should be optimized after they are modified
$this->daily('optimizeArchiveTable', null, self::LOWEST_PRIORITY);
+
+ $this->weekly('updateSpammerBlacklist');
}
public function purgeOutdatedArchives()
{
if ($this->willPurgingCausePotentialProblemInUI()) {
$this->logger->info("Purging temporary archives: skipped (browser triggered archiving not enabled & not running after core:archive)");
- return false;
+ return;
}
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
@@ -101,6 +105,19 @@ class Tasks extends \Piwik\Plugin\Tasks
}
/**
+ * Update the referrer spam blacklist
+ *
+ * @see https://github.com/piwik/referrer-spam-blacklist
+ */
+ public function updateSpammerBlacklist()
+ {
+ $url = 'https://raw.githubusercontent.com/piwik/referrer-spam-blacklist/master/spammers.txt';
+ $list = Http::sendHttpRequest($url, 10);
+ $list = preg_split("/\r\n|\n|\r/", $list);
+ Option::set(ReferrerSpamFilter::OPTION_STORAGE_NAME, serialize($list));
+ }
+
+ /**
* we should only purge outdated & custom range archives if we know cron archiving has just run,
* or if browser triggered archiving is enabled. if cron archiving has run, then we know the latest
* archives are in the database, and we can remove temporary ones. if browser triggered archiving is