From 02dd832932c814e50cb53d5aa7391650b741826e Mon Sep 17 00:00:00 2001
From: Martin Ambrus
Date: Wed, 22 Nov 2017 10:03:54 +0100
Subject: [PATCH 001/126] fix: undefined index
---
Templates/Profile/profile.tpl | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/Templates/Profile/profile.tpl b/Templates/Profile/profile.tpl
index 3e965532..b8e4f5a4 100644
--- a/Templates/Profile/profile.tpl
+++ b/Templates/Profile/profile.tpl
@@ -1,6 +1,6 @@
Player profile
-
-
-
+
+
-
+
From 65a62becc24e38e9412bd07911a69de437239156 Mon Sep 17 00:00:00 2001
From: Martin Ambrus
Date: Wed, 22 Nov 2017 11:47:17 +0100
Subject: [PATCH 002/126] fix: rat reinforcement does not arrive due to a wrong
reinfs check
#366
---
GameEngine/Automation.php | 2 +-
GameEngine/Database.php | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
index b2630e1b..efb09dbb 100755
--- a/GameEngine/Automation.php
+++ b/GameEngine/Automation.php
@@ -3438,7 +3438,7 @@ class Automation {
$DefenderID = $database->getVillageField($data['to'],"owner");
if (isset($AttackerID) && $session->uid==$AttackerID || $session->uid==$DefenderID) $reload=true;
$database->addEnforce($data);
- $reinf = $database->getEnforce($data['to'],$data['from']);
+ $reinf = $database->getEnforce($data['from'],$data['to']);
$database->modifyEnforce($reinf['id'],31,1,1);
$data_fail = '0,0,4,1,0,0,0,0,0,0,0,0,0,0';
$database->addNotice($to['owner'],$to['wref'],(isset($targetally) ? $targetally : 0),8,'village of the elders reinforcement '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
diff --git a/GameEngine/Database.php b/GameEngine/Database.php
index 1aa6a30f..7712f1b9 100755
--- a/GameEngine/Database.php
+++ b/GameEngine/Database.php
@@ -6094,7 +6094,7 @@ References: User ID/Message ID, Mode
}
}
- return ($array_passed ? self::$villageReinforcementsCache : self::$villageReinforcementsCache[$vid[0].$from[0]]);
+ return ($array_passed ? self::$villageFromReinforcementsCache : self::$villageFromReinforcementsCache[$vid[0].$from[0]]);
}
function getOasisEnforce($ref, $mode=0, $use_cache = true) {
@@ -6211,7 +6211,7 @@ References: User ID/Message ID, Mode
$modes = [];
for($i = $start; $i <= $end; $i++) {
- $units[] = $i;
+ $units[] = ($i < 0 ? 0 : $i);
$amounts[] = $data['t' . $j . ''];
$modes[] = 1;
$j++;
@@ -6237,7 +6237,7 @@ References: User ID/Message ID, Mode
$start2 = ($tribe - 1) * 10 + 1;
$start3 = ($tribe - 1) * 10;
if($start3 == 0){
- $start3 = "";
+ $start3 = "";
}
$end2 = ($tribe * 10);
//add unit
@@ -6248,11 +6248,11 @@ References: User ID/Message ID, Mode
$modes = [];
for($i = $start; $i <= $end; $i++) {
- $units[] = $i;
+ $units[] = ($i < 0 ? 0 : $i);
$amounts[] = $data['t' . $j . ''];
$modes[] = 1;
- $units[] = $i;
+ $units[] = ($i < 0 ? 0 : $i);
$amounts[] = ${'dead'.$j};
$modes[] = 0;
From 30fc76e85bc3a3384b63b9877a76b561adcaa9e6 Mon Sep 17 00:00:00 2001
From: Martin Ambrus
Date: Wed, 22 Nov 2017 12:20:05 +0100
Subject: [PATCH 003/126] fix: old version cannot save config data anymore
---
GameEngine/Admin/Mods/editAdminInfo.php | 25 +++++++++++++++-------
GameEngine/Admin/Mods/editExtraSet.php | 17 +++++++++++----
GameEngine/Admin/Mods/editLogSet.php | 27 ++++++++++++++++--------
GameEngine/Admin/Mods/editNewsboxSet.php | 27 ++++++++++++++++--------
GameEngine/Admin/Mods/editPlusSet.php | 11 +++++++++-
GameEngine/Admin/Mods/editServerSet.php | 25 +++++++++++++++-------
6 files changed, 93 insertions(+), 39 deletions(-)
diff --git a/GameEngine/Admin/Mods/editAdminInfo.php b/GameEngine/Admin/Mods/editAdminInfo.php
index 8e66d6b2..747c02dd 100755
--- a/GameEngine/Admin/Mods/editAdminInfo.php
+++ b/GameEngine/Admin/Mods/editAdminInfo.php
@@ -14,9 +14,18 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
+if (file_exists('constant_format.tpl')) {
+ die(
+ 'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
+ 'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
+ 'directory - otherwise saving configuration won\'t work.
' .
+ 'The constant_format.tpl file can be downloaded at ' .
+ 'https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl');
+}
+
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%DOMAIN%'", DOMAIN, $text);
$text = preg_replace("'%HOMEPAGE%'", HOMEPAGE, $text);
$text = preg_replace("'%SERVER%'", SERVER, $text);
-
+
// PLUS settings need to be kept intact
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", PLUS_PRODUCTION, $text);
@@ -123,7 +132,7 @@ $fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", (defined('PLUS_PACKAGE_D_GOLD') ? PLUS_PACKAGE_D_GOLD : '1000'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'), $text);
-
+
fwrite($fh, $text);
fclose($fh);
diff --git a/GameEngine/Admin/Mods/editExtraSet.php b/GameEngine/Admin/Mods/editExtraSet.php
index 7183a27a..e4b4cdc1 100755
--- a/GameEngine/Admin/Mods/editExtraSet.php
+++ b/GameEngine/Admin/Mods/editExtraSet.php
@@ -14,9 +14,18 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
+if (file_exists('constant_format.tpl')) {
+ die(
+ 'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
+ 'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
+ 'directory - otherwise saving configuration won\'t work.
' .
+ 'The constant_format.tpl file can be downloaded at ' .
+ 'https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl');
+}
+
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%DOMAIN%'", DOMAIN, $text);
$text = preg_replace("'%HOMEPAGE%'", HOMEPAGE, $text);
$text = preg_replace("'%SERVER%'", SERVER, $text);
-
+
// PLUS settings need to be kept intact
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", PLUS_PRODUCTION, $text);
@@ -120,7 +129,7 @@ $fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", (defined('PLUS_PACKAGE_D_GOLD') ? PLUS_PACKAGE_D_GOLD : '1000'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'), $text);
-
+
fwrite($fh, $text);
fclose($fh);
diff --git a/GameEngine/Admin/Mods/editLogSet.php b/GameEngine/Admin/Mods/editLogSet.php
index 35137df3..14b801b2 100755
--- a/GameEngine/Admin/Mods/editLogSet.php
+++ b/GameEngine/Admin/Mods/editLogSet.php
@@ -14,9 +14,18 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
+if (file_exists('constant_format.tpl')) {
+ die(
+ 'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
+ 'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
+ 'directory - otherwise saving configuration won\'t work.
' .
+ 'The constant_format.tpl file can be downloaded at ' .
+ 'https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl');
+}
+
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%DOMAIN%'", DOMAIN, $text);
$text = preg_replace("'%HOMEPAGE%'", HOMEPAGE, $text);
$text = preg_replace("'%SERVER%'", SERVER, $text);
-
+
// PLUS settings need to be kept intact
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", PLUS_PRODUCTION, $text);
@@ -120,7 +129,7 @@ $fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", (defined('PLUS_PACKAGE_D_GOLD') ? PLUS_PACKAGE_D_GOLD : '1000'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'), $text);
-
+
fwrite($fh, $text);
fclose($fh);
diff --git a/GameEngine/Admin/Mods/editNewsboxSet.php b/GameEngine/Admin/Mods/editNewsboxSet.php
index eba2c130..10a2fc9c 100755
--- a/GameEngine/Admin/Mods/editNewsboxSet.php
+++ b/GameEngine/Admin/Mods/editNewsboxSet.php
@@ -14,9 +14,18 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
+if (file_exists('constant_format.tpl')) {
+ die(
+ 'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
+ 'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
+ 'directory - otherwise saving configuration won\'t work.
' .
+ 'The constant_format.tpl file can be downloaded at ' .
+ 'https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl');
+}
+
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%DOMAIN%'", DOMAIN, $text);
$text = preg_replace("'%HOMEPAGE%'", HOMEPAGE, $text);
$text = preg_replace("'%SERVER%'", SERVER, $text);
-
+
// PLUS settings need to be kept intact
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", PLUS_PRODUCTION, $text);
@@ -127,7 +136,7 @@ $fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", (defined('PLUS_PACKAGE_D_GOLD') ? PLUS_PACKAGE_D_GOLD : '1000'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'), $text);
-
+
fwrite($fh, $text);
fclose($fh);
diff --git a/GameEngine/Admin/Mods/editPlusSet.php b/GameEngine/Admin/Mods/editPlusSet.php
index 798646d0..1ff28834 100644
--- a/GameEngine/Admin/Mods/editPlusSet.php
+++ b/GameEngine/Admin/Mods/editPlusSet.php
@@ -15,11 +15,20 @@ include_once("../../Database.php");
include_once("../../config.php");
$id = (int) $_POST['id'];
+if (file_exists('constant_format.tpl')) {
+ die(
+ 'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
+ 'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
+ 'directory - otherwise saving configuration won\'t work.
' .
+ 'The constant_format.tpl file can be downloaded at ' .
+ 'https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl');
+}
+
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\config.php");
$text = file_get_contents("constant_format.tpl");
-
+
$SUPPORT_MSGS_IN_ADMIN = (ADMIN_RECEIVE_SUPPORT_MESSAGES == false ? 'false' : 'true');
$ADMINS_RAIDABLE = (ADMIN_ALLOW_INCOMING_RAIDS == false ? 'false' : 'true');
diff --git a/GameEngine/Admin/Mods/editServerSet.php b/GameEngine/Admin/Mods/editServerSet.php
index f20ebb1d..78838fa4 100755
--- a/GameEngine/Admin/Mods/editServerSet.php
+++ b/GameEngine/Admin/Mods/editServerSet.php
@@ -14,9 +14,18 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
+if (file_exists('constant_format.tpl')) {
+ die(
+ 'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
+ 'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
+ 'directory - otherwise saving configuration won\'t work.
' .
+ 'The constant_format.tpl file can be downloaded at ' .
+ 'https://raw.githubusercontent.com/Shadowss/TravianZ/master/install/data/constant_format.tpl');
+}
+
$myFile = "../../config.php";
$fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%DOMAIN%'", DOMAIN, $text);
$text = preg_replace("'%HOMEPAGE%'", HOMEPAGE, $text);
$text = preg_replace("'%SERVER%'", SERVER, $text);
-
+
// PLUS settings need to be kept intact
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
$text = preg_replace("'%PLUS_PRODUCTION%'", PLUS_PRODUCTION, $text);
@@ -115,7 +124,7 @@ $fh = fopen($myFile, 'w') or die("
Can't open file: GameEngine\con
$text = preg_replace("'%PLUS_PACKAGE_D_GOLD%'", (defined('PLUS_PACKAGE_D_GOLD') ? PLUS_PACKAGE_D_GOLD : '1000'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_PRICE%'", (defined('PLUS_PACKAGE_E_PRICE') ? PLUS_PACKAGE_E_PRICE : '49,99'), $text);
$text = preg_replace("'%PLUS_PACKAGE_E_GOLD%'", (defined('PLUS_PACKAGE_E_GOLD') ? PLUS_PACKAGE_E_GOLD : '2000'), $text);
-
+
fwrite($fh, $text);
fclose($fh);
From 0134b0abe922180550d77bcbb227ce980544e55b Mon Sep 17 00:00:00 2001
From: Martin Ambrus
Date: Wed, 22 Nov 2017 12:21:16 +0100
Subject: [PATCH 004/126] fix: old version cannot save config data anymore
---
GameEngine/Admin/Mods/editAdminInfo.php | 2 +-
GameEngine/Admin/Mods/editExtraSet.php | 2 +-
GameEngine/Admin/Mods/editLogSet.php | 2 +-
GameEngine/Admin/Mods/editNewsboxSet.php | 2 +-
GameEngine/Admin/Mods/editPlusSet.php | 2 +-
GameEngine/Admin/Mods/editServerSet.php | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/GameEngine/Admin/Mods/editAdminInfo.php b/GameEngine/Admin/Mods/editAdminInfo.php
index 747c02dd..672ae9cf 100755
--- a/GameEngine/Admin/Mods/editAdminInfo.php
+++ b/GameEngine/Admin/Mods/editAdminInfo.php
@@ -14,7 +14,7 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
-if (file_exists('constant_format.tpl')) {
+if (!file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
diff --git a/GameEngine/Admin/Mods/editExtraSet.php b/GameEngine/Admin/Mods/editExtraSet.php
index e4b4cdc1..7ad37818 100755
--- a/GameEngine/Admin/Mods/editExtraSet.php
+++ b/GameEngine/Admin/Mods/editExtraSet.php
@@ -14,7 +14,7 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
-if (file_exists('constant_format.tpl')) {
+if (!file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
diff --git a/GameEngine/Admin/Mods/editLogSet.php b/GameEngine/Admin/Mods/editLogSet.php
index 14b801b2..59b1ab1f 100755
--- a/GameEngine/Admin/Mods/editLogSet.php
+++ b/GameEngine/Admin/Mods/editLogSet.php
@@ -14,7 +14,7 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
-if (file_exists('constant_format.tpl')) {
+if (!file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
diff --git a/GameEngine/Admin/Mods/editNewsboxSet.php b/GameEngine/Admin/Mods/editNewsboxSet.php
index 10a2fc9c..f1ec6e0e 100755
--- a/GameEngine/Admin/Mods/editNewsboxSet.php
+++ b/GameEngine/Admin/Mods/editNewsboxSet.php
@@ -14,7 +14,7 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
-if (file_exists('constant_format.tpl')) {
+if (!file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
diff --git a/GameEngine/Admin/Mods/editPlusSet.php b/GameEngine/Admin/Mods/editPlusSet.php
index 1ff28834..6f271bd4 100644
--- a/GameEngine/Admin/Mods/editPlusSet.php
+++ b/GameEngine/Admin/Mods/editPlusSet.php
@@ -15,7 +15,7 @@ include_once("../../Database.php");
include_once("../../config.php");
$id = (int) $_POST['id'];
-if (file_exists('constant_format.tpl')) {
+if (!file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
diff --git a/GameEngine/Admin/Mods/editServerSet.php b/GameEngine/Admin/Mods/editServerSet.php
index 78838fa4..dc883216 100755
--- a/GameEngine/Admin/Mods/editServerSet.php
+++ b/GameEngine/Admin/Mods/editServerSet.php
@@ -14,7 +14,7 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php");
$id = (int) $_POST['id'];
-if (file_exists('constant_format.tpl')) {
+if (!file_exists('constant_format.tpl')) {
die(
'You seem to be running a new version of TravianZ which was installed using an old installer. ' .
'Please download constant_format.tpl file and copy it into the GameEngine/Admin/Mods ' .
From 98ddbe235f3283a2513a493391e063eb8298f877 Mon Sep 17 00:00:00 2001
From: Martin Ambrus
Date: Wed, 22 Nov 2017 12:34:38 +0100
Subject: [PATCH 005/126] fix: pagination returns to ALL from Attacks page in
battle reports
Closes #343
---
Admin/Templates/Notice/all.tpl | 25 ++++++++++++-------------
Templates/Message/archive.tpl | 14 +++++++-------
Templates/Message/inbox.tpl | 8 ++++----
Templates/Notice/all.tpl | 23 +++++++++++------------
4 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/Admin/Templates/Notice/all.tpl b/Admin/Templates/Notice/all.tpl
index 714a8561..4f3ab47c 100644
--- a/Admin/Templates/Notice/all.tpl
+++ b/Admin/Templates/Notice/all.tpl
@@ -1,4 +1,4 @@
-