From 60c2ed2f606f7e84ed44253c2e8ca2ae76ea2ee5 Mon Sep 17 00:00:00 2001 From: Catalin Novgorodschi <1140613+Shadowss@users.noreply.github.com> Date: Thu, 7 May 2026 11:20:05 +0300 Subject: [PATCH] Incremental Refactor Templates 3 Incremental Refactor Templates 2 --- Admin/Templates/natars.tpl | 6 +- Templates/Building.tpl | 228 ++++++++++++--- Templates/dorf2.tpl | 572 ++++++++++++++++++++++++++++--------- Templates/field.tpl | 224 +++++++++++++-- Templates/footer.tpl | 100 +++++-- Templates/header.tpl | 346 ++++++++++++++++------ Templates/index.php | 36 +-- Templates/indexnews.tpl | 25 +- Templates/links.tpl | 185 ++++++++++-- Templates/menu.tpl | 438 +++++++++++++++++++++------- Templates/movement.tpl | 485 +++++++++++++++++++++---------- Templates/multivillage.tpl | 301 ++++++++++++------- Templates/natars.tpl | 107 ++++++- Templates/news.tpl | 12 +- Templates/production.tpl | 143 +++++++--- Templates/quest.tpl | 107 +++++-- Templates/res.tpl | 173 +++++++---- Templates/rules.tpl | 20 +- Templates/support.tpl | 22 +- Templates/text.tpl | 68 ++++- Templates/text_format.tpl | 50 +++- Templates/troops.tpl | 145 ++++++++-- Templates/version.tpl | 23 +- sql_updates.txt | 165 ----------- 24 files changed, 2924 insertions(+), 1057 deletions(-) delete mode 100644 sql_updates.txt diff --git a/Admin/Templates/natars.tpl b/Admin/Templates/natars.tpl index 5051c1c1..b0d0e593 100644 --- a/Admin/Templates/natars.tpl +++ b/Admin/Templates/natars.tpl @@ -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 'No artifacts found'; } 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){ diff --git a/Templates/Building.tpl b/Templates/Building.tpl index 07f98161..1c0d09b4 100644 --- a/Templates/Building.tpl +++ b/Templates/Building.tpl @@ -1,56 +1,204 @@ -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'); + } +} ?> -NewBuilding){ ?> + +NewBuilding) { ?> + - - + + - - - buildArray as $jobs) { - if($jobs['master'] == 0){ - echo " + - if($jobs['loopcon'] == 1) echo " (waiting loop)"; + - echo ""; - echo ""; - }else{ - echo " -
- gold >= 2) { - ?> - Finish all construction and research orders in this village immediately for 2 Gold? - + +
+ + + gold) && $session->gold >= 2) { + ?> + + + Finish all construction and research orders in this village immediately for 2 Gold? + + +
checker\">"; - echo "\"cancel\""; - echo "".Building::procResType($jobs['type'])." (Level ".$jobs['level'].")."; +
in timer."\">"; - echo $generator->getTimeFormat($jobs['timestamp']-time()); - echo " hrs.done at ".date('H:i', $jobs['timestamp'])."
checker\">"; - echo "\"cancel\""; - echo Building::procResType($jobs['type'])." (Level ".$jobs['level'].")"; - } - } - ?> -
- - + 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); + ?> + + + + + + + cancel + + + + + + + + + + + + + (Level ) + + + + + + + + + (Level ) (master builder) + + + + + + + + + + + in + + getTimeFormat($remainingTime); ?> + + hrs. + + + + + done at + + + + + +   + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Templates/dorf2.tpl b/Templates/dorf2.tpl index 2a67c1f8..5024ace6 100644 --- a/Templates/dorf2.tpl +++ b/Templates/dorf2.tpl @@ -1,150 +1,464 @@ isset($resarray['f'.$fieldId]) ? (int)$resarray['f'.$fieldId] : 0, + 'type' => isset($resarray['f'.$fieldId.'t']) ? (int)$resarray['f'.$fieldId.'t'] : 0 + ); + } +} ?> + +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']; + } +} +?> + + + -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']; -} -?> - - + + + + + + + - "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 ""; - } - }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 ""; - } -} -?> - - - - - -tribe == 3) $session->tribe = ''; -if($building->walling()) $vmapc = "d2_1".$session->tribe; -else $vmapc = ($village->resarray['f40'] == 0) ? "d2_0" : "d2_1".$session->tribe; -?> -
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 "\"$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 "\"$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 ''; + } + + 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 ''; } -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 "\"Rallyresarray['f39']."\" />"; - else echo "\"Rally"; -} -else echo "\"Rallyresarray['f39']."\" />"; - ?> + + + + + + + + + + + resarray['f99t'] == 40){ - if($village->resarray['f99'] >= 0 && $village->resarray['f99'] <= 19){ - echo 'Worldwonder'; - } - if($village->resarray['f99'] >= 20 && $village->resarray['f99'] <= 39){ - echo 'Worldwonder'; - } - if($village->resarray['f99'] >= 40 && $village->resarray['f99'] <= 59){ - echo 'Worldwonder'; - } - if($village->resarray['f99'] >= 60 && $village->resarray['f99'] <= 79){ - echo 'Worldwonder'; - } - if($village->resarray['f99'] >= 80 && $village->resarray['f99'] <= 99){ - echo 'Worldwonder'; - } - if($village->resarray['f99'] == 100){ - echo '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; } ?> + + + +
+ +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 '' . 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 '' . 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 'Rally Point Level ' . (int)$village->resarray['f39'] . ''; + + } else { + + echo 'Rally Point building site'; + } + +} else { + + echo 'Rally Point Level ' . (int)$village->resarray['f39'] . ''; +} +?> + +resarray['f99t']) && + (int)$village->resarray['f99t'] == 40 +) { + + $wwLevel = (int)$village->resarray['f99']; + + if ($wwLevel >= 0 && $wwLevel <= 19) { + echo 'Worldwonder'; + } + + if ($wwLevel >= 20 && $wwLevel <= 39) { + echo 'Worldwonder'; + } + + if ($wwLevel >= 40 && $wwLevel <= 59) { + echo 'Worldwonder'; + } + + if ($wwLevel >= 60 && $wwLevel <= 79) { + echo 'Worldwonder'; + } + + if ($wwLevel >= 80 && $wwLevel <= 99) { + echo 'Worldwonder'; + } + + if ($wwLevel == 100) { + echo 'Worldwonder'; + } +} +?> + + +
> + > + resarray['f'.($i + 18).'t'] != 0){ - echo "
".$village->resarray['f'.($i + 18)]."
"; - } +/** + * Level numbers + */ +for ($i = 1; $i <= 20; $i++) { + + $fieldId = $i + 18; + + if ((int)$village->resarray['f'.$fieldId.'t'] != 0) { + + echo '
' + . (int)$village->resarray['f'.$fieldId] + . '
'; + } } -if($village->resarray['f39t'] != 0){ - echo "
".$village->resarray['f39']."
"; + +/** + * Rally point level + */ +if ((int)$village->resarray['f39t'] != 0) { + + echo '
' + . (int)$village->resarray['f39'] + . '
'; } -if($village->resarray['f40t'] != 0){ - echo "
".$village->resarray['f40']."
"; + +/** + * Wall level + */ +if ((int)$village->resarray['f40t'] != 0) { + + echo '
' + . (int)$village->resarray['f40'] + . '
'; } -if($village->resarray['f99t'] != 0){ - echo "
".$village->resarray['f99']."
"; + +/** + * WW level + */ +if ((int)$village->resarray['f99t'] != 0) { + + echo '
' + . (int)$village->resarray['f99'] + . '
'; } ?> -
- + +
+ + + + +
- - onclick="vil_levels_toggle()" /> + + + + onclick="vil_levels_toggle()" /> \ No newline at end of file diff --git a/Templates/field.tpl b/Templates/field.tpl index 00b2a36f..0a562362 100644 --- a/Templates/field.tpl +++ b/Templates/field.tpl @@ -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' +); ?> + + + + 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 " \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 '' . "\r\n"; } ?> - + + + + -
+ + +
+ "; - } + +/** + * 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 '' . safeHTML($altText) . ''; } ?> - + + + +
\ No newline at end of file diff --git a/Templates/footer.tpl b/Templates/footer.tpl index 1f8d94c0..25dda5b9 100644 --- a/Templates/footer.tpl +++ b/Templates/footer.tpl @@ -1,32 +1,94 @@ ## +## - 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'; ?> + + + +
+ + + +
+ + +
+ +
\ No newline at end of file diff --git a/Templates/header.tpl b/Templates/header.tpl index db091e8f..168318c0 100644 --- a/Templates/header.tpl +++ b/Templates/header.tpl @@ -1,104 +1,278 @@ -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'; +} ?> + + \ No newline at end of file diff --git a/Templates/index.php b/Templates/index.php index 9fcb4aed..726b2151 100644 --- a/Templates/index.php +++ b/Templates/index.php @@ -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']), '/\\'); ?> -
-
- -

404 - File not found

- - Not Found
- -

We looked 404 times already but can't find anything, Not even an X marking the spot.

- -

This system is not complete yet. So the page probably does not exist.

- -
- -
+
+

404 - File not found

+ Not Found
+

We looked 404 times already but can't find anything, Not even an X marking the spot.

+

This system is not complete yet. So the page probably does not exist.


+
\ No newline at end of file diff --git a/Templates/indexnews.tpl b/Templates/indexnews.tpl index c33ae3f1..e392d5ab 100644 --- a/Templates/indexnews.tpl +++ b/Templates/indexnews.tpl @@ -1,17 +1,24 @@

[Release by: TravianZ]

Thank you for using our version!

diff --git a/Templates/links.tpl b/Templates/links.tpl index e49957b2..d104bb89 100644 --- a/Templates/links.tpl +++ b/Templates/links.tpl @@ -1,39 +1,176 @@ - ## +## 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 ''; -foreach($links as $link) { - // Check, if the url is extern - if(substr($link['url'], -1, 1) == '*') { - $target = ' target="_blank"'; - $external = ''; - $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 ''; + // Blochează javascript: + if (stripos($url, 'javascript:') === 0) { + return '#'; + } + + return $url; + } } -} -print '
Links:
'; + +/** + * 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; + } +?> + + + + + + + + + + + + + + + +'; + } +?> + + + + + + + + + + + + + +
+ Links: +
+ + \ No newline at end of file diff --git a/Templates/menu.tpl b/Templates/menu.tpl index e330c369..2daaef83 100644 --- a/Templates/menu.tpl +++ b/Templates/menu.tpl @@ -1,141 +1,367 @@ pageLoadTimeStart(); -/** --------------------------------------------------- **\ -| ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* | -+---------------------------------------------------------+ -| Credits: All the developers including the leaders: | -| Advocaite & Dzoki & Donnchadh | -| | -| Copyright: TravianZ Project All rights reserved | -\** --------------------------------------------------- **/ - -?>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; ?> + + + -
- -

-
+
-
- + +

+ + + -

access == MULTIHUNTER) { + + + - echo "Multihunter Panel"; - } ?> access == ADMIN) { - echo "".ADMIN_PANEL.""; - echo "".MASS_MESSAGE.""; - echo 'Build Cropper'; - echo "".SYSTEM_MESSAGE.""; - } ?>

-

- -

-

- + + +

+ +
+ + + +
+ + + + + +

+ + + + + + + + + + + + + + - TravianZ Plus - - - -

- isDeleting($session->uid); - if($timestamp){ - echo "
"; - - if($timestamp > time() + 172800){ - echo "uid . "&a=1&e=4\">\"Cancel "; - } - - $time = $generator->getTimeFormat(($timestamp - time())); - echo " The account will be deleted in timer . "\">" . $time . " .
"; - } - ?> -
+ + Multihunter Panel + + -

-
-

Hi username; ?>,

- -
-
-

»

-
-
+ /** + * Admin links + */ + if($isAdmin) { + ?> + + + -



-


"; - include("Templates/links.tpl"); - } + + + + + + Build Cropper + + + + + + -
-
+ + + - +

-
+

+ + + +

+ + +

+ + + + TravianZ + + P + l + u + s + + + + + + + + +

+ + isDeleting($userId); + + if($timestamp) { + + echo '
'; + + /** + * Allow cancellation if more than 48h remain + */ + if($timestamp > (time() + 172800)) { + + echo ' + Cancel process + '; + } + + /** + * Remaining deletion time + */ + $time = $generator->getTimeFormat($timestamp - time()); + + echo ' + The account will be deleted in + + ' . $time . ' + . + '; + + echo '
'; + } ?> -
-
-
- pageLoadTimeEnd()-$start_timer)*1000); -?> ms +
+ + + +
+ +

+ +

+ +
+ +

+ Hi , +

+ + + +
+ +
+ +

+ + » + +

+ +
+ +
+ +



+ +
+ +


"; + include("Templates/links.tpl"); + } + ?> + +
+ +
+ + + +
+ + + +
+ +
+ +
+ + + + + pageLoadTimeEnd() - $start_timer) * 1000 + ); + ?> + + + ms + +
+ + + + + + -
-
+
-
+ +
+ + +} +?> + + + - + \ No newline at end of file diff --git a/Templates/movement.tpl b/Templates/movement.tpl index c3b76b0c..d675044a 100644 --- a/Templates/movement.tpl +++ b/Templates/movement.tpl @@ -1,178 +1,365 @@ - + + + ' . $title . ' + + + + » + + + + +
+ + ' . $count . ' ' . $short . ' + +
+ +
+ in  + + ' . $generator->getTimeFormat($arrivalTime - time()) . ' + +  ' . HOURS . ' +
+ + '; + } +} + +/** + * --------------------------------------------------------- + * 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 ''; +$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 ' - '; +/** + * --------------------------------------------------------- + * 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 ' +
'.TROOP_MOVEMENTS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival)-time()).' '.HOURS.'
+ + + + + + '; } -/* 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 ' - '; +/** + * 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 ' - '; +/** + * 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 ' - '; +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 ' - '; +/** + * ========================================================= + * 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 ' - '; -} \ No newline at end of file + +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 ' + +
' . TROOP_MOVEMENTS . '
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival1)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival2)-time()).' '.HOURS.'
'.$title.'»
'.$lala.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival3)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival5)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival6)-time()).' '.HOURS.'
'; +} +?> \ No newline at end of file diff --git a/Templates/multivillage.tpl b/Templates/multivillage.tpl index c75331d9..39b3ad68 100644 --- a/Templates/multivillage.tpl +++ b/Templates/multivillage.tpl @@ -1,127 +1,214 @@ -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; + } + ?> - - getArrayMemberVillage($session->uid); -if(isset($_GET['w'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['r'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['z'])) { - for($i=1;$i<=count($session->villages);++$i){echo' + + - - - '; - } -} -else if(isset($_GET['o'])) { - for($i=1;$i<=count($session->villages);++$i){echo' + + + + + + + - - - '; + + + + + + + + + +villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['c'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['t'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['d'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['aid'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['uid'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['vill']) && isset($_GET['id'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - } -} -else if(isset($_GET['t']) && isset($_GET['id'])) { - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - }}else{ - for($i=1;$i<=count($session->villages);++$i){echo' - - - - '; - }}?> - +?> + + +
:
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
+ + : + +
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
+ ● + + +
+ ( +
+ +
+ | +
+ +
+ ) +
+ +
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
('.$returnVillageArray[$i-1]['x'].'
|
'.$returnVillageArray[$i-1]['y'].')
+ +?> \ No newline at end of file diff --git a/Templates/natars.tpl b/Templates/natars.tpl index e60133d7..7f3fe2c6 100644 --- a/Templates/natars.tpl +++ b/Templates/natars.tpl @@ -1,17 +1,94 @@ - ($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]; + $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) { ?> -

-
- will spawn in: - getTimeFormat($spawnTime); ?> -
- \ No newline at end of file +

+ +
+ + + + will spawn in: + + + + getTimeFormat($spawnTime); ?> + + +
+ + \ No newline at end of file diff --git a/Templates/news.tpl b/Templates/news.tpl index 13e4748b..cbfc6452 100644 --- a/Templates/news.tpl +++ b/Templates/news.tpl @@ -1,14 +1,22 @@ - + + getProd("wood") : 0; +$clayProd = isset($village) ? $village->getProd("clay") : 0; +$ironProd = isset($village) ? $village->getProd("iron") : 0; +$cropProd = isset($village) ? $village->getProd("crop") : 0; ?> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:
<?php echo LUMBER; ?>:getProd("wood"); ?>
<?php echo CLAY; ?>:getProd("clay"); ?>
<?php echo IRON; ?>:getProd("iron"); ?>
<?php echo CROP; ?>:getProd("crop"); ?>
+ : +
+ <?php echo LUMBER; ?> + + : + + + + +
+ <?php echo CLAY; ?> + + : + + + + +
+ <?php echo IRON; ?> + + : + + + + +
+ <?php echo CROP; ?> + + : + + + + +
\ No newline at end of file diff --git a/Templates/quest.tpl b/Templates/quest.tpl index 383629a4..aa005406 100644 --- a/Templates/quest.tpl +++ b/Templates/quest.tpl @@ -1,37 +1,102 @@ -= 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) { +?> + +
- - To the task - - To the task + + + + To the task + + + + To the task + +
+ + + quest.number = null; + + quest.number = 0; + + + quest.last = 37; + + quest.last = 30; + + +cache_preload = new Image(); +cache_preload.src = "img/x.gif"; +cache_preload.className = "wood"; + + + \ No newline at end of file diff --git a/Templates/res.tpl b/Templates/res.tpl index dda9396f..addf2544 100644 --- a/Templates/res.tpl +++ b/Templates/res.tpl @@ -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 ## ## ## ################################################################################# -?> -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; ?>
- - - - - - - - - - acrop > 0){ ?> - - - - - - - -
<?php echo LUMBER; ?>awood)."/".$village->maxstore; ?><?php echo CLAY; ?>aclay)."/".$village->maxstore; ?><?php echo IRON; ?>airon)."/".$village->maxstore; ?><?php echo CROP; ?>acrop)."/".$village->maxcrop; ?>maxcrop; ?><?php echo CROP_COM; ?>pop+$technology->getUpkeep($village->unitall,0))."/".$totalproduction.""; ?>
- - + +
+ - - - - - - + + + + + + + + + + + + + + + + acrop > 0) { ?> + + + + + + + + + + + +
                                                                    gold <= 1){ - echo 'Remaining gold '.$session->gold.' Gold'; - } - else if($session->gold >=2){ - echo 'Remaining gold '.$session->gold.' Gold'; - } - ?> - + <?php echo LUMBER; ?> + + + + <?php echo CLAY; ?> + + + + <?php echo IRON; ?> + + + + <?php echo CROP; ?> + + + + 0/ + + <?php echo CROP_COM; ?> + + pop + $technology->getUpkeep($village->unitall, 0)) . "/" . $totalproduction; ?> +
+ + + + + + + + + + + + + + + + +
                                                                     + gold <= 1) { + echo ' + Gold + ' . $session->gold . ' Gold + '; + } else { + echo 'Gold + ' . $session->gold . ' Gold'; + } + ?> +
- - -
- + + \ No newline at end of file diff --git a/Templates/rules.tpl b/Templates/rules.tpl index 953430c3..110c35c6 100644 --- a/Templates/rules.tpl +++ b/Templates/rules.tpl @@ -1,4 +1,22 @@ -

Game rules

+ + +

Game rules

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. diff --git a/Templates/support.tpl b/Templates/support.tpl index 3fe09d0d..35a64582 100644 --- a/Templates/support.tpl +++ b/Templates/support.tpl @@ -1,4 +1,22 @@ -

-
+ +
+
+
\ No newline at end of file diff --git a/Templates/text.tpl b/Templates/text.tpl index c723b6d9..9f942fc8 100644 --- a/Templates/text.tpl +++ b/Templates/text.tpl @@ -1,26 +1,68 @@ -Wonder of the World Villages\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 +\"WW\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="

World Wonder Construction Plans

\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\"Ancient\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]' => '', + '[i]' => '', + '[/i]' => '', + '[u]' => '', + '[/u]' => '', +); -//bbcode = html code -$txt = preg_replace("/\[b\]/is",'', $txt); -$txt = preg_replace("/\[\/b\]/is",'', $txt); -$txt = preg_replace("/\[i\]/is",'', $txt); -$txt = preg_replace("/\[\/i\]/is",'', $txt); -$txt = preg_replace("/\[u\]/is",'', $txt); -$txt = preg_replace("/\[\/u\]/is",'', $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); - ?> \ No newline at end of file diff --git a/Templates/text_format.tpl b/Templates/text_format.tpl index 51a7eedc..c02d8a08 100644 --- a/Templates/text_format.tpl +++ b/Templates/text_format.tpl @@ -1,26 +1,52 @@ - HTML conversion + * (kept compatible with legacy regex behavior) + * --------------------------------------------------------- + */ +$bbMap = array( + '[b]' => '', + '[/b]' => '', + '[i]' => '', + '[/i]' => '', + '[u]' => '', + '[/u]' => '', +); -//bbcode = html code -$txt = preg_replace("/\[b\]/is",'', $txt); -$txt = preg_replace("/\[\/b\]/is",'', $txt); -$txt = preg_replace("/\[i\]/is",'', $txt); -$txt = preg_replace("/\[\/i\]/is",'', $txt); -$txt = preg_replace("/\[u\]/is",'', $txt); -$txt = preg_replace("/\[\/u\]/is",'', $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); - ?> \ No newline at end of file diff --git a/Templates/troops.tpl b/Templates/troops.tpl index ed4c971d..4934e01d 100644 --- a/Templates/troops.tpl +++ b/Templates/troops.tpl @@ -1,37 +1,138 @@ - + - - - + + + + + + + + + getAllUnits($village->wid,True,1); -$TroopsPresent = False; -for($i=1;$i<=50;$i++) { - if($troops['u'.$i] > 0) { - echo ""; - echo ""; - $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 ' + + + + + + + '; + + $troopsPresent = true; + } } -if($troops['hero'] > 0) { - echo ""; - echo ""; - $TroopsPresent = True; + +/** + * --------------------------------------------------------- + * Hero handling + * --------------------------------------------------------- + */ +if (!empty($troops['hero'])) { + + echo ' + + + + + + + '; + + $troopsPresent = true; } -$units = $technology->getUnitList($village->wid); -if(!$TroopsPresent) { - echo ""; + +/** + * --------------------------------------------------------- + * Empty state + * --------------------------------------------------------- + */ +if (!$troopsPresent) { + echo ''; } ?> -
+ +
\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" />".$troops['u'.$i]."".$technology->getUnitName($i)."
+ + ' . $unitName . ' + + + ' . $troops[$unitKey] . ' + + ' . $unitName . ' +
\"Hero\"".$troops['hero']."Hero
+ + Hero + + + ' . (int)$troops['hero'] . ' + + Hero +
none
none
-
+ + + + +
\ No newline at end of file diff --git a/Templates/version.tpl b/Templates/version.tpl index ba39d9e3..504bb132 100644 --- a/Templates/version.tpl +++ b/Templates/version.tpl @@ -1,3 +1,22 @@ -
+ + +
-
+
+
\ No newline at end of file diff --git a/sql_updates.txt b/sql_updates.txt deleted file mode 100644 index 557c8c73..00000000 --- a/sql_updates.txt +++ /dev/null @@ -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`; \ No newline at end of file