diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Http/Controllers/GuestbookController.php | 19 | ||||
-rw-r--r-- | app/Http/Middleware/PreventRequestsDuringMaintenance.php | 4 | ||||
-rw-r--r-- | app/Http/Middleware/RateLimiter.php | 6 | ||||
-rw-r--r-- | app/Http/Middleware/RedirectIfAuthenticated.php | 2 | ||||
-rw-r--r-- | app/Http/Middleware/TrustProxies.php | 5 | ||||
-rw-r--r-- | app/Http/Middleware/VerifyCsrfToken.php | 4 | ||||
-rw-r--r-- | app/Providers/AuthServiceProvider.php | 1 |
7 files changed, 20 insertions, 21 deletions
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 @@ class GuestbookController extends Controller { $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<int, string> */ - 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 @@ class RedirectIfAuthenticated } 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<int, string> */ - 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 |