web: Crawler-Abruf-Protokoll und Panel „Auslieferung" ohne Google-Link (Anhang 1: 1c.0, 1c.1, 1c.6)
Abrufe öffentlicher Meldungen durch bekannte Such- und KI-Dienste werden je Meldung mit Dienst, gekürztem User-Agent und Zeitpunkt protokolliert — keine IP. Dienste und Muster stehen in config/crawlers.php. Aufzeichnung wie der Aufruf-Zähler per defer() und fehlertolerant; Bereinigung hängt an press-releases:purge-events. VisibilityStats liefert die Abrufe je Dienst (letzter Abruf, Anzahl) und verliert den site:-Suchlink (Stufe 1 verspricht nichts, was von Dritten abhängt). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6446e19727
commit
7088d092d8
10 changed files with 440 additions and 7 deletions
41
app/Support/CrawlerIdentifier.php
Normal file
41
app/Support/CrawlerIdentifier.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
/**
|
||||
* Ordnet einen User-Agent einem bekannten Such- oder KI-Dienst zu
|
||||
* (config/crawlers.php). Null, wenn kein Dienst aus der Liste passt —
|
||||
* gewöhnliche Browser und unbekannte Bots werden nicht protokolliert.
|
||||
*/
|
||||
class CrawlerIdentifier
|
||||
{
|
||||
public static function identify(?string $userAgent): ?string
|
||||
{
|
||||
if ($userAgent === null || trim($userAgent) === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var array<string, array{label: string, kind: string, patterns: list<string>}> $services */
|
||||
$services = config('crawlers.services', []);
|
||||
|
||||
foreach ($services as $key => $service) {
|
||||
foreach ($service['patterns'] as $pattern) {
|
||||
if (stripos($userAgent, $pattern) !== false) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function label(string $service): string
|
||||
{
|
||||
return (string) (config('crawlers.services.'.$service.'.label') ?? $service);
|
||||
}
|
||||
|
||||
public static function kind(string $service): string
|
||||
{
|
||||
return (string) (config('crawlers.services.'.$service.'.kind') ?? 'ai');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue