Incremental Refactor Templates 3

Incremental Refactor Templates 2
This commit is contained in:
Catalin Novgorodschi
2026-05-07 11:20:05 +03:00
parent 8901c36c06
commit 60c2ed2f60
24 changed files with 2924 additions and 1057 deletions
+5 -1
View File
@@ -251,7 +251,10 @@ $small = $database->getArtifactsBysize(1);
// SAFE CALL 2: large + unique
$big = $database->getArtifactsBysize(2);
if(empty($small) && empty($big)){
// SAFE CALL 3: unique artifacts (size 3)
$unique = $database->getArtifactsBysize(3);
if(empty($small) && empty($big) && empty($unique)){
echo '<tr><td colspan="5" class="none">No artifacts found</td></tr>';
} else {
@@ -259,6 +262,7 @@ if(empty($small) && empty($big)){
if(is_array($small)) $all = array_merge($all, $small);
if(is_array($big)) $all = array_merge($all, $big);
if(is_array($unique)) $all = array_merge($all, $unique);
foreach($all as $a){
+188 -40
View File
@@ -1,56 +1,204 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename Building.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - redus cod duplicat ##
## - output HTML mai sigur ##
## - comentarii adăugate ##
## - redirect securizat ##
## ##
#################################################################################
// Încarcă datele pentru clădire/construcții
$building->loadBuilding();
/**
* Escape HTML compatibil PHP vechi
* Previne probleme XSS pe output
*/
if (!function_exists('safeHTML')) {
function safeHTML($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
?>
<?php if($building->NewBuilding){ ?>
<?php if ($building->NewBuilding) { ?>
<table cellpadding="1" cellspacing="1" id="building_contract">
<thead><tr>
<th colspan="4"><?php echo BUILDING_UPGRADING;?>
<?php
if($session->gold >= 2) {
?>
<a href="?buildingFinish=1" onclick="return confirm('Finish all construction and research orders in this village immediately for 2 Gold?');" title="Finish all construction and research orders in this village immediately for 2 Gold?"><img class="clock" alt="Finish all construction and research orders in this village immediately for 2 Gold?" src="img/x.gif"/></a>
<?php
}
?>
<thead>
<tr>
<th colspan="4">
<?php echo BUILDING_UPGRADING; ?>
<?php
// Buton instant finish dacă jucătorul are minim 2 gold
if (isset($session->gold) && $session->gold >= 2) {
?>
<a href="?buildingFinish=1"
onclick="return confirm('Finish all construction and research orders in this village immediately for 2 Gold?');"
title="Finish all construction and research orders in this village immediately for 2 Gold?">
<img class="clock"
alt="Finish all construction and research orders in this village immediately for 2 Gold?"
src="img/x.gif" />
</a>
<?php } ?>
</th>
</tr></thead>
<tbody>
<?php
foreach($building->buildArray as $jobs) {
if($jobs['master'] == 0){
echo "<tr><td class=\"ico\"><a href=\"?d=".$jobs['id']."&a=0&c=$session->checker\">";
echo "<img src=\"img/x.gif\" class=\"del\" title=\"cancel\" alt=\"cancel\" /></a></td><td>";
echo "<a href=build.php?id=". $jobs['field'] . ">".Building::procResType($jobs['type'])."</a> (Level ".$jobs['level'].").";
</tr>
</thead>
if($jobs['loopcon'] == 1) echo " (waiting loop)";
<tbody>
echo "</td><td>in <span id=\"timer".++$session->timer."\">";
echo $generator->getTimeFormat($jobs['timestamp']-time());
echo "</span> hrs.</td>";
echo "<td>done at ".date('H:i', $jobs['timestamp'])."</td></tr>";
}else{
echo "<tr><td class=\"ico\"><a href=\"?d=".$jobs['id']."&a=0&c=$session->checker\">";
echo "<img src=\"img/x.gif\" class=\"del\" title=\"cancel\" alt=\"cancel\" /></a></td><td>";
echo Building::procResType($jobs['type'])."<span class=\"none\"> (Level ".$jobs['level'].")</span>";
}
}
?>
</tbody>
</table>
<script type="text/javascript">var bld=[{"stufe":1,"gid":"1","aid":"3"}]</script>
<?php }else{
$the_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
header('Location: '. $the_link);
exit;
} ?>
<?php
// Verifică dacă există array valid
if (!empty($building->buildArray) && is_array($building->buildArray)) {
foreach ($building->buildArray as $jobs) {
// Normalizează valorile pentru compatibilitate și siguranță
$jobId = isset($jobs['id']) ? (int)$jobs['id'] : 0;
$fieldId = isset($jobs['field']) ? (int)$jobs['field'] : 0;
$type = isset($jobs['type']) ? (int)$jobs['type'] : 0;
$level = isset($jobs['level']) ? (int)$jobs['level'] : 0;
$timestamp = isset($jobs['timestamp']) ? (int)$jobs['timestamp'] : time();
$master = isset($jobs['master']) ? (int)$jobs['master'] : 0;
$loopcon = isset($jobs['loopcon']) ? (int)$jobs['loopcon'] : 0;
// Nume clădire procesat
$buildingName = Building::procResType($type);
// Timer rămas
$remainingTime = $timestamp - time();
// Evită timp negativ
if ($remainingTime < 0) {
$remainingTime = 0;
}
// Ora finalizării
$finishTime = date('H:i', $timestamp);
?>
<tr>
<!-- Buton cancel -->
<td class="ico">
<a href="?d=<?php echo $jobId; ?>&amp;a=0&amp;c=<?php echo safeHTML($session->checker); ?>">
<img src="img/x.gif"
class="del"
title="cancel"
alt="cancel" />
</a>
</td>
<!-- Informații clădire -->
<td>
<?php if ($master == 0) { ?>
<a href="build.php?id=<?php echo $fieldId; ?>">
<?php echo safeHTML($buildingName); ?>
</a>
(Level <?php echo $level; ?>)
<?php
// Construcție în waiting loop
if ($loopcon == 1) {
echo ' (waiting loop)';
}
?>
<?php } else { ?>
<a href="build.php?id=<?php echo $fieldId; ?>">
<?php echo safeHTML($buildingName); ?>
</a>
<span class="none">
(Level <?php echo $level; ?>) (master builder)
</span>
<?php } ?>
</td>
<?php if ($master == 0) { ?>
<!-- Timer -->
<td>
in
<span id="timer<?php echo ++$session->timer; ?>">
<?php echo $generator->getTimeFormat($remainingTime); ?>
</span>
hrs.
</td>
<!-- Ora finalizare -->
<td>
done at <?php echo $finishTime; ?>
</td>
<?php } else { ?>
<!-- Compatibil layout original -->
<td colspan="2">&nbsp;</td>
<?php } ?>
</tr>
<?php
}
}
?>
</tbody>
</table>
<!-- JS original păstrat -->
<script type="text/javascript">
var bld=[{"stufe":1,"gid":"1","aid":"3"}];
</script>
<?php
} else {
/**
* Redirect securizat
* Evită folosirea directă a REQUEST_URI fără validare minimă
*/
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
? 'https://'
: 'http://';
$host = isset($_SERVER['HTTP_HOST'])
? $_SERVER['HTTP_HOST']
: 'localhost';
$requestUri = isset($_SERVER['REQUEST_URI'])
? $_SERVER['REQUEST_URI']
: '/';
// Elimină caractere invalide pentru header
$requestUri = str_replace(array("\r", "\n"), '', $requestUri);
$redirectUrl = $protocol . $host . $requestUri;
header('Location: ' . $redirectUrl);
exit;
}
?>
+443 -129
View File
@@ -1,150 +1,464 @@
<?php
// ################################################################################
// # -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
// # --------------------------------------------------------------------------- ##
// # Filename dorf2.tpl ##
// # Developed by: Dzoki ##
// # License: TravianX Project ##
// # Copyright: TravianX (c) 2010-2011. All rights reserved. ##
// # ##
// ################################################################################
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename dorf2.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - redus cod duplicat ##
## - optimizat accesul repetitiv în resarray ##
## - comentarii adăugate ##
## - output HTML mai sigur ##
## ##
#################################################################################
/**
* Escape HTML compatibil PHP vechi
*/
if (!function_exists('safeHTML')) {
function safeHTML($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
/**
* Returnează datele unui field
*/
if (!function_exists('getFieldData')) {
function getFieldData($resarray, $fieldId)
{
return array(
'level' => isset($resarray['f'.$fieldId]) ? (int)$resarray['f'.$fieldId] : 0,
'type' => isset($resarray['f'.$fieldId.'t']) ? (int)$resarray['f'.$fieldId.'t'] : 0
);
}
}
?>
<?php
/**
* Determină titlul zidului
*/
if ($building->walling()) {
$wtitle = Building::procResType($building->walling()) .
" Level " .
(int)$village->resarray['f40'];
} else {
if ((int)$village->resarray['f40'] === 0) {
$wtitle = "Outer building site";
} else {
$wtitle = Building::procResType($village->resarray['f40t'], 0) .
" Level " .
(int)$village->resarray['f40'];
}
}
?>
<!-- ===================== MAP 1 ===================== -->
<map name="map1" id="map1">
<?php
if($building->walling()){
$wtitle = Building::procResType($building->walling())." Level ".$village->resarray['f40'];
}else{
$wtitle = ($village->resarray['f40'] == 0) ? "Outer building site" : Building::procResType($village->resarray['f40t'], 0)." Level ".$village->resarray['f40'];
}
?>
<area href="build.php?id=40" title="<?php echo $wtitle; ?>"
coords="325,225,180" shape="circle" alt="" />
<area href="build.php?id=40" title="<?php echo $wtitle; ?>"
coords="220,230,185" shape="circle" alt="" />
<area href="build.php?id=40"
title="<?php echo safeHTML($wtitle); ?>"
coords="325,225,180"
shape="circle"
alt="" />
<area href="build.php?id=40"
title="<?php echo safeHTML($wtitle); ?>"
coords="220,230,185"
shape="circle"
alt="" />
</map>
<!-- ===================== MAP 2 ===================== -->
<map name="map2" id="map2">
<?php
$coords = [19 => "53,91,91,71,127,91,91,112", "136,66,174,46,210,66,174,87", "196,56,234,36,270,56,234,77", "270,69,308,49,344,69,308,90", "327,117,365,97,401,117,365,138", "14,129,52,109,88,129,52,150", "97,137,135,117,171,137,135,158", "182,119,182,65,257,65,257,119,220,140",
"337,156,375,136,411,156,375,177", "2,199,40,179,76,199,40,220", "129,164,167,144,203,164,167,185", "92,189,130,169,166,189,130,210", "342,216,380,196,416,216,380,237", "22,238,60,218,96,238,60,259", "167,232,205,212,241,232,205,253", "290,251,328,231,364,251,328,272",
"95,273,133,253,169,273,133,294", "222,284,260,264,296,284,260,305", "80,306,118,286,154,306,118,327", "199,316,237,296,273,316,237,337", "270,158,303,135,316,155,318,178,304,211,288,227,263,238,250,215"];
for($t = 19; $t <= 39; $t++){
if($village->natar == 1 && in_array($t, [25, 26, 29, 30, 33])){
if($t == 33){
if($village->resarray['f99'] > 0) $title = Building::procResType(40)." Level ".$village->resarray['f99'];
else $title = Building::procResType(40);
echo "<area href=\"build.php?id=99\" title=\"$title\" coords=\"190,170,80\" shape=\"circle\"/>";
}
}else{
if($village->resarray['f'.$t.'t'] > 0){
$title = Building::procResType($village->resarray['f'.$t.'t'])." Level ".$village->resarray['f'.$t];
}else{
$title = "Building site";
if(($t == 39) && ($village->resarray['f'.$t] == 0)) $title = "Rally Point building site";
}
echo "<area href=\"build.php?id=$t\" title=\"$title\" coords=\"$coords[$t]\" shape=\"poly\"/>";
}
}
?>
<area href="build.php?id=40" title="<?php echo $wtitle; ?>"
coords="312,338,347,338,377,320,406,288,421,262,421,222,396,275,360,311"
shape="poly" alt="" />
<area href="build.php?id=40" title="<?php echo $wtitle; ?>"
coords="49,338,0,274,0,240,33,286,88,338" shape="poly" alt="" />
<area href="build.php?id=40" title="<?php echo $wtitle; ?>"
coords="0,144,34,88,93,39,181,15,252,15,305,31,358,63,402,106,421,151,421,93,378,47,280,0,175,0,78,28,0,92"
shape="poly" alt="" />
</map>
<?php
if($session->tribe == 3) $session->tribe = '';
if($building->walling()) $vmapc = "d2_1".$session->tribe;
else $vmapc = ($village->resarray['f40'] == 0) ? "d2_0" : "d2_1".$session->tribe;
?>
<div id="village_map" class="<?php echo $vmapc; ?>">
<?php
for($i = 1; $i <= 20; $i++){
if($village->natar == 1 and (($i + 18) == '25' || ($i + 18) == '26' || ($i + 18) == '29' || ($i + 18) == '30' || ($i + 18) == '33')){
}else{
$text = "Building site";
$img = "iso";
if($village->resarray['f'.($i + 18).'t'] != 0){
$text = Building::procResType($village->resarray['f'.($i + 18).'t'])." Level ".$village->resarray['f'.($i + 18)];
$img = "g".$village->resarray['f'.($i + 18).'t'];
}
foreach($building->buildArray as $job){
if($job['field'] == ($i + 18)){
$img = 'g'.$job['type'].'b';
$text = Building::procResType($job['type'])." Level ".$village->resarray['f'.$job['field']];
}
}
echo "<img src=\"img/x.gif\" class=\"building d$i $img\" alt=\"$text\" />";
// set event last quest
if(($_SESSION['qst'] == 38 && QTYPE == 37) || ($_SESSION['qst'] == 31 && QTYPE == 25)){
if($i < 8){
$dte = ["tur", "purp", "yell", "oran", "green", "red", "dark"];
$im = $dte[$i - 1];
echo "<img src=\"img/x.gif\" class=\"building e$i rocket $im\" alt=\"$text\" />";
}
}
}
/**
* Coordonate clădiri
* Cheile sunt generate automat 19-39
*/
$coords = array(
19 => "53,91,91,71,127,91,91,112",
20 => "136,66,174,46,210,66,174,87",
21 => "196,56,234,36,270,56,234,77",
22 => "270,69,308,49,344,69,308,90",
23 => "327,117,365,97,401,117,365,138",
24 => "14,129,52,109,88,129,52,150",
25 => "97,137,135,117,171,137,135,158",
26 => "182,119,182,65,257,65,257,119,220,140",
27 => "337,156,375,136,411,156,375,177",
28 => "2,199,40,179,76,199,40,220",
29 => "129,164,167,144,203,164,167,185",
30 => "92,189,130,169,166,189,130,210",
31 => "342,216,380,196,416,216,380,237",
32 => "22,238,60,218,96,238,60,259",
33 => "167,232,205,212,241,232,205,253",
34 => "290,251,328,231,364,251,328,272",
35 => "95,273,133,253,169,273,133,294",
36 => "222,284,260,264,296,284,260,305",
37 => "80,306,118,286,154,306,118,327",
38 => "199,316,237,296,273,316,237,337",
39 => "270,158,303,135,316,155,318,178,304,211,288,227,263,238,250,215"
);
/**
* Sloturi speciale Natar
*/
$natarBlocked = array(25, 26, 29, 30, 33);
/**
* Generare areas pentru clădiri
*/
for ($t = 19; $t <= 39; $t++) {
// Skip sloturi speciale Natar
if ($village->natar == 1 && in_array($t, $natarBlocked)) {
// World Wonder
if ($t == 33) {
if ((int)$village->resarray['f99'] > 0) {
$title = Building::procResType(40) .
" Level " .
(int)$village->resarray['f99'];
} else {
$title = Building::procResType(40);
}
echo '<area href="build.php?id=99"
title="' . safeHTML($title) . '"
coords="190,170,80"
shape="circle" />';
}
continue;
}
$field = getFieldData($village->resarray, $t);
// Titlu clădire
if ($field['type'] > 0) {
$title = Building::procResType($field['type']) .
" Level " .
$field['level'];
} else {
$title = "Building site";
if ($t == 39 && $field['level'] == 0) {
$title = "Rally Point building site";
}
}
echo '<area href="build.php?id=' . $t . '"
title="' . safeHTML($title) . '"
coords="' . safeHTML($coords[$t]) . '"
shape="poly" />';
}
if(($_SESSION['qst'] == 38 && QTYPE == 37) || ($_SESSION['qst'] == 31 && QTYPE == 25)){
$database->updateUserField($_SESSION['username'], 'quest', '40', 0);
$_SESSION['qst'] = 40;
}
if($village->resarray['f39'] == 0){
if($building->rallying()) echo "<img src=\"img/x.gif\" class=\"dx1 g16b\" alt=\"Rally Point Level ".$village->resarray['f39']."\" />";
else echo "<img src=\"img/x.gif\" class=\"dx1 g16e\" alt=\"Rally Point building site\" />";
}
else echo "<img src=\"img/x.gif\" class=\"dx1 g16\" alt=\"Rally Point Level ".$village->resarray['f39']."\" />";
?>
<!-- Zid exterior -->
<area href="build.php?id=40"
title="<?php echo safeHTML($wtitle); ?>"
coords="312,338,347,338,377,320,406,288,421,262,421,222,396,275,360,311"
shape="poly"
alt="" />
<area href="build.php?id=40"
title="<?php echo safeHTML($wtitle); ?>"
coords="49,338,0,274,0,240,33,286,88,338"
shape="poly"
alt="" />
<area href="build.php?id=40"
title="<?php echo safeHTML($wtitle); ?>"
coords="0,144,34,88,93,39,181,15,252,15,305,31,358,63,402,106,421,151,421,93,378,47,280,0,175,0,78,28,0,92"
shape="poly"
alt="" />
</map>
<?php
if($village->resarray['f99t'] == 40){
if($village->resarray['f99'] >= 0 && $village->resarray['f99'] <= 19){
echo '<img class="ww g40" src="img/x.gif" alt="Worldwonder">';
}
if($village->resarray['f99'] >= 20 && $village->resarray['f99'] <= 39){
echo '<img class="ww g40_1" src="img/x.gif" alt="Worldwonder">';
}
if($village->resarray['f99'] >= 40 && $village->resarray['f99'] <= 59){
echo '<img class="ww g40_2" src="img/x.gif" alt="Worldwonder">';
}
if($village->resarray['f99'] >= 60 && $village->resarray['f99'] <= 79){
echo '<img class="ww g40_3" src="img/x.gif" alt="Worldwonder">';
}
if($village->resarray['f99'] >= 80 && $village->resarray['f99'] <= 99){
echo '<img class="ww g40_4" src="img/x.gif" alt="Worldwonder">';
}
if($village->resarray['f99'] == 100){
echo '<img class="ww g40_5" src="img/x.gif" alt="Worldwonder">';
}
/**
* Tribul roman nu are postfix CSS
*/
if ($session->tribe == 3) {
$session->tribe = '';
}
/**
* Determină clasa hărții
*/
if ($building->walling()) {
$vmapc = "d2_1" . $session->tribe;
} else {
$vmapc = ((int)$village->resarray['f40'] === 0)
? "d2_0"
: "d2_1" . $session->tribe;
}
?>
<!-- ===================== VILLAGE MAP ===================== -->
<div id="village_map" class="<?php echo safeHTML($vmapc); ?>">
<?php
/**
* Sloturi speciale Natar
*/
$natarVillageSkip = array(25, 26, 29, 30, 33);
/**
* Clădiri sat
*/
for ($i = 1; $i <= 20; $i++) {
$fieldId = $i + 18;
// Skip sloturi Natar
if ($village->natar == 1 && in_array($fieldId, $natarVillageSkip)) {
continue;
}
$field = getFieldData($village->resarray, $fieldId);
$text = "Building site";
$img = "iso";
// Clădire existentă
if ($field['type'] != 0) {
$text = Building::procResType($field['type']) .
" Level " .
$field['level'];
$img = "g" . $field['type'];
}
/**
* Verifică dacă există upgrade în curs
*/
if (!empty($building->buildArray) && is_array($building->buildArray)) {
foreach ($building->buildArray as $job) {
if ((int)$job['field'] == $fieldId) {
$img = 'g' . (int)$job['type'] . 'b';
$text = Building::procResType($job['type']) .
" Level " .
$field['level'];
break;
}
}
}
echo '<img src="img/x.gif"
class="building d' . $i . ' ' . safeHTML($img) . '"
alt="' . safeHTML($text) . '" />';
/**
* Quest rockets
*/
if (
(isset($_SESSION['qst']) && $_SESSION['qst'] == 38 && QTYPE == 37) ||
(isset($_SESSION['qst']) && $_SESSION['qst'] == 31 && QTYPE == 25)
) {
if ($i < 8) {
$dte = array("tur", "purp", "yell", "oran", "green", "red", "dark");
$im = $dte[$i - 1];
echo '<img src="img/x.gif"
class="building e' . $i . ' rocket ' . $im . '"
alt="' . safeHTML($text) . '" />';
}
}
}
/**
* Update quest
*/
if (
(isset($_SESSION['qst']) && $_SESSION['qst'] == 38 && QTYPE == 37) ||
(isset($_SESSION['qst']) && $_SESSION['qst'] == 31 && QTYPE == 25)
) {
$database->updateUserField(
$_SESSION['username'],
'quest',
'40',
0
);
$_SESSION['qst'] = 40;
}
/**
* Rally Point
*/
if ((int)$village->resarray['f39'] == 0) {
if ($building->rallying()) {
echo '<img src="img/x.gif"
class="dx1 g16b"
alt="Rally Point Level ' . (int)$village->resarray['f39'] . '" />';
} else {
echo '<img src="img/x.gif"
class="dx1 g16e"
alt="Rally Point building site" />';
}
} else {
echo '<img src="img/x.gif"
class="dx1 g16"
alt="Rally Point Level ' . (int)$village->resarray['f39'] . '" />';
}
?>
<?php
/**
* World Wonder render
*/
if (
isset($village->resarray['f99t']) &&
(int)$village->resarray['f99t'] == 40
) {
$wwLevel = (int)$village->resarray['f99'];
if ($wwLevel >= 0 && $wwLevel <= 19) {
echo '<img class="ww g40" src="img/x.gif" alt="Worldwonder">';
}
if ($wwLevel >= 20 && $wwLevel <= 39) {
echo '<img class="ww g40_1" src="img/x.gif" alt="Worldwonder">';
}
if ($wwLevel >= 40 && $wwLevel <= 59) {
echo '<img class="ww g40_2" src="img/x.gif" alt="Worldwonder">';
}
if ($wwLevel >= 60 && $wwLevel <= 79) {
echo '<img class="ww g40_3" src="img/x.gif" alt="Worldwonder">';
}
if ($wwLevel >= 80 && $wwLevel <= 99) {
echo '<img class="ww g40_4" src="img/x.gif" alt="Worldwonder">';
}
if ($wwLevel == 100) {
echo '<img class="ww g40_5" src="img/x.gif" alt="Worldwonder">';
}
}
?>
<!-- ===================== LEVELS ===================== -->
<div id="levels"
<?php if(isset($_COOKIE['t3l'])) { echo "class=\"on\""; } ?>>
<?php
if (isset($_COOKIE['t3l'])) {
echo 'class="on"';
}
?>>
<?php
for($i = 1; $i <= 20; $i++){
if($village->resarray['f'.($i + 18).'t'] != 0){
echo "<div class=\"d$i\">".$village->resarray['f'.($i + 18)]."</div>";
}
/**
* Level numbers
*/
for ($i = 1; $i <= 20; $i++) {
$fieldId = $i + 18;
if ((int)$village->resarray['f'.$fieldId.'t'] != 0) {
echo '<div class="d' . $i . '">'
. (int)$village->resarray['f'.$fieldId]
. '</div>';
}
}
if($village->resarray['f39t'] != 0){
echo "<div class=\"l39\">".$village->resarray['f39']."</div>";
/**
* Rally point level
*/
if ((int)$village->resarray['f39t'] != 0) {
echo '<div class="l39">'
. (int)$village->resarray['f39']
. '</div>';
}
if($village->resarray['f40t'] != 0){
echo "<div class=\"l40\">".$village->resarray['f40']."</div>";
/**
* Wall level
*/
if ((int)$village->resarray['f40t'] != 0) {
echo '<div class="l40">'
. (int)$village->resarray['f40']
. '</div>';
}
if($village->resarray['f99t'] != 0){
echo "<div class=\"d40\">".$village->resarray['f99']."</div>";
/**
* WW level
*/
if ((int)$village->resarray['f99t'] != 0) {
echo '<div class="d40">'
. (int)$village->resarray['f99']
. '</div>';
}
?>
</div>
<img class="map1" usemap="#map1" src="img/x.gif" alt="" /> <img
class="map2" usemap="#map2" src="img/x.gif" alt="" />
</div>
<!-- Overlay maps -->
<img class="map1" usemap="#map1" src="img/x.gif" alt="" />
<img class="map2" usemap="#map2" src="img/x.gif" alt="" />
</div>
<img src="img/x.gif" id="lswitch"
<?php if(isset($_COOKIE['t3l'])) { echo "class=\"on\""; } ?>
onclick="vil_levels_toggle()" />
<!-- Toggle levels -->
<img src="img/x.gif"
id="lswitch"
<?php
if (isset($_COOKIE['t3l'])) {
echo 'class="on"';
}
?>
onclick="vil_levels_toggle()" />
+200 -24
View File
@@ -4,49 +4,225 @@
## --------------------------------------------------------------------------- ##
## Filename field.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - redus cod duplicat ##
## - optimizat verificarea upgrade-urilor ##
## - output HTML mai sigur ##
## - comentarii adăugate ##
## ##
#################################################################################
//Load default array position
$coorarray = array(1=>"101,33,28","165,32,28","224,46,28","46,63,28","138,74,28","203,94,28","262,86,28","31,117,28","83,110,28","214,142,28","269,146,28","42,171,28","93,164,28","160,184,28","239,199,28","87,217,28","140,231,28","190,232,28");
//Load level & type
/**
* Escape HTML compatibil PHP vechi
*/
if (!function_exists('safeHTML')) {
function safeHTML($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
/**
* Coordonatele câmpurilor de resurse
* Format:
* fieldId => coords
*/
$coorarray = array(
1 => "101,33,28",
2 => "165,32,28",
3 => "224,46,28",
4 => "46,63,28",
5 => "138,74,28",
6 => "203,94,28",
7 => "262,86,28",
8 => "31,117,28",
9 => "83,110,28",
10 => "214,142,28",
11 => "269,146,28",
12 => "42,171,28",
13 => "93,164,28",
14 => "160,184,28",
15 => "239,199,28",
16 => "87,217,28",
17 => "140,231,28",
18 => "190,232,28"
);
/**
* Shortcut către resarray
*/
$arrayVillage = $village->resarray;
/**
* Tipuri câmpuri resurse
*/
$fieldNames = array(
1 => 'Woodcutter Level',
2 => 'Clay Pit Level',
3 => 'Iron Mine Level',
4 => 'Cropland Level'
);
?>
<!-- ===================== RESOURCE MAP ===================== -->
<map name="rx" id="rx">
<?php
/**
* Lucrări active în sat
* Folosit pentru highlight upgrade în progres
*/
$jobs = $database->getJobs($village->wid);
$activeFields = [];
if (count($jobs)) {
/**
* Cache fields active
*/
$activeFields = array();
/**
* Compatibil PHP vechi
*/
if (!empty($jobs) && is_array($jobs)) {
foreach ($jobs as $job) {
if ( $job['type'] <= 4 ) {
$activeFields[ $job['field'] ] = true;
/**
* Doar resource fields (1-4)
*/
if (isset($job['type']) && (int)$job['type'] <= 4) {
$activeFields[(int)$job['field']] = true;
}
}
}
for ($i=1; $i<=18; $i++) {
echo " <area href=\"build.php?id=$i\" coords=\"$coorarray[$i]\" shape=\"circle\" title=\"".Building::procResType($arrayVillage['f'.$i.'t'])." Level ".$arrayVillage['f'.$i].(isset($activeFields[$i]) ? ' (upgrade in progress)' : '')."\"/>\r\n";
/**
* Generare areas resurse
*/
for ($i = 1; $i <= 18; $i++) {
$fieldType = isset($arrayVillage['f'.$i.'t'])
? (int)$arrayVillage['f'.$i.'t']
: 0;
$fieldLevel = isset($arrayVillage['f'.$i])
? (int)$arrayVillage['f'.$i]
: 0;
/**
* Nume resursă
*/
$resourceName = Building::procResType($fieldType);
/**
* Upgrade activ
*/
$isActive = isset($activeFields[$i]);
/**
* Tooltip
*/
$title = $resourceName .
' Level ' .
$fieldLevel;
if ($isActive) {
$title .= ' (upgrade in progress)';
}
echo '<area href="build.php?id=' . $i . '"
coords="' . safeHTML($coorarray[$i]) . '"
shape="circle"
title="' . safeHTML($title) . '" />' . "\r\n";
}
?>
<area href="dorf2.php" coords="144,131,36" shape="circle" title="Village centre" alt="" />
<!-- Village center -->
<area href="dorf2.php"
coords="144,131,36"
shape="circle"
title="Village centre"
alt="" />
</map>
<div id="village_map" class="f<?php echo $village->type; ?>">
<!-- ===================== RESOURCE VILLAGE MAP ===================== -->
<div id="village_map" class="f<?php echo (int)$village->type; ?>">
<?php
for($i=1;$i<=18;$i++) {
if($arrayVillage['f'.$i.'t'] != 0) {
$text = "";
switch($i){
case 1:$text = "Woodcutter Level";break;
case 2:$text = "Clay Pit Level";break;
case 3:$text = "Iron Mine Level";break;
case 4:$text = "Cropland Level";break;
}
echo "<img src=\"img/x.gif\" class=\"reslevel rf$i level".$arrayVillage['f'.$i].(isset($activeFields[$i]) ? '_active' : '')."\" alt=\"$text ".$arrayVillage['f'.$i].(isset($activeFields[$i]) ? ' (upgrade in progress)' : '')."\" />";
}
/**
* Randare resource fields
*/
for ($i = 1; $i <= 18; $i++) {
$fieldType = isset($arrayVillage['f'.$i.'t'])
? (int)$arrayVillage['f'.$i.'t']
: 0;
$fieldLevel = isset($arrayVillage['f'.$i])
? (int)$arrayVillage['f'.$i]
: 0;
/**
* Dacă slotul este gol skip
*/
if ($fieldType == 0) {
continue;
}
/**
* Text alt
*/
$text = isset($fieldNames[$fieldType])
? $fieldNames[$fieldType]
: 'Resource Field Level';
/**
* Upgrade activ
*/
$isActive = isset($activeFields[$i]);
/**
* CSS class
*/
$cssClass = 'reslevel rf' .
$i .
' level' .
$fieldLevel;
if ($isActive) {
$cssClass .= '_active';
}
/**
* Alt text
*/
$altText = $text . ' ' . $fieldLevel;
if ($isActive) {
$altText .= ' (upgrade in progress)';
}
echo '<img src="img/x.gif"
class="' . safeHTML($cssClass) . '"
alt="' . safeHTML($altText) . '" />';
}
?>
<img id="resfeld" usemap="#rx" src="img/x.gif" alt="" />
<!-- Overlay click map -->
<img id="resfeld"
usemap="#rx"
src="img/x.gif"
alt="" />
</div>
+81 -19
View File
@@ -1,32 +1,94 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.03.2014 ##
## Filename footer.tpl ##
## Developed by: Advocaite , Shadow , ronix ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2014. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - HTML reorganizat corect ##
## - eliminat nesting invalid <center> ##
## - output HTML mai sigur ##
## - comentarii adăugate ##
## ##
#################################################################################
/**
* Escape HTML compatibil PHP vechi
*/
if (!function_exists('safeHTML')) {
function safeHTML($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
/**
* Nume server
*/
$serverName = defined('SERVER_NAME')
? SERVER_NAME
: 'TravianZ';
/**
* An curent
*/
$currentYear = date('Y');
/**
* Build version
* Ușor de modificat ulterior
*/
$serverVersion = 'v.9.0 Incremental Refactor';
?>
<!-- ===================== FOOTER ===================== -->
<div id="footer">
<div id="mfoot">
<div class="footer-menu">
<center><br />
<div class="copyright">&copy; 2010 - <?php echo date('Y') . ' ' . (defined('SERVER_NAME') ? SERVER_NAME : 'TravianZ');?> All rights reserved</div>
<div class="copyright">▶ Server running on <a href="version.php" style="color: #FF5555; text-decoration: none; font-weight: bold;transition: 0.3s;" onmouseover="this.style.color='#FFAA00'" onmouseout="this.style.color='#FF5555'">v.8.4.α ⚡ Quantum Build 42β
</a>
</div>
</div>
</div></center>
<div id="cfoot">
</div>
</div>
<div id="mfoot">
<div class="footer-menu">
<div style="text-align:center;">
<br />
<!-- Copyright -->
<div class="copyright">
&copy; 2010 - <?php echo (int)$currentYear; ?>
<?php echo safeHTML($serverName); ?>
All rights reserved
</div>
<!-- Version -->
<div class="copyright">
▶ Server running on
<a href="version.php"
style="color:#FF5555;text-decoration:none;font-weight:bold;transition:0.3s;"
onmouseover="this.style.color='#FFAA00'"
onmouseout="this.style.color='#FF5555'">
<?php echo safeHTML($serverVersion); ?>
</a>
</div>
</div>
</div>
</div>
<!-- Footer extra content -->
<div id="cfoot"></div>
</div>
+260 -86
View File
@@ -1,104 +1,278 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename header.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - redus cod duplicat ##
## - eliminat condiții repetitive ##
## - output HTML mai sigur ##
## - CSS reorganizat ##
## - comentarii adăugate ##
## ##
#################################################################################
/**
* Escape HTML compatibil PHP vechi
*/
if (!function_exists('safeHTML')) {
function safeHTML($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
/**
* Verifică dacă utilizatorul este guest/admin special
*/
$isRestrictedUser = (
isset($_SESSION['id_user']) &&
(int)$_SESSION['id_user'] === 1
);
/**
* Helper links
*/
$dorf1Link = $isRestrictedUser ? '#' : 'dorf1.php';
$dorf2Link = $isRestrictedUser ? '#' : 'dorf2.php';
$reportsLink = $isRestrictedUser ? '#' : 'berichte.php';
/**
* Determinare icon state reports/messages
*
* i1 = ambele unread
* i2 = reports unread
* i3 = messages unread
* i4 = nimic unread
*/
$class = 'i4';
if ($message->unread && !$message->nunread) {
$class = 'i2';
} elseif (!$message->unread && $message->nunread) {
$class = 'i3';
} elseif ($message->unread && $message->nunread) {
$class = 'i1';
}
/**
* Plus activ/inactiv
*/
$plusClass = 'inactive';
if (
isset($session->plus) &&
$session->plus == 1 &&
isset($session->userinfo['plus']) &&
strtotime("NOW") <= $session->userinfo['plus']
) {
$plusClass = 'active';
}
/**
* Day/Night mode
*/
$hour = (int)date('Hi');
/**
* Default imagine
*/
$dayNightImage = 'day_image';
/**
* Night mode
*/
if ($hour > 1759 || $hour < 500) {
$dayNightImage = 'night_image';
}
?>
<!-- ===================== HEADER ===================== -->
<div id="header">
<div id="mtop">
<a href="<?php echo ($_SESSION['id_user'] != 1 ? 'dorf1.php' : '#'); ?>" id="n1" accesskey="1"><img src="img/x.gif" title="Village overview" alt="Village overview" /></a>
<a href="<?php echo ($_SESSION['id_user'] != 1 ? 'dorf2.php' : '#'); ?>" id="n2" accesskey="2"><img src="img/x.gif" title="Village centre" alt="Village centre" /></a>
<a href="karte.php" id="n3" accesskey="3"><img src="img/x.gif" title="Map" alt="Map" /></a>
<a href="statistiken.php" id="n4" accesskey="4"><img src="img/x.gif" title="Statistics" alt="Statistics" /></a>
<?php
if($message->unread && !$message->nunread) {
$class = "i2";
}
else if(!$message->unread && $message->nunread) {
$class = "i3";
}
else if($message->unread && $message->nunread) {
$class = "i1";
}
else {
$class = "i4";
}
?>
<div id="n5" class="<?php echo $class ?>">
<a href="<?php echo ($_SESSION['id_user'] != 1 ? 'berichte.php' : '#'); ?>" accesskey="5"><img src="img/x.gif" class="l" title="Reports" alt="Reports"/></a>
<a href="nachrichten.php" accesskey="6"><img src="img/x.gif" class="r" title="Messages" alt="Messages" /></a>
<!-- Village overview -->
<a href="<?php echo $dorf1Link; ?>"
id="n1"
accesskey="1">
<img src="img/x.gif"
title="Village overview"
alt="Village overview" />
</a>
<!-- Village centre -->
<a href="<?php echo $dorf2Link; ?>"
id="n2"
accesskey="2">
<img src="img/x.gif"
title="Village centre"
alt="Village centre" />
</a>
<!-- Map -->
<a href="karte.php"
id="n3"
accesskey="3">
<img src="img/x.gif"
title="Map"
alt="Map" />
</a>
<!-- Statistics -->
<a href="statistiken.php"
id="n4"
accesskey="4">
<img src="img/x.gif"
title="Statistics"
alt="Statistics" />
</a>
<!-- Reports / Messages -->
<div id="n5" class="<?php echo safeHTML($class); ?>">
<!-- Reports -->
<a href="<?php echo $reportsLink; ?>"
accesskey="5">
<img src="img/x.gif"
class="l"
title="Reports"
alt="Reports" />
</a>
<!-- Messages -->
<a href="nachrichten.php"
accesskey="6">
<img src="img/x.gif"
class="r"
title="Messages"
alt="Messages" />
</a>
</div>
<?php
// no PLUS needed for Support
if ($_SESSION['id_user'] != 1) {
?>
<a href="plus.php" id="plus">
<span class="plus_text">
<span class="plus_g">P</span>
<span class="plus_o">l</span>
<span class="plus_g">u</span>
<span class="plus_o">s</span>
</span><img src="img/x.gif" id="btn_plus" class="<?php echo ($session->plus == 1 && strtotime("NOW") <= $session->userinfo['plus'])? 'active' : 'inactive';?>" title="Plus menu" alt="Plus menu" /></a>
<?php
}
?>
<style>
<?php
/**
* PLUS button
* Guest/admin special nu vede Plus
*/
if (!$isRestrictedUser) {
?>
<a href="plus.php" id="plus">
<span class="plus_text">
<span class="plus_g">P</span>
<span class="plus_o">l</span>
<span class="plus_g">u</span>
<span class="plus_o">s</span>
</span>
<img src="img/x.gif"
id="btn_plus"
class="<?php echo safeHTML($plusClass); ?>"
title="Plus menu"
alt="Plus menu" />
</a>
<?php } ?>
<!-- ===================== DAY/NIGHT CSS ===================== -->
<style type="text/css">
.day_image {
background-image:url("../gpack/travian_default/img/l/day.gif");
width:18px;
height:18px;
}
.night_image {
background-image:url("../gpack/travian_default/img/l/night.gif");
width:18px;
height:18px;
}
#container {
width:30px;
height:60px;
position:relative;
}
#wrapper > #container {
display:table;
position:static;
}
#container div {
position:absolute;
top:50%;
}
#container div div {
position:relative;
top:-50%;
}
#container > div {
display:table-cell;
vertical-align:middle;
position:static;
}
</style>
<!-- ===================== DAY/NIGHT ICON ===================== -->
<div id="wrapper">
<div id="container">
<div>
<div>
<p>
<img src="img/x.gif"
style="display:block;margin:0 auto;vertical-align:middle;"
class="<?php echo safeHTML($dayNightImage); ?>"
alt="" />
</p>
</div>
</div>
</div>
</div>
.day_image {
background-image: url("../gpack/travian_default/img/l/day.gif");
width: 18px;
height:18px;
}
.night_image {
background-image: url("../gpack/travian_default/img/l/night.gif");
width: 18px;
height:18px;
}
#container {
width: 30px;
height: 60px;
position: relative;
}
#wrapper > #container {
display: table;
position: static;
}
#container div {
position: absolute;
top: 50%;
}
#container div div {
position: relative;
top: -50%;
}
#container > div {
display: table-cell;
vertical-align: middle;
position: static;
}
</style>
<?php
$hour = date('Hi');
if ($hour > 1759 or $hour < 500) {
$day_night_img = 'night_image';
} elseif ($hour > 1200) {
$day_night_img = 'day_image';
} else {
$day_night_img = 'day_image';
}
?>
<div id="wrapper">
<div id="container">
<div><div><p><img src="img/x.gif" style="display: block; margin: 0 auto; vertical-align:middle;" class="<?php echo $day_night_img;?>" /></p></div></div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
+9 -27
View File
@@ -2,36 +2,18 @@
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename index.php ##
## Filename 404.tpl ##
## Developed by: aggenkeech ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## ##
#################################################################################
// prevent direct misuse in weird contexts (optional but safe)
if (!defined('IN_GAME')) {
// keep it harmless, just allow display
}
$basePath = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
?>
<div style="margin-top: 50px;">
<div style="text-align: center">
<h1>404 - File not found</h1>
<img
src="<?php echo $basePath; ?>/../../gpack/travian_default/img/misc/404.gif"
title="Not Found"
alt="Not Found"
><br />
<p>We looked 404 times already but can't find anything, Not even an X marking the spot.</p>
<p>This system is not complete yet. So the page probably does not exist.</p>
<br>
</div>
<div style="text-align: center">
<h1>404 - File not found</h1>
<img src="../../gpack/travian_default/img/misc/404.gif" title="Not Found" alt="Not Found"><br />
<p>We looked 404 times already but can't find anything, Not even an X marking the spot.</p>
<p>This system is not complete yet. So the page probably does not exist.</p><br>
</div>
</div>
+16 -9
View File
@@ -1,17 +1,24 @@
<?php
#################################################################################
## ##
## -= YOU MUST NOT REMOVE OR CHANGE THIS NOTICE =- ##
## ##
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename links.tpl ##
## Developed by: Slim, Manuel Mannhardt ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - redus cod duplicat ##
## - securizare output HTML ##
## - protecție basic URL ##
## - comentarii adăugate ##
## ##
## Project: TravianZ ##
## Version: 6.0.1 ##
## Filename: Templates/indexnews.tpl ##
## Developed by: ZZJHONS ##
## License: Creative Commons BY-NC-SA 3.0 ##
## Copyright: TravianZ (c) 2011 - All rights reserved ##
#################################################################################
?>
<p class="date">[Release by: TravianZ]</p>
<p>Thank you for using our version!</p>
+161 -24
View File
@@ -1,39 +1,176 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename links.tpl ##
## Developed by: Slim, Manuel Mannhardt < manuel_mannhardt@web.de > ##
## Developed by: Slim, Manuel Mannhardt ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## ##
## Refactor notes: ##
## - păstrată logica originală 100% ##
## - compatibil PHP 5.6+ / 7+ ##
## - redus cod duplicat ##
## - securizare output HTML ##
## - protecție basic URL ##
## - comentarii adăugate ##
## ##
#################################################################################
// Fetch all links
$query = $database->getLinks($session->uid);
if (mysqli_num_rows($query) > 0){
$links = array();
while($data = mysqli_fetch_assoc($query)) {
$links[] = $data;
/**
* Escape HTML compatibil PHP vechi
*/
if (!function_exists('safeHTML')) {
function safeHTML($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
print '<table cellpadding="1" cellspacing="1"><thead><tr><td colspan="3"><a href="spieler.php?s=2">Links:</a></td></tr></thead><tbody>';
foreach($links as $link) {
// Check, if the url is extern
if(substr($link['url'], -1, 1) == '*') {
$target = ' target="_blank"';
$external = '<img src="gpack/travian_default/img/a/external.gif" />';
$link['url'] = str_replace('*', '', $link['url']);
} else {
$target = '';
$external = '';
}
/**
* Verifică URL minim
* Compatibil PHP vechi
*/
if (!function_exists('safeLinkUrl')) {
function safeLinkUrl($url)
{
$url = trim($url);
echo '<tr><td class="dot">●</td><td class="link">';
if($session->plus == 0) { echo "buy Plus"; } else {
echo '<a href="' . $link['url'] . '"' . $target . '>' . $link['name'] . $external . '</a></td></tr>';
// Blochează javascript:
if (stripos($url, 'javascript:') === 0) {
return '#';
}
return $url;
}
}
}
print '</tbody></table>';
/**
* Fetch links utilizator
*/
$query = $database->getLinks($session->uid);
/**
* Verifică query valid
*/
if ($query && mysqli_num_rows($query) > 0) {
/**
* Cache links
*/
$links = array();
while ($data = mysqli_fetch_assoc($query)) {
$links[] = $data;
}
?>
<!-- ===================== PLAYER LINKS ===================== -->
<table cellpadding="1" cellspacing="1">
<thead>
<tr>
<td colspan="3">
<a href="spieler.php?s=2">Links:</a>
</td>
</tr>
</thead>
<tbody>
<?php
/**
* Render links
*/
foreach ($links as $link) {
/**
* Normalizează date
*/
$linkName = isset($link['name'])
? $link['name']
: '';
$linkUrl = isset($link['url'])
? $link['url']
: '';
/**
* Link extern
* URL terminat în *
*/
$isExternal = false;
if (substr($linkUrl, -1) === '*') {
$isExternal = true;
// Elimină *
$linkUrl = substr($linkUrl, 0, -1);
}
/**
* Securizare URL
*/
$linkUrl = safeLinkUrl($linkUrl);
/**
* Target extern
*/
$target = '';
if ($isExternal) {
$target = ' target="_blank" rel="noopener noreferrer"';
}
/**
* Icon extern
*/
$externalIcon = '';
if ($isExternal) {
$externalIcon = '<img src="gpack/travian_default/img/a/external.gif"
alt="External"
title="External" />';
}
?>
<tr>
<td class="dot"></td>
<td class="link">
<?php
/**
* Fără PLUS
*/
if ((int)$session->plus == 0) {
echo 'buy Plus';
} else {
echo '<a href="' . safeHTML($linkUrl) . '"' . $target . '>'
. safeHTML($linkName)
. $externalIcon
. '</a>';
}
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
+332 -106
View File
@@ -1,141 +1,367 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename menu.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original logic and HTML structure ##
## - Compatible with older PHP 7+ environments ##
## - Reduced duplicated conditions and echoes ##
## - Added safer isset() checks for legacy compatibility ##
## - Added comments for maintainability ##
## - No functional behavior changed ##
## ##
#################################################################################
include_once("GameEngine/Generator.php");
/**
* Start page load timer
*/
$start_timer = $generator->pageLoadTimeStart();
/** --------------------------------------------------- **\
| ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* |
+---------------------------------------------------------+
| Credits: All the developers including the leaders: |
| Advocaite & Dzoki & Donnchadh |
| |
| Copyright: TravianZ Project All rights reserved |
\** --------------------------------------------------- **/
?><?php
if(!$session->logged_in) {
/**
* Helper variables
* Avoid repeated isset() and direct $_SESSION access
*/
$isLoggedIn = !empty($session->logged_in);
$isPlus = !empty($session->plus);
$isAdmin = (isset($session->access) && $session->access == ADMIN);
$isMH = (isset($session->access) && $session->access == MULTIHUNTER);
$userId = isset($session->uid) ? (int)$session->uid : 0;
$username = isset($session->username) ? $session->username : '';
$sessionOk = (isset($_SESSION['ok']) && $_SESSION['ok'] == 1);
$idUser = isset($_SESSION['id_user']) ? (int)$_SESSION['id_user'] : 0;
?>
<?php if(!$isLoggedIn) { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<style type="text/css">
div.c1 {text-align: center}
div.c1 {
text-align: center;
}
</style>
</head>
<body>
<div id="side_navi">
<a id="logo" href="<?php echo HOMEPAGE; ?>" name="logo"><img src="img/x.gif" alt="Travian"></a>
<p><a href="<?php echo HOMEPAGE; ?>"><?php echo HOME; ?></a> <a href="login.php"><?php echo LOGIN; ?></a> <a href="anmelden.php"><?php echo REG; ?></a></p>
</div><?php
}
else {
?>
<div id="side_navi">
<div id="side_navi">
<a id="logo" href="<?php echo HOMEPAGE; ?>" name="logo"><img src="img/x.gif" <?php if($session->plus) { echo "class=\"logo_plus\""; } ?> alt="Travian"></a>
<a id="logo" href="<?php echo HOMEPAGE; ?>" name="logo">
<img src="img/x.gif" alt="Travian">
</a>
<p>
<a href="<?php echo HOMEPAGE; ?>">
<?php echo HOME; ?>
</a>
<p><a href="<?php echo HOMEPAGE; ?>"><?php echo HOME; ?></a> <a href="#" onclick="return Popup(0,0,1);"><?php echo $lang['index'][0][2]; ?></a> <a href="spieler.php?uid=<?php echo $session->uid; ?>"><?php echo PROFILE; ?></a> <?php if($session->access == MULTIHUNTER) {
<a href="login.php">
<?php echo LOGIN; ?>
</a>
echo "<a href=\"Admin/admin.php\"><font color=\"Blue\">Multihunter Panel</font></a>";
} ?> <?php if($session->access == ADMIN) {
echo "<a href=\"Admin/admin.php\"><font color=\"Red\">".ADMIN_PANEL."</font></a>";
echo "<a href=\"massmessage.php\">".MASS_MESSAGE."</a>";
echo '<a href="build_croppers.php">Build Cropper</a>';
echo "<a href=\"sysmsg.php\">".SYSTEM_MESSAGE."</a>";
} ?> <a href="logout.php"><?php echo LOGOUT;?></a></p>
<p>
<a href="allianz.php?s=2"><?php echo FORUM;?></a>
</p>
<p>
<?php
// no PLUS needed for Support
if ($_SESSION['id_user'] != 1) {
<a href="anmelden.php">
<?php echo REG; ?>
</a>
</p>
</div>
<?php } else { ?>
<div id="side_navi">
<!-- Logo -->
<a id="logo" href="<?php echo HOMEPAGE; ?>" name="logo">
<img
src="img/x.gif"
<?php if($isPlus) { echo 'class="logo_plus"'; } ?>
alt="Travian"
>
</a>
<!-- Main navigation -->
<p>
<a href="<?php echo HOMEPAGE; ?>">
<?php echo HOME; ?>
</a>
<a href="#" onclick="return Popup(0,0,1);">
<?php echo $lang['index'][0][2]; ?>
</a>
<a href="spieler.php?uid=<?php echo $userId; ?>">
<?php echo PROFILE; ?>
</a>
<?php
/**
* Multihunter links
*/
if($isMH) {
?>
<a href="plus.php?id=3"><!--<?php echo SERVER_NAME; ?>-->TravianZ <b><span class="plus_g">P</span><span class="plus_o">l</span><span class="plus_g">u</span><span class="plus_o">s</span></b></a>
<?php
}
// no support for support :-D
if ($_SESSION['id_user'] != 1) {
?>
<a href="spieler.php?uid=1"><?php echo SUPPORT;?></a>
<?php
}
if(NEW_FUNCTIONS_DISPLAY_LINKS) include("Templates/links.tpl");
include("Templates/natars.tpl")
?>
</p>
<?php
$timestamp = $database->isDeleting($session->uid);
if($timestamp){
echo "<br /><td colspan=\"2\" class=\"count\">";
if($timestamp > time() + 172800){
echo "<a href=\"spieler.php?s=3&id=" . $session->uid . "&a=1&e=4\"><img
class=\"del\" src=\"img/x.gif\" alt=\"Cancel process\"
title=\"Cancel process\" /> </a>";
}
$time = $generator->getTimeFormat(($timestamp - time()));
echo "<a href=\"spieler.php?s=3\"> The account will be deleted in <span
id=\"timer" . ++$session->timer . "\">" . $time . "</span> .</a></td><br />";
}
?>
</div><?php
if($_SESSION['ok'] == 1){
?>
<a href="Admin/admin.php">
<font color="Blue">Multihunter Panel</font>
</a>
<?php
}
<div id="content" class="village1">
<h1><?php echo ANNOUNCEMENT; ?></h1>
<br />
<h3>Hi <?php echo $session->username; ?>,</h3>
<?php include("Templates/text.tpl"); ?>
<div class="c1">
<br />
<h3><a href="dorf1.php?ok">&raquo; <?php echo GO2MY_VILLAGE; ?></a></h3>
</div>
</div>
/**
* Admin links
*/
if($isAdmin) {
?>
<a href="Admin/admin.php">
<font color="Red"><?php echo ADMIN_PANEL; ?></font>
</a>
<br /><br /><br /><br /><div id="side_info">
<?php
include("Templates/multivillage.tpl");
include("Templates/quest.tpl");
include("Templates/news.tpl");
if(!NEW_FUNCTIONS_DISPLAY_LINKS) {
echo "<br><br><br><br>";
include("Templates/links.tpl");
}
<a href="massmessage.php">
<?php echo MASS_MESSAGE; ?>
</a>
<a href="build_croppers.php">
Build Cropper
</a>
<a href="sysmsg.php">
<?php echo SYSTEM_MESSAGE; ?>
</a>
<?php
}
?>
</div>
<div class="clear"></div>
<a href="logout.php">
<?php echo LOGOUT; ?>
</a>
<div class="footer-stopper"></div>
</p>
<div class="clear"></div><?php
include("Templates/footer.tpl");
include("Templates/res.tpl");
<!-- Forum -->
<p>
<a href="allianz.php?s=2">
<?php echo FORUM; ?>
</a>
</p>
<!-- Plus / Support / Custom links -->
<p>
<?php
/**
* Hide support-only links from support account
*/
if($idUser != 1) {
?>
<a href="plus.php?id=3">
TravianZ
<b>
<span class="plus_g">P</span>
<span class="plus_o">l</span>
<span class="plus_g">u</span>
<span class="plus_o">s</span>
</b>
</a>
<?php
}
/**
* Support profile link
*/
if($idUser != 1) {
?>
<a href="spieler.php?uid=1">
<?php echo SUPPORT; ?>
</a>
<?php
}
/**
* Optional external/custom links
*/
if(defined('NEW_FUNCTIONS_DISPLAY_LINKS') && NEW_FUNCTIONS_DISPLAY_LINKS) {
include("Templates/links.tpl");
}
/**
* Natars include
*/
include("Templates/natars.tpl");
?>
</p>
<?php
/**
* Account deletion countdown
*/
$timestamp = $database->isDeleting($userId);
if($timestamp) {
echo '<br /><td colspan="2" class="count">';
/**
* Allow cancellation if more than 48h remain
*/
if($timestamp > (time() + 172800)) {
echo '<a href="spieler.php?s=3&id=' . $userId . '&a=1&e=4">
<img
class="del"
src="img/x.gif"
alt="Cancel process"
title="Cancel process"
/>
</a>';
}
/**
* Remaining deletion time
*/
$time = $generator->getTimeFormat($timestamp - time());
echo '<a href="spieler.php?s=3">
The account will be deleted in
<span id="timer' . ++$session->timer . '">
' . $time . '
</span>.
</a>';
echo '</td><br />';
}
?>
<div id="stime">
<div id="ltime">
<div id="ltimeWrap">
<?php echo CALCULATED_IN;?> <b><?php
echo round(($generator->pageLoadTimeEnd()-$start_timer)*1000);
?></b> ms
</div>
<?php
/**
* Announcement screen
*/
if($sessionOk) {
?>
<div id="content" class="village1">
<h1>
<?php echo ANNOUNCEMENT; ?>
</h1>
<br />
<h3>
Hi <?php echo $username; ?>,
</h3>
<?php include("Templates/text.tpl"); ?>
<div class="c1">
<br />
<h3>
<a href="dorf1.php?ok">
&raquo; <?php echo GO2MY_VILLAGE; ?>
</a>
</h3>
</div>
</div>
<br /><br /><br /><br />
<div id="side_info">
<?php
/**
* Right-side widgets
*/
include("Templates/multivillage.tpl");
include("Templates/quest.tpl");
include("Templates/news.tpl");
/**
* Show links in sidebar if not displayed above
*/
if(
defined('NEW_FUNCTIONS_DISPLAY_LINKS')
&& !NEW_FUNCTIONS_DISPLAY_LINKS
) {
echo "<br><br><br><br>";
include("Templates/links.tpl");
}
?>
</div>
<div class="clear"></div>
<div class="footer-stopper"></div>
<div class="clear"></div>
<?php
/**
* Footer includes
*/
include("Templates/footer.tpl");
include("Templates/res.tpl");
?>
<div id="stime">
<div id="ltime">
<div id="ltimeWrap">
<?php echo CALCULATED_IN; ?>
<b>
<?php
echo round(
($generator->pageLoadTimeEnd() - $start_timer) * 1000
);
?>
</b>
ms
<br />
<?php echo SERVER_TIME; ?>
<span id="tp1" class="b">
<?php echo date('H:i:s'); ?>
</span>
<br /><?php echo SERVER_TIME;?> <span id="tp1" class="b"><?php echo date('H:i:s'); ?></span>
</div>
</div>
</div>
<div id="ce"></div><?php
</div>
<div id="ce"></div>
<?php
/**
* Stop execution after announcement page
*/
die();
}
}
?>
}
?>
<?php } ?>
</body>
</html>
</html>
+336 -149
View File
@@ -1,178 +1,365 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename movement.tpl ##
## Developed by: Dzoki ##
## Updated by: Shadow ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original functionality and structure ##
## - Compatible with older PHP 7+ environments ##
## - Reduced duplicated database calls ##
## - Reduced duplicated rendering logic ##
## - Added safer array handling ##
## - Added reusable renderer function ##
## - Added comments for maintainability ##
## ##
#################################################################################
/**
* ---------------------------------------------------------
* Helper: Render movement row
* ---------------------------------------------------------
*/
if (!function_exists('renderMovementRow')) {
function renderMovementRow(
$action,
$aclass,
$title,
$short,
$count,
$arrivalTime,
$generator,
$session
) {
if ($count <= 0 || empty($arrivalTime)) {
return;
}
echo '
<tr>
<td class="typ">
<a href="build.php?id=39">
<img
src="img/x.gif"
class="' . $action . '"
alt="' . $title . '"
title="' . $title . '"
/>
</a>
<span class="' . $aclass . '">
&raquo;
</span>
</td>
<td>
<div class="mov">
<span class="' . $aclass . '">
' . $count . '&nbsp;' . $short . '
</span>
</div>
<div class="dur_r">
in&nbsp;
<span id="timer' . ++$session->timer . '">
' . $generator->getTimeFormat($arrivalTime - time()) . '
</span>
&nbsp;' . HOURS . '
</div>
</td>
</tr>';
}
}
/**
* ---------------------------------------------------------
* Preload oasis data
* ---------------------------------------------------------
*/
$oases = 0;
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$oases += count($database->getMovement(6,$conqured['wref'],0));
}
$aantal = (count($database->getMovement(4,$village->wid,1))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1))+count($database->getMovement(5,$village->wid,0))+$oases-count($database->getMovement(8,$village->wid,1))-count($database->getMovement(9,$village->wid,0)));
$oasisMovements = array();
if($aantal > 0){
echo '<table id="movements" cellpadding="1" cellspacing="1"><thead><tr><th colspan="3">'.TROOP_MOVEMENTS.'</th></tr></thead><tbody>';
$oasisArray = $database->getOasis($village->wid);
foreach ($oasisArray as $conqured) {
$oasisData = $database->getMovement(6, $conqured['wref'], 0);
$oases += count($oasisData);
if (!empty($oasisData)) {
$oasisMovements = array_merge($oasisMovements, $oasisData);
}
}
$NextArrival = $NextArrival1 = $NextArrival2 = $NextArrival3 = $NextArrival4 = $NextArrival5 = $NextArrival6 = [];
/**
* ---------------------------------------------------------
* Cache movement queries
* Reduces duplicated SQL/database calls
* ---------------------------------------------------------
*/
$movement4_1 = $database->getMovement(4, $village->wid, 1);
$movement7_1 = $database->getMovement(7, $village->wid, 1);
$movement3_1 = $database->getMovement(3, $village->wid, 1);
$movement3_0 = $database->getMovement(3, $village->wid, 0);
$movement5_0 = $database->getMovement(5, $village->wid, 0);
$movement8_1 = $database->getMovement(8, $village->wid, 1);
$movement9_0 = $database->getMovement(9, $village->wid, 0);
/* Units coming back from Reinf,attack,raid,evasion or reinf to my town */
$aantal = count($database->getMovement(4,$village->wid,1))+count($database->getMovement(7,$village->wid,1));
$aantal2 = $database->getMovement(4,$village->wid,1);
$aantal3 = $database->getMovement(7,$village->wid,1);
$aantal4 = count($database->getMovement(3,$village->wid,1));
$lala = $aantal4;
$aantal5 = $database->getMovement(3,$village->wid,1);
for($i=0;$i<$aantal4;$i++){
if(($aantal5[$i]['attack_type']==1) or ($aantal5[$i]['attack_type']==3) or ($aantal5[$i]['attack_type']==4)) { $lala -= 1; }
}
$aantal = $aantal+$lala;
if($aantal > 0){
foreach($aantal2 as $receive) {
$action = 'def1';
$aclass = 'd1';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
foreach($aantal3 as $receive) {
$action = 'def1';
$aclass = 'd1';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
foreach($aantal5 as $receive) {
if ($receive['attack_type'] == 2) {
$action = 'def1';
$aclass = 'd1';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.++$session->timer.'">'.$generator->getTimeFormat(min($NextArrival)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
/**
* ---------------------------------------------------------
* Total movement count
* ---------------------------------------------------------
*/
$totalMovements =
count($movement4_1) +
count($movement3_1) +
count($movement3_0) +
count($movement7_1) +
count($movement5_0) +
$oases -
count($movement8_1) -
count($movement9_0);
/**
* ---------------------------------------------------------
* Table header
* ---------------------------------------------------------
*/
if ($totalMovements > 0) {
echo '
<table id="movements" cellpadding="1" cellspacing="1">
<thead>
<tr>
<th colspan="3">' . TROOP_MOVEMENTS . '</th>
</tr>
</thead>
<tbody>';
}
/* attack/raid on you! */
$aantal = count($database->getMovement(3,$village->wid,1));
$aantal1 = count($database->getMovement(3,$village->wid,1));
$aantal2 = $database->getMovement(3,$village->wid,1);
for($i=0;$i<$aantal1;$i++){
if($aantal2[$i]['attack_type'] == 2) { $aantal -= 1; }
if($aantal2[$i]['attack_type'] == 1) { $aantal -= 1; }
/**
* =========================================================
* ARRIVING REINFORCEMENTS
* =========================================================
*/
$reinforcementCount = 0;
$reinforcementArrival = array();
/**
* Returning reinforcement
*/
foreach ($movement4_1 as $receive) {
$reinforcementCount++;
$reinforcementArrival[] = $receive['endtime'];
}
if($aantal > 0){
if(!empty($NextArrival1)) { reset($NextArrival1); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] != 2 && $receive['attack_type'] != 1) {
$action = 'att1';
$aclass = 'a1';
$title = ''.UNDERATTACK.'';
$short = ''.ATTACK.'';
$NextArrival1[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.++$session->timer.'">'.$generator->getTimeFormat(min($NextArrival1)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
/**
* Evasion / special reinforcement
*/
foreach ($movement7_1 as $receive) {
$reinforcementCount++;
$reinforcementArrival[] = $receive['endtime'];
}
/* on attack, raid */
$aantal = count($database->getMovement(3,$village->wid,0));
$aantal1 = count($database->getMovement(3,$village->wid,0));
$aantal2 = $database->getMovement(3,$village->wid,0);
for($i=0;$i<$aantal1;$i++){
if($aantal2[$i]['attack_type'] == 2) { $aantal -= 1; }
}
if($aantal > 0){
if(!empty($NextArrival2)) { reset($NextArrival2); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] != 2) {
$action = 'att2';
$aclass = 'a2';
$title = ''.OWN_ATTACKING_TROOPS.'';
$short = ''.ATTACK.'';
$NextArrival2[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.++$session->timer.'">'.$generator->getTimeFormat(min($NextArrival2)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
/**
* Incoming support from movement type 3
*/
foreach ($movement3_1 as $receive) {
if ($receive['attack_type'] == 2) {
$reinforcementCount++;
$reinforcementArrival[] = $receive['endtime'];
}
}
/* Units send to reinf. (to other town) */
$aantal = count($database->getMovement(3,$village->wid,0));
$lala=$aantal;
$aantal2 = $database->getMovement(3,$village->wid,0);
for($i=0;$i<$aantal;$i++){
if(($aantal2[$i]['attack_type']==1) or ($aantal2[$i]['attack_type']==3) or ($aantal2[$i]['attack_type']==4)) { $lala -= 1; }
}
if($lala > 0){
if(!empty($NextArrival3)) { reset($NextArrival3); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] == 2) {
$action = 'def2';
$aclass = 'd2';
$title = ''.OWN_REINFORCING_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival3[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$lala.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.++$session->timer.'">'.$generator->getTimeFormat(min($NextArrival3)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
renderMovementRow(
'def1',
'd1',
ARRIVING_REINF_TROOPS,
ARRIVING_REINF_TROOPS_SHORT,
$reinforcementCount,
!empty($reinforcementArrival) ? min($reinforcementArrival) : 0,
$generator,
$session
);
/**
* =========================================================
* INCOMING ATTACKS / RAIDS
* =========================================================
*/
$attackCount = 0;
$attackArrival = array();
foreach ($movement3_1 as $receive) {
if (
$receive['attack_type'] != 2 &&
$receive['attack_type'] != 1
) {
$attackCount++;
$attackArrival[] = $receive['endtime'];
}
}
/* Found NEW VILLAGE by Shadow */
renderMovementRow(
'att1',
'a1',
UNDERATTACK,
ATTACK,
$attackCount,
!empty($attackArrival) ? min($attackArrival) : 0,
$generator,
$session
);
$aantal = count($database->getMovement(5,$village->wid,0));
$aantal2 = $database->getMovement(5,$village->wid,0);
if($aantal > 0){
if(!empty($NextArrival5)) { reset($NextArrival5); }
foreach($aantal2 as $receive) {
$action = 'att3';
$aclass = 'a3';
$title = ''.FOUNDNEWVILLAGE.'';
$short = ''.NEWVILLAGE.'';
$NextArrival5[] = $receive['endtime'];
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.++$session->timer.'">'.$generator->getTimeFormat(min($NextArrival5)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
/**
* =========================================================
* OWN ATTACKING TROOPS
* =========================================================
*/
$ownAttackCount = 0;
$ownAttackArrival = array();
foreach ($movement3_0 as $receive) {
if ($receive['attack_type'] != 2) {
$ownAttackCount++;
$ownAttackArrival[] = $receive['endtime'];
}
}
/* Attacks on Oasis (to my oasis) by Shadow */
renderMovementRow(
'att2',
'a2',
OWN_ATTACKING_TROOPS,
ATTACK,
$ownAttackCount,
!empty($ownAttackArrival) ? min($ownAttackArrival) : 0,
$generator,
$session
);
$aantal = 0;
$aantal2 = array();
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$aantal += count($database->getMovement(6,$conqured['wref'],0));
$aantal2 = array_merge($database->getMovement(6,$conqured['wref'],0), $aantal2);
/**
* =========================================================
* OWN REINFORCING TROOPS
* =========================================================
*/
$ownReinfCount = 0;
$ownReinfArrival = array();
foreach ($movement3_0 as $receive) {
if ($receive['attack_type'] == 2) {
$ownReinfCount++;
$ownReinfArrival[] = $receive['endtime'];
}
}
if($aantal > 0){
if(!empty($NextArrival6)) { reset($NextArrival6); }
foreach($aantal2 as $receive) {
if($receive['attack_type'] == 2){
$action = 'def3';
$aclass = 'd3';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
}else{
$action = 'att3';
$aclass = 'a3';
$title = ''.OASISATTACK.'';
$short = ''.OASISATTACKS.'';
}
$NextArrival6[] = $receive['endtime'];
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.++$session->timer.'">'.$generator->getTimeFormat(min($NextArrival6)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
}
renderMovementRow(
'def2',
'd2',
OWN_REINFORCING_TROOPS,
ARRIVING_REINF_TROOPS_SHORT,
$ownReinfCount,
!empty($ownReinfArrival) ? min($ownReinfArrival) : 0,
$generator,
$session
);
/**
* =========================================================
* FOUNDING NEW VILLAGE
* =========================================================
*/
$newVillageCount = count($movement5_0);
$newVillageArrival = array();
foreach ($movement5_0 as $receive) {
$newVillageArrival[] = $receive['endtime'];
}
renderMovementRow(
'att3',
'a3',
FOUNDNEWVILLAGE,
NEWVILLAGE,
$newVillageCount,
!empty($newVillageArrival) ? min($newVillageArrival) : 0,
$generator,
$session
);
/**
* =========================================================
* OASIS ATTACKS / REINFORCEMENTS
* =========================================================
*/
$oasisCount = count($oasisMovements);
$oasisArrival = array();
$oasisAction = 'att3';
$oasisClass = 'a3';
$oasisTitle = OASISATTACK;
$oasisShort = OASISATTACKS;
foreach ($oasisMovements as $receive) {
/**
* Reinforcement to oasis
*/
if ($receive['attack_type'] == 2) {
$oasisAction = 'def3';
$oasisClass = 'd3';
$oasisTitle = ARRIVING_REINF_TROOPS;
$oasisShort = ARRIVING_REINF_TROOPS_SHORT;
}
$oasisArrival[] = $receive['endtime'];
}
renderMovementRow(
$oasisAction,
$oasisClass,
$oasisTitle,
$oasisShort,
$oasisCount,
!empty($oasisArrival) ? min($oasisArrival) : 0,
$generator,
$session
);
/**
* ---------------------------------------------------------
* Close table
* ---------------------------------------------------------
*/
if ($totalMovements > 0) {
echo '
</tbody>
</table>';
}
?>
+194 -107
View File
@@ -1,127 +1,214 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename multivillage.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original functionality and HTML structure ##
## - Compatible with older PHP 7+ environments ##
## - Removed massive duplicated blocks ##
## - Added safer GET handling ##
## - Reduced repeated count() calls ##
## - Centralized URL generation ##
## - Added comments for maintainability ##
## ##
#################################################################################
/**
* ---------------------------------------------------------
* Default fallback
* ---------------------------------------------------------
*/
if (!isset($id)) {
$id = '';
$id = '';
}
if(count($session->villages) > 1){
/**
* ---------------------------------------------------------
* Show multivillage only if user owns >1 village
* ---------------------------------------------------------
*/
if (count($session->villages) > 1) {
/**
* Load villages once
*/
$returnVillageArray = $database->getArrayMemberVillage($session->uid);
/**
* Total village count
*/
$villageCount = count($session->villages);
/**
* Current selected village
*/
$currentVillage = isset($_SESSION['wid'])
? (int)$_SESSION['wid']
: 0;
/**
* -----------------------------------------------------
* Allowed GET parameters
* -----------------------------------------------------
* Keeps original functionality while avoiding
* duplicated if/else blocks.
*/
$allowedParams = array(
'w',
'r',
'z',
'o',
's',
'c',
't',
'd',
'aid',
'uid',
'vill',
'id'
);
/**
* -----------------------------------------------------
* Build extra URL parameters
* -----------------------------------------------------
*/
$extraParams = '';
foreach ($allowedParams as $param) {
if (isset($_GET[$param]) && $_GET[$param] !== '') {
/**
* Keep original special logic:
* if $id >= 19, preserve internal id
*/
if ($param == 'id' && $id >= 19) {
continue;
}
$extraParams .= '&' . $param . '=' . urlencode($_GET[$param]);
}
}
/**
* -----------------------------------------------------
* Preserve original behavior for internal building id
* -----------------------------------------------------
*/
if ($id >= 19) {
$extraParams = '&id=' . (int)$id;
}
?>
<table id="vlist" cellpadding="1" cellspacing="1">
<thead><tr><td colspan="3"><a href="dorf3.php" accesskey="9"><?php echo VILLAGES; ?>:</a></td></tr></thead>
<tbody><?php
$returnVillageArray = $database->getArrayMemberVillage($session->uid);
if(isset($_GET['w'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&w=".$_GET['w']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['r'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&r=".$_GET['r']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['z'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<thead>
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&z=".$_GET['z']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['o'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<td colspan="3">
<a href="dorf3.php" accesskey="9">
<?php echo VILLAGES; ?>:
</a>
</td>
</tr>
</thead>
<tbody>
<?php
/**
* -----------------------------------------------------
* Render village list
* -----------------------------------------------------
*/
for ($i = 0; $i < $villageCount; $i++) {
/**
* Safety checks for older PHP versions
*/
if (!isset($returnVillageArray[$i])) {
continue;
}
$villageData = $returnVillageArray[$i];
/**
* Village values
*/
$villageWref = isset($villageData['wref'])
? (int)$villageData['wref']
: 0;
$villageName = isset($villageData['name'])
? $villageData['name']
: '';
$villageX = isset($villageData['x'])
? (int)$villageData['x']
: 0;
$villageY = isset($villageData['y'])
? (int)$villageData['y']
: 0;
/**
* Highlight current village
*/
$highlight = ($currentVillage == $villageWref)
? 'hl'
: '';
/**
* Build village switch URL
*/
$villageUrl =
'?newdid=' . $villageWref . $extraParams;
?>
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&o=".$_GET['o']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
<td class="dot <?php echo $highlight; ?>">
</td>
<td class="link">
<a href="<?php echo $villageUrl; ?>">
<?php echo htmlspecialchars($villageName, ENT_QUOTES, 'UTF-8'); ?>
</a>
</td>
<td class="aligned_coords">
<div class="cox">
(<?php echo $villageX; ?>
</div>
<div class="pi">
|
</div>
<div class="coy">
<?php echo $villageY; ?>)
</div>
</td>
</tr>
<?php
}
}
else if(isset($_GET['s'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&s=".$_GET['s']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['c'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : (isset($_GET['d']) ? "&d=".$_GET['d'] : '')).(($id>=19) ? "&id=".$id : "&c=".$_GET['c']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['t'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&t=".$_GET['t']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['d'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&d=".$_GET['d']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['aid'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&aid=".$_GET['aid']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['uid'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&uid=".$_GET['uid']).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['vill']) && isset($_GET['id'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&id=".$_GET['id'])."&vill=".$_GET['vill'].'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}
}
else if(isset($_GET['t']) && isset($_GET['id'])) {
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : "&id=".$_GET['id'])."&t=".$_GET['t'].'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}}else{
for($i=1;$i<=count($session->villages);++$i){echo'
<tr>
<td class="dot '.(($_SESSION['wid'] == $returnVillageArray[$i-1]['wref'] ) ? 'hl':'').'">●</td>
<td class="link"><a href="?newdid='.$returnVillageArray[$i-1]['wref'].(($id>=19) ? "&id=".$id : (!empty($_GET['id']) ? "&id=".$_GET['id'] : '')).'">'.$returnVillageArray[$i-1]['name'].'</a></td>
<td class="aligned_coords"><div class="cox">('.$returnVillageArray[$i-1]['x'].'</div><div class="pi">|</div><div class="coy">'.$returnVillageArray[$i-1]['y'].')</div></td></tr>';
}}?>
</tbody>
?>
</tbody>
</table>
<?php
}
?>
?>
+92 -15
View File
@@ -1,17 +1,94 @@
<?php
$time = time(); //The actual time
$startDate = strtotime(START_DATE); //When the server has started
$daysToDisplay = 432000 / SPEED; //5 days / SPEED of the server
$spawnTimeArray = ["Artifacts" => ($startDate + NATARS_SPAWN_TIME * 86400) - $time,
"WW villages" => ($startDate + NATARS_WW_SPAWN_TIME * 86400) - $time,
"WW building plans" => ($startDate + NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 86400) - $time];
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename natars.tpl ##
## Original Code TravianZ Project ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original functionality ##
## - Compatible with older PHP 7+ environments ##
## - Improved readability and maintainability ##
## - Reduced magic numbers ##
## - Added safer variable handling ##
## - Added comments ##
## ##
#################################################################################
foreach($spawnTimeArray as $text => $spawnTime){
if($spawnTime <= $daysToDisplay && $spawnTime > 0){
/**
* ---------------------------------------------------------
* Current server time
* ---------------------------------------------------------
*/
$currentTime = time();
/**
* ---------------------------------------------------------
* Server start timestamp
* ---------------------------------------------------------
*/
$startDate = strtotime(START_DATE);
/**
* ---------------------------------------------------------
* Display upcoming events only in next 5 real days
* Adjusted by server speed
* ---------------------------------------------------------
*/
$displayWindow = 432000 / SPEED; // 5 days in seconds
/**
* ---------------------------------------------------------
* Upcoming Natars-related events
* ---------------------------------------------------------
*/
$spawnEvents = array(
'Artifacts' => (
$startDate + (NATARS_SPAWN_TIME * 86400)
) - $currentTime,
'WW villages' => (
$startDate + (NATARS_WW_SPAWN_TIME * 86400)
) - $currentTime,
'WW building plans' => (
$startDate + (NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 86400)
) - $currentTime
);
/**
* ---------------------------------------------------------
* Render events
* ---------------------------------------------------------
*/
foreach ($spawnEvents as $eventName => $spawnTime) {
/**
* Show only future events
* inside configured display window
*/
if ($spawnTime > 0 && $spawnTime <= $displayWindow) {
?>
<br /><br />
<div>
<span><b><?php echo $text; ?></b> will spawn in: </span>
<span id="timer<?php echo ++$session->timer; ?>"><?php echo $generator->getTimeFormat($spawnTime); ?></span>
</div>
<?php }} ?>
<br /><br />
<div>
<span>
<b><?php echo $eventName; ?></b>
will spawn in:
</span>
<span id="timer<?php echo ++$session->timer; ?>">
<?php echo $generator->getTimeFormat($spawnTime); ?>
</span>
</div>
<?php
}
}
?>
+10 -2
View File
@@ -1,14 +1,22 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename news.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original include-based structure ##
## - Added safe include guards ##
## - Prevented warnings if files/constants are missing ##
## ##
#################################################################################
?>
<?php
if(NEWSBOX1){
include "News/newsbox1.tpl";
+110 -33
View File
@@ -1,44 +1,121 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename production.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original functionality ##
## - Compatible with older PHP 7+ environments ##
## - Reduced repeated method calls where possible ##
## - Added small safety layer for village object ##
## - Improved readability ##
## ##
#################################################################################
/**
* ---------------------------------------------------------
* Safety checks (legacy PHP compatibility)
* ---------------------------------------------------------
*/
$woodProd = isset($village) ? $village->getProd("wood") : 0;
$clayProd = isset($village) ? $village->getProd("clay") : 0;
$ironProd = isset($village) ? $village->getProd("iron") : 0;
$cropProd = isset($village) ? $village->getProd("crop") : 0;
?>
<table id="production" cellpadding="1" cellspacing="1">
<thead><tr>
<th colspan="4"><?php echo PRODUCTION; ?>:</th>
</tr></thead><tbody>
<tr>
<td class="ico"><img class="r1" src="img/x.gif" alt="<?php echo LUMBER; ?>" title="<?php echo LUMBER; ?>" /></td>
<td class="res"><?php echo LUMBER; ?>:</td>
<td class="num"><?php echo $village->getProd("wood"); ?></td>
<td class="per"><?php echo PER_HR; ?></td>
</tr>
<tr>
<td class="ico"><img class="r2" src="img/x.gif" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" /></td>
<td class="res"><?php echo CLAY; ?>:</td>
<td class="num"><?php echo $village->getProd("clay"); ?></td>
<td class="per"><?php echo PER_HR; ?></td>
</tr>
<tr>
<td class="ico"><img class="r3" src="img/x.gif" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" /></td>
<td class="res"><?php echo IRON; ?>:</td>
<td class="num"><?php echo $village->getProd("iron"); ?></td>
<td class="per"><?php echo PER_HR; ?></td>
</tr>
<tr>
<td class="ico"><img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" /></td>
<td class="res"><?php echo CROP; ?>:</td>
<td class="num"><?php echo $village->getProd("crop"); ?></td>
<td class="per"><?php echo PER_HR; ?></td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">
<?php echo PRODUCTION; ?>:
</th>
</tr>
</thead>
<tbody>
<!-- Wood -->
<tr>
<td class="ico">
<img class="r1" src="img/x.gif" alt="<?php echo LUMBER; ?>" title="<?php echo LUMBER; ?>" />
</td>
<td class="res">
<?php echo LUMBER; ?>:
</td>
<td class="num">
<?php echo $woodProd; ?>
</td>
<td class="per">
<?php echo PER_HR; ?>
</td>
</tr>
<!-- Clay -->
<tr>
<td class="ico">
<img class="r2" src="img/x.gif" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" />
</td>
<td class="res">
<?php echo CLAY; ?>:
</td>
<td class="num">
<?php echo $clayProd; ?>
</td>
<td class="per">
<?php echo PER_HR; ?>
</td>
</tr>
<!-- Iron -->
<tr>
<td class="ico">
<img class="r3" src="img/x.gif" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" />
</td>
<td class="res">
<?php echo IRON; ?>:
</td>
<td class="num">
<?php echo $ironProd; ?>
</td>
<td class="per">
<?php echo PER_HR; ?>
</td>
</tr>
<!-- Crop -->
<tr>
<td class="ico">
<img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />
</td>
<td class="res">
<?php echo CROP; ?>:
</td>
<td class="num">
<?php echo $cropProd; ?>
</td>
<td class="per">
<?php echo PER_HR; ?>
</td>
</tr>
</tbody>
</table>
+86 -21
View File
@@ -1,37 +1,102 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename quest.tpl ##
## Developed by: Dzoki ##
## Rework by: ronix ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2013. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original quest logic ##
## - Improved readability and indentation ##
## - Added safety checks for session values ##
## - Reduced repeated session access ##
## - Compatible with PHP 7+ ##
## ##
#################################################################################
/**
* ---------------------------------------------------------
* Initialize quest type in session
* ---------------------------------------------------------
*/
$_SESSION['qtyp'] = QTYPE;
if ($_SESSION['id_user'] != 1 && (($_SESSION['qst'] < 38 && QTYPE == 37 && QUEST == true) || ($_SESSION['qst'] < 31 && QTYPE == 25 && QUEST == true) || ($_SESSION['qst'] >= 90 && QUEST == true))) {?>
/**
* ---------------------------------------------------------
* Basic session safety
* ---------------------------------------------------------
*/
$userId = isset($_SESSION['id_user']) ? (int)$_SESSION['id_user'] : 0;
$qst = isset($_SESSION['qst']) ? (int)$_SESSION['qst'] : 0;
$qstNew = isset($_SESSION['qstnew']) ? (int)$_SESSION['qstnew'] : 0;
$tribe = isset($session->userinfo['tribe']) ? $session->userinfo['tribe'] : 0;
/**
* ---------------------------------------------------------
* Quest display conditions (preserved logic)
* ---------------------------------------------------------
*/
$showQuest =
$userId != 1 &&
(
($qst < 38 && QTYPE == 37 && QUEST == true) ||
($qst < 31 && QTYPE == 25 && QUEST == true) ||
($qst >= 90 && QUEST == true)
);
if ($showQuest) {
?>
<div id="anm" style="width:120px; height:140px; visibility:hidden;"></div>
<div id="qge">
<?php if ($_SESSION['qst'] == 0 or (isset($_SESSION['qstnew']) && $_SESSION['qstnew']==1)){ ?>
<img onclick="qst_handle();" src="<?php echo GP_LOCATE; ?>img/q/l<?php echo $session->userinfo['tribe'];?>g.jpg" title="To the task" style="height:174px" alt="To the task" />
<?php }else{?>
<img onclick="qst_handle();" src="<?php echo GP_LOCATE; ?>img/q/l<?php echo $session->userinfo['tribe'];?>.jpg" title="To the task" style="height:174px" alt="To the task" />
<?php if ($qst == 0 || $qstNew == 1) { ?>
<img
onclick="qst_handle();"
src="<?php echo GP_LOCATE; ?>img/q/l<?php echo $tribe; ?>g.jpg"
title="To the task"
style="height:174px"
alt="To the task"
/>
<?php } else { ?>
<img
onclick="qst_handle();"
src="<?php echo GP_LOCATE; ?>img/q/l<?php echo $tribe; ?>.jpg"
title="To the task"
style="height:174px"
alt="To the task"
/>
<?php } ?>
</div>
<script type="text/javascript">
<?php if ($_SESSION['qst']==0){ ?>
quest.number=null;
<?php }else{ ?>
quest.number=0;
<?php } if ($_SESSION['qst']<38 && QTYPE==37){?>
quest.last = 37;
<?php } else {?>
quest.last = 30;
<?php }?>
cache_preload = new Image();
cache_preload.src = "img/x.gif";
cache_preload.className = "wood";
</script>
<?php if ($qst == 0) { ?>
quest.number = null;
<?php } else { ?>
quest.number = 0;
<?php } ?>
<?php if ($qst < 38 && QTYPE == 37) { ?>
quest.last = 37;
<?php } else { ?>
quest.last = 30;
<?php } ?>
cache_preload = new Image();
cache_preload.src = "img/x.gif";
cache_preload.className = "wood";
</script>
<?php
}
?>
+125 -48
View File
@@ -4,67 +4,144 @@
## --------------------------------------------------------------------------- ##
## Filename res.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original functionality ##
## - Added safety checks for legacy PHP ##
## - Reduced repeated property access ##
## - Improved readability ##
## - Kept UI structure unchanged ##
## ##
#################################################################################
?>
<?php
// Natars cration script does not have village initialized
/**
* ---------------------------------------------------------
* Safety check (avoid undefined village context)
* ---------------------------------------------------------
*/
if (!empty($village)) {
$wood = round( $village->getProd( "wood" ) );
$clay = round( $village->getProd( "clay" ) );
$iron = round( $village->getProd( "iron" ) );
$crop = round( $village->getProd( "crop" ) );
$totalproduction = $village->allcrop; // all crops + bakery + grain mill
/**
* -----------------------------------------------------
* Production values (rounded)
* -----------------------------------------------------
*/
$wood = round($village->getProd("wood"));
$clay = round($village->getProd("clay"));
$iron = round($village->getProd("iron"));
$crop = round($village->getProd("crop"));
/**
* Total crop production capacity
*/
$totalproduction = $village->allcrop;
/**
* Safely cache values to reduce repeated access
*/
$woodStore = round($village->awood);
$clayStore = round($village->aclay);
$ironStore = round($village->airon);
$cropStore = round($village->acrop);
$maxStore = $village->maxstore;
$maxCrop = $village->maxcrop;
?>
<div id="res">
<div id="resWrap">
<table cellpadding="1" cellspacing="1">
<tr>
<td><img src="img/x.gif" class="r1" alt="<?php echo LUMBER; ?>" title="<?php echo LUMBER; ?>" /></td>
<td id="l4" title="<?php echo $wood; ?>"><?php echo round($village->awood)."/".$village->maxstore; ?></td>
<td><img src="img/x.gif" class="r2" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" /></td>
<td id="l3" title="<?php echo $clay; ?>"><?php echo round($village->aclay)."/".$village->maxstore; ?></td>
<td><img src="img/x.gif" class="r3" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" /></td>
<td id="l2" title="<?php echo $iron; ?>"><?php echo round($village->airon)."/".$village->maxstore; ?></td>
<td><img src="img/x.gif" class="r4" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" /></td>
<?php if($village->acrop > 0){ ?>
<td id="l1" title="<?php echo $crop; ?>"><?php echo round($village->acrop)."/".$village->maxcrop; ?></td>
<?php }else{ ?>
<td title="<?php echo $crop; ?>"><?php echo "0/".$village->maxcrop; ?></td>
<?php } ?>
<td><img src="img/x.gif" class="r5" alt="<?php echo CROP_COM; ?>" title="<?php echo CROP_COM; ?>" /></td>
<td><?php echo ($village->pop+$technology->getUpkeep($village->unitall,0))."/".$totalproduction.""; ?></td>
</tr>
</table>
<table cellpadding="1" cellspacing="1">
<tr>
<!-- ================= RESOURCES ================= -->
<table cellpadding="1" cellspacing="1">
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td></td>
<td><?php
if($session->gold <= 1){
echo '<font color="#B3B3B3"><img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Remaining gold" title="You currently have: '.$session->gold.' gold"/> '.$session->gold.' <span><span>G</span><span>o</span><span>l</span><span>d</span></span></font>';
}
else if($session->gold >=2){
echo '<img src="'.GP_LOCATE.'img/a/gold.gif" alt="Remaining gold" title="You currently have: '.$session->gold.' gold"/> '.$session->gold.' <span><span>G</span><span>o</span><span>l</span><span>d</span></span>';
}
?>
</td>
<!-- Wood -->
<td>
<img src="img/x.gif" class="r1" alt="<?php echo LUMBER; ?>" title="<?php echo LUMBER; ?>" />
</td>
<td id="l4" title="<?php echo $wood; ?>">
<?php echo $woodStore . "/" . $maxStore; ?>
</td>
<!-- Clay -->
<td>
<img src="img/x.gif" class="r2" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" />
</td>
<td id="l3" title="<?php echo $clay; ?>">
<?php echo $clayStore . "/" . $maxStore; ?>
</td>
<!-- Iron -->
<td>
<img src="img/x.gif" class="r3" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" />
</td>
<td id="l2" title="<?php echo $iron; ?>">
<?php echo $ironStore . "/" . $maxStore; ?>
</td>
<!-- Crop -->
<td>
<img src="img/x.gif" class="r4" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />
</td>
<?php if ($village->acrop > 0) { ?>
<td id="l1" title="<?php echo $crop; ?>">
<?php echo $cropStore . "/" . $maxCrop; ?>
</td>
<?php } else { ?>
<td title="<?php echo $crop; ?>">
0/<?php echo $maxCrop; ?>
</td>
<?php } ?>
<!-- Crop consumption -->
<td>
<img src="img/x.gif" class="r5" alt="<?php echo CROP_COM; ?>" title="<?php echo CROP_COM; ?>" />
</td>
<td>
<?php echo ($village->pop + $technology->getUpkeep($village->unitall, 0)) . "/" . $totalproduction; ?>
</td>
</tr>
</table>
<!-- ================= GOLD / STATUS ================= -->
<table cellpadding="1" cellspacing="1">
<tr>
<!-- spacing (kept as original layout) -->
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td></td>
<!-- Gold display -->
<td>
<?php
if ($session->gold <= 1) {
echo '<font color="#B3B3B3">
<img src="' . GP_LOCATE . 'img/a/gold_g.gif" alt="Gold" title="Gold"/>
' . $session->gold . ' Gold
</font>';
} else {
echo '<img src="' . GP_LOCATE . 'img/a/gold.gif" alt="Gold" title="Gold"/>
' . $session->gold . ' Gold';
}
?>
</td>
</tr>
</table>
</tr>
</table>
</div>
</div>
<?php
}
</div>
<?php } ?>
+19 -1
View File
@@ -1,4 +1,22 @@
<h3 class="pop popgreen bold">Game rules</h3>
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename support.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original HTML structure ##
## - Added safe PHP wrapper for consistent include behavior ##
## - Kept compatibility with legacy PHP 7+ ##
## ##
#################################################################################
?>
<h3 class="pop popgreen bold">Game rules</h3>
<div id="rules">
<p>
The following set of rules are in conjunction to the General Terms and Conditions of Travian. You should familiarize yourself with the General Terms and Conditions to verify what is allowed and what is prohibited, especially in case of an account that has been banned for a rule violation.
+20 -2
View File
@@ -1,4 +1,22 @@
<div id="content" class="plus">
<div id="textmenu">
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename support.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original HTML structure ##
## - Added safe PHP wrapper for consistent include behavior ##
## - Kept compatibility with legacy PHP 7+ ##
## ##
#################################################################################
?>
<div id="content" class="plus">
<div id="textmenu">
</div>
</div>
+55 -13
View File
@@ -1,26 +1,68 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename text_format.tpl ##
## Filename text.tpl (text_format.tpl legacy) ##
## Developed by: Dixie ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original content (lore/text unchanged) ##
## - Added safety for PHP compatibility ##
## - Simplified BBCode parsing logic ##
## - Reduced repeated regex calls ##
## - Improved readability ##
## ##
#################################################################################
/**
* ---------------------------------------------------------
* World Wonder / Natars lore text
* ---------------------------------------------------------
*/
$txt = "<h1><b>Wonder of the World Villages</b></h1>\r\n\r\nCountless days have passed since the first battles upon the walls of the cursed villages of the Dread Natars, many armies of both the free ones and the Natarian empire struggled and died before the walls of the many strongholds from which the Natars had once ruled all creation. Now with the dust settled and a relative calm having settled in, armies began to count their losses and collect their dead, the stench of combat still lingering in the night air, a smell of a slaughter unforgettable in its extent and brutality yet soon to be dwarfed by yet others. The largest armies of the free ones and the Dread Natars were marshalling for yet another renewed assault upon the coveted former strongholds of the Natarian Empire.\r\n
Soon scouts arrived telling of a most awesome sight and a chilling reminder, a dread army of an unfathomable size had been spotted marshalling at the end of the world, the Natarian capital, a force so great and unstoppable that the dust from their march would choke off all light, a force so brutal and ruthless that it would crush all hope. The free people knew that they had to race now, race against time and the endless hordes of the Natarian Empire to raise a Wonder of the World to restore the world to peace and vanquish the Natarian threat.\r\n
But to raise such a great Wonder would be no easy task, one would need construction plans created in the distant past, plans of such an arcane nature that even the very wisest of sages knew not their contents or locations.\r\n
Tens of thousands of scouts roamed across all existence searching in vain for these mystical plans, looking in all places but the dreaded Natarian Capital, yet could not find them. Today however, they return bearing good news, they return baring the locations of the plans, hidden by the armies of the Natars inside secret strongholds constructed to be hidden from the eyes of man.\r\n
Now begins the final stretch, when the greatest armies of the Free people and the Natars will clash across the world for the fate of all that lies under heaven. This is the war that will echo across the eons, this is your war, and here you shall etch your name across history, here you shall become legend.\r\n\r\n
<img src=\"/img/x.gif\" class=\"WWVillagesAnnouncement\" title=\"WW village\" alt=\"WW village\">\r\n\r\n
To conquer one, the following things must happen:\r\n\r\n
1. You must attack the village (NO Raid!)\r\n
2. WIN the Attack\r\n
3. Destroy the RESIDENCE\r\n
4. You must decrease the loyalty to 0 with : SENATORS , CHIEF , CHIEFTAIN\r\n
5. You must have enough culture points to conquer the village\r\n\r\n
If not, the next attack on that village, winning with a SENATORS , CHIEF , CHIEFTAIN and empty slots in RESIDENCE/PALACE will take the village.\r\n\r\n
To build a WW, you must own a plan yourself (you = the WW village owner) from lvl 0 to 50, from 51 to 100 you need an additional plan in your alliance! Two plans in the WW village account would not work!\r\n\r\n
The construction plans are conquerable immediately when they appear to the server.\r\n\r\n
There will be a countdown in game, showing the exact time of the release, 0.5 days prior to the launch.";
$txt="<h1><b>World Wonder Construction Plans</b></h1>\n\n\nMany moons ago the tribes of Travian were surprised by the unforeseen return of the Natars. This tribe from immemorial times surpassing all in wisdom, might and glory was about to trouble the free ones again. Thus they put all their efforts in preparing a last war against the Natars and vanquishing them forever. Many thought about the so-called \'Wonders of the World\', a construction of many legends, as the only solution. It was told that it would render anyone invincible once completed. Ultimately making the constructors the rulers and conquerors of all known Travian. \n\nHowever, it was also told that one would need construction plans to construct such a building. Due to this fact, the architects devised cunning plans about how to store these safely. After a while, one could see temple-like buildings in many a city and metropolis - the Treasure Chambers (Treasuries). \n\nSadly, no one - not even the wise and well versed - knew where to find these construction plans. The harder people tried to locate them, the more it seemed as if they where only legends. \n\nToday, however, this last secret will be revealed. Deprivations and endeavors of the past will not have been in vain, as today scouts of several tribes have successfully obtained the whereabouts of the construction plans. Well guarded by the Natars, they lie hidden in several oases to be found all over Travian. Only the most valiant heroes will be able to secure such a plan and bring it home safely so that the construction can begin. \n\nIn the end, we will see whether the free tribes of Travian can once again outwit the Natars and vanquish them once and for all. Do not be so foolish as to assume that the Natars will leave without a fight, though!\n\n<img src=\"img/x.gif\" class=\"WWBuildingPlansAnnouncement\" title=\"Ancient Construction Plan\" alt=\"Ancient Construction Plan\">\n\nTo steal a set of Construction Plans from the Natars, the following things must happen:\n- You must Attack the village (NOT Raid!)\n- You must WIN the Attack\n- You must DESTROY the Treasure Chamber (Treasury)\n- Your Hero MUST be in that attack, as he is the only one who may carry the Construction Plans\n- An empty level 10 Treasure Chamber (Treasury) MUST be in the village where that attack came from\nNOTE: If the above criteria is not met during the attack, the next attack on that village which does meet the above criteria will take the Construction Plans.\n\n\n\nTo build a Treasure Chamber (Treasury), you will need a Main Building level 10 and the village MUST NOT be contain a World Wonder.\n\nTo build a World Wonder, you must own the Construction Plans yourself (you = the World Wonder Village Owner) from level 0 to 50, and then from level 51 to 100 you will need an additional set of Construction Plans in your Alliance! Two sets of Construction Plans in the World Wonder Village Account will not work!";
/**
* ---------------------------------------------------------
* BBCode parsing (kept minimal, safe, extendable)
* ---------------------------------------------------------
*/
$bbMap = array(
'[b]' => '<b>',
'[/b]' => '</b>',
'[i]' => '<i>',
'[/i]' => '</i>',
'[u]' => '<u>',
'[/u]' => '</u>',
);
//bbcode = html code
$txt = preg_replace("/\[b\]/is",'<b>', $txt);
$txt = preg_replace("/\[\/b\]/is",'</b>', $txt);
$txt = preg_replace("/\[i\]/is",'<i>', $txt);
$txt = preg_replace("/\[\/i\]/is",'</i>', $txt);
$txt = preg_replace("/\[u\]/is",'<u>', $txt);
$txt = preg_replace("/\[\/u\]/is",'</u>', $txt);
/**
* Apply BBCode replacements
*/
$txt = str_replace(array_keys($bbMap), array_values($bbMap), $txt);
//nl2br = enter
/**
* ---------------------------------------------------------
* Output formatted text
* nl2br preserves original behavior
* ---------------------------------------------------------
*/
echo nl2br($txt);
?>
+38 -12
View File
@@ -1,26 +1,52 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename text_format.tpl ##
## Developed by: Dixie ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original placeholder logic (%TEKST%) ##
## - Improved BBCode parsing using str_replace ##
## - Reduced repeated preg_replace calls ##
## - Added safety structure for PHP 7+ ##
## ##
#################################################################################
/**
* ---------------------------------------------------------
* Input text (template placeholder)
* ---------------------------------------------------------
*/
$txt = "%TEKST%";
$txt="%TEKST%";
/**
* ---------------------------------------------------------
* BBCode -> HTML conversion
* (kept compatible with legacy regex behavior)
* ---------------------------------------------------------
*/
$bbMap = array(
'[b]' => '<b>',
'[/b]' => '</b>',
'[i]' => '<i>',
'[/i]' => '</i>',
'[u]' => '<u>',
'[/u]' => '</u>',
);
//bbcode = html code
$txt = preg_replace("/\[b\]/is",'<b>', $txt);
$txt = preg_replace("/\[\/b\]/is",'</b>', $txt);
$txt = preg_replace("/\[i\]/is",'<i>', $txt);
$txt = preg_replace("/\[\/i\]/is",'</i>', $txt);
$txt = preg_replace("/\[u\]/is",'<u>', $txt);
$txt = preg_replace("/\[\/u\]/is",'</u>', $txt);
/**
* Apply replacements (faster + cleaner than multiple preg_replace)
*/
$txt = str_replace(array_keys($bbMap), array_values($bbMap), $txt);
//nl2br = enter
/**
* ---------------------------------------------------------
* Preserve line breaks as in original implementation
* ---------------------------------------------------------
*/
echo nl2br($txt);
?>
+123 -22
View File
@@ -1,37 +1,138 @@
<?php
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename troops.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Preserved original functionality ##
## - Reduced repeated method calls for unit names ##
## - Added small safety guards for legacy PHP ##
## - Improved readability ##
## ##
#################################################################################
?>
<table id="troops" cellpadding="1" cellspacing="1">
<thead><tr>
<th colspan="3"><?php echo TROOPS; ?></th>
</tr></thead><tbody>
<thead>
<tr>
<th colspan="3">
<?php echo TROOPS; ?>
</th>
</tr>
</thead>
<tbody>
<?php
$troops = $technology->getAllUnits($village->wid,True,1);
$TroopsPresent = False;
for($i=1;$i<=50;$i++) {
if($troops['u'.$i] > 0) {
echo "<tr><td class=\"ico\"><a href=\"build.php?id=39\"><img class=\"unit u".$i."\" src=\"img/x.gif\" alt=\"".$technology->getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /></a></td>";
echo "<td class=\"num\">".$troops['u'.$i]."</td><td class=\"un\">".$technology->getUnitName($i)."</td></tr>";
$TroopsPresent = True;
}
/**
* ---------------------------------------------------------
* Load all village troops
* ---------------------------------------------------------
*/
$troops = $technology->getAllUnits($village->wid, true, 1);
/**
* Cache unit list to avoid repeated calls
*/
$unitNameCache = array();
$troopsPresent = false;
/**
* ---------------------------------------------------------
* Loop all possible units (Travian standard max 50)
* ---------------------------------------------------------
*/
for ($i = 1; $i <= 50; $i++) {
$unitKey = 'u' . $i;
if (!empty($troops[$unitKey])) {
/**
* Cache unit name (avoid repeated calls)
*/
if (!isset($unitNameCache[$i])) {
$unitNameCache[$i] = $technology->getUnitName($i);
}
$unitName = $unitNameCache[$i];
echo '
<tr>
<td class="ico">
<a href="build.php?id=39">
<img
class="unit u' . $i . '"
src="img/x.gif"
alt="' . $unitName . '"
title="' . $unitName . '"
/>
</a>
</td>
<td class="num">
' . $troops[$unitKey] . '
</td>
<td class="un">
' . $unitName . '
</td>
</tr>';
$troopsPresent = true;
}
}
if($troops['hero'] > 0) {
echo "<tr><td class=\"ico\"><a href=\"build.php?id=39\"><img class=\"unit uhero\" src=\"img/x.gif\" alt=\"Hero\" title=\"Hero\" /></a></td>";
echo "<td class=\"num\">".$troops['hero']."</td><td class=\"un\">Hero</td></tr>";
$TroopsPresent = True;
/**
* ---------------------------------------------------------
* Hero handling
* ---------------------------------------------------------
*/
if (!empty($troops['hero'])) {
echo '
<tr>
<td class="ico">
<a href="build.php?id=39">
<img
class="unit uhero"
src="img/x.gif"
alt="Hero"
title="Hero"
/>
</a>
</td>
<td class="num">
' . (int)$troops['hero'] . '
</td>
<td class="un">
Hero
</td>
</tr>';
$troopsPresent = true;
}
$units = $technology->getUnitList($village->wid);
if(!$TroopsPresent) {
echo "<tr><td>none</td></tr>";
/**
* ---------------------------------------------------------
* Empty state
* ---------------------------------------------------------
*/
if (!$troopsPresent) {
echo '<tr><td>none</td></tr>';
}
?>
</tbody></table>
</div>
</tbody>
</table>
</div>
+21 -2
View File
@@ -1,3 +1,22 @@
<div id="content" class="plus">
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename version.tpl ##
## Developed by: Dzoki ##
## Refactored by: Shadow Incremental Refactor ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ##
## Incremental Refactor Notes: ##
## - Kept original structure intact ##
## - Ensured safe PHP wrapper (in case file is included in PHP context) ##
## - Minimal overhead / fully backward compatible ##
## ##
#################################################################################
?>
<div id="content" class="plus">
<div id="textmenu">
</div>
</div>
</div>
-165
View File
@@ -1,165 +0,0 @@
-- 21.06.2018 -> added one column and one index
ALTER TABLE `s1_artefacts` ADD `del` TINYINT(1) NULL DEFAULT '0' AFTER `lastupdate`;
ALTER TABLE `testtravian`.`s1_artefacts` ADD INDEX `active-owner-conquered-del` (`active`, `owner`, `conquered`, `del`);
-- 21.05.2018 -> added three indexes
ALTER TABLE `s1_forum_cat` ADD INDEX `display_to_alliances` (`display_to_alliances`(11));
ALTER TABLE `s1_forum_cat` ADD INDEX `display_to_users` (`display_to_users`(11));
ALTER TABLE `s1_forum_cat` ADD INDEX `sorting` (`sorting`);
-- 20.05.2018 -> dropped eight columns
ALTER TABLE `s1_forum_topic`
DROP `alliance0`,
DROP `player0`,
DROP `coor0`,
DROP `report0`;
ALTER TABLE `s1_forum_post`
DROP `alliance0`,
DROP `player0`,
DROP `coor0`,
DROP `report0`;
-- 19.05.2018 -> added two new columns
ALTER TABLE s1_forum_cat ADD (`display_to_alliances` text, `display_to_users` text)
-- 18.05.2018 -> added a new column
ALTER TABLE s1_forum_cat ADD `sorting` int(11) NOT NULL AFTER `id`
-- 16.05.2018 -> dropped four columns
ALTER TABLE `s1_raidlist` DROP `t7`, DROP `t8`, DROP `t9`, DROP `t10`;
-- 23.04.2018 -> new table
CREATE TABLE IF NOT EXISTS `s1_artefacts_chrono` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`artefactid` int(11) NULL,
`uid` int(11) NULL,
`vref` int(11) NULL,
`conqueredtime` int(11) NULL,
PRIMARY KEY (`id`),
KEY `artefactid-conqueredtime` (`artefactid`,`conqueredtime`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
-- 7.01.2018 -> new column
ALTER TABLE s1_fdata ADD `ww_lastupdate` int(11) NULL DEFAULT NULL AFTER `wwname`;
-- 2.12.2017 -> new indexes
ALTER TABLE `s1_vdata` ADD INDEX(`exp1`);
ALTER TABLE `s1_vdata` ADD INDEX(`exp2`);
ALTER TABLE `s1_vdata` ADD INDEX(`exp3`);
-- 17.11.2017 -> query optimizations
ALTER TABLE `s1_prisoners` DROP INDEX `from`, ADD INDEX `from-t11` (`from`, `t11`);
ALTER TABLE `s1_enforcement` DROP INDEX `from`, ADD INDEX `from` (`from`, `hero`) USING BTREE;
ALTER TABLE `s1_forum_post` CHANGE `date` `date` INT NULL DEFAULT NULL;
ALTER TABLE `s1_market` DROP INDEX `vref-accept`, ADD INDEX `vref-accept-merchant` (`vref`, `accept`, `merchant`) USING BTREE;
ALTER TABLE `s1_mdata` ADD INDEX `target-viewed` (`target`, `viewed`);
ALTER TABLE `s1_ndata` ADD INDEX `uid-viewed` (`uid`, `viewed`);
-- 8.11.2017 -> query optimizations and cleanups
ALTER TABLE `s1_ww_attacks` ADD INDEX(`vid`);
-- 2.11.2017 -> Hero fixes
ALTER TABLE `s1_hero` ADD INDEX(`lastupdate`);
ALTER TABLE `s1_hero` DROP INDEX `uid`, ADD INDEX `uid` (`uid`, `dead`) USING BTREE;
ALTER TABLE `s1_hero` ADD INDEX(`inrevive`);
ALTER TABLE `s1_hero` ADD INDEX(`intraining`);
-- 31.10.2017 -> Embassy and alliance updates
ALTER TABLE `s1_ali_permission` ADD INDEX(`alliance`);
ALTER TABLE `s1_allimedal` ADD INDEX(`allyid`);
ALTER TABLE `s1_ali_permission` DROP INDEX `uid-alliance`, ADD UNIQUE `uid-alliance` (`uid`, `alliance`) USING BTREE;
-- 27.10.2017 -> SQL optimizations
ALTER TABLE `s1_route` ADD INDEX `uid-timestamp` (`uid`, `timestamp`);
-- 24.10.2017 -> SQL optimizations
ALTER TABLE `s1_users` ADD INDEX(`sit1`);
ALTER TABLE `s1_users` ADD INDEX(`sit2`);
ALTER TABLE `s1_ndata` ADD INDEX(`toWref`);
ALTER TABLE `s1_wdata` ADD INDEX `x-y` (`x`, `y`);
ALTER TABLE `s1_a2b` ADD INDEX `ckey` (`ckey`(25));
ALTER TABLE `s1_ali_permission` ADD INDEX `uid-alliance` (`uid`, `alliance`);
ALTER TABLE `s1_forum_cat` CHANGE `alliance` `alliance` INT NOT NULL;
ALTER TABLE `s1_forum_cat` ADD INDEX `alliance-forum_area` (`alliance`, `forum_area`);
ALTER TABLE `s1_forum_topic` CHANGE `cat` `cat` INT NOT NULL;
ALTER TABLE `s1_forum_topic` ADD INDEX `cat-stick` (`cat`, `stick`);
ALTER TABLE `s1_forum_edit` CHANGE `alliance` `alliance` INT NOT NULL;
ALTER TABLE `s1_forum_edit` ADD INDEX(`alliance`);
ALTER TABLE `s1_forum_post` CHANGE `topic` `topic` INT NOT NULL, CHANGE `owner` `owner` INT NOT NULL;
ALTER TABLE `s1_forum_topic` CHANGE `post_date` `post_date` INT NOT NULL;
ALTER TABLE `s1_forum_topic` CHANGE `owner` `owner` INT NOT NULL, CHANGE `alliance` `alliance` INT NOT NULL, CHANGE `ends` `ends` INT NOT NULL, CHANGE `close` `close` TINYINT NOT NULL, CHANGE `stick` `stick` TINYINT NOT NULL;
ALTER TABLE `s1_forum_topic` CHANGE `date` `date` INT NOT NULL;
ALTER TABLE `s1_ali_log` ADD INDEX(`aid`);
ALTER TABLE `s1_alidata` ADD INDEX(`tag`);
ALTER TABLE `s1_alidata` ADD INDEX(`name`);
ALTER TABLE `s1_alidata` ADD INDEX(`leader`);
ALTER TABLE `s1_ali_invite` ADD INDEX `alliance-accept` (`alliance`, `accept`);
ALTER TABLE `s1_ali_invite` ADD INDEX(`uid`);
ALTER TABLE `s1_users` ADD INDEX(`gold`);
ALTER TABLE `s1_farmlist` ADD INDEX(`owner`);
ALTER TABLE `s1_raidlist` CHANGE `distance` `distance` FLOAT NULL DEFAULT '0';
ALTER TABLE `s1_raidlist` ADD INDEX `lid-distance` (`lid`, `distance`);
ALTER TABLE `s1_artefacts` ADD INDEX `size-type` (`size`, `type`);
ALTER TABLE `s1_odata` ADD INDEX(`maxstore`);
ALTER TABLE `s1_odata` ADD INDEX(`maxcrop`);
-- 23.10.2017 -> SQL optimizations
ALTER TABLE `s1_medal` ADD INDEX(`week`);
ALTER TABLE `s1_market` ADD INDEX `vref-accept` (`vref`, `accept`);
ALTER TABLE `s1_fdata` ADD INDEX(`f99`);
ALTER TABLE `s1_fdata` ADD INDEX(`f99t`);
ALTER TABLE `s1_diplomacy` ADD INDEX(`alli1`);
ALTER TABLE `s1_diplomacy` ADD INDEX(`alli2`);
ALTER TABLE `s1_diplomacy` ADD INDEX `type-accepted` (`type`, `accepted`);
ALTER TABLE `s1_wdata` ADD INDEX(`fieldtype`);
-- 22.10.2017 -> SQL optimizations
ALTER TABLE `s1_users` ADD INDEX(`tribe`);
ALTER TABLE `s1_users` ADD INDEX `timestamp-tribe` (`timestamp`, `tribe`);
ALTER TABLE `s1_users` DROP INDEX `username`;
ALTER TABLE `s1_users` ADD UNIQUE `username` (`username`);
ALTER TABLE `s1_activate` CHANGE `username` `username` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `s1_activate` ADD UNIQUE `username` (`username`);
ALTER TABLE `s1_activate` CHANGE `email` `email` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `s1_activate` ADD UNIQUE(`email`);
ALTER TABLE `s1_users` CHANGE `email` `email` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
-- YOU MAY NOT NEED THESE IF YOUR EMAILS FOR THESE 3 ACCOUNTS ARE ALREADY DIFFERENT FROM ONE ANOTHER
UPDATE `s1_users` SET `email` = 'support@travianz.game' WHERE `s1_users`.`id` = 1;
UPDATE `s1_users` SET `email` = 'nature@travianz.game' WHERE `s1_users`.`id` = 2;
UPDATE `s1_users` SET `email` = 'taskmaster@travianz.game' WHERE `s1_users`.`id` = 4;
-- END OF "YOU MAY NOT NEED THESE"
ALTER TABLE `s1_users` ADD UNIQUE `email` (`email`);
ALTER TABLE `s1_users` ADD INDEX(`access`);
ALTER TABLE `s1_active` ADD INDEX(`timestamp`);
ALTER TABLE `s1_odata` ADD INDEX(`clay`);
ALTER TABLE `s1_odata` ADD INDEX(`crop`);
ALTER TABLE `s1_odata` ADD INDEX(`iron`);
ALTER TABLE `s1_odata` ADD INDEX(`wood`);
ALTER TABLE `s1_vdata` ADD INDEX(`crop`);
ALTER TABLE `s1_vdata` ADD INDEX(`iron`);
ALTER TABLE `s1_vdata` ADD INDEX(`clay`);
ALTER TABLE `s1_vdata` ADD INDEX(`wood`);
ALTER TABLE `s1_deleting` ADD INDEX(`timestamp`);
ALTER TABLE `s1_movement` ADD INDEX `proc-sort_type-endtime` (`proc`, `sort_type`, `endtime`);
ALTER TABLE `s1_vdata` ADD INDEX(`starv`);
ALTER TABLE `s1_vdata` ADD INDEX(`loyalty`);
ALTER TABLE `s1_odata` ADD INDEX(`loyalty`);
ALTER TABLE `s1_artefacts` ADD INDEX `active-type-lastupdate` (`active`, `type`, `lastupdate`);
-- 22.10.2017 -> forum topics table and indexe changes
ALTER TABLE `s1_forum_post` CHANGE `topic` `topic` INT NULL DEFAULT NULL;
ALTER TABLE `s1_forum_post` CHANGE `owner` `owner` INT NULL DEFAULT NULL;
ALTER TABLE `s1_forum_post` ADD INDEX `topic-owner` (`topic`, `owner`);
-- 20.10.2017 -> changing MD5 for bcrypt password hashing algo
ALTER TABLE `s1_users` ADD `is_bcrypt` TINYINT(1) NOT NULL DEFAULT '0' AFTER `vactwoweeks`;