Loheide-eu-mitarbeiterplatt.../app/Support/Audit.php
Friederich Loheide 43244d751a Self-Updater und Lizenzprüfung
Umsetzung von docs/specs/self-updater.md für Laravel:
- Installierter Stand als SHA in storage/.version, Fortschritt in storage/.update-progress,
  selbstheilender Wartungsmodus in storage/.maintenance
- Update-Client je Kanal (stable/development), nur HTTPS, begrenzte Redirects,
  ZIP-Download per Stream mit PK- und SHA-256-Prüfung
- Entpacken mit zweistufigem ZIP-Slip-Schutz, Übernahme mit geschützten Pfaden
  (atomar je Datei, nie löschen), Migrationen, Cache- und OPcache-Reset
- Lizenzspeicher außerhalb der DB, Geräte-ID als Zufallszahl, rotierendes Gerätetoken
  wird bei jeder Antwort (auch Fehler und Downloads) sofort gespeichert
- Lizenzfehler mit verständlichen Meldungen – sie sperren nie das Portal
- Seite „Aktualisierung“ mit Kanal, Suche, Changelog-Vorschau, Fortschritt,
  Migrationen, Änderungsprotokoll, Lizenz und Datenschutzhinweis
- Wartungs-Middleware (503 + Retry-After) und Auto-Migration per Fingerabdruck
- Audit-Log für Updates, Kanalwechsel und Lizenzänderungen
- Version 0.2.0

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 06:02:19 +00:00

30 lines
806 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Support;
use App\Models\AuditLog;
use Illuminate\Support\Facades\Log;
use Throwable;
/**
* Protokoll für Admin-Aktionen. Schreibt zusätzlich ins Log – falls die
* Datenbank gerade nicht erreichbar ist (z. B. mitten in einem Update).
*/
class Audit
{
/**
* @param array<string, mixed> $data
*/
public static function log(string $action, array $data = [], ?int $userId = null): void
{
$userId ??= auth()->id();
Log::info("audit: {$action}", [...$data, 'user_id' => $userId]);
try {
AuditLog::query()->create(['user_id' => $userId, 'action' => $action, 'data' => $data]);
} catch (Throwable $e) {
Log::warning('Audit-Eintrag konnte nicht gespeichert werden: '.$e->getMessage());
}
}
}