From 65b02f3b8df505b60230af0647d7187f4dc7cfd7 Mon Sep 17 00:00:00 2001 From: Frankie B Date: Sun, 16 Jul 2023 15:27:48 +0100 Subject: Add ability to ban users from guestbook (by IP) --- app/Http/Controllers/GuestbookController.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app') diff --git a/app/Http/Controllers/GuestbookController.php b/app/Http/Controllers/GuestbookController.php index aff30ed..da5391d 100644 --- a/app/Http/Controllers/GuestbookController.php +++ b/app/Http/Controllers/GuestbookController.php @@ -16,6 +16,12 @@ class GuestbookController extends Controller { 'message' => 'required' ]); + $matching_bans = DB::select('SELECT reason FROM guestbook_bans WHERE ip_address = ?', array($request->ip())); + + if (count($matching_bans) > 0 ) { + return view('errors.guestbook-ban')->with('reason', $matching_bans[0]->reason); + } + DB::insert('INSERT INTO guestbook_entries (name, timestamp, ip_address, agent, message) values (?, ?, ?, ?, ?)', array( htmlspecialchars($request->get('name')), time(), -- cgit v1.2.3-54-g00ecf