blob: a2c39fb4c578a7251980a7f2497df06a693475dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
@extends('layouts.default')
@section('title', 'Guestbook')
@section('content')
@php
use UAParser\Parser;
$parser = Parser::create();
$db_alive = true;
try {
DB::connection()->getPdo();
} catch (Exception $e) {
$db_alive = false;
}
@endphp
@if (!$db_alive)
@include('components.errors.db-error')
@else
<br>
<table class="gb-entry-form-container" role="presentation">
<tr>
<td>
<form method="POST" action="/guestbook">
@csrf
<x-honeypot/>
<table class="gb-entry-form" role="presentation">
<tr>
<td>
<label for="name"><strong>Name:</strong></label>
</td>
<td>
<input name="name" type="text" id="name">
</td>
<td>
<span class="text-danger">{{ $errors->first('name') }}</span>
</td>
</tr>
<tr>
<td>
<label for="message"><strong>Message:</strong></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></td>
<td>
<button type="submit">Submit</button>
</td>
</tr>
</table>
</form>
</td>
<td>
<p><i>A few things to note:</i></p>
<ul>
<li>You can submit an entry <u>once every hour</u>.</li>
<li>Your IP address is logged but <u>not</u> publicly displayed.</li>
<li>Any entries that appear to be spam <u>will</u> be removed.</li>
</ul>
</td>
</tr>
</table>
<hr>
@php
$entries = DB::select('
SELECT name, timestamp, message, agent
FROM guestbook__entries
ORDER BY id DESC
');
@endphp
<h2>Entries <small>({{ count($entries) }} total)</small></h2>
@foreach ($entries as $entry)
@php
$user_agent = $parser->parse($entry->agent);
@endphp
<table class="gb-entry" role="presentation">
<tr>
<td>
Submitted by <strong>{{ $entry->name }}</strong>
on <strong>{{ gmdate('Y-m-d', $entry->timestamp) }}</strong>
at <strong>{{ gmdate('h:i:s A (e)', $entry->timestamp) }}</strong>
<hr>
{{ $entry->message }}
<hr>
@if($entry->agent === "Agent Unavailable")
<address>Agent unavailable</address>
@else
<address>Posted using <strong>{{ $user_agent->ua->toString() }}</strong>
on <strong>{{ $user_agent->os->toString() }}</strong></address>
@endif
</td>
</tr>
</table>
<br>
@endforeach
@endif
@stop
|