Add UA to guestbook

This commit is contained in:
floppydiskette 2024-01-26 12:26:37 +00:00
parent 7d0c7e41bf
commit fdeb7f1c48
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
4 changed files with 745 additions and 509 deletions

View file

@ -13,7 +13,8 @@
"laravel/tinker": "^2.8",
"scrivo/highlight.php": "v9.18.1.10",
"sentry/sentry-laravel": "^4.1",
"spatie/laravel-honeypot": "^4.3"
"spatie/laravel-honeypot": "^4.3",
"ua-parser/uap-php": "^3.9.14"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",

1220
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -286,13 +286,24 @@ table.gb-entry-form tr td span.text-danger {
}
table.gb-entry-form tr td textarea,
table.gb-entry-form tr td input {
table.gb-entry-form tr td input,
table.gb-entry-form tr td button{
margin-bottom: 5px;
margin-left: 10px;
background-color: var(--background);
border: var(--foreground) solid 1px;
}
table.gb-entry-form tr td button {
color: var(--foreground);
background-color: var(--background-secondary);
}
table.gb-entry-form tr td button:hover {
color: var(--background);
background-color: var(--foreground);
}
table.gb-entry-form-container {
width: 100%;
}
@ -327,6 +338,10 @@ table.gb-entry hr {
border-bottom: none;
}
table.gb-entry address {
font-size: 0.8pc;
}
table.gb-admin {
margin-bottom: 5px;
width: 500px;

View file

@ -2,6 +2,8 @@
@section('title', 'Guestbook')
@section('content')
@php
use UAParser\Parser;
$parser = Parser::create();
$db_alive = true;
try {
DB::connection()->getPdo();
@ -66,13 +68,16 @@
<hr>
@php
$entries = DB::select('
SELECT name, timestamp, message
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>
@ -81,6 +86,13 @@
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>