mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-02 18:44:21 +00:00
Full Refactor Admin Panel & Logs
Full Refactor Admin Panel & Logs (now you can see detailed logs in admin panel)
This commit is contained in:
@@ -3,45 +3,82 @@
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename editPlus.php ##
|
||||
## Type BACKEND ##
|
||||
## Developed by: aggenkeech ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
if (empty($_SESSION['access']) || $_SESSION['access'] < 9) {
|
||||
die("Access Denied: You are not Admin!");
|
||||
}
|
||||
|
||||
include_once("../../config.php");
|
||||
|
||||
// go max 5 levels up - we don't have folders that go deeper than that
|
||||
// ---------------------------------------------------------------------------
|
||||
// Autoloader path
|
||||
// ---------------------------------------------------------------------------
|
||||
$autoprefix = '';
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$autoprefix = str_repeat('../', $i);
|
||||
if (file_exists($autoprefix.'autoloader.php')) {
|
||||
// we have our path, let's leave
|
||||
if (file_exists($autoprefix . 'autoloader.php')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
include_once($autoprefix."GameEngine/Database.php");
|
||||
include_once($autoprefix . "GameEngine/Database.php");
|
||||
|
||||
$id = (int) $_POST['id'];
|
||||
// ---------------------------------------------------------------------------
|
||||
// Input
|
||||
// ---------------------------------------------------------------------------
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
header("Location: ../../../Admin/admin.php?p=search");
|
||||
exit;
|
||||
}
|
||||
|
||||
$bonusDuration = [];
|
||||
$time = time();
|
||||
$bonusDuration['plus'] = (int) $_POST['plus'] * 86400; //Plus
|
||||
$bonusDuration['b1'] = (int) $_POST['wood'] * 86400; //+25% Wood
|
||||
$bonusDuration['b2'] = (int) $_POST['clay'] * 86400; //+25% Clay
|
||||
$bonusDuration['b3'] = (int) $_POST['iron'] * 86400; //+25% Iron
|
||||
$bonusDuration['b4'] = (int) $_POST['crop'] * 86400; //+25% Crop
|
||||
$bonusDuration = [
|
||||
'plus' => (int)($_POST['plus'] ?? 0) * 86400,
|
||||
'b1' => (int)($_POST['wood'] ?? 0) * 86400,
|
||||
'b2' => (int)($_POST['clay'] ?? 0) * 86400,
|
||||
'b3' => (int)($_POST['iron'] ?? 0) * 86400,
|
||||
'b4' => (int)($_POST['crop'] ?? 0) * 86400,
|
||||
];
|
||||
|
||||
$user = $database->getUserArray($id, 1);
|
||||
if (!$user) {
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=$id&e=notfound");
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach($bonusDuration as $index => $bonus){
|
||||
$bonusDuration[$index] = $bonusDuration[$index] + ($user[$index] < $time ? $time : $user[$index]);
|
||||
if($bonusDuration[$index] < $time) $bonusDuration[$index] = 0;
|
||||
foreach ($bonusDuration as $key => $add) {
|
||||
$current = (int)($user[$key] ?? 0);
|
||||
$base = $current < $time ? $time : $current;
|
||||
$bonusDuration[$key] = $add > 0 ? $base + $add : $current;
|
||||
if ($bonusDuration[$key] < $time) {
|
||||
$bonusDuration[$key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$database->updateUserField($id, array_keys($bonusDuration), array_values($bonusDuration), 1);
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=".$id."");
|
||||
// ---------------------------------------------------------------------------
|
||||
// Log admin
|
||||
// ---------------------------------------------------------------------------
|
||||
$adminId = (int)$_SESSION['id'];
|
||||
$logText = "Updated Plus/bonuses for user <a href='admin.php?p=player&uid=$id'>$id</a> (plus={$_POST['plus']}d, wood={$_POST['wood']}d, clay={$_POST['clay']}d, iron={$_POST['iron']}d, crop={$_POST['crop']}d)";
|
||||
$logEsc = $database->escape($logText);
|
||||
|
||||
$database->query(
|
||||
"INSERT INTO " . TB_PREFIX . "admin_log (`id`, `user`, `log`, `time`) " .
|
||||
"VALUES (0, '$adminId', '$logEsc', $time)"
|
||||
);
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=" . $id);
|
||||
exit;
|
||||
?>
|
||||
Reference in New Issue
Block a user