v1.6.33 : exclusion AS, compteurs 7/14/30j, 👍 uniquement
- Carte visiteurs uniques non-bot : 7 / 14 / 30 jours en tête de /admin/stats - Bouton ✕ par AS pour l'exclure des stats ; section AS exclus avec ↺ - Alerte IPs sans résolution AS dans la carte pays - Parser : fenêtre 30 jours, calcul visiteurs uniques toutes IPs non-bot - Graphiques adaptés à 30 jours (labels x/3) - Réactions articles : 👍 uniquement (suppression 🔥 et 🤔) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+41
-10
@@ -25,7 +25,7 @@ class AccessLogParser
|
||||
string $pattern = '*-access.log',
|
||||
string $cacheFile = '',
|
||||
int $cacheTtl = 600,
|
||||
int $days = 14,
|
||||
int $days = 30,
|
||||
array $botPatterns = []
|
||||
) {
|
||||
$this->logDir = rtrim($logDir, '/');
|
||||
@@ -45,7 +45,8 @@ class AccessLogParser
|
||||
* ips_by_day:array<string,list<int>>,
|
||||
* ip_top_paths:array<string,array<string,array{n:int,ts:int}>>,
|
||||
* ip_agents:array<string,list<string>>,
|
||||
* all_uas:array<string,int>
|
||||
* all_uas:array<string,int>,
|
||||
* unique_visitors:array<int,int>
|
||||
* }
|
||||
*/
|
||||
public function stats(): array
|
||||
@@ -121,15 +122,45 @@ class AccessLogParser
|
||||
$ipTopAgents[$ip] = array_keys(array_slice($agents, 0, 5, true));
|
||||
}
|
||||
|
||||
// Visiteurs uniques par période — calculé sur TOUS les IPs non-bot (pas seulement le top 200)
|
||||
$uniqueVisitors = [7 => 0, 14 => 0, 30 => 0];
|
||||
$start7 = $this->days - 7;
|
||||
$start14 = $this->days - 14;
|
||||
foreach ($ipAllDays as $ipDay) {
|
||||
$active7 = $active14 = $active30 = false;
|
||||
foreach ($ipDay as $offset => $cnt) {
|
||||
if ($cnt <= 0) {
|
||||
continue;
|
||||
}
|
||||
$active30 = true;
|
||||
if ($offset >= $start14) {
|
||||
$active14 = true;
|
||||
}
|
||||
if ($offset >= $start7) {
|
||||
$active7 = true;
|
||||
}
|
||||
}
|
||||
if ($active7) {
|
||||
++$uniqueVisitors[7];
|
||||
}
|
||||
if ($active14) {
|
||||
++$uniqueVisitors[14];
|
||||
}
|
||||
if ($active30) {
|
||||
++$uniqueVisitors[30];
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
'pages' => $pages,
|
||||
'books' => $books,
|
||||
'ips' => $ips,
|
||||
'pages_by_day' => $pagesByDay,
|
||||
'ips_by_day' => $ipsByDay,
|
||||
'ip_top_paths' => $ipTopPaths,
|
||||
'ip_agents' => $ipTopAgents,
|
||||
'all_uas' => array_slice($allUas, 0, 300, true),
|
||||
'pages' => $pages,
|
||||
'books' => $books,
|
||||
'ips' => $ips,
|
||||
'pages_by_day' => $pagesByDay,
|
||||
'ips_by_day' => $ipsByDay,
|
||||
'ip_top_paths' => $ipTopPaths,
|
||||
'ip_agents' => $ipTopAgents,
|
||||
'all_uas' => array_slice($allUas, 0, 300, true),
|
||||
'unique_visitors' => $uniqueVisitors,
|
||||
];
|
||||
@mkdir(dirname($this->cacheFile), 0755, true);
|
||||
@file_put_contents($this->cacheFile, json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
Reference in New Issue
Block a user