Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie

This commit is contained in:
2026-08-27 08:57:05 +00:00
parent 6485f693dc
commit 74612aefbb
55 changed files with 6019 additions and 876 deletions
+41 -12
View File
@@ -1,12 +1,25 @@
<?php
/**
* BotGuard - Bot, AI Crawler, and Scraper detection & protection
* BotGuard - Bot, AI Crawler, and Scraper detection & protection.
*
* Detecteert en blokkeert bots, AI-crawlers en scrapers op basis van de
* User-Agent string, en genereert dynamische robots.txt-inhoud op basis
* van de beveiligingsinstellingen.
*
* @since 2.6.4
*/
class BotGuard
{
/**
* Map of bot signatures by category and pattern
* Geeft de map met bot-handtekeningen per categorie en patroon.
*
* Retourneert een multi-dimensionale array met de categorieën 'ai',
* 'search' en 'scraper', elk met een mapping van patroon naar weergavelabel.
*
* @since 2.6.4
*
* @return array<string,array<string,string>> Bot-handtekeningen per categorie.
*/
public static function getBotSignatures(): array
{
@@ -62,10 +75,16 @@ class BotGuard
}
/**
* Identify a User-Agent string
* Identificeer een User-Agent string.
*
* @param string $ua User-Agent string
* @return array Array with category, pattern, and display label
* Vergelijkt de User-Agent met de bekende bot-handtekeningen (ai, search,
* scraper), daarna met een generieke bot-regex. Bij geen match wordt de
* bezoeker als mens beschouwd.
*
* @since 2.6.4
*
* @param string $ua User-Agent string.
* @return array{category:string,pattern:string,label:string} Array met category, pattern en display label.
*/
public static function identify(string $ua): array
{
@@ -105,11 +124,16 @@ class BotGuard
}
/**
* Determine if a request should be blocked based on security settings
* Bepaal of een request geblokkeerd moet worden op basis van beveiligingsinstellingen.
*
* @param string $ua User-Agent string
* @param array $securitySettings Security configuration array
* @return string|null Reason string if blocked, null if allowed
* Controleert achtereenvolgens: lege User-Agent, custom blocklist, en
* categorie-specifieke blokkades (ai, search, scraper, generic bot).
*
* @since 2.6.4
*
* @param string $ua User-Agent string.
* @param array $securitySettings Beveiligingsconfiguratie-array.
* @return string|null Reden-string indien geblokkeerd (bijv. 'blocked:ai'), null indien toegestaan.
*/
public static function shouldBlock(string $ua, array $securitySettings): ?string
{
@@ -158,10 +182,15 @@ class BotGuard
}
/**
* Generate dynamic robots.txt content based on security settings
* Genereer dynamische robots.txt-inhoud op basis van de beveiligingsinstellingen.
*
* @param array $securitySettings Security configuration array
* @return string Robots.txt content
* Stelt globale regels op voor zoekmachines en voegt, indien AI-bots
* geblokkeerd worden, per AI-crawler een Disallow-blok toe.
*
* @since 2.6.4
*
* @param array $securitySettings Beveiligingsconfiguratie-array.
* @return string Robots.txt-inhoud.
*/
public static function generateRobotsTxt(array $securitySettings): string
{