diff options
author | Frankie B <git@diskfloppy.me> | 2024-07-11 22:23:46 +0100 |
---|---|---|
committer | Frankie B <git@diskfloppy.me> | 2024-07-11 22:23:46 +0100 |
commit | 069cf70f5be260e6fcf44d80a9befca01e4c5ed6 (patch) | |
tree | ecb1efc8146ed3799bd42a093288f3102dc11a47 /app/Http | |
parent | ccec714beed04d1585444c9321781b39db27f53d (diff) |
Remove admin pages
Diffstat (limited to 'app/Http')
-rw-r--r-- | app/Http/Controllers/AdminBookmarksController.php | 15 | ||||
-rw-r--r-- | app/Http/Controllers/AdminGuestbookController.php | 34 | ||||
-rw-r--r-- | app/Http/Controllers/AdminImportController.php | 69 |
3 files changed, 0 insertions, 118 deletions
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 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\BookmarkCategory; -use Illuminate\Support\Facades\DB; -use Illuminate\View\View; - -class AdminBookmarksController extends Controller -{ - public function show() : View { - $categories = BookmarkCategory::with('sites')->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 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\GuestbookEntry; -use Illuminate\Support\Facades\DB; -use Illuminate\View\View; -use UAParser\Parser; - -class AdminGuestbookController extends Controller -{ - function getGuestbookUniqueAddr(): int { - $uniqueIpsCount = DB::table('guestbook__entries')->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 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\BookmarkCategory; -use App\Models\BookmarkSite; -use App\Models\GuestbookEntry; -use Exception; -use Illuminate\Http\Request; -use Illuminate\View\View; - -class AdminImportController extends Controller -{ - public function show() : View { - return view('admin.import'); - } - - public function submit(Request $request) - { - $request->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)"); - } - } -} |