mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-04 11:54:25 +00:00
Redesign Admin Panel
Full frontend & backend redesign and refactor
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
#################################################################################
|
||||
## editAli.php - Backend pentru editAli.tpl ##
|
||||
#################################################################################
|
||||
|
||||
include_once("../../config.php");
|
||||
include_once("../../Session.php");
|
||||
include_once("../../Database.php");
|
||||
|
||||
$session = new Session();
|
||||
$database = new Database();
|
||||
|
||||
// doar admini
|
||||
if(!$session->isAdmin()){
|
||||
header("Location: ../../../Admin/admin.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$aid = (int)($_POST['aid'] ?? 0);
|
||||
$admid = (int)($_POST['admid'] ?? 0);
|
||||
|
||||
// verificare sesiune
|
||||
if($admid != $session->uid || $aid <= 0){
|
||||
die("Access denied");
|
||||
}
|
||||
|
||||
$tag = $database->escape(substr(trim($_POST['tag']), 0, 8));
|
||||
$name = $database->escape(substr(trim($_POST['name']), 0, 25));
|
||||
$leader = (int)$_POST['leader'];
|
||||
$max = (int)$_POST['max'];
|
||||
if($max < 3) $max = 3;
|
||||
if($max > 60) $max = 60;
|
||||
|
||||
$notice = $database->escape($_POST['notice']);
|
||||
$desc = $database->escape($_POST['desc']);
|
||||
|
||||
// update alidata
|
||||
$database->query("UPDATE ".TB_PREFIX."alidata SET
|
||||
tag = '$tag',
|
||||
name = '$name',
|
||||
leader = $leader,
|
||||
`max` = $max,
|
||||
notice = '$notice',
|
||||
`desc` = '$desc'
|
||||
WHERE id = $aid");
|
||||
|
||||
// log admin
|
||||
$database->query("INSERT INTO ".TB_PREFIX."admin_log (uid, action, time) VALUES ($admid, 'Edited alliance $aid ($tag)', ".time().")");
|
||||
|
||||
// redirect inapoi
|
||||
header("Location: ../../../Admin/admin.php?p=alliance&aid=$aid&edited=1");
|
||||
exit;
|
||||
?>
|
||||
@@ -5,9 +5,9 @@
|
||||
## Filename editBuildings.php ##
|
||||
## Type BACKEND ##
|
||||
## Developed by: aggenkeech ##
|
||||
## Fix by: ronix ##
|
||||
## Fix by: ronix + Shadow 2026 (WW lvl 100 + auto pop) ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2011-2014. All rights reserved. ##
|
||||
## Copyright: TravianZ (c) 2011-2026. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
@@ -52,16 +52,25 @@ for ($i = 1; $i <= 40; $i++) {
|
||||
$gid = (int)($_POST["id{$i}gid"] ?? 0);
|
||||
// limităm la valori rezonabile Travian
|
||||
$level = max(0, min(20, $level));
|
||||
$gid = max(0, min(40, $gid));
|
||||
$gid = max(0, min(44, $gid)); // 44 = ziduri speciale
|
||||
$sets[] = "f{$i} = $level";
|
||||
$sets[] = "f{$i}t = $gid";
|
||||
}
|
||||
|
||||
// câmpurile speciale f99 (capcană / zid?)
|
||||
// câmpurile speciale f99
|
||||
$level99 = (int)($_POST['id99level'] ?? 0);
|
||||
$gid99 = (int)($_POST['id99gid'] ?? 0);
|
||||
$sets[] = "f99 = " . max(0, min(20, $level99));
|
||||
$sets[] = "f99t = " . max(0, min(40, $gid99));
|
||||
|
||||
// --- FIX WW: gid 40 = World Wonder, level maxim 100 ---
|
||||
if ($gid99 == 40) {
|
||||
$level99 = max(0, min(100, $level99));
|
||||
} else {
|
||||
$level99 = max(0, min(20, $level99)); // capcană, etc.
|
||||
}
|
||||
$gid99 = max(0, min(44, $gid99));
|
||||
|
||||
$sets[] = "f99 = " . $level99;
|
||||
$sets[] = "f99t = " . $gid99;
|
||||
|
||||
$setSql = implode(', ', $sets);
|
||||
|
||||
@@ -70,9 +79,23 @@ $setSql = implode(', ', $sets);
|
||||
// ---------------------------------------------------------------------------
|
||||
$database->query("UPDATE " . TB_PREFIX . "fdata SET $setSql WHERE vref = $id");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// recalculăm populația după editare
|
||||
// ---------------------------------------------------------------------------
|
||||
$automation = new Automation();
|
||||
$automation->recountPop($id);
|
||||
$pop = $automation->recountPop($id);
|
||||
|
||||
// --- FIX: recountPop original nu include f99 (WW), îl adăugăm ---
|
||||
$fdata = $database->getResourceLevel($id);
|
||||
if ((int)$fdata['f99t'] === 40) {
|
||||
$wwLevel = (int)$fdata['f99'];
|
||||
if ($wwLevel > 0) {
|
||||
// buildingPOP există în Automation
|
||||
$wwPop = $automation->buildingPOP(40, $wwLevel);
|
||||
$pop += $wwPop;
|
||||
$database->query("UPDATE " . TB_PREFIX . "vdata SET pop = $pop WHERE wref = $id");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Log admin
|
||||
|
||||
+21
-3
@@ -3021,10 +3021,11 @@ class MYSQLi_DB implements IDbConnection {
|
||||
$q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'";
|
||||
return mysqli_query($this->dblink,$q);
|
||||
}
|
||||
|
||||
|
||||
function getAllianceName($id, $use_cache = true) {
|
||||
// return from cache
|
||||
return $this->getAlliance($id, $use_cache)['tag'];
|
||||
if (!$id) return '-';
|
||||
$alliance = $this->getAlliance($id, $use_cache);
|
||||
return $alliance['tag'] ?? '-';
|
||||
}
|
||||
|
||||
// no need to cache this method
|
||||
@@ -8751,6 +8752,22 @@ $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (
|
||||
hero.wref = $wref";
|
||||
return mysqli_query($this->dblink, $q);
|
||||
}
|
||||
|
||||
public function getMaintenance() {
|
||||
$q = "SELECT * FROM ".TB_PREFIX."maintenance WHERE id=1 LIMIT 1";
|
||||
$res = $this->query_return($q);
|
||||
return $res[0]?? ['active'=>0];
|
||||
}
|
||||
public function setMaintenance($active, $uid=0) {
|
||||
$time = time();
|
||||
$active = (int)$active;
|
||||
$uid = (int)$uid;
|
||||
// REPLACE creează rândul dacă nu există
|
||||
return $this->query("REPLACE INTO ".TB_PREFIX."maintenance
|
||||
(id, active, started_by, started_at)
|
||||
VALUES (1, $active, $uid, $time)");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changed the actual capital with a new one
|
||||
@@ -8767,6 +8784,7 @@ $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// database is not needed if we're displaying static pages
|
||||
$req_file = basename($_SERVER['PHP_SELF']);
|
||||
if (!in_array($req_file, ['tutorial.php', 'anleitung.php'])) {
|
||||
|
||||
@@ -115,6 +115,7 @@ class MyGenerator
|
||||
*/
|
||||
public function getTimeFormat($time)
|
||||
{
|
||||
$time = (int) $time;
|
||||
$min = 0;
|
||||
$hr = 0;
|
||||
|
||||
@@ -139,6 +140,7 @@ class MyGenerator
|
||||
*/
|
||||
public function procMtime($time, $pref = 3)
|
||||
{
|
||||
$time = (int) $time;
|
||||
$time += 0; // placeholder for timezone adjustments
|
||||
|
||||
$today = date('d', time()) - 1;
|
||||
|
||||
+33
-18
@@ -87,27 +87,42 @@ class Session {
|
||||
var $sit1;
|
||||
var $sit2;
|
||||
var $cp;
|
||||
function __construct() {
|
||||
global $database;
|
||||
function __construct() {
|
||||
global $database;
|
||||
|
||||
$this->time = time();
|
||||
$this->time = time();
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$this->logged_in = $this->checkLogin();
|
||||
|
||||
if ($this->logged_in && TRACK_USR) {
|
||||
$database->updateActiveUser($this->username, $this->time);
|
||||
}
|
||||
|
||||
$this->referrer = $_SESSION['url'] ?? "/";
|
||||
$this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
|
||||
|
||||
$this->SurfControl();
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$this->logged_in = $this->checkLogin();
|
||||
|
||||
if ($this->logged_in && TRACK_USR) {
|
||||
$database->updateActiveUser($this->username, $this->time);
|
||||
}
|
||||
|
||||
// aici se seteaza access-ul in checkLogin, dar sa fim siguri
|
||||
if(!isset($this->access)) {
|
||||
$this->access = $this->logged_in ? $database->getUserField($this->uid, "access", 1) : 0;
|
||||
}
|
||||
|
||||
// === MAINTENANCE CHECK - DUPA ce avem access ===
|
||||
$maint = $database->getMaintenance();
|
||||
if($maint['active'] == 1 && $this->access < 9) {
|
||||
// evita loop infinit
|
||||
if(strpos($_SERVER['PHP_SELF'], 'maintenance.php') === false) {
|
||||
header('Location: maintenance.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->referrer = $_SESSION['url'] ?? "/";
|
||||
$this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
|
||||
|
||||
$this->SurfControl();
|
||||
}
|
||||
|
||||
/**
|
||||
* LOGIN USER
|
||||
*/
|
||||
@@ -140,7 +155,7 @@ class Session {
|
||||
$data = $database->getVillage($userFields["id"]);
|
||||
}
|
||||
|
||||
$_SESSION['wid'] = $data['wref'];
|
||||
$_SESSION['wid'] = isset($data['wref']) ? (int)$data['wref'] : 0;
|
||||
}
|
||||
|
||||
$this->logged_in = true;
|
||||
|
||||
Reference in New Issue
Block a user