1
0

remove crawler counts from admin/project-lawful
All checks were successful
Build Docker and Deploy / Build Docker (push) Successful in 1m7s
Build Docker and Deploy / Deploy to Server (push) Successful in 18s

This commit is contained in:
2023-09-18 21:01:54 +02:00
parent caa0a3a857
commit 96ae786bb0
20 changed files with 3477 additions and 9 deletions

View File

@@ -57,6 +57,41 @@ class ProjectLawful implements IWebsiteModule
return $this->site->modules->Database()->sql_query_assoc('SELECT variant, COUNT(*) AS `count` FROM projectlawful_downloadcounter GROUP BY variant ORDER BY variant');
}
public function listDownloadCountsExt()
{
// https://github.com/JayBizzle/Crawler-Detect
require_once __DIR__ . '/../../extern/crawler-detect/src/Fixtures/AbstractProvider.php';
require_once __DIR__ . '/../../extern/crawler-detect/src/Fixtures/Crawlers.php';
require_once __DIR__ . '/../../extern/crawler-detect/src/Fixtures/Exclusions.php';
require_once __DIR__ . '/../../extern/crawler-detect/src/Fixtures/Headers.php';
require_once __DIR__ . '/../../extern/crawler-detect/src/CrawlerDetect.php';
$CrawlerDetect = new \Jaybizzle\CrawlerDetect\CrawlerDetect;
$r = [];
foreach ($this->site->modules->Database()->sql_query_assoc('SELECT * FROM projectlawful_downloadcounter ORDER BY timestamp ASC') as $entry)
{
if (!key_exists($entry['variant'], $r)) $r[$entry['variant']] = [0, 0, ''];
$v = $r[$entry['variant']];
if ($CrawlerDetect->isCrawler($entry['useragent']))
{
$r[$entry['variant']] = [$v[0] + 0, $v[1] + 1, $entry['timestamp']];
}
else
{
$r[$entry['variant']] = [$v[0] + 1, $v[1] + 1, $v[2]];
}
}
ksort($r);
return $r;
}
public function variantExists(string $variant)
{
return isset($this->variants[$variant]);