Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie
This commit is contained in:
@@ -1,13 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Analytics - Aggregated stats recorder & statistics manager for CodePress CMS
|
||||
* Analytics - Aggregated stats recorder & statistics manager for CodePress CMS.
|
||||
*
|
||||
* Registreert geaggregeerde bezoekersstatistieken (views, uniques, landen,
|
||||
* referrers, bots) in een JSON-bestand met file locking en retentie-cleanup.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class Analytics
|
||||
{
|
||||
/**
|
||||
* Pad naar het JSON-statistiekbestand.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var string Pad naar stats.json.
|
||||
*/
|
||||
private string $statsFile;
|
||||
|
||||
/**
|
||||
* Analytics configuratie-array.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var array<string,mixed> Analytics configuratie.
|
||||
*/
|
||||
private array $config;
|
||||
|
||||
/**
|
||||
* Initialiseer de Analytics-recorder.
|
||||
*
|
||||
* Stelt het pad naar het statistiekbestand in en maakt de opslagmap aan
|
||||
* indien deze nog niet bestaat.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param array $analyticsConfig {
|
||||
* Optioneel. Analytics configuratie.
|
||||
*
|
||||
* @type bool $enabled Of analytics actief is. Default false.
|
||||
* @type int $retention_days Aantal dagen dat statistieken bewaard blijven. Default 400.
|
||||
* }
|
||||
*/
|
||||
public function __construct(array $analyticsConfig = [])
|
||||
{
|
||||
$this->config = $analyticsConfig;
|
||||
@@ -19,14 +52,21 @@ class Analytics
|
||||
}
|
||||
|
||||
/**
|
||||
* Record a page visit in aggregated stats.json
|
||||
* Registreer een paginabezoek in de geaggregeerde statistieken.
|
||||
*
|
||||
* @param string $page Page key
|
||||
* @param string $ip Client IP
|
||||
* @param string $userAgent User Agent string
|
||||
* @param string $referrer Referrer string
|
||||
* @param string $country Resolved country code (e.g. NL, BE)
|
||||
* @param string $status Status string (ok, blocked:ai, blocked:ratelimit, etc.)
|
||||
* Identificeert bezoeker (bot/mens), anonimiseert het IP-adres per dag met
|
||||
* een zout, aggregeert totals/countries/pages/referrers/days/uniques, past
|
||||
* de retentie toe en schrijft atomair (met bestandslock) naar stats.json.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param string $page Page key van de bezochte pagina.
|
||||
* @param string $ip Client IP-adres.
|
||||
* @param string $userAgent User-Agent string van de bezoeker.
|
||||
* @param string $referrer Referrer URL string.
|
||||
* @param string|null $country Opgeloste landcode (bijv. NL, BE). Null indien onbekend.
|
||||
* @param string $status Status string (ok, blocked:ai, blocked:ratelimit, enz.).
|
||||
* @return void
|
||||
*/
|
||||
public function record(string $page, string $ip, string $userAgent, string $referrer, ?string $country, string $status): void
|
||||
{
|
||||
@@ -145,10 +185,16 @@ class Analytics
|
||||
}
|
||||
|
||||
/**
|
||||
* Get aggregated statistics data for a specific period
|
||||
* Haal geaggregeerde statistieken op voor een specifieke periode.
|
||||
*
|
||||
* @param int $days Number of days (e.g. 7, 30, 90, 0 for all)
|
||||
* @return array Aggregated stats
|
||||
* Leest stats.json en aggregeert totals, landen, pagina's, referrers en
|
||||
* een daily chart. Bij $days = 0 wordt alles-tijd geretourneerd, anders
|
||||
* worden ontbrekende dagen in de range opgevuld voor een vloeiende grafiek.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param int $days Aantal dagen (bijv. 7, 30, 90), of 0 voor alles-tijd. Default 30.
|
||||
* @return array<string,mixed> Geaggregeerde statistieken met keys totals, countries, pages, referrers, daily_chart.
|
||||
*/
|
||||
public function getStats(int $days = 30): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user