From 8c0a2a6383a447bcfe988f8fa46f3923e30bff17 Mon Sep 17 00:00:00 2001 From: Frankie B Date: Sat, 29 Jul 2023 18:03:13 +0100 Subject: [PATCH] Merge fixes into v5.5 branch (#12) --------- Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com> --- app/Http/Controllers/GuestbookController.php | 19 ++- .../PreventRequestsDuringMaintenance.php | 4 +- app/Http/Middleware/RateLimiter.php | 6 +- .../Middleware/RedirectIfAuthenticated.php | 2 +- app/Http/Middleware/TrustProxies.php | 5 +- app/Http/Middleware/VerifyCsrfToken.php | 4 +- app/Providers/AuthServiceProvider.php | 1 - config/app.php | 157 ------------------ config/broadcasting.php | 27 --- config/database.php | 39 ----- config/hashing.php | 37 +---- config/logging.php | 38 ----- database/factories/UserFactory.php | 38 ----- public/css/master.css | 72 ++++---- public/css/minimal.css | 4 +- .../admin/guestbook-del-confirm.blade.php | 2 +- .../views/pages/admin/guestbook.blade.php | 6 +- resources/views/pages/guestbook.blade.php | 6 +- 18 files changed, 59 insertions(+), 408 deletions(-) delete mode 100644 database/factories/UserFactory.php diff --git a/app/Http/Controllers/GuestbookController.php b/app/Http/Controllers/GuestbookController.php index c7aa88e..70707d7 100644 --- a/app/Http/Controllers/GuestbookController.php +++ b/app/Http/Controllers/GuestbookController.php @@ -18,17 +18,20 @@ public function guestbookPost(Request $request) { $matching_bans = DB::select('SELECT reason FROM guestbook__bans WHERE ip_address = ?', array($request->ip())); - if (count($matching_bans) > 0 ) { + if (!empty($matching_bans)) { return view('errors.guestbook-ipban')->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(), - $request->ip(), - $request->userAgent(), - htmlspecialchars($request->get('message')) - )); + DB::insert( + 'INSERT INTO guestbook__entries (name, timestamp, ip_address, agent, message) values (?, ?, ?, ?, ?)', + [ + htmlspecialchars($request->get('name')), + time(), + $request->ip(), + $request->userAgent(), + htmlspecialchars($request->get('message')) + ] + ); return back()->with('success', 'Entry submitted successfully!'); } diff --git a/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/app/Http/Middleware/PreventRequestsDuringMaintenance.php index 74cbd9a..842e4b9 100644 --- a/app/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/app/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -11,7 +11,5 @@ class PreventRequestsDuringMaintenance extends Middleware * * @var array */ - protected $except = [ - // - ]; + protected $except = []; } diff --git a/app/Http/Middleware/RateLimiter.php b/app/Http/Middleware/RateLimiter.php index 8c00b57..09eb0a9 100644 --- a/app/Http/Middleware/RateLimiter.php +++ b/app/Http/Middleware/RateLimiter.php @@ -17,14 +17,14 @@ class RateLimiter public function handle(Request $request, Closure $next): Response { $ipAddress = $request->ip(); - $cacheKey = 'rate_limit_' . $ipAddress; + $cacheKey = 'rate_limit_'.$ipAddress; if (Cache::has($cacheKey)) { - // If the cache key exists, the IP has submitted an entry within the last hour + // If the cache key exists, the IP has submitted an entry within the last hour. return response()->view('errors.guestbook-ratelimit', [], 429); } - // Add the IP address to the cache and set the expiration time to one hour + // Add the IP address to the cache and set the expiration time to one hour. Cache::put($cacheKey, true, 3600); return $next($request); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index afc78c4..fdc707b 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -26,5 +26,5 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp } return $next($request); - } + } // End handle(). } diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 3391630..69f4e53 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -19,10 +19,11 @@ class TrustProxies extends Middleware * * @var int */ - protected $headers = + protected $headers =( Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | - Request::HEADER_X_FORWARDED_AWS_ELB; + Request::HEADER_X_FORWARDED_AWS_ELB + ); } diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 9e86521..70e23e1 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -11,7 +11,5 @@ class VerifyCsrfToken extends Middleware * * @var array */ - protected $except = [ - // - ]; + protected $except = []; } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 54756cd..3751a10 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -// use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider diff --git a/config/app.php b/config/app.php index 1ad039a..87399c6 100644 --- a/config/app.php +++ b/config/app.php @@ -4,187 +4,30 @@ use Illuminate\Support\ServiceProvider; return [ - - /* - |-------------------------------------------------------------------------- - | Application Name - |-------------------------------------------------------------------------- - | - | This value is the name of your application. This value is used when the - | framework needs to place the application's name in a notification or - | any other location as required by the application or its packages. - | - */ - 'name' => env('APP_NAME', 'diskfloppy.me'), 'version' => '5.5.0', - - /* - |-------------------------------------------------------------------------- - | Application Environment - |-------------------------------------------------------------------------- - | - | This value determines the "environment" your application is currently - | running in. This may determine how you prefer to configure various - | services the application utilizes. Set this in your ".env" file. - | - */ - 'env' => env('APP_ENV', 'production'), - - /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | - */ - 'debug' => (bool) env('APP_DEBUG', false), - - /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | - */ - 'url' => env('APP_URL', 'http://localhost'), 'api_root' => env('API_ROOT', 'http://localhost:3000'), 'asset_url' => env('ASSET_URL'), - - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ - 'timezone' => 'UTC', - - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - 'locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ - 'fallback_locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Faker Locale - |-------------------------------------------------------------------------- - | - | This locale will be used by the Faker PHP library when generating fake - | data for your database seeds. For example, this will be used to get - | localized telephone numbers, street address information and more. - | - */ - 'faker_locale' => 'en_US', - - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ - 'key' => env('APP_KEY'), - 'cipher' => 'AES-256-CBC', - - /* - |-------------------------------------------------------------------------- - | Maintenance Mode Driver - |-------------------------------------------------------------------------- - | - | These configuration options determine the driver used to determine and - | manage Laravel's "maintenance mode" status. The "cache" driver will - | allow maintenance mode to be controlled across multiple machines. - | - | Supported drivers: "file", "cache" - | - */ - 'maintenance' => [ 'driver' => 'file', - // 'store' => 'redis', ], - - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ - 'providers' => ServiceProvider::defaultProviders()->merge([ - /* - * Package Service Providers... - */ - - /* - * Application Service Providers... - */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, - // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, ])->toArray(), - - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | - */ - 'aliases' => Facade::defaultAliases()->merge([ // 'Example' => App\Facades\Example::class, ])->toArray(), - ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 2410485..98a0093 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,35 +1,8 @@ env('BROADCAST_DRIVER', 'null'), - - /* - |-------------------------------------------------------------------------- - | Broadcast Connections - |-------------------------------------------------------------------------- - | - | Here you may define all of the broadcast connections that will be used - | to broadcast events to other systems or over websockets. Samples of - | each available type of connection are provided inside this array. - | - */ - 'connections' => [ - 'pusher' => [ 'driver' => 'pusher', 'key' => env('PUSHER_APP_KEY'), diff --git a/config/database.php b/config/database.php index 67ae798..5e2b5d4 100644 --- a/config/database.php +++ b/config/database.php @@ -3,36 +3,8 @@ use Illuminate\Support\Str; return [ - - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ - 'default' => env('DB_CONNECTION', 'mysql'), - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - 'connections' => [ 'mysql' => [ 'driver' => 'mysql', @@ -55,16 +27,5 @@ ], ], - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - 'migrations' => 'migrations', ]; diff --git a/config/hashing.php b/config/hashing.php index bcd3be4..eca4888 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -1,52 +1,17 @@ 'bcrypt', - /* - |-------------------------------------------------------------------------- - | Bcrypt Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Bcrypt algorithm. This will allow you - | to control the amount of time it takes to hash the given password. - | - */ - 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], - /* - |-------------------------------------------------------------------------- - | Argon Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Argon algorithm. These will allow you - | to control the amount of time it takes to hash the given password. - | - */ 'argon' => [ 'memory' => 65536, 'threads' => 1, 'time' => 4, ], - ]; diff --git a/config/logging.php b/config/logging.php index c44d276..2da9712 100644 --- a/config/logging.php +++ b/config/logging.php @@ -6,51 +6,13 @@ use Monolog\Processor\PsrLogMessageProcessor; return [ - - /* - |-------------------------------------------------------------------------- - | Default Log Channel - |-------------------------------------------------------------------------- - | - | This option defines the default log channel that gets used when writing - | messages to the logs. The name specified in this option should match - | one of the channels defined in the "channels" configuration array. - | - */ - 'default' => env('LOG_CHANNEL', 'stack'), - /* - |-------------------------------------------------------------------------- - | Deprecations Log Channel - |-------------------------------------------------------------------------- - | - | This option controls the log channel that should be used to log warnings - | regarding deprecated PHP and library features. This allows you to get - | your application ready for upcoming major versions of dependencies. - | - */ - 'deprecations' => [ 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 'trace' => false, ], - /* - |-------------------------------------------------------------------------- - | Log Channels - |-------------------------------------------------------------------------- - | - | Here you may configure the log channels for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" - | - */ - 'channels' => [ 'stack' => [ 'driver' => 'stack', diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php deleted file mode 100644 index a6ecc0a..0000000 --- a/database/factories/UserFactory.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ -class UserFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => fake()->name(), - 'email' => fake()->unique()->safeEmail(), - 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password - 'remember_token' => Str::random(10), - ]; - } - - /** - * Indicate that the model's email address should be unverified. - */ - public function unverified(): static - { - return $this->state(fn (array $attributes) => [ - 'email_verified_at' => null, - ]); - } -} diff --git a/public/css/master.css b/public/css/master.css index 27ca004..dcec607 100644 --- a/public/css/master.css +++ b/public/css/master.css @@ -1,6 +1,6 @@ body { font-family: sans-serif; - margin: 0px; + margin: 0; color: #ddd; background-color: #333; } @@ -54,13 +54,7 @@ h2, h3 { margin-top: 1em; clear: left; - h1, - h2, - h3 { - margin-top: 1em; - clear: left; - color: #fff; - } + color: #fff; } img { @@ -125,9 +119,10 @@ div.codeblock pre { max-width: 90%; min-width: 400px; } + div.codeblock pre h1, div.codeblock pre hr { - margin: 0px + margin: 0 } div.codeblock pre h1 small { @@ -168,12 +163,12 @@ nav div a img { nav div h1 { font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, - Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, + Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; font-weight: normal; font-size: 30px; margin: 10px; - margin-left: 0px; + margin-left: 0; } div.date { @@ -186,10 +181,7 @@ div.note { table { border-collapse: collapse; - table { - border-collapse: collapse; - border-color: #fff; - } + border-color: #fff; } table.noborder td { @@ -295,14 +287,12 @@ table td { } td { - padding: 0px; + padding: 0; vertical-align: top; } table.skami { - table.skami { - border-color: #eeeeee; - } + border-color: #eeeeee; } .header .pagetree { @@ -344,7 +334,7 @@ table.computers { td.computer { width: 50%; - border: 0px; + border: 0; } div.footer { @@ -362,78 +352,74 @@ a { text-decoration: none; } -table.gb_entryform tr td { +table.gb-entryform tr td { border: none; } -table.gb_entryform tr td label { +table.gb-entryform tr td label { padding-right: 5px; } -table.gb_entryform tr td span.text-danger { +table.gb-entryform tr td span.text-danger { padding-left: 5px; color: rgb(255, 114, 114); } -table.gb_entryform tr td textarea, -table.gb_entryform tr td input { +table.gb-entryform tr td textarea, +table.gb-entryform tr td input { margin-bottom: 5px; } -table.gb_entryform_container { +table.gb-entryform-container { width: 100%; } -table.gb_entryform_container tr td { +table.gb-entryform-container tr td { border: none; vertical-align: top; } -table.gb_entryform_container tr td p, -table.gb_entryform_container tr td ul { - margin: 0px; +table.gb-entryform-container tr td p, +table.gb-entryform-container tr td ul { + margin: 0; } -table.gb_entryform tbody tr td textarea { +table.gb-entryform tbody tr td textarea { width: 210px; } -table.gb_entry tr td { +table.gb-entry tr td { border: solid #ffffff 1px; width: 500px; vertical-align: top; padding: 5px; } -table.gb_entry { +table.gb-entry { margin-bottom: 5px; } -table.gb_admin { +table.gb-admin { margin-bottom: 5px; width: 500px; - table.gb_admin { - margin-bottom: 5px; - width: 500px; - border: #fff solid; - } + border: #fff solid; } -table.gb_admin tr td { +table.gb-admin tr td { border-right: none; border-bottom: none; vertical-align: top; padding: 5px; } -table.gb_admin tr td.gb_del { +table.gb-admin tr td.gb-del { border-left: none; vertical-align: top; padding: 5px; width: 32px; } -table.gb_admin tr td.gb_message { +table.gb-admin tr td.gb-message { border-top: none; vertical-align: top; padding: 5px; @@ -448,7 +434,7 @@ table.infotable tr td { table.infotable tr td h1, table.infotable tr td h2, table.infotable tr td small { - margin: 0px; + margin: 0; } table.infotable tr td small { diff --git a/public/css/minimal.css b/public/css/minimal.css index d81245c..d70d9d6 100644 --- a/public/css/minimal.css +++ b/public/css/minimal.css @@ -4,12 +4,12 @@ html { body { font-family: sans-serif; - margin: 0px; + margin: 0; margin-left: 10px; color: #ddd; background-color: #333; } -table.gb_entry_details tr td { +table.gb-entry_details tr td { padding-right: 5px; } diff --git a/resources/views/pages/admin/guestbook-del-confirm.blade.php b/resources/views/pages/admin/guestbook-del-confirm.blade.php index ebdafd2..7db9e6d 100644 --- a/resources/views/pages/admin/guestbook-del-confirm.blade.php +++ b/resources/views/pages/admin/guestbook-del-confirm.blade.php @@ -6,7 +6,7 @@

Are you sure you want to delete this entry?

Entry Details:

- +
diff --git a/resources/views/pages/admin/guestbook.blade.php b/resources/views/pages/admin/guestbook.blade.php index a3b073f..d510910 100644 --- a/resources/views/pages/admin/guestbook.blade.php +++ b/resources/views/pages/admin/guestbook.blade.php @@ -10,19 +10,19 @@ @endphp

Entries ({{ count($entries) }} total)

@foreach ($entries as $entry) -
ID: {{ $entry->id }}
+
- - diff --git a/resources/views/pages/guestbook.blade.php b/resources/views/pages/guestbook.blade.php index a0112c1..9037ab5 100644 --- a/resources/views/pages/guestbook.blade.php +++ b/resources/views/pages/guestbook.blade.php @@ -2,13 +2,13 @@ @section('title', 'Guestbook') @section('content')
-
Name: {{ $entry->name }}
IP:   {{ $entry->ip_address }}
Date: {{ gmdate("H:i:s - Y-m-d", $entry->timestamp) }}
+ del
+
{{ htmlspecialchars($entry->message) }}
+
@csrf - +
@@ -62,7 +62,7 @@ @endphp

Entries ({{ count($entries) }} total)

@foreach ($entries as $entry) - +
Submitted by {{ $entry->name }}