Full Refactor Admin Panel & Logs

Full Refactor Admin Panel & Logs (now you can see detailed logs in admin panel)
This commit is contained in:
novgorodschi catalin
2026-05-22 11:26:50 +03:00
parent 29b8e91968
commit d636065b80
36 changed files with 2473 additions and 1539 deletions
+49 -14
View File
@@ -3,29 +3,64 @@
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename addABTroops.php ##
## Type BACKEND ##
## Developed by: ronix ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2014. All rights reserved. ##
## ##
#################################################################################
if(!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../Database.php");
$id = (int) $_POST['id'];
$village = $database->getVillage($id);
$user = $database->getUserArray($village['owner'],1);
$atech="";
$btech="";
for($i=1; $i<9; $i++) {
$atech.="a".$i."=".$database->escape($_POST['a'.$i]).", ";
$btech.="b".$i."=".$database->escape($_POST['b'.$i]).(($i > 7) ? "" : ", ");
if (!isset($_SESSION)) {
session_start();
}
if (empty($_SESSION['access']) || $_SESSION['access'] < 9) {
die("Access Denied: You are not Admin!");
}
$q = "UPDATE ".TB_PREFIX."abdata SET ".$atech.$btech." WHERE vref = $id";
include_once __DIR__ . "/../../Database.php";
/* ---------------------------------------------------------------------------
* Input
* --------------------------------------------------------------------------- */
$id = (int)($_POST['id'] ?? 0);
if ($id <= 0) {
header("Location: ../../../Admin/admin.php");
exit;
}
$village = $database->getVillage($id);
/* ---------------------------------------------------------------------------
* Update a1-a8 / b1-b8
* --------------------------------------------------------------------------- */
$fields = [];
for ($i = 1; $i <= 8; $i++) {
$a = (int)($_POST['a' . $i] ?? 0);
$b = (int)($_POST['b' . $i] ?? 0);
$fields[] = "a$i = $a";
$fields[] = "b$i = $b";
}
$q = "UPDATE " . TB_PREFIX . "abdata SET " . implode(", ", $fields) . " WHERE vref = $id";
$database->query($q);
$database->query("Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Changed troop upgrade levels in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")");
header("Location: ../../../Admin/admin.php?p=village&did=".$id."&ab");
/* ---------------------------------------------------------------------------
* Log admin - adaptat pentru structura ta:
* CREATE TABLE `s1_admin_log` (`id` int, `user` text, `log` text, `time` int)
* --------------------------------------------------------------------------- */
$adminId = (string)(int)$_SESSION['id'];
$time = time();
$logText = "Changed troop upgrade levels in village <a href='admin.php?p=village&did=$id'>$id</a>";
// escapăm corect pentru coloana TEXT
$adminIdEsc = $database->escape($adminId);
$logEsc = $database->escape($logText);
$database->query(
"INSERT INTO " . TB_PREFIX . "admin_log (`id`, `user`, `log`, `time`) " .
"VALUES (0, '$adminIdEsc', '$logEsc', $time)"
);
header("Location: ../../../Admin/admin.php?p=village&did=" . $id . "&ab");
exit;
?>