diff options
-rw-r--r-- | app/Http/Controllers/GuestbookController.php | 6 | ||||
-rw-r--r-- | resources/views/errors/guestbook-ban.blade.php | 12 |
2 files changed, 18 insertions, 0 deletions
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(), diff --git a/resources/views/errors/guestbook-ban.blade.php b/resources/views/errors/guestbook-ban.blade.php new file mode 100644 index 0000000..257dd72 --- /dev/null +++ b/resources/views/errors/guestbook-ban.blade.php @@ -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 |