Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WeaponPaints module update & VIP / Appeals / Reports / Token changing method / Rank page sorting #125

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ DEFAULT_THEME_DARK = true
RANKS="Disabled"
VIP="Disabled"
SKINS="Disabled"
REPORTS="Disabled"
APPEALS="Disabled"
#============MODULES DB===============
DB_HOST_VIP=
DB_DATABASE_VIP=
Expand Down
3 changes: 2 additions & 1 deletion .env.vercel.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
RANKS="Disabled"
VIP="Disabled"
SKINS="Disabled"

REPORTS="Disabled"
APPEALS="Disabled"
#-------------------- MODULES DB ----------------------
DB_HOST_VIP=
DB_DATABASE_VIP=
Expand Down
23 changes: 20 additions & 3 deletions app/Http/Controllers/Appeal/AppealController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ public function store(Request $request)
'reason' => 'required|string',
'email' => 'required|email',
]);

$existingAppeal = Appeal::where(function ($query) use ($validated) {
if (isset($validated['steamid'])) {
$query->where('steamid', $validated['steamid']);
}

if (isset($validated['ip'])) {
$query->orWhere('ip', $validated['ip']);
}
})
->where('status', 'PENDING')
->first();

if ($existingAppeal) {
return redirect()->route('appeals.create')->with('error', __('You have a pending Appeal request.'));
}

if(SaBan::where('player_steamid', $validated['steamid'])
->where('status', 'ACTIVE')
->exists()) {
Expand All @@ -40,10 +57,10 @@ public function store(Request $request)
// Save the appeal
$appeal = Appeal::create($data);
CommonHelper::sendActionLog('appeal', $appeal->id);
return redirect()->route('appeals.create')->with('success', 'Appeal submitted successfully.');
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');
return redirect()->route('appeals.create')->with('error', __('No active bans exists for this Steam ID or IP'));
}
}

Expand All @@ -70,6 +87,6 @@ public function updateStatus(Request $request, $id)
$appeal->save();
Mail::to($appeal->email)->send(new AppealApproved($appeal));

return redirect()->route('appeals.list', $appeal->id)->with('success', 'Appeal status updated successfully.');
return redirect()->route('appeals.list', $appeal->id)->with('success', __('Appeal status updated successfully.'));
}
}
90 changes: 85 additions & 5 deletions app/Http/Controllers/K4Ranks/RanksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,54 @@ public function getPlayersList(Request $request)
} else {
// New Logic
$query = ZenithPlayerStorage::selectRaw('*, (SELECT COUNT(*) + 1 FROM zenith_player_storage AS zps WHERE CAST(JSON_EXTRACT(zps.`K4-Zenith-Ranks.storage`, "$.Points") AS UNSIGNED) > CAST(JSON_EXTRACT(zenith_player_storage.`K4-Zenith-Ranks.storage`, "$.Points") AS UNSIGNED)) AS `position`');

if (!empty($searchValue)) {
$query->where('steam_id', 'like', '%' . $searchValue . '%')
->orWhereRaw('JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Ranks.storage`, "$.Rank")) like ?', ['%' . $searchValue . '%'])
->orWhere('name', 'like', '%' . $searchValue . '%');
}

if ($orderColumn !== null) {
$columnName = $request->input('columns.' . $orderColumn . '.data');
if ($columnName == 'points') {
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Ranks.storage`, "$.Points")) AS UNSIGNED) ' . $orderDirection);
} else {
$query->orderBy($columnName, $orderDirection);

// Handle different column sorting cases
switch ($columnName) {
case 'points':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Ranks.storage`, "$.Points")) AS UNSIGNED) ' . $orderDirection);
break;
case 'kills':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.Kills")) AS UNSIGNED) ' . $orderDirection);
break;
case 'deaths':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.Deaths")) AS UNSIGNED) ' . $orderDirection);
break;
case 'assists':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.Assists")) AS UNSIGNED) ' . $orderDirection);
break;
case 'headshots':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.Headshots")) AS UNSIGNED) ' . $orderDirection);
break;
case 'rounds_ct':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.RoundsCT")) AS UNSIGNED) ' . $orderDirection);
break;
case 'rounds_t':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.RoundsT")) AS UNSIGNED) ' . $orderDirection);
break;
case 'rounds_overall':
$query->orderByRaw('(CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.RoundsCT")) AS UNSIGNED) + CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.RoundsT")) AS UNSIGNED)) ' . $orderDirection);
break;
case 'games_won':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.GameWin")) AS UNSIGNED) ' . $orderDirection);
break;
case 'games_lost':
$query->orderByRaw('CAST(JSON_UNQUOTE(JSON_EXTRACT(`K4-Zenith-Stats.storage`, "$.GameLose")) AS UNSIGNED) ' . $orderDirection);
break;
case 'position':
$query->orderBy('position', $orderDirection);
break;
default:
$query->orderBy($columnName, $orderDirection);
break;
}
}
}
Expand Down Expand Up @@ -132,7 +169,6 @@ public function getPlayersList(Request $request)
"recordsFiltered" => !empty($searchValue) ? count($formattedData) : ($useOldLogic ? Ranks::count() : ZenithPlayerStorage::count()),
"data" => $formattedData
]);

}

public function viewProfile(Request $request, $steam_id, $server_id) {
Expand Down Expand Up @@ -183,6 +219,50 @@ public function viewProfile(Request $request, $steam_id, $server_id) {
->limit(5)
->get()
->transform(function ($weapon) {
$weaponNameMap = [
'healthshot' => 'Healthshot',
'inferno' => 'Molotov/Inc.',
'knife' => 'Knife',
'grenade' => 'Grenade',
'deagle' => 'Desert Eagle',
'elite' => 'Dual Berettas',
'fiveseven' => 'Five-SeveN',
'glock' => 'Glock-18',
'ak47' => 'AK-47',
'aug' => 'AUG',
'awp' => 'AWP',
'famas' => 'FAMAS',
'g3sg1' => 'G3SG1',
'galilar' => 'Galil AR',
'm249' => 'M249',
'm4a1' => 'M4A1',
'mac10' => 'MAC-10',
'p90' => 'P90',
'mp5sd' => 'MP5-SD',
'ump45' => 'UMP-45',
'xm1014' => 'XM1014',
'bizon' => 'PP-Bizon',
'mag7' => 'MAG-7',
'negev' => 'Negev',
'sawedoff' => 'Sawed-Off',
'tec9' => 'Tec-9',
'taser' => 'Zeus x27',
'hkp2000' => 'P2000',
'mp7' => 'MP7',
'mp9' => 'MP9',
'nova' => 'Nova',
'p250' => 'P250',
'scar20' => 'SCAR-20',
'sg556' => 'SG 553',
'ssg08' => 'SSG 08',
'm4a1_silencer' => 'M4A1-S',
'usp-s' => 'USP-S',
'cz75a' => 'CZ75-Auto',
'revolver' => 'R8 Revolver'
];

$weapon->weaponname = $weaponNameMap[$weapon->weapon] ?? $weapon->weapon;

// Define the image path based on weapon name
$imagePath = 'images/weapons/weapon_' . strtolower($weapon->weapon) . '.png';

Expand Down
7 changes: 6 additions & 1 deletion app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function showSettings()
'RANKS' => env('RANKS'),
'VIP' => env('VIP'),
'SKINS' => env('SKINS'),
'REPORTS' => env('REPORTS'),
'APPEALS' => env('APPEALS'),
'K4LegacySupport' => env('K4LegacySupport')
],
'VIP Module' => [
Expand Down Expand Up @@ -57,13 +59,16 @@ public function showSettings()

public function updateSettings(Request $request)
{
$data = $request->all();
$data = $request->except(['_token']);

// Update the .env file or settings storage
foreach ($data as $key => $value) {
$this->setEnvironmentValue($key, $value);
}

\Artisan::call('config:clear');
\Artisan::call('cache:clear');

return redirect()->back()->with('success', 'Settings updated successfully.');
}

Expand Down
Loading
Loading