Merge fixes into v5.5 branch (#12)
--------- Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
This commit is contained in:
parent
4f50fa52c3
commit
8e36d3dcba
18 changed files with 59 additions and 408 deletions
|
@ -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!');
|
||||
}
|
||||
|
|
|
@ -11,7 +11,5 @@ class PreventRequestsDuringMaintenance extends Middleware
|
|||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
protected $except = [];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -26,5 +26,5 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp
|
|||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
} // End handle().
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,5 @@ class VerifyCsrfToken extends Middleware
|
|||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
protected $except = [];
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue