timestamp); } /** * Liefert den Grund, warum die Anfrage als Bot gilt, oder null. */ public function blockReason(Request $request): ?string { if (filled($request->input(self::HONEYPOT_FIELD))) { return 'honeypot'; } try { $startedAt = (int) decrypt((string) $request->input(self::TIMESTAMP_FIELD)); } catch (DecryptException) { return 'invalid_form_token'; } if (now()->timestamp - $startedAt < self::MIN_SECONDS) { return 'too_fast'; } return null; } /** * Protokolliert eine abgefangene Anfrage ohne Freitext-Inhalte. * * @param 'contact'|'register' $form * @param array $context */ public static function log(Request $request, string $form, string $reason, array $context = []): void { Log::channel('form_spam')->info('Formular abgefangen', [ 'form' => $form, 'reason' => $reason, 'ip' => $request->ip(), 'host' => $request->getHost(), 'user_shop_id' => Util::getUserShop()?->id, 'email_domain' => Str::after((string) $request->input('email'), '@') ?: null, ...$context, ]); } }