From dd7ee34e20aaca72254c015744c652211d33ba7b Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Mon, 27 Jul 2026 10:42:44 +0300 Subject: [PATCH] Enable GPACK for Player Enable GPACK for Player --- Admin/Templates/config.tpl | 2 +- Admin/admin.php | 5 ++ GameEngine/Profile.php | 20 +++++- GameEngine/Session.php | 7 +++ README.md | 2 +- Templates/Alliance/medal.php | 5 +- Templates/Profile/graphic.tpl | 7 ++- a2b.php | 10 +-- a2b2.php | 11 ++-- allianz.php | 10 +-- banned.php | 8 +-- berichte.php | 8 +-- build.php | 10 +-- build_croppers.php | 18 ++---- crop_finder.php | 11 ++-- dorf1.php | 8 +-- dorf2.php | 8 +-- dorf3.php | 8 +-- install/data/constant_format.tpl | 105 ++++++++++++++++--------------- install/process.php | 4 +- install/templates/config.tpl | 4 ++ karte.php | 8 +-- logout.php | 8 +-- maintenance.php | 13 +--- nachrichten.php | 8 +-- packages.php | 8 +-- plus.php | 8 +-- plus1.php | 8 +-- rules.php | 8 +-- spieler.php | 8 +-- statistiken.php | 8 +-- version.php | 8 +-- warsim.php | 8 +-- winner.php | 10 +-- 34 files changed, 162 insertions(+), 220 deletions(-) diff --git a/Admin/Templates/config.tpl b/Admin/Templates/config.tpl index e85e58ce..67fa8290 100644 --- a/Admin/Templates/config.tpl +++ b/Admin/Templates/config.tpl @@ -110,7 +110,7 @@ $editIcon = '
? - + diff --git a/Admin/admin.php b/Admin/admin.php index 7d2ea410..0c51f70d 100644 --- a/Admin/admin.php +++ b/Admin/admin.php @@ -40,6 +40,11 @@ include_once("../GameEngine/config.php"); include_once("../GameEngine/Database.php"); include_once("../GameEngine/Lang/" . LANG . ".php"); include_once("../GameEngine/Admin/database.php"); + +// Helperul care descopera pachetele grafice din gpack/ (tz_available_gpacks). +// Sabloanele panoului il folosesc pentru selectorul de pachet; fara acest +// include, functia nu exista la randare si lista arata doar pachetul curent. +include_once("../GameEngine/Admin/Mods/config_template.php"); include_once("../GameEngine/Data/buidata.php"); include_once("../GameEngine/Artifacts.php"); include_once("../GameEngine/MultiAccount.php"); diff --git a/GameEngine/Profile.php b/GameEngine/Profile.php index 95b053e4..63e569de 100755 --- a/GameEngine/Profile.php +++ b/GameEngine/Profile.php @@ -269,11 +269,29 @@ class Profile { private function gpack($post) { global $database, $session; + $chosen = trim((string) $post['custom_url']); + + // Acceptam doar pachete locale reale: "gpack//" cu travian.css pe + // disc. Fara verificare, o cale gresita (sau trimisa manual) ar lasa + // jucatorul cu o pagina fara stiluri, din care nu mai poate reveni. + $isLocalPack = (bool) preg_match('#^gpack/[A-Za-z0-9_\-]+/$#', $chosen) + && is_file(__DIR__ . '/../' . $chosen . 'travian.css'); + + // Sirul gol inseamna "inapoi la pachetul serverului" si e mereu permis. + if ($chosen !== '' && !$isLocalPack) { + header("Location: spieler.php?s=4"); + exit; + } + $database->gpack( $database->RemoveXSS($session->uid), - $database->RemoveXSS($post['custom_url']) + $database->RemoveXSS($chosen) ); + // Sesiunea trebuie sa reflecte imediat alegerea: config.php citeste de + // acolo, iar fara asta pachetul nou s-ar aplica abia dupa o relogare. + $_SESSION['gpack'] = $chosen; + // Invalidate the 30s session user-cache (see Session::PopulateVar) so the // new graphics pack applies immediately, without a re-login. unset($_SESSION['cache_user_' . ($_SESSION['username'] ?? '')]); diff --git a/GameEngine/Session.php b/GameEngine/Session.php index 78341612..e277ec0b 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -426,6 +426,13 @@ function __construct() { $this->uid = $_SESSION['id_user'] = $this->userarray['id']; $this->gpack = $this->userarray['gpack']; + + // Pachetul grafic ales de jucator ajunge in sesiune, exact ca limba de + // mai sus: config.php se incarca INAINTE de a exista o conexiune la baza + // de date, deci singurul mod de a-i spune ce pachet vrea jucatorul este + // prin sesiune. Fara asta, GP_LOCATE ramanea mereu pachetul serverului, + // oricat de des si-l schimba jucatorul din profil. + $_SESSION['gpack'] = (string) $this->userarray['gpack']; $this->access = $this->userarray['access']; $this->plus = ($this->userarray['plus'] > $this->time); $this->goldclub = $this->userarray['goldclub']; diff --git a/README.md b/README.md index 6296dead..dc7f7b4b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This repository currently targets modern local/server setups with PHP 8.x and Ma Project Status -* Version: v10 Full Refactor +* Version: v11 Full Refactor * PHP 8.3+ compatible * Actively maintained * Suitable for production servers diff --git a/Templates/Alliance/medal.php b/Templates/Alliance/medal.php index da879019..1821d9e5 100644 --- a/Templates/Alliance/medal.php +++ b/Templates/Alliance/medal.php @@ -14,9 +14,8 @@ // ------------------------------------------------- // GPACK (unchanged logic, cleaner) // ------------------------------------------------- -$gpack = ($session->gpack == null || GP_ENABLE == false) - ? GP_LOCATE - : $session->gpack; +// GP_LOCATE contine deja pachetul efectiv (vezi config.php). +$gpack = GP_LOCATE; // ------------------------------------------------- // PROFILE SHORTCODES (UNCHANGED LOGIC) diff --git a/Templates/Profile/graphic.tpl b/Templates/Profile/graphic.tpl index 90c2c083..0600175c 100644 --- a/Templates/Profile/graphic.tpl +++ b/Templates/Profile/graphic.tpl @@ -214,7 +214,12 @@ if (isset($_GET["custom_url"])) { ? tz_available_gpacks(__DIR__ . '/../../gpack') : array('gpack/travian_default/' => 'Travian Default'); - $gpActive = rtrim((string) $session->gpack, '/') . '/'; + // Pachetul marcat ca activ e cel EFECTIV folosit acum. Cand + // GP_ENABLE e false, alegerea din baza de date e ignorata de joc, + // deci ar fi inselator sa aratam altceva decat pachetul serverului. + $gpActive = (defined('GP_ENABLE') && GP_ENABLE && $session->gpack) + ? rtrim((string) $session->gpack, '/') . '/' + : (defined('SERVER_GP') ? SERVER_GP : GP_LOCATE); foreach ($gpPacks as $gpPath => $gpLabel) { $gpIsActive = (rtrim($gpPath, '/') . '/') === $gpActive; diff --git a/a2b.php b/a2b.php index 6ef535a9..746c6007 100644 --- a/a2b.php +++ b/a2b.php @@ -102,15 +102,11 @@ $process = $units->procUnits($_POST); gpack == null || GP_ENABLE == false){ - echo " + // GP_LOCATE contine deja pachetul efectiv: alegerea jucatorului cand + // e permisa si valida, altfel pachetul serverului (vezi config.php). + echo " "; - }else{ - echo " - - "; - } ?> diff --git a/allianz.php b/allianz.php index ee9d4da1..09aaaba6 100644 --- a/allianz.php +++ b/allianz.php @@ -126,15 +126,11 @@ if(isset($_GET['aid']) || isset($_GET['fid']) || isset($_GET['fid2']) || ?>lang/en/compact.css?f4b7i" rel="stylesheet" type="text/css" /> gpack == null || GP_ENABLE == false) { - echo " + // GP_LOCATE contine deja pachetul efectiv: alegerea jucatorului cand + // e permisa si valida, altfel pachetul serverului (vezi config.php). + echo " "; - } else { - echo " - - "; - } ?> gpack == null || GP_ENABLE == false) { + // GP_LOCATE contine deja pachetul efectiv (vezi config.php). echo " "; - } else { - echo " - - "; - } ?> -gpack == null || GP_ENABLE == false) { - echo " "; - echo " "; -} else { - echo " "; - echo " "; -} ?> +"; + echo " "; ?> diff --git a/dorf1.php b/dorf1.php index 9e67d16c..de0abcd6 100644 --- a/dorf1.php +++ b/dorf1.php @@ -60,15 +60,11 @@ else $building->procBuild($_GET); gpack == null || GP_ENABLE == false) { + // GP_LOCATE contine deja pachetul efectiv: alegerea jucatorului cand + // e permisa si valida, altfel pachetul serverului (vezi config.php). echo " "; - } else { - echo " - - "; - } ?>