From b6fb43cba1263738dea57b76b871ee71a0ffff72 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Jun 2026 19:03:39 +0200 Subject: [PATCH] Fix remaining issues: pagination, throttle, i18n, config defaults, indexes - Add pagination to ShopController (50 per page) - Add throttle:3,10 to radio application store route - Replace mixed Dutch/English labels in RadioWizardController (English only) - Replace Dutch error messages in RadioController and RadioSetupController - Add config('habbo.defaults.avatar_look') for SocialAuthController - Remove hardcoded default stream URL from RadioSetupController - Add database indexes for radio_listener_points.earned_at and bans.ip --- .../Admin/RadioSetupController.php | 6 +-- .../Admin/RadioWizardController.php | 46 +++++++++---------- .../Controllers/Auth/SocialAuthController.php | 2 +- .../Controllers/Community/RadioController.php | 12 ++--- app/Http/Controllers/Shop/ShopController.php | 2 +- config/habbo.php | 4 ++ ..._08_000002_add_indexes_for_performance.php | 30 ++++++++++++ routes/community.php | 2 +- 8 files changed, 69 insertions(+), 35 deletions(-) create mode 100644 database/migrations/2026_06_08_000002_add_indexes_for_performance.php diff --git a/app/Http/Controllers/Admin/RadioSetupController.php b/app/Http/Controllers/Admin/RadioSetupController.php index 46f87e0..2237e1b 100755 --- a/app/Http/Controllers/Admin/RadioSetupController.php +++ b/app/Http/Controllers/Admin/RadioSetupController.php @@ -25,7 +25,7 @@ class RadioSetupController extends Controller $settings = [ // Basic Radio Settings 'radio_enabled' => '1', - 'radio_stream_url' => 'https://stream.radioking.com/radio/83232/radio.mp3', + 'radio_stream_url' => '', 'radio_style' => 'dark', 'radio_auto_play' => '0', @@ -112,10 +112,10 @@ class RadioSetupController extends Controller Artisan::call('cache:clear'); return redirect()->route('admin.radio.setup') - ->with('success', 'Radio instellingen zijn gereset.'); + ->with('success', 'Radio settings have been reset.'); } catch (\Exception $e) { return redirect()->route('admin.radio.setup') - ->with('error', 'Fout bij resetten: ' . $e->getMessage()); + ->with('error', 'Error during reset: ' . $e->getMessage()); } } diff --git a/app/Http/Controllers/Admin/RadioWizardController.php b/app/Http/Controllers/Admin/RadioWizardController.php index af26723..ec56f3d 100755 --- a/app/Http/Controllers/Admin/RadioWizardController.php +++ b/app/Http/Controllers/Admin/RadioWizardController.php @@ -68,7 +68,7 @@ class RadioWizardController extends Controller 'shoutcast' => 'SHOUTcast', 'icecast' => 'Icecast', 'azurecast' => 'AzureCast', - 'other' => 'Anders', + 'other' => 'Other', ]; return view('admin.radio.wizard.step-2', [ @@ -99,7 +99,7 @@ class RadioWizardController extends Controller $validated = $request->validate($rules); session()->put(self::SESSION_KEY . '.stream_url', $validated['stream_url']); - session()->put(self::SESSION_KEY . '.stream_name', $validated['stream_name'] ?? 'Mijn Radio'); + session()->put(self::SESSION_KEY . '.stream_name', $validated['stream_name'] ?? 'My Radio'); if ($platform === 'azurecast') { session()->put(self::SESSION_KEY . '.azurecast_base_url', $validated['azurecast_base_url'] ?? ''); @@ -208,7 +208,7 @@ class RadioWizardController extends Controller 'shoutcast' => 'SHOUTcast', 'icecast' => 'Icecast', 'azurecast' => 'AzureCast', - 'other' => 'Anders', + 'other' => 'Other', ]; $testResults = null; @@ -240,7 +240,7 @@ class RadioWizardController extends Controller if (! $data || empty($data['stream_url'])) { return response()->json([ 'success' => false, - 'error' => 'Geen stream URL gevonden. Start de wizard opnieuw.', + 'error' => 'No stream URL found. Please restart the wizard.', ]); } @@ -262,7 +262,7 @@ class RadioWizardController extends Controller if (! $data) { return redirect()->route('admin.radio.wizard') - ->with('error', 'Geen wizard data gevonden. Start opnieuw.'); + ->with('error', 'No wizard data found. Please start over.'); } try { @@ -275,10 +275,10 @@ class RadioWizardController extends Controller session()->forget(self::SESSION_KEY); return redirect()->route('admin.radio.setup') - ->with('success', 'Radio systeem is succesvol geïnstalleerd en geconfigureerd!'); + ->with('success', 'Radio system has been successfully installed and configured!'); } catch (\Exception $e) { return redirect()->route('admin.radio.wizard.step', ['step' => 5]) - ->with('error', 'Fout tijdens opslaan: ' . $e->getMessage()); + ->with('error', 'Error while saving: ' . $e->getMessage()); } } @@ -289,7 +289,7 @@ class RadioWizardController extends Controller $settings = [ 'radio_enabled' => '1', 'radio_stream_url' => $data['stream_url'] ?? '', - 'radio_stream_name' => $data['stream_name'] ?? 'Mijn Radio', + 'radio_stream_name' => $data['stream_name'] ?? 'My Radio', 'radio_style' => 'dark', 'radio_auto_play' => '0', 'radio_stream_platform' => $platform, @@ -356,12 +356,12 @@ class RadioWizardController extends Controller { $list = []; $list['Stream URL'] = $data['stream_url'] ?? '-'; - $list['Stream Naam'] = $data['stream_name'] ?? 'Mijn Radio'; + $list['Stream Name'] = $data['stream_name'] ?? 'My Radio'; $list['Platform'] = match ($data['platform'] ?? 'other') { 'shoutcast' => 'SHOUTcast', 'icecast' => 'Icecast', 'azurecast' => 'AzureCast', - default => 'Anders', + default => 'Other', }; if (! empty($data['now_playing_api'])) { @@ -372,19 +372,19 @@ class RadioWizardController extends Controller $list['Listeners API'] = $data['listeners_api']; } - $list['Nu Afspelen'] = ($data['enable_now_playing'] ?? true) ? 'Aan' : 'Uit'; - $list['Luisteraars'] = ($data['enable_listeners'] ?? true) ? 'Aan' : 'Uit'; - $list['Huidige DJ'] = ($data['enable_current_dj'] ?? true) ? 'Aan' : 'Uit'; - $list['Shouts'] = ($data['enable_shouts'] ?? true) ? 'Aan' : 'Uit'; - $list['DJ Aanmeldingen'] = ($data['enable_applications'] ?? true) ? 'Aan' : 'Uit'; - $list['Radio Widget'] = ($data['enable_widget'] ?? true) ? 'Aan' : 'Uit'; - $list['Widget Overal'] = ($data['enable_widget_globally'] ?? true) ? 'Ja' : 'Nee'; - $list['Widget Positie'] = $data['widget_position'] ?? 'bottom-right'; - $list['Punten Systeem'] = ($data['enable_points'] ?? true) ? 'Aan' : 'Uit'; - $list['Song Verzoeken'] = ($data['enable_requests'] ?? true) ? 'Aan' : 'Uit'; - $list['Contesten'] = ($data['enable_contests'] ?? true) ? 'Aan' : 'Uit'; - $list['Giveaways'] = ($data['enable_giveaways'] ?? false) ? 'Aan' : 'Uit'; - $list['Discord'] = ($data['enable_discord'] ?? false) ? 'Aan' : 'Uit'; + $list['Now Playing'] = ($data['enable_now_playing'] ?? true) ? 'On' : 'Off'; + $list['Listeners'] = ($data['enable_listeners'] ?? true) ? 'On' : 'Off'; + $list['Current DJ'] = ($data['enable_current_dj'] ?? true) ? 'On' : 'Off'; + $list['Shouts'] = ($data['enable_shouts'] ?? true) ? 'On' : 'Off'; + $list['DJ Applications'] = ($data['enable_applications'] ?? true) ? 'On' : 'Off'; + $list['Radio Widget'] = ($data['enable_widget'] ?? true) ? 'On' : 'Off'; + $list['Widget Everywhere'] = ($data['enable_widget_globally'] ?? true) ? 'Yes' : 'No'; + $list['Widget Position'] = $data['widget_position'] ?? 'bottom-right'; + $list['Points System'] = ($data['enable_points'] ?? true) ? 'On' : 'Off'; + $list['Song Requests'] = ($data['enable_requests'] ?? true) ? 'On' : 'Off'; + $list['Contests'] = ($data['enable_contests'] ?? true) ? 'On' : 'Off'; + $list['Giveaways'] = ($data['enable_giveaways'] ?? false) ? 'On' : 'Off'; + $list['Discord'] = ($data['enable_discord'] ?? false) ? 'On' : 'Off'; return $list; } diff --git a/app/Http/Controllers/Auth/SocialAuthController.php b/app/Http/Controllers/Auth/SocialAuthController.php index c89d9f9..9d57239 100755 --- a/app/Http/Controllers/Auth/SocialAuthController.php +++ b/app/Http/Controllers/Auth/SocialAuthController.php @@ -86,7 +86,7 @@ class SocialAuthController extends Controller 'account_created' => time(), 'last_login' => time(), 'motto' => 'New player', - 'look' => 'hr-100-61.hd-180-1.ch-210-66', + 'look' => config('habbo.defaults.avatar_look'), 'ip_register' => request()->ip(), 'ip_current' => request()->ip(), ]); diff --git a/app/Http/Controllers/Community/RadioController.php b/app/Http/Controllers/Community/RadioController.php index aa2a219..002d08a 100755 --- a/app/Http/Controllers/Community/RadioController.php +++ b/app/Http/Controllers/Community/RadioController.php @@ -268,7 +268,7 @@ class RadioController extends Controller if ($activeSession) { return response()->json([ - 'error' => 'Je hebt al een actieve sessie', + 'error' => 'You already have an active session', 'session_id' => $activeSession->id, ], 400); } @@ -280,7 +280,7 @@ class RadioController extends Controller ]); return response()->json([ - 'message' => 'Sessie gestart', + 'message' => 'Session started', 'session_id' => $session->id, ]); } @@ -292,13 +292,13 @@ class RadioController extends Controller $activeSession = RadioHistory::where('user_id', $userId)->whereNull('ended_at')->first(); if (! $activeSession) { - return response()->json(['error' => 'Geen actieve sessie gevonden'], 404); + return response()->json(['error' => 'No active session found'], 404); } $activeSession->endSession(); return response()->json([ - 'message' => 'Sessie beëindigd', + 'message' => 'Session ended', 'duration' => $activeSession->duration, ]); } @@ -306,7 +306,7 @@ class RadioController extends Controller public function getShouts(): JsonResponse { if (! $this->getSetting(RadioSettings::ShoutsEnabled)) { - return response()->json(['error' => 'Shouts zijn uitgeschakeld', 'shouts' => []], 403); + return response()->json(['error' => 'Shouts are disabled', 'shouts' => []], 403); } $shouts = Cache::remember('api_radio_shouts', 30, fn () => RadioShout::with('user:id,username') @@ -315,7 +315,7 @@ class RadioController extends Controller ->get() ->map(fn ($shout) => [ 'id' => $shout->id, - 'username' => $shout->user?->username ?? 'Anoniem', + 'username' => $shout->user?->username ?? 'Anonymous', 'message' => $shout->message, 'created_at' => $shout->created_at->diffForHumans(), ])); diff --git a/app/Http/Controllers/Shop/ShopController.php b/app/Http/Controllers/Shop/ShopController.php index a9cb283..10a9fc4 100755 --- a/app/Http/Controllers/Shop/ShopController.php +++ b/app/Http/Controllers/Shop/ShopController.php @@ -28,7 +28,7 @@ class ShopController extends Controller } return view('shop.shop', [ - 'articles' => $query->with(['rank:id,rank_name', 'features'])->get(), + 'articles' => $query->with(['rank:id,rank_name', 'features'])->paginate(50), 'categories' => WebsiteShopCategory::whereHas('articles')->get(), ]); } diff --git a/config/habbo.php b/config/habbo.php index 0361bd2..f8954a9 100755 --- a/config/habbo.php +++ b/config/habbo.php @@ -54,6 +54,10 @@ return [ 'external_override_texts' => env('EXTERNAL_OVERRIDE_TEXTS'), ], + 'defaults' => [ + 'avatar_look' => env('DEFAULT_AVATAR_LOOK', 'hr-100-61.hd-180-1.ch-210-66'), + ], + 'findretros' => [ 'enabled' => (bool) env('FINDRETROS_ENABLED', false), 'name' => env('FINDRETROS_NAME', 'Example'), diff --git a/database/migrations/2026_06_08_000002_add_indexes_for_performance.php b/database/migrations/2026_06_08_000002_add_indexes_for_performance.php new file mode 100644 index 0000000..8f8fc2f --- /dev/null +++ b/database/migrations/2026_06_08_000002_add_indexes_for_performance.php @@ -0,0 +1,30 @@ +index(['earned_at', 'user_id', 'points'], 'idx_listener_points_earned'); + }); + + Schema::table('bans', function (Blueprint $table) { + $table->index('ip', 'idx_bans_ip'); + }); + } + + public function down(): void + { + Schema::table('radio_listener_points', function (Blueprint $table) { + $table->dropIndex('idx_listener_points_earned'); + }); + + Schema::table('bans', function (Blueprint $table) { + $table->dropIndex('idx_bans_ip'); + }); + } +}; diff --git a/routes/community.php b/routes/community.php index cb94314..a55b529 100755 --- a/routes/community.php +++ b/routes/community.php @@ -37,7 +37,7 @@ Route::prefix('community')->group(function () { Route::prefix('radio')->group(function () { Route::get('/shouts', [RadioController::class, 'shouts'])->name('radio.shouts'); Route::get('/dj-aanmelden', [RadioController::class, 'apply'])->name('radio.apply'); - Route::post('/dj-aanmelden', [RadioController::class, 'storeApplication'])->name('radio.apply.store'); + Route::post('/dj-aanmelden', [RadioController::class, 'storeApplication'])->name('radio.apply.store')->middleware('throttle:3,10'); Route::post('/shouts', [RadioController::class, 'storeShout'])->name('radio.shouts.store'); Route::post('/session/start', [RadioController::class, 'startSession'])->name('radio.session.start'); Route::post('/session/end', [RadioController::class, 'endSession'])->name('radio.session.end');