From 069cf70f5be260e6fcf44d80a9befca01e4c5ed6 Mon Sep 17 00:00:00 2001 From: Frankie B Date: Thu, 11 Jul 2024 22:23:46 +0100 Subject: [PATCH] Remove admin pages --- .../Controllers/AdminBookmarksController.php | 15 ---- .../Controllers/AdminGuestbookController.php | 34 --------- .../Controllers/AdminImportController.php | 69 ------------------- resources/views/admin/bookmarks.blade.php | 28 -------- resources/views/admin/guestbook.blade.php | 32 --------- .../views/admin/import-success.blade.php | 12 ---- resources/views/admin/import.blade.php | 18 ----- 7 files changed, 208 deletions(-) delete mode 100644 app/Http/Controllers/AdminBookmarksController.php delete mode 100644 app/Http/Controllers/AdminGuestbookController.php delete mode 100644 app/Http/Controllers/AdminImportController.php delete mode 100644 resources/views/admin/bookmarks.blade.php delete mode 100644 resources/views/admin/guestbook.blade.php delete mode 100644 resources/views/admin/import-success.blade.php delete mode 100644 resources/views/admin/import.blade.php diff --git a/app/Http/Controllers/AdminBookmarksController.php b/app/Http/Controllers/AdminBookmarksController.php deleted file mode 100644 index c7d8afd..0000000 --- a/app/Http/Controllers/AdminBookmarksController.php +++ /dev/null @@ -1,15 +0,0 @@ -get(); - return view('admin.bookmarks', compact('categories')); - } -} diff --git a/app/Http/Controllers/AdminGuestbookController.php b/app/Http/Controllers/AdminGuestbookController.php deleted file mode 100644 index 5ebf451..0000000 --- a/app/Http/Controllers/AdminGuestbookController.php +++ /dev/null @@ -1,34 +0,0 @@ -distinct()->count('ip'); - return $uniqueIpsCount; - } - - function getGuestbookEntriesCount(): int { - $entryCount = DB::table('guestbook__entries')->count(); - return $entryCount; - } - public function show() : View { - $guestbook_unique_addr = $this->getGuestbookUniqueAddr(); - $guestbook_entry_count = $this->getGuestbookEntriesCount(); - $entries = GuestbookEntry::selectEntries(); - $parser = Parser::create(); - - return view('admin.guestbook', [ - 'guestbook_unique_addr' => $guestbook_unique_addr, - 'guestbook_entry_count' => $guestbook_entry_count, - 'entries' => $entries, - 'parser' => $parser, - ]); - } -} diff --git a/app/Http/Controllers/AdminImportController.php b/app/Http/Controllers/AdminImportController.php deleted file mode 100644 index dc32cec..0000000 --- a/app/Http/Controllers/AdminImportController.php +++ /dev/null @@ -1,69 +0,0 @@ -validate([ - 'data_file' => 'required|mimes:json', - ]); - - $file = $request->file('data_file'); - $jsonContent = file_get_contents($file->getRealPath()); - $data = json_decode($jsonContent, true); - $tables = []; - foreach($data as $item) { - if ($item['type'] !== "table") continue; - $tables[$item['name']] = [ - 'data' => $item['data'], - 'count' => count($item['data']) - ]; - - if ($item['name'] === "guestbook__entries") { - GuestbookEntry::importGuestbookEntry($item['data']); - } - $this->import($item['data'], $item['name']); - } - return view('admin.import-success', ['tables' => $tables]); - } - - /** - * Imports the given data to the specified table - * - * @param array $data The data to import - * @param string $table_name The name of the table to import to - * @return void - * @throws Exception Invalid table specified, to be replaced with custom exception - */ - public function import(array $data, string $table_name): void { - switch ($table_name) { - case 'guestbook__entries': - GuestbookEntry::importGuestbookEntry($data); - break; - case 'bookmark__categories' : - BookmarkCategory::importBookmarkCategory($data); - break; - case 'bookmark__sites': - BookmarkSite::importBookmark($data); - break; - case 'guestbook__bans': - break; - default: - // TODO: Replace with custom exception - throw new Exception("Invalid table specified ($table_name)"); - } - } -} diff --git a/resources/views/admin/bookmarks.blade.php b/resources/views/admin/bookmarks.blade.php deleted file mode 100644 index f06539c..0000000 --- a/resources/views/admin/bookmarks.blade.php +++ /dev/null @@ -1,28 +0,0 @@ - - Admin | Bookmarks - @foreach($categories as $category) -
-

{{ $category->name }}

- - - - - - - - - - @foreach($category->sites as $site) - - - - - - - - - @endforeach -
IDNameDescriptionURLPriority
{{ $site->id }}{{ $site->name }}{{ $site->description }}{{ $site->url }}{{ $site->priority }}
-
- @endforeach -
diff --git a/resources/views/admin/guestbook.blade.php b/resources/views/admin/guestbook.blade.php deleted file mode 100644 index 1f5dab3..0000000 --- a/resources/views/admin/guestbook.blade.php +++ /dev/null @@ -1,32 +0,0 @@ - - Admin | Guestbook -
-

Statistics

-
- Unique IP addresses: {{ $guestbook_unique_addr }}
- Entries: {{ $guestbook_entry_count }} -
-
-
-

Entries

-
- - - - - - - - - @foreach ($entries as $entry) - - - - - - - - @endforeach -
IDNameIP AddressMessage
{{ $entry->id }}{{ $entry->name }}{{ $entry->ip }}{{ $entry->message }}
-
-
diff --git a/resources/views/admin/import-success.blade.php b/resources/views/admin/import-success.blade.php deleted file mode 100644 index f6d5eb3..0000000 --- a/resources/views/admin/import-success.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - - Admin | Import -
-

Imported data

-
-
    - @foreach($tables as $name => $data) -
  • {{ ucwords(str_replace('__', ' ', $name)) }}: {{ $data['count'] }} record(s)
  • - @endforeach -
-
-
diff --git a/resources/views/admin/import.blade.php b/resources/views/admin/import.blade.php deleted file mode 100644 index e663724..0000000 --- a/resources/views/admin/import.blade.php +++ /dev/null @@ -1,18 +0,0 @@ - - Admin | Import -
- @csrf - -
-

What to import:

- -
- -
- -
- -
- -
-