Add ability to ban users from guestbook (by IP)

This commit is contained in:
floppydiskette 2023-07-16 15:27:48 +01:00
parent e1da508542
commit 65b02f3b8d
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:yXxSuswzElTluzXjKgvZK0bDGhTaj/XbArybRDr+Mfs
2 changed files with 18 additions and 0 deletions

View file

@ -16,6 +16,12 @@ public function guestbookPost(Request $request) {
'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(),

View file

@ -0,0 +1,12 @@
@extends('layouts.minimal')
@section('title', 'Error 403: IP Blocked!')
@section('content')
<h1>Error 403: IP Blocked!</h1>
<hr/>
<p>Your IP has been banned from submitting to the guestbook.</p>
@if (isset($reason))
<p><b>Reason:</b> {{ $reason }}</p>
@endif
<br/>
Click <a href="/guestbook">here</a> to go back to the guestbook.
@stop