aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers
diff options
context:
space:
mode:
authorFrankie B <git@diskfloppy.me>2023-07-16 01:49:09 +0100
committerGitHub <noreply@github.com>2023-07-16 01:49:09 +0100
commit8482a98ca6a767062917747a0b016a9ab4d35f01 (patch)
tree0ab0e8d3baf5b421ab909bc731334e2deff82fe0 /app/Http/Controllers
parent1b267f61029e7d4b824979709434ffb437c347b8 (diff)
feat: add guestbook with rate limiting (#6)
* Re-add guestbook w/ rate limiting * Add guestbook to navbar
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r--app/Http/Controllers/GuestbookController.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/Http/Controllers/GuestbookController.php b/app/Http/Controllers/GuestbookController.php
new file mode 100644
index 0000000..aff30ed
--- /dev/null
+++ b/app/Http/Controllers/GuestbookController.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use DB;
+
+class GuestbookController extends Controller {
+ public function guestbook() {
+ return view('pages.guestbook');
+ }
+
+ public function guestbookPost(Request $request) {
+ $this->validate($request, [
+ 'name' => 'required',
+ 'message' => 'required'
+ ]);
+
+ DB::insert('INSERT INTO guestbook_entries (name, timestamp, ip_address, agent, message) values (?, ?, ?, ?, ?)', array(
+ htmlspecialchars($request->get('name')),
+ time(),
+ $request->ip(),
+ $request->userAgent(),
+ htmlspecialchars($request->get('message'))
+ ));
+
+ return back()->with('success', 'Entry submitted successfully!');
+ }
+}