mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-12 23:56:08 +00:00
Added Account transactions with History
Added Account transactions with History
This commit is contained in:
@@ -1,51 +1,78 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename cp.php ##
|
||||
## Developed by: aggenkeech ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
|
||||
## ##
|
||||
## Project: TravianZ (Refactor incremental) ##
|
||||
## File: additional.tpl ##
|
||||
## Description: Implement Gold Log ##
|
||||
## Made by: Shadow ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: https://travianz.org ##
|
||||
## https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.php");
|
||||
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
if(($_SESSION['access']?? 0) < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = (int) $_POST['id'];
|
||||
$admid = $_POST['admid'];
|
||||
// --- INPUT ---
|
||||
$id = (int)($_POST['id']?? 0);
|
||||
$admid = (int)($_POST['admid']?? 0);
|
||||
$access = (int)($_POST['access']?? 2);
|
||||
$newGold = (int)($_POST['gold']?? 0);
|
||||
$sit1 = (int)($_POST['sitter1']?? 0);
|
||||
$sit2 = (int)($_POST['sitter2']?? 0);
|
||||
$protect = time() + ((int)($_POST['protect']?? 0) * 86400);
|
||||
$cp = (int)($_POST['cp']?? 0);
|
||||
$ap = (int)($_POST['off']?? 0);
|
||||
$dp = (int)($_POST['def']?? 0);
|
||||
$rr = (int)($_POST['res']?? 0);
|
||||
$apall = (int)($_POST['ooff']?? 0);
|
||||
$dpall = (int)($_POST['odef']?? 0);
|
||||
|
||||
//$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$admid."");
|
||||
//$access = mysqli_fetch_array($sql);
|
||||
//$sessionaccess = $access['access'];
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
if($id <= 0) die("Invalid user");
|
||||
|
||||
// --- GOLD LOGIC ---
|
||||
$oldGold = (int)$database->getUserField($id, 'gold', 1);
|
||||
$diffGold = $newGold - $oldGold;
|
||||
|
||||
// --- UPDATE USER (prepared-style, fără escape manual) ---
|
||||
$database->query("
|
||||
UPDATE ".TB_PREFIX."users SET
|
||||
access = $access,
|
||||
gold = $newGold,
|
||||
sit1 = $sit1,
|
||||
sit2 = $sit2,
|
||||
protect = $protect,
|
||||
cp = $cp,
|
||||
ap = $ap,
|
||||
dp = $dp,
|
||||
RR = $rr,
|
||||
apall = $apall,
|
||||
dpall = $dpall
|
||||
WHERE id = $id
|
||||
");
|
||||
|
||||
// --- LOG GOLD dacă s-a modificat ---
|
||||
if($diffGold!== 0){
|
||||
$vill = $database->getVillagesID($id);
|
||||
$wid = $vill[0]?? 0;
|
||||
$action = $diffGold > 0? 'Admin added Gold' : 'Admin removed Gold';
|
||||
$details = 'Admin adjustment by '.($session->username?? 'Admin');
|
||||
$now = time();
|
||||
|
||||
$database->query("
|
||||
INSERT INTO ".TB_PREFIX."gold_fin_log
|
||||
(wid, uid, action, gold, time, details)
|
||||
VALUES ($wid, $id, '$action', $diffGold, $now, '$details')
|
||||
");
|
||||
}
|
||||
|
||||
if($_SESSION['access'] != ADMIN) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
|
||||
|
||||
foreach ($_POST as $key => $value) {
|
||||
$_POST[$key] = $database->escape($value);
|
||||
}
|
||||
|
||||
$access = (int) $_POST['access'];
|
||||
$dur = (int) $_POST['protect'] * 86400;
|
||||
$protection = (time() + $dur);
|
||||
|
||||
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET
|
||||
access = ".$access.",
|
||||
gold = ".(int) $_POST['gold'].",
|
||||
sit1 = '".(int) $_POST['sitter1']."',
|
||||
sit2 = '".(int) $_POST['sitter2']."',
|
||||
protect = '".$protection."',
|
||||
cp = ".(int) $_POST['cp'].",
|
||||
ap = '".(int) $_POST['off']."',
|
||||
dp = '".(int) $_POST['def']."',
|
||||
RR = '".(int) $_POST['res']."',
|
||||
apall = '".(int) $_POST['ooff']."',
|
||||
dpall = '".(int) $_POST['odef']."'
|
||||
WHERE id = ".$id) or die(mysqli_error($database->dblink));
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=".$id."");
|
||||
?>
|
||||
// --- REDIRECT ---
|
||||
header("Location:../../../Admin/admin.php?p=player&uid=".$id);
|
||||
exit;
|
||||
Reference in New Issue
Block a user