Enable GPACK for Player

Enable GPACK for Player
This commit is contained in:
novgorodschi catalin
2026-07-27 10:42:44 +03:00
parent 81cf911128
commit dd7ee34e20
34 changed files with 162 additions and 220 deletions
+19 -1
View File
@@ -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/<nume>/" 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'] ?? '')]);
+7
View File
@@ -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'];