diff --git a/fp_altcha_spamschutz/log.php b/fp_altcha_spamschutz/log.php new file mode 100644 index 0000000..83f22be --- /dev/null +++ b/fp_altcha_spamschutz/log.php @@ -0,0 +1,96 @@ + + * + * Den aktuellen Zugriffsschlüssel finden Sie in der Datei data/fp_altcha_log_token.php im + * Plugin-Verzeichnis (einmalig per FTP/Datei-Manager auslesen). Die Datei wird automatisch + * angelegt, sobald das Angriffsprotokoll in den Plugin-Einstellungen aktiviert ist. + */ + +$dataDir = __DIR__ . '/data'; +$tokenFile = $dataDir . '/fp_altcha_log_token.php'; +$logFile = $dataDir . '/fp_altcha_attacklog.jsonl'; + +$expectedToken = \is_file($tokenFile) ? @include $tokenFile : null; +$providedToken = isset($_GET['key']) && \is_string($_GET['key']) ? $_GET['key'] : ''; +$tokenIsValid = \is_string($expectedToken) + && $expectedToken !== '' + && $providedToken !== '' + && \hash_equals($expectedToken, $providedToken); + +if (!$tokenIsValid) { + \http_response_code(404); + echo 'Not found'; + exit; +} + +\header('Content-Type: text/html; charset=UTF-8'); +\header('X-Robots-Tag: noindex, nofollow'); + +$entries = []; +if (\is_file($logFile)) { + $lines = @\file($logFile, \FILE_IGNORE_NEW_LINES | \FILE_SKIP_EMPTY_LINES) ?: []; + foreach (\array_reverse($lines) as $line) { + $decoded = \json_decode($line, true); + if (\is_array($decoded)) { + $entries[] = $decoded; + } + } +} + +$anzahl = \count($entries); + +echo '' + . 'fp_altcha_spamschutz – Angriffsprotokoll' + . ''; + +echo '

fp_altcha_spamschutz – Angriffsprotokoll (' + . $anzahl . ' Einträge, neueste zuerst)

'; + +if ($anzahl === 0) { + echo '

Noch keine abgelehnten Anfragen protokolliert.

'; +} else { + echo '' + . ''; + + foreach ($entries as $entry) { + $zeit = \htmlspecialchars((string) ($entry['zeit'] ?? ''), \ENT_QUOTES, 'UTF-8'); + $formular = \htmlspecialchars((string) ($entry['formular'] ?? ''), \ENT_QUOTES, 'UTF-8'); + $ip = \htmlspecialchars((string) ($entry['ip'] ?? ''), \ENT_QUOTES, 'UTF-8'); + $pruefung = \htmlspecialchars((string) ($entry['sicherheitspruefung'] ?? ''), \ENT_QUOTES, 'UTF-8'); + $muster = !empty($entry['namensmuster']) ? 'ja' : 'nein'; + $honeypot = !empty($entry['honeypot']) ? 'ja' : 'nein'; + + echo '' + . '' + . '' + . '' + . '' + . '' + . '' + . ''; + } + + echo '
ZeitFormularIPSicherheitsprüfungNamensmusterHoneypot
' . $zeit . '' . $formular . '' . $ip . '' . $pruefung . '' . $muster . '' . $honeypot . '
'; +} + +echo '';