From 8482a98ca6a767062917747a0b016a9ab4d35f01 Mon Sep 17 00:00:00 2001
From: Frankie B <git@diskfloppy.me>
Date: Sun, 16 Jul 2023 01:49:09 +0100
Subject: feat: add guestbook with rate limiting (#6)

* Re-add guestbook w/ rate limiting
* Add guestbook to navbar
---
 resources/views/pages/guestbook.blade.php | 53 +++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 resources/views/pages/guestbook.blade.php

(limited to 'resources/views/pages')

diff --git a/resources/views/pages/guestbook.blade.php b/resources/views/pages/guestbook.blade.php
new file mode 100644
index 0000000..f6b758a
--- /dev/null
+++ b/resources/views/pages/guestbook.blade.php
@@ -0,0 +1,53 @@
+@extends('layouts.default')
+@section('title', 'guestbook')
+@section('content')
+    <br/>
+    <form method="POST" action="/guestbook">
+        @csrf
+        <x-honeypot />
+        <table class="gb_entryform">
+            <tr>
+                <td>
+                    <label for="name">Name:</label>
+                </td>
+                <td>
+                    <input name="name" type="text" id="name" placeholder="John Doe">
+                </td>
+                <td>
+                    <span class="text-danger">{{ $errors->first('name') }}</span>
+                </td>
+            </tr>
+            <tr>
+                <td>
+                    <label for="message">Message:</label>
+                </td>
+                <td>
+                    <textarea name="message" id="message" rows="3"></textarea>
+                </td>
+                <td>
+                    <span class="text-danger">{{ $errors->first('message') }}</span>
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <button type="submit">Submit</button>
+                </td>
+            </tr>
+        </table>
+    </form>
+    <p>You can submit an entry <u>once every hour</u>.</p>
+    <p>Your IP address <u>will</u> be logged but <u>will not</u> be publically displayed.</p>
+    <hr/>
+    @php
+        $entries = DB::select('SELECT name, timestamp, message FROM guestbook_entries ORDER BY id DESC');
+    @endphp
+    <h1>Entries <small>({{ count($entries) }} total)</small></h1>
+    @foreach ($entries as $entry)
+        <table class="gb_entry"><tr><td>
+            Name:&nbsp;{{ $entry->name }}<br/>
+            Date:&nbsp;{{ gmdate("H:i:s - Y-m-d", $entry->timestamp) }}<br/><br/>
+            {{ htmlspecialchars($entry->message) }}
+        </td></tr></table>
+    @endforeach
+@stop
+
-- 
cgit v1.2.3-54-g00ecf