diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 19209d8..026c6c5 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -25,7 +25,7 @@ jobs:
node-version: 17
- name: Install Composer dependencies
- run: composer install --prefer-dist --no-interaction --no-suggest
+ run: composer install --prefer-dist --no-interaction --no-suggest --no-dev
- name: Install NPM dependencies
run: npm install
diff --git a/app/Helpers/PermissionHelper.php b/app/Helpers/PermissionHelper.php
index 3e87934..16ec858 100755
--- a/app/Helpers/PermissionHelper.php
+++ b/app/Helpers/PermissionHelper.php
@@ -2,98 +2,141 @@
namespace App\Helpers;
+use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
class PermissionsHelper
{
- public static function isAdmin()
+
+ public static function isSuperAdmin()
{
// Get the authenticated user
$user = Auth::user();
// Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->exists()) {
+ if ($user && $user->permissions()->where('flag' ,'@css/root')->exists()) {
return true;
}
return false;
}
- public static function isSuperAdmin()
+ public static function hasUnBanPermission(int $serverId=null)
{
// Get the authenticated user
+ $allowed = false;
$user = Auth::user();
-
- // Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->where('flags' ,'@css/root')->exists()) {
- return true;
+ // Admin expired on all servers
+ if (!self::validateExpiryOnAllServers($user) && !$serverId) {
+ $allowed = false;
+ } elseif ($serverId && self::hasValidPermission($user, $serverId, '@css/unban')) {
+ // has permission on the server
+ $allowed = true;
+ } elseif ($user && !$serverId && $user->permissions()->whereIn('flag', ['@css/chat', '@css/unban'])->exists()) {
+ // Check perms exists for atleast one of the server - For UI Actions
+ $allowed = true;
}
- return false;
+ return $allowed;
}
- public static function hasUnBanPermission()
+ public static function hasUnMutePermission(int $serverId=null)
{
// Get the authenticated user
+ $allowed = false;
$user = Auth::user();
-
- // Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->whereIn('flags', ['@css/unban','@css/root'])->exists()) {
- return true;
+ // Admin expired on all servers
+ if (!self::validateExpiryOnAllServers($user) && !$serverId) {
+ $allowed = false;
+ } elseif ($serverId && self::hasValidPermission($user, $serverId, '@css/chat')) {
+ // has permission on the server
+ $allowed = true;
+ } elseif ($user && !$serverId && $user->permissions()->whereIn('flag', ['@css/chat', '@css/root'])->exists()) {
+ // Check perms exists for atleast one of the server - For UI Actions
+ $allowed = true;
}
- return false;
+ return $allowed;
}
- public static function hasUnMutePermission()
+ public static function hasBanPermission(int $serverId=null)
{
// Get the authenticated user
+ $allowed = false;
$user = Auth::user();
-
- // Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->whereIn('flags', ['@css/chat','@css/root'])->exists()) {
- return true;
+ // Admin expired on all servers
+ if (!self::validateExpiryOnAllServers($user) && !$serverId) {
+ $allowed = false;
+ } elseif ($serverId && self::hasValidPermission($user, $serverId, '@css/ban')) {
+ // has permission on the server
+ $allowed = true;
+ } elseif ($user && !$serverId && $user->permissions()->whereIn('flag', ['@css/ban', '@css/root'])->exists()) {
+ // Check perms exists for atleast one of the server - For UI Actions
+ $allowed = true;
}
- return false;
+ return $allowed;
}
- public static function hasBanPermission()
+ public static function hasMutePermission(int $serverId=null)
{
// Get the authenticated user
+ $allowed = false;
$user = Auth::user();
-
- // Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->whereIn('flags', ['@css/root', '@css/ban'])->exists()) {
- return true;
+ // Admin expired on all servers
+ if (!self::validateExpiryOnAllServers($user) && !$serverId) {
+ $allowed = false;
+ } elseif ($serverId && self::hasValidPermission($user, $serverId, '@css/chat')) {
+ // has permission on the server
+ $allowed = true;
+ } elseif ($user && !$serverId && $user->permissions()->whereIn('flag', ['@css/chat', '@css/root'])->exists()) {
+ // Check perms exists for atleast one of the server - For UI Actions
+ $allowed = true;
}
- return false;
+ return $allowed;
}
- public static function hasMutePermission()
+ public static function hasKickPermission(int $serverId=null)
{
// Get the authenticated user
+ $allowed = false;
$user = Auth::user();
-
- // Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->whereIn('flags', ['@css/root', '@css/chat'])->exists()) {
- return true;
+ // Admin expired on all servers
+ if (!self::validateExpiryOnAllServers($user) && !$serverId) {
+ $allowed = false;
+ } elseif ($serverId && self::hasValidPermission($user, $serverId, '@css/kick')) {
+ // has permission on the server
+ $allowed = true;
+ } elseif ($user && !$serverId && $user->permissions()->whereIn('flag', ['@css/kick', '@css/root'])->exists()) {
+ // Check perms exists for atleast one of the server - For UI Actions
+ $allowed = true;
}
- return false;
+ return $allowed;
}
- public static function hasKickPermission()
+ private static function validateExpiryOnAllServers(?\Illuminate\Contracts\Auth\Authenticatable $user)
{
- // Get the authenticated user
- $user = Auth::user();
-
- // Check if the user has the specified permission
- if ($user && $user->permissions()->where('player_steamid', $user->steam_id)->whereIn('flags', ['@css/root', '@css/kick'])->exists()) {
- return true;
- }
+ return $user->servers()
+ ->where(function ($query) {
+ $query->where('ends', '>=', Carbon::now()->toDateTimeString())
+ ->orWhereNull('ends');
+ })
+ ->exists();
+ }
- return false;
+ private static function hasValidPermission(\Illuminate\Contracts\Auth\Authenticatable $user, int $serverId, string $flag)
+ {
+ return $user->servers()
+ ->where('server_id', $serverId)
+ ->where(function ($query) {
+ $query->where('ends', '>=', Carbon::now()->toDateTimeString())
+ ->orWhereNull('ends');
+ })
+ ->first()
+ ?->adminFlags()
+ ->whereIn('flag', [$flag, '@css/root'])
+ ->exists();
}
}
diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
index 7491830..46f826d 100755
--- a/app/Http/Controllers/AdminController.php
+++ b/app/Http/Controllers/AdminController.php
@@ -7,6 +7,7 @@
use App\Http\Requests\StoreAdminRequest;
use App\Models\Permission;
use App\Models\SaAdmin;
+use App\Models\SaAdminsFlags;
use App\Models\SaServer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -34,20 +35,26 @@ public function store(StoreAdminRequest $request)
foreach ($validatedData['server_ids'] as $server_id) {
foreach ($validatedData['permissions'] as $permissionId) {
$existingAdmin = SaAdmin::where('player_steamid', $validatedData['steam_id'])
- ->where('flags', $permissionId)
->where('server_id', $server_id)
+ ->first()
+ ?->adminFlags()
+ ->where('flag', $permissionId)
->exists();
if (!$existingAdmin) {
$permission = Permission::find($permissionId);
$admin = new SaAdmin();
$admin->player_steamid = $validatedData['steam_id'];
$admin->player_name = $validatedData['player_name'];
- $admin->flags = $permission->permission;
$admin->immunity = $validatedData['immunity'];
$admin->server_id = $server_id;
$admin->ends = isset($validatedData['ends']) ? CommonHelper::formatDate($validatedData['ends']): null;
$admin->created = now();
$admin->save();
+
+ $adminFlag = new SaAdminsFlags();
+ $adminFlag->admin_id= $admin->id;
+ $adminFlag->flag = $permission->permission;
+ $adminFlag->save();
$adminAddedToServerCount[$server_id] = $server_id;
}
}
@@ -82,13 +89,14 @@ public function getAdminsList(Request $request)
'player_steamid',
'player_name',
'sa_admins.id',
- DB::raw('GROUP_CONCAT(flags SEPARATOR ", ") as flags'),
- DB::raw('GROUP_CONCAT(DISTINCT CONCAT(sa_servers.id, ") ", sa_servers.hostname) SEPARATOR ", ") as hostnames'),
+ DB::raw('GROUP_CONCAT(distinct sa_admins_flags.flag SEPARATOR ", ") as flags'),
+ DB::raw('GROUP_CONCAT(DISTINCT CONCAT("[Hostname] ", sa_servers.hostname) SEPARATOR ", ") as hostnames'),
'created',
'ends',
'server_id'
)
->join('sa_servers', 'sa_admins.server_id', '=', 'sa_servers.id')
+ ->join('sa_admins_flags', 'sa_admins_flags.admin_id', '=', 'sa_admins.id')
->groupBy('player_steamid')
->orderBy($orderColumnName, $orderDir)
->offset($start)
@@ -121,7 +129,7 @@ public function getAdminsList(Request $request)
public function edit($player_steam, $server_id)
{
- $admin = SaAdmin::with('permissions')
+ $admin = SaAdmin::with('adminFlags.permissions')
->where('player_steamid', $player_steam)
->where('server_id', $server_id)
->get();
@@ -130,7 +138,7 @@ public function edit($player_steam, $server_id)
}
$permissions = Permission::all();
$servers = SaServer::all();
- $adminPermissions = $admin->pluck('permissions.permission')->toArray();
+ $adminPermissions = $admin->pluck('adminFlags.*.permissions.permission')->flatten()->toArray();
return view('admin.admins.edit', compact('admin', 'permissions', 'adminPermissions', 'servers'));
}
@@ -145,14 +153,14 @@ public function update(Request $request, $player_steam)
'immunity' => 'required'
]);
- $admin = SaAdmin::with('permissions')
+ $admin = SaAdmin::with('adminFlags.permissions')
->where('player_steamid',$player_steam)
->where('server_id', $validated['server_id'])
->get();
$submittedPermissions = $validated['permissions'];
// Fetch current permissions from the database
- $currentPermissions = $admin->pluck('permissions.permission')->toArray();
+ $currentPermissions = $admin->pluck('adminFlags.*.permissions.permission')->flatten()->toArray();
// Determine permissions to add and delete
$permissionsToAdd = array_diff($submittedPermissions, $currentPermissions);
@@ -163,18 +171,25 @@ public function update(Request $request, $player_steam)
$saAdmin = new SaAdmin();
$saAdmin->player_steamid = $admin->first()->player_steamid;
$saAdmin->player_name = $admin->first()->player_name;
- $saAdmin->flags = $permissionName;
$saAdmin->immunity = $validated['immunity'];
$saAdmin->server_id = $admin->first()->server_id;
$admin->ends = isset($validated['ends']) ? CommonHelper::formatDate($validated['ends']): null;
$saAdmin->created = now();
$saAdmin->save();
+
+ $adminFlag = new SaAdminsFlags();
+ $adminFlag->admin_id= $saAdmin->id;
+ $adminFlag->flag = $permissionName;
+ $adminFlag->save();
}
// Handle permissions to delete
- SaAdmin::whereIn('flags', $permissionsToDelete)
- ->where('player_steamid', $player_steam)
+ $adminData = SaAdmin::where('player_steamid', $player_steam)
->where('server_id', $validated['server_id'])
+ ->get('id');
+
+ SaAdminsFlags::whereIn('flag', $permissionsToDelete)
+ ->whereIn('admin_id', $adminData->pluck('id')->toArray())
->delete();
// update new expiry
@@ -202,7 +217,6 @@ public function delete(Request $request, $player_steam)
$serverIds = $validated['server_ids'];
SaAdmin::where('player_steamid', $player_steam)
->whereIn('server_id', $serverIds)
- ->where('flags', '<>', '@css/root')
->delete();
return redirect()->route('admins.list')->with('success', 'Admin deleted successfully.');
diff --git a/app/Http/Controllers/BansController.php b/app/Http/Controllers/BansController.php
index 6e6e439..5b4140b 100755
--- a/app/Http/Controllers/BansController.php
+++ b/app/Http/Controllers/BansController.php
@@ -52,9 +52,17 @@ public function getBansList(Request $request)
$totalBans = SaBan::count();
$formattedData = [];
-
+ $siteDir = env('VITE_SITE_DIR');
// Format each ban record
foreach ($bans as $ban) {
+ $editAction = '';
+ if(PermissionsHelper::hasBanPermission($ban->server_id)) {
+ $editAction = "";
+ }
+ $unbanAction = '';
+ if(PermissionsHelper::hasUnBanPermission($ban->server_id) && $ban->status == 'ACTIVE') {
+ $unbanAction = "";
+ }
$formattedData[] = [
"id" => $ban->id,
"player_steamid" => $ban->player_steamid,
@@ -66,7 +74,7 @@ public function getBansList(Request $request)
"ends" => $ban->ends,
"created" => $ban->created,
"server_id" => $ban->server->hostname,
- 'action' => $ban->status == 'ACTIVE' && PermissionsHelper::hasUnBanPermission() ? "" : "",
+ 'action' => $unbanAction." ".$editAction,
"status" => $ban->status == 'ACTIVE' ? "
Active
" : ($ban->status == 'UNBANNED' ? "Unbanned
" : "Expired
"),
];
}
@@ -176,4 +184,40 @@ public function store(Request $request)
return redirect()->route('list.bans')->with('success', 'Ban added successfully');
}
+
+ public function edit($id)
+ {
+ $ban = SaBan::findOrFail($id);
+ $servers = SaServer::all();
+ return view('admin.bans.edit', ['ban' => $ban, 'servers' => $servers]);
+ }
+
+ public function update(Request $request, $id)
+ {
+ $validatedData = $request->validate([
+ 'player_steam_id' => 'required|numeric|digits:17',
+ 'reason' => 'required',
+ 'duration' => 'required_without:permanent'
+ ]);
+
+ try {
+ $ban = SaBan::findOrFail($id);
+ $ban->player_steamid = $validatedData['player_steam_id'];
+ $ban->reason = $validatedData['reason'];
+ $minutesDifference = 0;
+ $ban->duration = $minutesDifference;
+ if(!$request->has('permanent')) {
+ $carbonTimestamp = Carbon::parse($validatedData['duration']);
+ $minutesDifference = $carbonTimestamp->diffInMinutes(Carbon::now());
+ $ban->duration = $minutesDifference;
+ $ban->ends = CommonHelper::formatDate(Carbon::parse($validatedData['duration']));
+ }
+ $ban->status = 'ACTIVE';
+ $ban->save();
+ return redirect()->route('list.bans')->with('success', 'Ban updated successfully');
+ } catch(\Exception $e) {
+ Log::error('ban.update.error: ' . $e->getMessage());
+ return Redirect::back()->withErrors(['msg' => 'There was an error while updating the ban.']);
+ }
+ }
}
diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php
index 68ec836..642044e 100755
--- a/app/Http/Controllers/DashboardController.php
+++ b/app/Http/Controllers/DashboardController.php
@@ -32,12 +32,18 @@ public function home()
public function getMutes()
{
$recentMutes = SaMute::orderBy('created', 'desc')->take(5)->get();
+ foreach($recentMutes as $mute){
+ $mute->ends = $mute->duration == 0 ? "Permanent
" : $mute->ends;
+ }
return response()->json($recentMutes);
}
public function getBans()
{
$recentBans = SaBan::orderBy('created', 'desc')->take(5)->get();
+ foreach($recentBans as $ban){
+ $ban->ends = $ban->duration == 0 ? "Permanent
" : $ban->ends;
+ }
return response()->json($recentBans);
}
diff --git a/app/Http/Controllers/LogViewerController.php b/app/Http/Controllers/LogViewerController.php
new file mode 100644
index 0000000..48d7142
--- /dev/null
+++ b/app/Http/Controllers/LogViewerController.php
@@ -0,0 +1,34 @@
+extractLogMessage($line);
+ }
+ }
+
+ return view('logs', ['logContent' => $logContent]);
+ }
+
+ private function extractLogMessage($line)
+ {
+ // Enable Stack trace
+ if(env('APP_DEBUG') === true){
+ return $line;
+ }
+ if (strpos($line, '#') === 0) {
+ return null;
+ }
+ //Disable Stack Trace
+ return strstr($line, 'Stack trace:', true) ?: $line;
+ }
+}
diff --git a/app/Http/Controllers/MutesController.php b/app/Http/Controllers/MutesController.php
index 4b32c89..bcecdd2 100755
--- a/app/Http/Controllers/MutesController.php
+++ b/app/Http/Controllers/MutesController.php
@@ -52,9 +52,17 @@ public function getMutesList(Request $request)
$totalMutes = SaMute::count();
$formattedData = [];
-
+ $siteDir = env('VITE_SITE_DIR');
// Format each mute record
foreach ($mutes as $mute) {
+ $editAction = '';
+ if(PermissionsHelper::hasMutePermission($mute->server_id)) {
+ $editAction = "";
+ }
+ $unmuteAction = '';
+ if(PermissionsHelper::hasUnMutePermission($mute->server_id) && $mute->status == 'ACTIVE') {
+ $unmuteAction = "";
+ }
$formattedData[] = [
"id" => $mute->id,
"player_steamid" => $mute->player_steamid,
@@ -66,7 +74,7 @@ public function getMutesList(Request $request)
"created" => $mute->created,
"server_id" => $mute->server->hostname,
"status" => $mute->status == 'ACTIVE' ? "Active
" : ($mute->status == 'UNMUTED' ? "Unmuted
" : "Expired
"),
- 'action' => $mute->status == 'ACTIVE' && PermissionsHelper::hasUnMutePermission() ? "" : "",
+ 'action' => $unmuteAction." ".$editAction,
"duration" => $mute->duration == 0 && $mute->status != 'UNMUTED' ? "Permanent
" : CommonHelper::minutesToTime($mute->duration),
];
}
@@ -177,4 +185,40 @@ public function store(Request $request)
return redirect()->route('list.mutes')->with('success', 'Mute added successfully');
}
+
+ public function edit($id)
+ {
+ $mute = SaMute::findOrFail($id);
+ $servers = SaServer::all();
+ return view('admin.mutes.edit', ['mute' => $mute, 'servers' => $servers]);
+ }
+
+ public function update(Request $request, $id)
+ {
+ $validatedData = $request->validate([
+ 'player_steam_id' => 'required|numeric|digits:17',
+ 'reason' => 'required',
+ 'duration' => 'required_without:permanent'
+ ]);
+
+ try {
+ $mute = SaMute::findOrFail($id);
+ $mute->player_steamid = $validatedData['player_steam_id'];
+ $mute->reason = $validatedData['reason'];
+ $minutesDifference = 0;
+ $mute->duration = $minutesDifference;
+ if(!$request->has('permanent')) {
+ $carbonTimestamp = Carbon::parse($validatedData['duration']);
+ $minutesDifference = $carbonTimestamp->diffInMinutes(Carbon::now());
+ $mute->duration = $minutesDifference;
+ $mute->ends = CommonHelper::formatDate(Carbon::parse($validatedData['duration']));
+ }
+ $mute->status = 'ACTIVE';
+ $mute->save();
+ return redirect()->route('list.mutes')->with('success', 'Mute updated successfully');
+ } catch(\Exception $e) {
+ Log::error('mute.update.error: ' . $e->getMessage());
+ return Redirect::back()->withErrors(['msg' => 'There was an error while updating the mute.']);
+ }
+ }
}
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php
index d9600dd..06502ff 100755
--- a/app/Http/Controllers/ServerController.php
+++ b/app/Http/Controllers/ServerController.php
@@ -4,6 +4,7 @@
use App\Helpers\PermissionsHelper;
use App\Models\SaAdmin;
+use App\Models\SaAdminsFlags;
use App\Models\SaServer;
use App\Services\RconService;
use Carbon\Carbon;
@@ -26,6 +27,22 @@ public function getAllServerInfo(RconService $rcon)
foreach ($servers as $server) {
list($serverIp, $serverPort) = explode(":", $server->address);
+
+ if (!$this->isPortOpen($serverIp, $serverPort)) {
+ Log::error('rcon.servers.list Port Blocked! Unable to read data from port!');
+ $formattedServer = [
+ 'id' => $server->id,
+ 'name' => $server->hostname,
+ 'ip' => $serverIp,
+ 'port' => $serverPort,
+ 'players' => '0',
+ 'map' => 'Unable To Connect
',
+ 'connect_button' => 'Unable To Connect
'
+ ];
+ $formattedServers[] = $formattedServer;
+ continue;
+ }
+
// Fetch server information using the RconService
try {
$rcon->connect($serverIp, $serverPort);
@@ -40,7 +57,8 @@ public function getAllServerInfo(RconService $rcon)
'connect_button' => 'Connect',
];
$rcon->disconnect();
- } catch(\Exception) {
+ } catch (\Exception $e) {
+ Log::error('rcon.servers.list.error'. $e->getMessage());
$formattedServer = [
'id' => $server->id,
'name' => $server->hostname,
@@ -58,6 +76,16 @@ public function getAllServerInfo(RconService $rcon)
return response()->json($formattedServers);
}
+ private function isPortOpen($ip, $port, $timeout = 1) {
+ $fp = @fsockopen($ip, $port, $errno, $errstr, $timeout);
+ if ($fp) {
+ fclose($fp);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* @param Request $request
* @param $serverId
@@ -120,12 +148,16 @@ public function setup(Request $request)
$admin = new SaAdmin();
$admin->player_steamid = $request->input('STEAM_ID_64');
$admin->player_name = 'Admin';
- $admin->flags = '@css/root';
$admin->immunity = 1;
$admin->server_id = $server->id;
$admin->ends = Carbon::now()->addYears(5)->format(('Y-m-d'));
$admin->created = now();
$admin->save();
+
+ $adminFlag = new SaAdminsFlags();
+ $adminFlag->admin_id= $admin->id;
+ $adminFlag->flag = '@css/root';
+ $adminFlag->save();
}
return redirect()->route('home')->with('success', 'Environment variables updated successfully. Database connection established. Tables imported.');
} catch (\Exception $e) {
@@ -137,18 +169,19 @@ public function serverPlayerAction(Request $request) {
$requestType = $request->input('action');
$playerName = $request->input('name');
$serverId = $request->input('serverId');
+ $duration = '1440'; // 1 day
switch ($requestType){
case "ban":
if(PermissionsHelper::hasUnBanPermission())
- return $this-> executeCommand('css_ban '.$playerName, $serverId);
+ return $this-> executeCommand('css_ban '.$playerName.' 1440', $serverId);
break;
case "kick":
if(PermissionsHelper::hasKickPermission())
- return $this->executeCommand('css_kick '.$playerName, $serverId);
+ return $this->executeCommand('css_kick '.$playerName.' 1440', $serverId);
break;
case "mute":
if(PermissionsHelper::hasMutePermission())
- return $this->executeCommand('css_mute ' . $playerName, $serverId);
+ return $this->executeCommand('css_mute ' . $playerName.' 1440', $serverId);
break;
default: abort(403);
}
diff --git a/app/Models/SaAdmin.php b/app/Models/SaAdmin.php
index ddf2c36..17d8768 100755
--- a/app/Models/SaAdmin.php
+++ b/app/Models/SaAdmin.php
@@ -16,7 +16,7 @@ public function servers()
return $this->belongsTo(SaServer::class, 'server_id', 'id');
}
- public function permissions() {
- return $this->belongsTo(Permission::class, 'flags', 'permission');
+ public function adminFlags() {
+ return $this->hasMany(SaAdminsFlags::class, 'admin_id', 'id');
}
}
diff --git a/app/Models/SaAdminsFlags.php b/app/Models/SaAdminsFlags.php
new file mode 100644
index 0000000..1173e8a
--- /dev/null
+++ b/app/Models/SaAdminsFlags.php
@@ -0,0 +1,16 @@
+belongsTo(Permission::class, 'flag', 'permission');
+ }
+}
diff --git a/app/Models/User.php b/app/Models/User.php
index 43dae61..4b89d7b 100755
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -30,8 +30,19 @@ class User extends Authenticatable
protected $casts = [
'steam_id' => 'int'
];
-
public function permissions()
+ {
+ return $this->hasManyThrough(
+ SaAdminsFlags::class,
+ SaAdmin::class,
+ 'player_steamid',
+ 'admin_id',
+ 'steam_id',
+ 'id'
+ );
+ }
+
+ public function servers()
{
return $this->hasMany(SaAdmin::class, 'player_steamid', 'steam_id');
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 452e6b6..82a3f39 100755
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -19,6 +19,6 @@ public function register(): void
*/
public function boot(): void
{
- //
+ \Debugbar::disable();
}
}
diff --git a/body.md b/body.md
index b5bd9cf..b6f815e 100644
--- a/body.md
+++ b/body.md
@@ -1 +1,14 @@
-Release notes
+Release notes V 1.2.0
+## Important- This is major release for SimpleAdmin Support version 1.3.9
+
+## Update your simpleAdmin to latest version
+ if you do not want to update , you simple ignore this and continue using panel, but this panel update has new features.
+## Future olderversion support will be removed.
+# Update Log
+- Updated the panel to support latest version of cs2SimpleAdmin 1.3.9
+- Added edit/mute ban , you can now edit banned/unbanned players form listing to extend bans or re add ban
+- Added new link **/logs** to investigate errors (Can be used only by @css/root)
+- Improved server listing to detect if port is blocked (Now shows as unable to connect)
+- Added Servers specific permission checks for admins who have been granted only few servers with ban/mute to avoid access to other servers if doesnt exists.
+- Few listing improvements
+
diff --git a/composer.json b/composer.json
index 5cd92b8..3c6e7d6 100755
--- a/composer.json
+++ b/composer.json
@@ -15,6 +15,7 @@
"xpaw/php-source-query-class": "^2.1"
},
"require-dev": {
+ "barryvdh/laravel-debugbar": "^3.13",
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
diff --git a/composer.lock b/composer.lock
index 6f18e44..6c3a568 100755
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "3d44233c5c648583ec2aced044d9b58b",
+ "content-hash": "8d5237e6b06b06a082969f2dc5ce0fe5",
"packages": [
{
"name": "brick/math",
@@ -6011,6 +6011,90 @@
}
],
"packages-dev": [
+ {
+ "name": "barryvdh/laravel-debugbar",
+ "version": "v3.13.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/barryvdh/laravel-debugbar.git",
+ "reference": "00201bcd1eaf9b1d3debddcdc13c219e4835fb61"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/00201bcd1eaf9b1d3debddcdc13c219e4835fb61",
+ "reference": "00201bcd1eaf9b1d3debddcdc13c219e4835fb61",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/routing": "^9|^10|^11",
+ "illuminate/session": "^9|^10|^11",
+ "illuminate/support": "^9|^10|^11",
+ "maximebf/debugbar": "~1.22.0",
+ "php": "^8.0",
+ "symfony/finder": "^6|^7"
+ },
+ "require-dev": {
+ "mockery/mockery": "^1.3.3",
+ "orchestra/testbench-dusk": "^5|^6|^7|^8|^9",
+ "phpunit/phpunit": "^9.6|^10.5",
+ "squizlabs/php_codesniffer": "^3.5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.13-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Barryvdh\\Debugbar\\ServiceProvider"
+ ],
+ "aliases": {
+ "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
+ }
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/helpers.php"
+ ],
+ "psr-4": {
+ "Barryvdh\\Debugbar\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "barryvdh@gmail.com"
+ }
+ ],
+ "description": "PHP Debugbar integration for Laravel",
+ "keywords": [
+ "debug",
+ "debugbar",
+ "laravel",
+ "profiler",
+ "webprofiler"
+ ],
+ "support": {
+ "issues": "https://github.com/barryvdh/laravel-debugbar/issues",
+ "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.4"
+ },
+ "funding": [
+ {
+ "url": "https://fruitcake.nl",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/barryvdh",
+ "type": "github"
+ }
+ ],
+ "time": "2024-04-10T09:15:45+00:00"
+ },
{
"name": "fakerphp/faker",
"version": "v1.23.1",
@@ -6324,6 +6408,74 @@
},
"time": "2024-03-04T14:58:29+00:00"
},
+ {
+ "name": "maximebf/debugbar",
+ "version": "v1.22.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/maximebf/php-debugbar.git",
+ "reference": "7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96",
+ "reference": "7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2|^8",
+ "psr/log": "^1|^2|^3",
+ "symfony/var-dumper": "^4|^5|^6|^7"
+ },
+ "require-dev": {
+ "dbrekelmans/bdi": "^1",
+ "phpunit/phpunit": "^8|^9",
+ "symfony/panther": "^1|^2.1",
+ "twig/twig": "^1.38|^2.7|^3.0"
+ },
+ "suggest": {
+ "kriswallsmith/assetic": "The best way to manage assets",
+ "monolog/monolog": "Log using Monolog",
+ "predis/predis": "Redis storage"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.22-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "DebugBar\\": "src/DebugBar/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Maxime Bouroumeau-Fuseau",
+ "email": "maxime.bouroumeau@gmail.com",
+ "homepage": "http://maximebf.com"
+ },
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "barryvdh@gmail.com"
+ }
+ ],
+ "description": "Debug bar in the browser for php application",
+ "homepage": "https://github.com/maximebf/php-debugbar",
+ "keywords": [
+ "debug",
+ "debugbar"
+ ],
+ "support": {
+ "issues": "https://github.com/maximebf/php-debugbar/issues",
+ "source": "https://github.com/maximebf/php-debugbar/tree/v1.22.3"
+ },
+ "time": "2024-04-03T19:39:26+00:00"
+ },
{
"name": "mockery/mockery",
"version": "1.6.7",
diff --git a/config/app.php b/config/app.php
index f2b0971..8bb8bfa 100755
--- a/config/app.php
+++ b/config/app.php
@@ -11,7 +11,7 @@
|--------------------------------------------------------------------------
*/
'version' => '1.1.0',
- /*
+ /*pr
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
diff --git a/resources/js/bans/bans.ts b/resources/js/bans/bans.ts
index 9fb2ef8..8fed43b 100755
--- a/resources/js/bans/bans.ts
+++ b/resources/js/bans/bans.ts
@@ -45,7 +45,7 @@ function loadBans() {
},
{"data": "server_id"},
{"data": "status"},
- {"data": "action"},
+ {"data": "action", "width": "200px"},
{
"data": "duration", "render": function (data, type, row, meta) {
const progress = calculateProgress(row.created, row.ends);
diff --git a/resources/js/dashboard/servers.ts b/resources/js/dashboard/servers.ts
index 9d935dc..006385c 100755
--- a/resources/js/dashboard/servers.ts
+++ b/resources/js/dashboard/servers.ts
@@ -5,13 +5,16 @@ import {showLoader} from "../utility/utility";
import {hideLoader} from "../utility/utility";
// Make a GET request to fetch mutes data
+showLoader();
axios.get(serversListUrl)
.then(response => {
// Handle successful response
+ hideLoader();
appendTableData(constructTableRows(response.data), 'serverList');
})
.catch(error => {
// Handle error
+ hideLoader();
console.error('Error:', error);
});
@@ -91,8 +94,8 @@ function playerAction(playerName: string, action: string, serverId: string) {
},
success: function(response) {
hideLoader();
+ $("#"+playerName).remove();
toastr.success('Player '+action+' successful.');
- fetchPlayers(serverId);
},
error: function(xhr, status, error) {
hideLoader();
diff --git a/resources/js/mutes/mutes.ts b/resources/js/mutes/mutes.ts
index 4b7650a..bb2cf90 100755
--- a/resources/js/mutes/mutes.ts
+++ b/resources/js/mutes/mutes.ts
@@ -47,7 +47,7 @@ function loadMutes() {
},
{"data": "server_id"},
{"data": "status"},
- {"data": "action"},
+ {"data": "action", "width": "200px"},
{
"data": "duration", "render": function (data, type, row, meta) {
const progress = calculateProgress(row.created, row.ends);
diff --git a/resources/views/admin/bans/add.blade.php b/resources/views/admin/bans/add.blade.php
index bce92ca..ee93214 100755
--- a/resources/views/admin/bans/add.blade.php
+++ b/resources/views/admin/bans/add.blade.php
@@ -1,5 +1,7 @@
@extends('layouts.app')
@section('content')
+
+
@if (session('success'))
@endif
@@ -49,7 +51,9 @@
diff --git a/resources/views/admin/bans/edit.blade.php b/resources/views/admin/bans/edit.blade.php
new file mode 100644
index 0000000..6d6e14f
--- /dev/null
+++ b/resources/views/admin/bans/edit.blade.php
@@ -0,0 +1,71 @@
+@extends('layouts.app')
+
+@section('content')
+ @if (session('success'))
+
+ @endif
+ @if (session('error'))
+
+ @endif
+ @if ($errors->any())
+
+
+ @foreach ($errors->all() as $error)
+ - {{ $error }}
+ @endforeach
+
+
+ @endif
+
+
+@endsection
+@vite(['resources/js/bans/add.ts'])
diff --git a/resources/views/admin/mutes/add.blade.php b/resources/views/admin/mutes/add.blade.php
index d15167d..ae82a60 100755
--- a/resources/views/admin/mutes/add.blade.php
+++ b/resources/views/admin/mutes/add.blade.php
@@ -51,7 +51,9 @@
diff --git a/resources/views/admin/mutes/edit.blade.php b/resources/views/admin/mutes/edit.blade.php
new file mode 100644
index 0000000..3030072
--- /dev/null
+++ b/resources/views/admin/mutes/edit.blade.php
@@ -0,0 +1,71 @@
+@extends('layouts.app')
+
+@section('content')
+ @if (session('success'))
+
+ @endif
+ @if (session('error'))
+
+ @endif
+ @if ($errors->any())
+
+
+ @foreach ($errors->all() as $error)
+ - {{ $error }}
+ @endforeach
+
+
+ @endif
+
+
+@endsection
+@vite(['resources/js/mutes/add.ts'])
diff --git a/resources/views/admin/servers/players.blade.php b/resources/views/admin/servers/players.blade.php
index 560be0c..ac524e7 100755
--- a/resources/views/admin/servers/players.blade.php
+++ b/resources/views/admin/servers/players.blade.php
@@ -12,7 +12,7 @@
@foreach ($players as $player)
-
+
{{ $loop->iteration }} |
{{ $player['Name'] }} |
{{ $player['Frags'] }} |
diff --git a/resources/views/logs.blade.php b/resources/views/logs.blade.php
new file mode 100644
index 0000000..2bda055
--- /dev/null
+++ b/resources/views/logs.blade.php
@@ -0,0 +1,13 @@
+@extends('layouts.app')
+
+@section('content')
+ {{ $logContent }}
+@endsection
+
+
diff --git a/routes/web.php b/routes/web.php
index e18c5b7..af6a9ff 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -4,6 +4,7 @@
use App\Http\Controllers\BansController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\LoginController;
+use App\Http\Controllers\LogViewerController;
use App\Http\Controllers\MutesController;
use App\Http\Controllers\ServerController;
use Illuminate\Support\Facades\Auth;
@@ -54,10 +55,15 @@
Route::put('{player_steam_id}/unban', [BansController::class, 'unban'])->middleware('permission.unban');
Route::put('{player_steam_id}/unmute', [MutesController::class, 'unmute'])->middleware('permission.unmute');
Route::post('action', [ServerController::class, 'serverPlayerAction'])->name('player.action');
+ Route::put('ban/{id}', [BansController::class, 'update'])->name('ban.update')->middleware('permission.ban');
+ Route::put('mute/{id}', [MutesController::class, 'update'])->name('mute.update')->middleware('permission.mute');
+
});
Route::get('/ban/add', [BansController::class, 'create'])->middleware('permission.ban');
+ Route::get('/ban/edit/{id}', [BansController::class, 'edit'])->middleware('permission.ban');
Route::get('/mute/add', [MutesController::class, 'create'])->middleware('permission.mute');
+ Route::get('/mute/edit/{id}', [MutesController::class, 'edit'])->middleware('permission.mute');
Route::group(['prefix' => 'servers'], function () {
Route::get('/{server_id}/players', [ServerController::class, 'getPlayers']);
@@ -80,3 +86,5 @@
});
Route::post('/setup', [ServerController::class, 'setup']);
+Route::get('/logs', [LogViewerController::class, 'show'])->middleware('superadmin')->name('log-viewer');
+
diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/storage/debugbar/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore