{{ __('emails.greeting', ['name' => $appeal->name]) }}
++ {{ $appeal->status === 'approved' ? + __('emails.body.APPROVED') : + __('emails.body.REJECTED') }} +
+{{ __('emails.regards') }}
+diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 56bfa48..be9727c 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -2,6 +2,8 @@ namespace App\Helpers; +use App\Models\Appeal\Appeal; +use App\Models\Report\Report; use Carbon\Carbon; use Carbon\CarbonInterval; use Illuminate\Support\Facades\Cache; @@ -37,4 +39,12 @@ public static function steamProfile($resource) { }); } } + + public static function appealCheck() { + return Appeal::where('status', 'pending')->count(); + } + + public static function reportCheck() { + return Report::count(); + } } diff --git a/app/Http/Controllers/Appeal/AppealController.php b/app/Http/Controllers/Appeal/AppealController.php new file mode 100644 index 0000000..070f4b3 --- /dev/null +++ b/app/Http/Controllers/Appeal/AppealController.php @@ -0,0 +1,74 @@ +validate([ + 'ban_type' => 'required|string', + 'steamid' => 'required_if:ban_type,Steam ID|nullable|string', + 'ip' => 'required_if:ban_type,IP|nullable|ip', + 'name' => 'required|string', + 'reason' => 'required|string', + 'email' => 'required|email', + ]); + if(SaBan::where('player_steamid', $validated['steamid']) + ->where('status', 'ACTIVE') + ->exists()) { + $data = $request->only(['ban_type', 'steamid', 'ip', 'name', 'reason', 'email']); + $data['status'] = 'PENDING'; + // Save the appeal + Appeal::create($data); + + return redirect()->route('appeals.create')->with('success', 'Appeal submitted successfully.'); + } + else { + return redirect()->route('appeals.create')->with('error', 'No active bans exists for this Steam ID or IP'); + } + } + + public function list() + { + $appeals = Appeal::orderBy('created_at', 'desc')->get(); + return view('appeals.list', compact('appeals')); + } + + public function view($id) + { + $appeal = Appeal::findOrFail($id); + return view('appeals.show', compact('appeal')); + } + + public function updateStatus(Request $request, $id) + { + $request->validate([ + 'status' => 'required|in:APPROVED,REJECTED', + ]); + + $appeal = Appeal::findOrFail($id); + $appeal->status = $request->input('status'); + $appeal->save(); + Mail::to($appeal->email)->send(new AppealApproved($appeal)); + + return redirect()->route('appeals.list', $appeal->id)->with('success', 'Appeal status updated successfully.'); + } +} diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index d048e8f..234045e 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -10,6 +10,7 @@ use App\Models\SaMute; use App\Models\SaServer; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Http; class DashboardController extends Controller @@ -21,10 +22,18 @@ public function check() { public function home() { $updates = []; + $activeBans = null; + $activeMutes = null; $totalBans = SaBan::count(); $totalServers = SaServer::count(); $totalMutes = SaMute::count(); $totalAdmins = SaAdmin::distinct('player_steamid')->count(); + $totalActiveBans = SaBan::where('status', 'ACTIVE')->count(); + $totalActiveMutes = SaMute::where('status', 'ACTIVE')->count(); + if(auth()->check()){ + $activeBans = SaBan::where('player_steamid', Auth::user()->steam_id)->where('status', 'ACTIVE')->count(); + $activeMutes = SaMute::where('player_steamid', Auth::user()->steam_id)->where('status', 'ACTIVE')->count(); + } if(PermissionsHelper::isSuperAdmin()) { $updates = $this->checkUpdates(); } @@ -39,7 +48,11 @@ public function home() 'totalMutes', 'totalAdmins', 'updates', - 'topPlayersData' + 'topPlayersData', + 'activeBans', + 'activeMutes', + 'totalActiveBans', + 'totalActiveMutes' ) ); } diff --git a/app/Http/Controllers/Report/ReportController.php b/app/Http/Controllers/Report/ReportController.php new file mode 100644 index 0000000..8b86f06 --- /dev/null +++ b/app/Http/Controllers/Report/ReportController.php @@ -0,0 +1,57 @@ +validate([ + 'ban_type' => 'required|string', + 'steamid' => 'required_if:ban_type,Steam ID|nullable|string', + 'ip' => 'required_if:ban_type,IP|nullable|ip', + 'nickname' => 'required|string', + 'comments' => 'required|string', + 'name' => 'required|string', + 'email' => 'required|email', + 'server_id' => 'required|integer', + 'media_link' => 'nullable|url', + ]); + + $data = $request->only(['ban_type', 'steamid', 'ip', 'nickname', 'comments', 'name', 'email', 'server_id', 'media_link']); + Report::create($data); + + return redirect()->route('reports.create')->with('success', 'Report submitted successfully.'); + } + + public function list() + { + $reports = Report::orderBy('created_at', 'desc')->get(); + return view('reports.list', compact('reports')); + } + + public function show($id) + { + $report = Report::findOrFail($id); + return view('reports.show', compact('report')); + } + + public function destroy($id) + { + $report = Report::findOrFail($id); + $report->delete(); + + return redirect()->route('reports.list')->with('success', 'Report deleted successfully.'); + } +} diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index 0553934..8c4d305 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -5,11 +5,13 @@ use App\Helpers\PermissionsHelper; use App\Models\SaAdmin; use App\Models\SaAdminsFlags; +use App\Models\SaBan; use App\Models\SaServer; use App\Models\ServerVisibilitySetting; use App\Services\RconService; use Carbon\Carbon; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Http; @@ -56,7 +58,10 @@ public function getAllServerInfo(RconService $rcon) $serverVisibilitySettings = ServerVisibilitySetting::pluck('is_visible', 'server_id')->toArray(); $formattedServers = []; - + $loggedInPlayerSteam = null; + if(auth()->check()){ + $loggedInPlayerSteam = Auth::user()?->steam_id; + } foreach ($servers as $server) { if (isset($serverVisibilitySettings[$server->id]) && !$serverVisibilitySettings[$server->id]) { continue; // Skip hidden servers @@ -67,9 +72,18 @@ public function getAllServerInfo(RconService $rcon) try { $serverDetails = $this->getServerDetails($serverIp, $serverPort); if ($serverDetails) { + $banned = ''; + if($loggedInPlayerSteam){ + if(SaBan::where('player_steamid', $loggedInPlayerSteam) + ->where('server_id', $server->id) + ->where('status', 'ACTIVE') + ->exists()) { + $banned = ' Banned'; + } + } $formattedServer = [ 'id' => $server->id, - 'name' => $server->hostname, + 'name' => $server->hostname.$banned, 'ip' => $serverIp, 'port' => $serverPort, 'players' => $serverDetails['players'] . "/" . $serverDetails['max_players'], diff --git a/app/Mail/AppealApproved.php b/app/Mail/AppealApproved.php new file mode 100644 index 0000000..ce5d4e0 --- /dev/null +++ b/app/Mail/AppealApproved.php @@ -0,0 +1,29 @@ +appeal = $appeal; + } + + public function build() + { + return $this->subject('Your Ban Appeal has been'." ".ucfirst($this->appeal->status)) + ->view('appeals.email.appeal_status') + ->with([ + 'appeal' => $this->appeal, + ]); + } +} diff --git a/app/Models/Appeal/Appeal.php b/app/Models/Appeal/Appeal.php new file mode 100644 index 0000000..f1b5fe4 --- /dev/null +++ b/app/Models/Appeal/Appeal.php @@ -0,0 +1,18 @@ +belongsTo(\App\Models\SaServer::class); + } +} diff --git a/config/app.php b/config/app.php index d42269a..e9bc018 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ | Application Version |-------------------------------------------------------------------------- */ - 'version' => '3.4', + 'version' => '3.5', /* |-------------------------------------------------------------------------- | Application Name diff --git a/database/migrations/2024_06_15_083222_2024_06_14_000000_create_appeals_table.php.php b/database/migrations/2024_06_15_083222_2024_06_14_000000_create_appeals_table.php.php new file mode 100644 index 0000000..0da77a8 --- /dev/null +++ b/database/migrations/2024_06_15_083222_2024_06_14_000000_create_appeals_table.php.php @@ -0,0 +1,26 @@ +id(); + $table->string('ban_type'); + $table->string('steamid'); + $table->string('name'); + $table->text('reason'); + $table->string('email'); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('appeals'); + } +} + diff --git a/database/migrations/2024_06_15_142432_2024_06_14_000000_create_reports_table.php.php b/database/migrations/2024_06_15_142432_2024_06_14_000000_create_reports_table.php.php new file mode 100644 index 0000000..9dfcae3 --- /dev/null +++ b/database/migrations/2024_06_15_142432_2024_06_14_000000_create_reports_table.php.php @@ -0,0 +1,33 @@ +id(); + $table->string('ban_type'); + $table->string('steamid')->nullable(); + $table->ipAddress('ip')->nullable(); + $table->string('nickname'); + $table->text('comments'); + $table->string('name'); + $table->string('email'); + $table->unsignedBigInteger('server_id'); + $table->string('media_link')->nullable(); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('reports'); + } +}; diff --git a/lang/en.json b/lang/en.json index c2ae665..bfa89ae 100644 --- a/lang/en.json +++ b/lang/en.json @@ -193,5 +193,13 @@ "skins.skinPreview": "Skin Preview", "skins.wellWorn": "Well-Worn", "Sync New Servers": "Sync New Servers", - "Visibility": "Visibility" -} \ No newline at end of file + "Visibility": "Visibility", + "emails.subject.APPROVED": "Your Ban Appeal has been Approved ", + "emails.subject.REJECTED": "Your Ban Appeal has been Denied ", + "emails.greeting": "Dear :name,", + "emails.body.APPROVED": "Your ban appeal has been approved. You can now rejoin the server. If you have any questions, feel free to contact us.", + "emails.body.REJECTED": "Your ban appeal has been denied. If you have any questions or need further information, feel free to contact us.", + "emails.regards": "Best regards, Server Administration Team", + "emails.footer.copyright": "© :year :app_name. All rights reserved.", + "emails.footer.github": "GitHub Repository" +} diff --git a/resources/scss/dark/assets/main.scss b/resources/scss/dark/assets/main.scss index 57168a5..e7240bb 100644 --- a/resources/scss/dark/assets/main.scss +++ b/resources/scss/dark/assets/main.scss @@ -4886,3 +4886,16 @@ body.layout-dark .table tbody tr td { #sidebar ul.menu-categories li.menu.active>.dropdown-toggle { background-color: #4361ee !important; } +.dash-active-stat { + position: absolute; + margin-top: -24px; + left: 0px; + width: 100%; +} +body.layout-dark blockquote.blockquote{ + color:white !important; +} +.form-control.is-invalid { + background-position: right calc(.375em + .1875rem) center !important; + background-repeat: no-repeat !important; +} diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 280d49e..ea9911d 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -27,6 +27,20 @@ @endif + @if($activeBans) +
+ @endif + @if($activeMutes) + + @endif @if(PermissionsHelper::isSuperAdmin())+ If you are indeed on our ban list and you feel it is unjust or any other circumstances, + please fill out the appeal format below. ++ +
{{ __('emails.greeting', ['name' => $appeal->name]) }}
++ {{ $appeal->status === 'approved' ? + __('emails.body.APPROVED') : + __('emails.body.REJECTED') }} +
+{{ __('emails.regards') }}
+{{ __('ID') }} | +{{ __('Ban Type') }} | +{{ __('SteamID/IP') }} | +{{ __('Name') }} | +{{ __('Reason') }} | +{{ __('Email') }} | +{{ __('Status') }} | +{{ __('Created At') }} | +{{ __('Actions') }} | +
---|---|---|---|---|---|---|---|---|
{{ $appeal->id }} | +{{ $appeal->ban_type }} | +{{ $appeal->ban_type == 'Steam ID' ? $appeal->steamid : $appeal->ip }} | +{{ $appeal->name }} | +{{ $appeal->reason }} | +{{ $appeal->email }} | ++ + {{ $appeal->status }} + + | +{{ $appeal->created_at->format('Y-m-d H:i:s') }} | ++ {{ __('View') }} + | +
{{ __('Ban Type') }}: {{ $appeal->ban_type }}
+{{ __('Identifier') }}: {{ $appeal->ban_type === 'IP' ? $appeal->ip : $appeal->steamid }}
+{{ __('Name') }}: {{ $appeal->name }}
+{{ __('Reason') }}: {{ $appeal->reason }}
+{{ __('Email') }}: {{ $appeal->email }}
+{{ __('Status') }}: {{ $appeal->status }}
+{{ __('Created At') }}: {{ $appeal->created_at }}
+ + +