From 31c475e6445dbb35b4eb2b22b76f312f7b3aee93 Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Wed, 27 May 2026 12:26:24 +0300 Subject: [PATCH] Fix + Credits + Start Language Coding Fix Artefacts + Credits + Start Language Coding --- Admin/admin.php | 49 ++++++++++++-------- GameEngine/Database.php | 10 ++-- Templates/Build/27.tpl | 33 ++++++++----- Templates/Build/27_1.tpl | 63 ++++++++++++------------- Templates/Build/27_2.tpl | 37 ++++++--------- Templates/Build/27_3.tpl | 34 ++++++-------- Templates/Build/27_menu.tpl | 24 ++-------- Templates/Build/27_show.tpl | 79 ++++++++++++++++++-------------- Templates/Profile/account.tpl | 2 +- Templates/Profile/graphic.tpl | 2 +- Templates/Profile/medal.php | 2 +- Templates/Profile/menu.tpl | 2 +- Templates/Profile/menu2.tpl | 2 +- Templates/Profile/notfound.tpl | 2 +- Templates/Profile/overview.tpl | 2 +- Templates/Profile/preference.tpl | 72 +++++++++++++++++++++++++++-- Templates/Profile/profile.tpl | 2 +- Templates/Profile/special.tpl | 2 +- Templates/Profile/vacation.tpl | 2 +- var/db/struct.sql | 1 + 20 files changed, 241 insertions(+), 181 deletions(-) diff --git a/Admin/admin.php b/Admin/admin.php index ccdf5ee4..88a8d44c 100644 --- a/Admin/admin.php +++ b/Admin/admin.php @@ -276,30 +276,41 @@ if (!empty($_GET['p'])) { } break; - case 'village': - if (!empty($_GET['did'])) { - $village = $database->getVillage($_GET['did']); - $user = $database->getUserArray($village['owner'],1); - $subpage = 'Edit Village ('.$village['name'].' » '.$user['username'].')'; - } else { - $subpage = 'Edit Village (no village)'; - } - break; + case 'village': + if (!empty($_GET['did'])) { + $did = (int)$_GET['did']; + $village = $database->getVillage($did); + if ($village) { + $user = $database->getUserArray($village['owner'], 1); + $subpage = 'Edit Village ('.$village['name'].' » '.($user['username'] ?? '?').')'; + } else { + $subpage = 'Edit Village (ID '.$did.' not found)'; + $village = null; // important, ca să nu crape template-ul mai jos + } + } else { + $subpage = 'Edit Village (no village)'; + } + break; - case 'editResources': - if (!empty($_GET['did'])) { - $village = $database->getVillage($_GET['did']); - $user = $database->getUserArray($village['owner'],1); - $subpage = 'Edit Resources ('.$village['name'].' » '.$user['username'].')'; - } else { - $subpage = 'Edit Resources (no village)'; - } - break; + case 'editResources': + if (!empty($_GET['did'])) { + $village = $database->getVillage($_GET['did']); + if ($village) { + $user = $database->getUserArray($village['owner'], 1); + $subpage = 'Edit Troops ('.$village['name'].' » '.$user['username'].')'; + } else { + $subpage = 'Edit Resources (ID '.$did.' not found)'; + $village = null; + } + } else { + $subpage = 'Edit Resources (no village)'; + } + break; case 'addTroops': if (!empty($_GET['did'])) { $village = $database->getVillage($_GET['did']); - $user = $database->getUserArray($village['owner'],1); + $user = $database->getUserArray($village['owner'], 1); $subpage = 'Edit Troops ('.$village['name'].' » '.$user['username'].')'; } else { $subpage = 'Edit Troops (no village)'; diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 4631ee65..c7594983 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -3021,11 +3021,13 @@ 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) { - if (!$id) return '-'; - $alliance = $this->getAlliance($id, $use_cache); - return $alliance['tag'] ?? '-'; + $alliance = $this->getAlliance($id, $use_cache); + if (!is_array($alliance) || !isset($alliance['tag'])) { + return null; + } + return $alliance['tag']; } // no need to cache this method diff --git a/Templates/Build/27.tpl b/Templates/Build/27.tpl index d259f584..7be88d38 100644 --- a/Templates/Build/27.tpl +++ b/Templates/Build/27.tpl @@ -1,25 +1,36 @@ - -
-

resarray['f'.$id]; ?>

+

resarray['f'.$id] ?? 0; ?>

getTypeLevel(27) ?? 0; - if($building->getTypeLevel(27) > 0){ + if($treasuryLevel > 0){ include("27_menu.tpl"); - if(isset($_GET['show']) && !empty($_GET['show']) && $_GET['show'] > 0) include("27_show.tpl"); - else - { - if(!isset($_GET['t'])) include("27_1.tpl"); - elseif(isset($_GET['t']) && $_GET['t'] == 2) include("27_2.tpl"); - elseif(isset($_GET['t']) && $_GET['t'] == 3) include("27_3.tpl"); + + $show = (int)($_GET['show'] ?? 0); + $t = (int)($_GET['t'] ?? 0); + + if($show > 0) { + include("27_show.tpl"); + } else { + if($t === 0 || $t === 1) { + include("27_1.tpl"); + } elseif($t === 2) { + include("27_2.tpl"); + } elseif($t === 3) { + include("27_3.tpl"); + } else { + include("27_1.tpl"); + } } + } else { + echo ''.TREASURY_COMMENCE.'
'; } - else echo ''.TREASURY_COMMENCE.'
'; + include("upgrade.tpl"); ?>
\ No newline at end of file diff --git a/Templates/Build/27_1.tpl b/Templates/Build/27_1.tpl index b90fedca..a46c9d0e 100644 --- a/Templates/Build/27_1.tpl +++ b/Templates/Build/27_1.tpl @@ -1,10 +1,8 @@ getOwnArtefactsInfo($session->uid); -$wref = $village->wid; -$coor = $database->getCoor($wref); - +$ownArtifacts = $database->getOwnArtefactsInfo($session->uid ?? 0); +$wref = $village->wid ?? 0; ?>
@@ -23,25 +21,25 @@ $coor = $database->getCoor($wref); '.ANY_ARTEFACTS.''; -else -{ +if (empty($ownArtifacts)) { + echo ''.ANY_ARTEFACTS.''; +} else { foreach($ownArtifacts as $ownArtifact){ - $coor2 = $database->getCoor($ownArtifact['vref']); $ownArtifactInfo = Artifacts::getArtifactInfo($ownArtifact); + $conquered = !empty($ownArtifact['conquered']) ? date("d.m.Y H:i", $ownArtifact['conquered']) : '-'; + $villageName = $database->getVillageField($ownArtifact['vref'], "name") ?? '-'; + echo ''; echo ' ' . $ownArtifact['name'] . ' ' . $ownArtifact['effect'] . '
- Treasury '.$ownArtifactInfo['requiredLevel'].', Effect '.$ownArtifactInfo['effectInfluence'].' + Treasury '.($ownArtifactInfo['requiredLevel'] ?? 0).', Effect '.($ownArtifactInfo['effectInfluence'] ?? '').'
'; - echo '' . $database->getVillageField($ownArtifact['vref'], "name") . ''; - echo ''.date("d.m.Y H:i", $ownArtifact['conquered']) . ''; + echo '' . $villageName . ''; + echo ''.$conquered.''; } } - ?> @@ -51,14 +49,10 @@ else - - - - @@ -66,37 +60,38 @@ else getArtifactsBysize([1, 2, 3]); -if(count($artifacts) == 0) echo ''.NO_ARTEFACTS_AREA.''; -else -{ +if(count($artifacts) == 0) { + echo ''.NO_ARTEFACTS_AREA.''; +} else { $rows = []; foreach($artifacts as $artifact){ $coordinates = $database->getCoor($artifact['vref']); - $distance = $database->getDistance($village->coor['x'], $village->coor['y'], $coordinates['x'], $coordinates['y']); - $rows[(string)$distance] = $artifact; + // cheia unică previne suprascrierea când 2 artefacte sunt la aceeași distanță + $rows[$distance.'_'.$artifact['id']] = ['dist' => $distance, 'data' => $artifact]; } ksort($rows); - foreach($rows as $distance => $row) { + foreach($rows as $row) { + $distance = $row['dist']; + $artifact = $row['data']; + $artifactInfo = Artifacts::getArtifactInfo($artifact); + $ownerName = $database->getUserField($artifact['owner'], "username", 0) ?? 'Natars'; + echo ' - + - '.$row['name'].' '.$row['effect'].' -
'; - - $artifactInfo = Artifacts::getArtifactInfo($row); - - echo '
'.TREASURY.' '.$artifactInfo['requiredLevel'] . ', '.EFFECT.' '.$artifactInfo['effectInfluence'].' -
- '.$database->getUserField($row['owner'], "username", 0).' - + '.$artifact['name'].' '.$artifact['effect'].' +
'.TREASURY.' '.($artifactInfo['requiredLevel'] ?? 0).', '.EFFECT.' '.($artifactInfo['effectInfluence'] ?? '').'
+ + + '.$ownerName.' + '.$distance.' '; } } - ?> diff --git a/Templates/Build/27_2.tpl b/Templates/Build/27_2.tpl index 11e68dc1..cb0a1d09 100644 --- a/Templates/Build/27_2.tpl +++ b/Templates/Build/27_2.tpl @@ -2,19 +2,11 @@
-

resarray['f' . $id]; - -?>

+

resarray['f' . $id] ?? 0; ?>

- + @@ -30,10 +22,9 @@ getArtifactsBysize(1); if(count($artifactsArray) == 0) { - echo ''; + echo ''; } else { $previous = ""; foreach($artifactsArray as $artifact){ @@ -41,24 +32,24 @@ if($previous != "" && $previous != $artifact['type']) echo ''; $previous = $artifact['type']; + $ownerId = $artifact['owner']; + $aid = $database->getUserField($ownerId, "alliance", 0); + $ownerName = $database->getUserField($ownerId, "username", 0); + $allianceName = $aid ? $database->getAllianceName($aid) : ''; + echo ' - - + + '; } } -?> - + ?>
'.NO_ARTEFACTS.'
'.NO_ARTEFACTS.'
- '.$artifact['name'] . ' '.$artifact['effect'].'
'.TREASURY.' 10, '.EFFECT.' '.ACCOUNT.'
+ '.$artifact['name'] . ' '.$artifact['effect'].'
'.TREASURY.' 10, '.EFFECT.' '.VILLAGE.'
'.$database->getUserField($artifact['owner'], "username", 0).''.$database->getAllianceName($database->getUserField($artifact['owner'], "alliance", 0)).''.$ownerName.''.($aid ? ''.$allianceName.'' : '-').'
- + -
+
\ No newline at end of file diff --git a/Templates/Build/27_3.tpl b/Templates/Build/27_3.tpl index 18ade655..719b0eed 100644 --- a/Templates/Build/27_3.tpl +++ b/Templates/Build/27_3.tpl @@ -2,19 +2,11 @@
-

resarray['f' . $id]; - -?>

+

resarray['f' . $id] ?? 0; ?>

- + @@ -30,10 +22,9 @@ getArtifactsBysize([2, 3]); if(count($artifactsArray) == 0) { - echo ''; + echo ''; } else { $previous = ""; foreach($artifactsArray as $artifact){ @@ -41,23 +32,24 @@ if($previous != "" && $previous != $artifact['type']) echo ''; $previous = $artifact['type']; + $ownerId = $artifact['owner']; + $aid = $database->getUserField($ownerId, "alliance", 0); + $ownerName = $database->getUserField($ownerId, "username", 0); + $allianceName = $aid ? $database->getAllianceName($aid) : ''; + echo ' - - + + '; } } -?> + ?>
'.NO_ARTEFACTS.'
'.NO_ARTEFACTS.'
'.$artifact['name'] . ' '.$artifact['effect'].'
'.TREASURY.' 20, '.EFFECT.' '.ACCOUNT.'
'.$database->getUserField($artifact['owner'], "username", 0).''.$database->getAllianceName($database->getUserField($artifact['owner'], "alliance", 0)).''.$ownerName.''.($aid ? ''.$allianceName.'' : '-').'
- + -
+
\ No newline at end of file diff --git a/Templates/Build/27_menu.tpl b/Templates/Build/27_menu.tpl index 72d78846..c7187486 100644 --- a/Templates/Build/27_menu.tpl +++ b/Templates/Build/27_menu.tpl @@ -1,25 +1,7 @@
- - "> + > - | > - if(isset($_GET['t']) && $_GET['t'] == 2) { - echo "class=\"selected\""; - } - -?>"> - - | "> + | >
\ No newline at end of file diff --git a/Templates/Build/27_show.tpl b/Templates/Build/27_show.tpl index 84b71a49..e24168ef 100644 --- a/Templates/Build/27_show.tpl +++ b/Templates/Build/27_show.tpl @@ -1,37 +1,39 @@ getArtefactDetails($_GET['show']); +$showId = (int)($_GET['show'] ?? 0); +$artifact = $database->getArtefactDetails($showId); + if(empty($artifact)){ - header("location: build.php?gid=27"); + header("location: build.php?id=" . ($id ?? 0)); exit; } $artifactInfo = Artifacts::getArtifactInfo($artifact); - +$imgClass = str_replace(['type', '.gif'], '', $artifact['img'] ?? ''); ?> -
+
- + @@ -39,9 +41,11 @@ $artifactInfo = Artifacts::getArtifactInfo($artifact); @@ -49,42 +53,46 @@ $artifactInfo = Artifacts::getArtifactInfo($artifact); - + - + - + - + - + - + - + @@ -102,30 +110,33 @@ $artifactInfo = Artifacts::getArtifactInfo($artifact); getArtifactsChronology($_GET['show']); +$owners = $database->getArtifactsChronology($showId); if(!empty($owners)){ -foreach($owners as $owner){ + foreach($owners as $owner){ + $chronoUsername = $database->getUserField($owner['uid'] ?? 0, "username", 0) ?? "[?]"; + $chronoVillage = (!empty($owner['vref']) && $database->checkVilExist($owner['vref'])) ? ($database->getVillageField($owner['vref'], "name") ?? '[?]') : '[?]'; + $chronoTime = !empty($owner['conqueredtime']) ? date("d.m.Y H:i:s", $owner['conqueredtime']) : '-'; ?> - + diff --git a/Templates/Profile/account.tpl b/Templates/Profile/account.tpl index 795f7fb8..4c5fadcb 100644 --- a/Templates/Profile/account.tpl +++ b/Templates/Profile/account.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/graphic.tpl b/Templates/Profile/graphic.tpl index 2507a907..fa951b12 100644 --- a/Templates/Profile/graphic.tpl +++ b/Templates/Profile/graphic.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/medal.php b/Templates/Profile/medal.php index ccf8deea..6a11852a 100644 --- a/Templates/Profile/medal.php +++ b/Templates/Profile/medal.php @@ -11,7 +11,7 @@ ## Fixed by: Shadow / Skype : cata7007 ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ-by-Shadow/ ## ## ## ################################################################################# diff --git a/Templates/Profile/menu.tpl b/Templates/Profile/menu.tpl index 92482b2b..302e2247 100644 --- a/Templates/Profile/menu.tpl +++ b/Templates/Profile/menu.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/menu2.tpl b/Templates/Profile/menu2.tpl index da408ac2..ecca4811 100644 --- a/Templates/Profile/menu2.tpl +++ b/Templates/Profile/menu2.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/notfound.tpl b/Templates/Profile/notfound.tpl index a026efc2..4511805c 100644 --- a/Templates/Profile/notfound.tpl +++ b/Templates/Profile/notfound.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/overview.tpl b/Templates/Profile/overview.tpl index 63ed2e40..52488c46 100644 --- a/Templates/Profile/overview.tpl +++ b/Templates/Profile/overview.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/preference.tpl b/Templates/Profile/preference.tpl index 204e4ec2..9ad29d42 100644 --- a/Templates/Profile/preference.tpl +++ b/Templates/Profile/preference.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# @@ -176,7 +176,7 @@ while ($data = mysqli_fetch_assoc($query)) { // ========================= // USER SETTINGS SAVE // ========================= -if (isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) { +if (isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone']) || isset($_POST['lang'])) { $v1 = isset($_POST['v1']) ? 1 : 0; $v2 = isset($_POST['v2']) ? 1 : 0; @@ -189,6 +189,24 @@ if (isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) { $timezone = isset($_POST['timezone']) ? (int)$_POST['timezone'] : 1; $tformat = isset($_POST['tformat']) ? (int)$_POST['tformat'] : 0; +// ========================= +// LANGUAGE +// ========================= + +$lang = LANG; + +if(isset($_POST['lang'])) +{ + $allowedLangs = ['en','ro','de','fr','es','it','ru','tr']; + + $selectedLang = strtolower(trim($_POST['lang'])); + + if(in_array($selectedLang, $allowedLangs)) + { + $lang = $selectedLang; + } +} + // update user preferences $database->query(" UPDATE " . TB_PREFIX . "users SET @@ -200,10 +218,14 @@ if (isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) { v5=$v5, v6=$v6, timezone=$timezone, - tformat=$tformat + tformat=$tformat, + lang='$lang' WHERE id=" . (int)$session->uid . " "); + // schimbare instant în sesiune + $_SESSION['lang'] = $lang; + header("Location: spieler.php?s=2"); exit; } @@ -467,7 +489,49 @@ if (isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
- - +
-getUserField($artifact['owner'], "username", 0)) != "[?]"){?> +getUserField($artifact['owner'] ?? 0, "username", 0) ?? "[?]"; +if($artifactOwnerUsername != "[?]" && !empty($artifact['owner'])){ ?> - + [?]
-checkVilExist($artifact['vref'])){?> -getVillageField($artifact['vref'], "name");?> - +checkVilExist($artifact['vref'])){ + $villageName = $database->getVillageField($artifact['vref'], "name") ?? '[?]'; +?> + + [?]
-getUserField($artifact['owner'], "alliance", 0)) > 0){ ?> -getAllianceName($alliance); ?> - +getUserField($artifact['owner'] ?? 0, "alliance", 0) ?? 0); +if($alliance > 0){ + $allianceName = $database->getAllianceName($alliance) ?? '-'; +?> + + -
-getUserField($owner['uid'], "username", 0)) != "[?]"){?> - - + + + [?] -checkVilExist($owner['vref'])){?> -getVillageField($owner['vref'], "name");?> - + + + [?]
- + + + + + + + + + + + + + +
Language settings
Game language + +
diff --git a/Templates/Profile/profile.tpl b/Templates/Profile/profile.tpl index 98251560..8c0c9006 100644 --- a/Templates/Profile/profile.tpl +++ b/Templates/Profile/profile.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/special.tpl b/Templates/Profile/special.tpl index 99c5392f..d3195696 100644 --- a/Templates/Profile/special.tpl +++ b/Templates/Profile/special.tpl @@ -9,7 +9,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/Templates/Profile/vacation.tpl b/Templates/Profile/vacation.tpl index 1abf3b29..708c8400 100644 --- a/Templates/Profile/vacation.tpl +++ b/Templates/Profile/vacation.tpl @@ -10,7 +10,7 @@ ## Refactored by Shadow ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## -## URLs: http://travian.shadowss.ro ## +## URLs: http://travianz.org ## ## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# diff --git a/var/db/struct.sql b/var/db/struct.sql index d3e0b95a..5fa89ce8 100644 --- a/var/db/struct.sql +++ b/var/db/struct.sql @@ -1533,6 +1533,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( `username` varchar(100) DEFAULT NULL, `password` varchar(100) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, + `lang` varchar(5) NOT NULL DEFAULT 'en', `tribe` tinyint(1) DEFAULT NULL, `access` tinyint(1) DEFAULT '1', `gold` int(9) DEFAULT '0',