aboutsummaryrefslogtreecommitdiff
path: root/app/Http
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http')
-rw-r--r--app/Http/Controllers/BookmarksController.php15
-rw-r--r--app/Http/Controllers/CalculatorsController.php13
-rw-r--r--app/Http/Controllers/ComputersController.php13
-rw-r--r--app/Http/Controllers/Controller.php12
-rw-r--r--app/Http/Controllers/GuestbookController.php47
-rw-r--r--app/Http/Controllers/HomeController.php33
-rw-r--r--app/Http/Controllers/MusicController.php69
-rw-r--r--app/Http/Kernel.php72
-rw-r--r--app/Http/Middleware/Authenticate.php17
-rw-r--r--app/Http/Middleware/EncryptCookies.php17
-rw-r--r--app/Http/Middleware/PreventRequestsDuringMaintenance.php15
-rw-r--r--app/Http/Middleware/RateLimiter.php35
-rw-r--r--app/Http/Middleware/RedirectIfAuthenticated.php30
-rw-r--r--app/Http/Middleware/TrimStrings.php19
-rw-r--r--app/Http/Middleware/TrustHosts.php20
-rw-r--r--app/Http/Middleware/TrustProxies.php29
-rw-r--r--app/Http/Middleware/ValidateSignature.php22
-rw-r--r--app/Http/Middleware/VerifyCsrfToken.php15
18 files changed, 0 insertions, 493 deletions
diff --git a/app/Http/Controllers/BookmarksController.php b/app/Http/Controllers/BookmarksController.php
deleted file mode 100644
index 56aacc7..0000000
--- a/app/Http/Controllers/BookmarksController.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\Models\BookmarkSite;
-use App\Models\BookmarkCategory;
-use Illuminate\View\View;
-
-class BookmarksController extends Controller
-{
- public function show() : View {
- $categories = BookmarkCategory::with('sites')->get();
- return view('bookmarks', compact('categories'));
- }
-}
diff --git a/app/Http/Controllers/CalculatorsController.php b/app/Http/Controllers/CalculatorsController.php
deleted file mode 100644
index 38a7a41..0000000
--- a/app/Http/Controllers/CalculatorsController.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-use Illuminate\View\View;
-
-class CalculatorsController extends Controller
-{
- public function show() : View {
- return view('calculators');
- }
-}
diff --git a/app/Http/Controllers/ComputersController.php b/app/Http/Controllers/ComputersController.php
deleted file mode 100644
index e16e70d..0000000
--- a/app/Http/Controllers/ComputersController.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-use Illuminate\View\View;
-
-class ComputersController extends Controller
-{
- public function show() : View {
- return view('computers');
- }
-}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
deleted file mode 100644
index 77ec359..0000000
--- a/app/Http/Controllers/Controller.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
-use Illuminate\Foundation\Validation\ValidatesRequests;
-use Illuminate\Routing\Controller as BaseController;
-
-class Controller extends BaseController
-{
- use AuthorizesRequests, ValidatesRequests;
-}
diff --git a/app/Http/Controllers/GuestbookController.php b/app/Http/Controllers/GuestbookController.php
deleted file mode 100644
index df726ef..0000000
--- a/app/Http/Controllers/GuestbookController.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\Models\GuestbookEntry;
-use Illuminate\Http\Request;
-use Illuminate\Http\RedirectResponse;
-use Illuminate\Contracts\View\View;
-use Illuminate\Validation\ValidationException;
-use UAParser\Parser;
-
-class GuestbookController extends Controller {
- public function show(): View {
- $entries = GuestbookEntry::selectEntries();
- $parser = Parser::create();
-
- return view('guestbook')
- ->with('entries', $entries)
- ->with('parser', $parser);
- }
-
- /**
- * Creates a new guestbook entry
- *
- * @param Request $request
- * @return RedirectResponse
- * @throws ValidationException
- */
- public function addEntry(Request $request): RedirectResponse {
- $this->validate($request, [
- 'name' => 'required',
- 'message' => 'required'
- ]);
-
-
- GuestbookEntry::insertGuestbookEntry($request);
- return back()->with('success', 'Entry submitted successfully!');
- }
-
- public function banIP(string $addr) {
- // TODO: Add banning system
- // $matching_bans = DB::select('SELECT reason FROM guestbook__bans WHERE ip_address = ?', array($request->ip()));
- // if (!empty($matching_bans)) {
- // return view('errors.guestbook-ipban')->with('reason', $matching_bans[0]->reason);
- // }
- }
-}
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
deleted file mode 100644
index e046d58..0000000
--- a/app/Http/Controllers/HomeController.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\Config;
-use Illuminate\Support\Facades\Http;
-use Illuminate\View\View;
-use DateTime;
-
-class HomeController extends Controller {
- /**
- * Returns age based on birthday date and current date (GMT)
- * @return int
- */
- function returnAge(): int {
- date_default_timezone_set('Europe/London');
- $birthday = new DateTime("2005-06-07");
- $currentDate = DateTime::createFromFormat("Y-m-d", date("Y-m-d"));
- $age = $birthday->diff($currentDate);
- return $age->y;
- }
-
- /**
- * Shows home page
- * @return View
- */
- public function show(): View {
- return view('home', [
- 'age' => $this->returnAge(),
- ]);
- }
-}
diff --git a/app/Http/Controllers/MusicController.php b/app/Http/Controllers/MusicController.php
deleted file mode 100644
index 5e31d86..0000000
--- a/app/Http/Controllers/MusicController.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\Config;
-use Illuminate\Support\Facades\Http;
-use Illuminate\View\View;
-
-class MusicController extends Controller
-{
- public function getCurrentTrack() {
- // If it's already cached just return that
- if (Cache::has('current_track')) {
- return Cache::get('current_track');
- }
-
- $response = Http::withQueryParameters([
- 'method' => 'user.getrecenttracks',
- 'user' => Config::get('services.lastfm.user'),
- 'format' => 'json',
- 'nowplaying' => 'true',
- 'api_key' => Config::get('services.lastfm.key')
- ])->get('https://ws.audioscrobbler.com/2.0/');
- $data = $response->json();
- error_log($response->body());
- $track_data = $data["recenttracks"]["track"][0];
- $current_track = [
- 'title' => $track_data["name"],
- 'artist' => $track_data["artist"]["#text"],
- 'url' => $track_data["url"],
- ];
- Cache::put('current_track', $current_track, now()->addSeconds(15));
- return $current_track;
- }
-
- public function getTopTracks() {
- // If it's already cached just return that
- if (Cache::has('top_tracks')) {
- return Cache::get('top_tracks');
- }
-
- $response = Http::withQueryParameters([
- 'method' => 'user.gettoptracks',
- 'user' => Config::get('services.lastfm.user'),
- 'format' => 'json',
- 'period' => '1month',
- 'limit' => 10,
- 'api_key' => Config::get('services.lastfm.key')
- ])->get('https://ws.audioscrobbler.com/2.0/');
- $data = $response->json();
- $topTracks = [];
- foreach ($data["toptracks"]["track"] as $track) {
- $topTracks[] = [
- 'title' => $track["name"],
- 'artist' => $track["artist"]["name"],
- 'url' => $track["url"],
- 'plays' => $track["playcount"],
- ];
- }
- Cache::put('top_tracks', $topTracks, now()->addSeconds(15));
- return $topTracks;
- }
- public function show() : View {
- return view('music')
- ->with('current_track', $this->getCurrentTrack())
- ->with('top_tracks', $this->getTopTracks());
- }
-}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
deleted file mode 100644
index 4eab7b8..0000000
--- a/app/Http/Kernel.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-namespace App\Http;
-
-use Illuminate\Foundation\Http\Kernel as HttpKernel;
-
-class Kernel extends HttpKernel
-{
- /**
- * The application's global HTTP middleware stack.
- *
- * These middleware are run during every request to your application.
- *
- * @var array<int, class-string|string>
- */
- protected $middleware = [
- // \App\Http\Middleware\TrustHosts::class,
- \App\Http\Middleware\TrustProxies::class,
- \Illuminate\Http\Middleware\HandleCors::class,
- \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
- \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
- \App\Http\Middleware\TrimStrings::class,
- \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
- ];
-
- /**
- * The application's route middleware groups.
- *
- * @var array<string, array<int, class-string|string>>
- */
- protected $middlewareGroups = [
- 'web' => [
- \App\Http\Middleware\EncryptCookies::class,
- \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
- \Illuminate\Session\Middleware\StartSession::class,
- \Illuminate\View\Middleware\ShareErrorsFromSession::class,
- \App\Http\Middleware\VerifyCsrfToken::class,
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
- ],
-
- 'api' => [
- // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
- \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
- ],
- ];
-
- protected $routeMiddleware = [
- 'rate_limit' => \App\Http\Middleware\RateLimiter::class,
- ];
-
-
- /**
- * The application's middleware aliases.
- *
- * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
- *
- * @var array<string, class-string|string>
- */
- protected $middlewareAliases = [
- 'auth' => \App\Http\Middleware\Authenticate::class,
- 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
- 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
- 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
- 'can' => \Illuminate\Auth\Middleware\Authorize::class,
- 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
- 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
- 'signed' => \App\Http\Middleware\ValidateSignature::class,
- 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
- 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
- ];
-}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
deleted file mode 100644
index d4ef644..0000000
--- a/app/Http/Middleware/Authenticate.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Auth\Middleware\Authenticate as Middleware;
-use Illuminate\Http\Request;
-
-class Authenticate extends Middleware
-{
- /**
- * Get the path the user should be redirected to when they are not authenticated.
- */
- protected function redirectTo(Request $request): ?string
- {
- return $request->expectsJson() ? null : route('login');
- }
-}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
deleted file mode 100644
index 5ee1433..0000000
--- a/app/Http/Middleware/EncryptCookies.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
-
-class EncryptCookies extends Middleware
-{
- /**
- * The names of the cookies that should not be encrypted.
- *
- * @var array<int, string>
- */
- protected $except = [
- "colorscheme"
- ];
-}
diff --git a/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/app/Http/Middleware/PreventRequestsDuringMaintenance.php
deleted file mode 100644
index 842e4b9..0000000
--- a/app/Http/Middleware/PreventRequestsDuringMaintenance.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
-
-class PreventRequestsDuringMaintenance extends Middleware
-{
- /**
- * The URIs that should be reachable while maintenance mode is enabled.
- *
- * @var array<int, string>
- */
- protected $except = [];
-}
diff --git a/app/Http/Middleware/RateLimiter.php b/app/Http/Middleware/RateLimiter.php
deleted file mode 100644
index 821868f..0000000
--- a/app/Http/Middleware/RateLimiter.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Closure;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Cache;
-use Symfony\Component\HttpFoundation\Response;
-
-class RateLimiter
-{
- /**
- * Handle an incoming request.
- *
- * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
- */
- public function handle(Request $request, Closure $next): Response
- {
- if (auth()->check()) {
- return $next($request);
- }
- $ipAddress = $request->ip();
- $cacheKey = 'rate_limit_'.$ipAddress;
-
- if (Cache::has($cacheKey)) {
- // 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.
- Cache::put($cacheKey, true, 3600);
-
- return $next($request);
- }
-}
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
deleted file mode 100644
index fdc707b..0000000
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use App\Providers\RouteServiceProvider;
-use Closure;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
-use Symfony\Component\HttpFoundation\Response;
-
-class RedirectIfAuthenticated
-{
- /**
- * Handle an incoming request.
- *
- * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
- */
- public function handle(Request $request, Closure $next, string ...$guards): Response
- {
- $guards = empty($guards) ? [null] : $guards;
-
- foreach ($guards as $guard) {
- if (Auth::guard($guard)->check()) {
- return redirect(RouteServiceProvider::HOME);
- }
- }
-
- return $next($request);
- } // End handle().
-}
diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php
deleted file mode 100644
index 88cadca..0000000
--- a/app/Http/Middleware/TrimStrings.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
-
-class TrimStrings extends Middleware
-{
- /**
- * The names of the attributes that should not be trimmed.
- *
- * @var array<int, string>
- */
- protected $except = [
- 'current_password',
- 'password',
- 'password_confirmation',
- ];
-}
diff --git a/app/Http/Middleware/TrustHosts.php b/app/Http/Middleware/TrustHosts.php
deleted file mode 100644
index c9c58bd..0000000
--- a/app/Http/Middleware/TrustHosts.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Http\Middleware\TrustHosts as Middleware;
-
-class TrustHosts extends Middleware
-{
- /**
- * Get the host patterns that should be trusted.
- *
- * @return array<int, string|null>
- */
- public function hosts(): array
- {
- return [
- $this->allSubdomainsOfApplicationUrl(),
- ];
- }
-}
diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php
deleted file mode 100644
index 69f4e53..0000000
--- a/app/Http/Middleware/TrustProxies.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Http\Middleware\TrustProxies as Middleware;
-use Illuminate\Http\Request;
-
-class TrustProxies extends Middleware
-{
- /**
- * The trusted proxies for this application.
- *
- * @var array<int, string>|string|null
- */
- protected $proxies;
-
- /**
- * The headers that should be used to detect proxies.
- *
- * @var int
- */
- 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
- );
-}
diff --git a/app/Http/Middleware/ValidateSignature.php b/app/Http/Middleware/ValidateSignature.php
deleted file mode 100644
index 093bf64..0000000
--- a/app/Http/Middleware/ValidateSignature.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
-
-class ValidateSignature extends Middleware
-{
- /**
- * The names of the query string parameters that should be ignored.
- *
- * @var array<int, string>
- */
- protected $except = [
- // 'fbclid',
- // 'utm_campaign',
- // 'utm_content',
- // 'utm_medium',
- // 'utm_source',
- // 'utm_term',
- ];
-}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
deleted file mode 100644
index 70e23e1..0000000
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
-
-class VerifyCsrfToken extends Middleware
-{
- /**
- * The URIs that should be excluded from CSRF verification.
- *
- * @var array<int, string>
- */
- protected $except = [];
-}