From cbd343e369c25bfa9c2870baaa8aa5dc1a6574de Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Fri, 7 Jul 2023 05:54:01 +0200 Subject: [PATCH 1/7] Fixed city walls and rallypoint incorrect availability --- Templates/Build/avaliable.tpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index dcfdea97..e871b10c 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -111,19 +111,19 @@ if((($granary == 0 && $granary1 == 0) || $granary == 20) && $mainbuilding >= 1 & include("avaliable/granary.tpl"); } if($wall == 0 && $wall1 == 0) { - if($session->tribe == 1 && $id != 39) { + if($session->tribe == 1 && $id == 40) { include("avaliable/citywall.tpl"); } - if($session->tribe == 2 && $id != 39) { + if($session->tribe == 2 && $id == 40) { include("avaliable/earthwall.tpl"); } - if($session->tribe == 3 && $id != 39) { + if($session->tribe == 3 && $id == 40) { include("avaliable/palisade.tpl"); } - if($session->tribe == 4 && $id != 39) { + if($session->tribe == 4 && $id == 40) { include("avaliable/earthwall.tpl"); } - if($session->tribe == 5 && $id != 39) { + if($session->tribe == 5 && $id == 40) { include("avaliable/citywall.tpl"); } } @@ -139,7 +139,7 @@ if((($greatgranary == 0 && $greatgranary1 == 0) || $greatgranary == 20) && $main if((($trapper == 0 && $trapper1 == 0) || $trapper == 20) && $rallypoint >= 1 && $session->tribe == 3 && $id != 39 && $id != 40) { include("avaliable/trapper.tpl"); } -if($rallypoint == 0 && $rallypoint1 == 0 && $id != 40) { +if($rallypoint == 0 && $rallypoint1 == 0 && $id == 39) { include("avaliable/rallypoint.tpl"); } if($embassy == 0 && $embassy1 == 0 && $id != 39 && $id != 40 && $mainbuilding >= 1) { From f560ddf7be979080bbf6ed0fdde3b1f676b78157 Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Sun, 9 Jul 2023 12:03:15 +0200 Subject: [PATCH 2/7] Fix for infinite refreshing --- GameEngine/Automation.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 53c07126..17da3dbb 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -19,21 +19,23 @@ // make sure we only run the automation script once and wait until it's done, // so concurrent AJAX calls from many different users won't overload the server if ( !defined('AUTOMATION_MANUAL_RUN') ) { - if ( file_exists( AUTOMATION_LOCK_FILE_NAME ) ) { - // check that the file is not too old, in which case our PHP script hung - // and we need to remove the lock and run automation again - $fileTime = filemtime( AUTOMATION_LOCK_FILE_NAME ); - - // allow for 60 seconds of old automation script processing time, which is still way too plenty - if ( ! $fileTime || time() - $fileTime > 60 ) { - @unlink( AUTOMATION_LOCK_FILE_NAME ); + if(defined('AUTOMATION_LOCK_FILE_NAME')){ + if ( file_exists( AUTOMATION_LOCK_FILE_NAME ) ) { + // check that the file is not too old, in which case our PHP script hung + // and we need to remove the lock and run automation again + $fileTime = filemtime( AUTOMATION_LOCK_FILE_NAME ); + + // allow for 60 seconds of old automation script processing time, which is still way too plenty + if ( ! $fileTime || time() - $fileTime > 60 ) { + @unlink( AUTOMATION_LOCK_FILE_NAME ); + } else { + // automation file exists and is valid, don't run another automation + exit; + } } else { - // automation file exists and is valid, don't run another automation - exit; + // create automation lock file + file_put_contents( AUTOMATION_LOCK_FILE_NAME, '' ); } - } else { - // create automation lock file - file_put_contents( AUTOMATION_LOCK_FILE_NAME, '' ); } } From 3d95916c2979ba9ca5c472cb17733690dbcdb983 Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Sun, 9 Jul 2023 12:03:56 +0200 Subject: [PATCH 3/7] Fix for db throws and install process not going through --- GameEngine/Database.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index e244372e..a695c0f4 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -1356,6 +1356,7 @@ class MYSQLi_DB implements IDbConnection { } function setFieldTaken($id) { + if(empty($id)) return; if (!is_array($id)) { $id = [$id]; } @@ -5655,6 +5656,8 @@ References: User ID/Message ID, Mode list($moveid) = $this->escape_input($moveid); } + if(empty($moveid)) return; + // rather than re-selecting data and updating cache here, let's just // flush the cache and let it re-cach itself as neccessary self::$marketMovementCache = []; @@ -6012,6 +6015,7 @@ References: User ID/Message ID, Mode function addUnits($vid, $troopsArray = null) { list($vid, $type, $values) = $this->escape_input($vid, $type, $values); + if(empty($vid)) return; if (!is_array($vid)) $vid = [$vid]; $types = $values = ""; @@ -6201,6 +6205,7 @@ References: User ID/Message ID, Mode } function addTech($vid) { + if(empty($vid)) return; if (!is_array($vid)) { $vid = [$vid]; } @@ -6214,6 +6219,7 @@ References: User ID/Message ID, Mode } function addABTech($vid) { + if(empty($vid)) return; if (!is_array($vid)) { $vid = [$vid]; } @@ -7056,9 +7062,13 @@ References: User ID/Message ID, Mode try { // check that we don't have the structure in place already // (we'd have at least 1 user present, since 4 are being created by default - Support, Nature, Multihunter & Taskmaster) - $data_exist = $this->query_return("SELECT * FROM " . TB_PREFIX . "users LIMIT 1"); - if ($data_exist && count($data_exist)) { - return false; + try { + $data_exist = $this->query_return("SELECT * FROM " . TB_PREFIX . "users LIMIT 1"); + if ($data_exist && count($data_exist)) { + return false; + } + } catch (\Exception $e) { + } // load the DB structure SQL file @@ -7073,6 +7083,7 @@ References: User ID/Message ID, Mode return false; } } catch (\Exception $e) { + echo($e); return -1; } From 77016b7e533e9ca44f00c5e84e618eca5056a9e1 Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Sun, 9 Jul 2023 12:04:16 +0200 Subject: [PATCH 4/7] Fixed crash during sending message to another player --- GameEngine/Message.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GameEngine/Message.php b/GameEngine/Message.php index 5e4c45dd..8e86b609 100755 --- a/GameEngine/Message.php +++ b/GameEngine/Message.php @@ -407,7 +407,7 @@ class Message { $userally = $database->getUserField($session->uid,"alliance",0); $permission=mysqli_fetch_array(mysqli_query($database->dblink,"SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'")); - if(WORD_CENSOR) { + if(defined('WORD_CENSOR')) { $topic = $this->wordCensor($topic); $text = $this->wordCensor($text); } @@ -496,7 +496,7 @@ class Message { } // Vulnerability closed by Shadow - if(WORD_CENSOR) { + if(defined('WORD_CENSOR')) { $topic = $this->wordCensor($topic); $text = $this->wordCensor($text); } From f28e2bf9c0ee1baf10b93409e1f3544cb5232a90 Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Sun, 9 Jul 2023 21:09:00 +0200 Subject: [PATCH 5/7] session test --- GameEngine/Session.php | 6 +++++- ajax.php | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/GameEngine/Session.php b/GameEngine/Session.php index 080abf4a..c317ad2f 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -80,7 +80,10 @@ class Session { global $database; //TienTN fix $this->time = time(); - if (!isset($_SESSION)) session_start(); + if (!isset($_SESSION)) { + session_name('TRAVIAN_SESSION'); + session_start(); + } $this->logged_in = $this->checkLogin(); @@ -138,6 +141,7 @@ class Session { } public function Logout() { + session_name('TRAVIAN_SESSION'); global $database; $this->logged_in = false; $database->updateUserField($_SESSION['username'], "sessid", "", 0); diff --git a/ajax.php b/ajax.php index d337d54e..9214a372 100644 --- a/ajax.php +++ b/ajax.php @@ -69,6 +69,7 @@ switch($_GET['f']) { $qact3=null; } if (!isset($_SESSION)) { + session_name('TRAVIAN_SESSION'); session_start(); } if (isset($_SESSION['qtyp']) && $_SESSION['qtyp']==37) { From 5d7f12ed87453cb51b991927ca87e5735c31c71c Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Mon, 10 Jul 2023 08:14:11 +0200 Subject: [PATCH 6/7] Removed debug --- GameEngine/Session.php | 12 ++++++++++-- ajax.php | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/GameEngine/Session.php b/GameEngine/Session.php index c317ad2f..3ccd2366 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -1,6 +1,16 @@ time = time(); if (!isset($_SESSION)) { - session_name('TRAVIAN_SESSION'); session_start(); } @@ -141,7 +150,6 @@ class Session { } public function Logout() { - session_name('TRAVIAN_SESSION'); global $database; $this->logged_in = false; $database->updateUserField($_SESSION['username'], "sessid", "", 0); diff --git a/ajax.php b/ajax.php index 9214a372..d337d54e 100644 --- a/ajax.php +++ b/ajax.php @@ -69,7 +69,6 @@ switch($_GET['f']) { $qact3=null; } if (!isset($_SESSION)) { - session_name('TRAVIAN_SESSION'); session_start(); } if (isset($_SESSION['qtyp']) && $_SESSION['qtyp']==37) { From e859bdde9a22c3ad3a8ec88e99660d3ce4b05f2d Mon Sep 17 00:00:00 2001 From: Hubert Walczak Date: Mon, 14 Aug 2023 17:26:12 +0200 Subject: [PATCH 7/7] Delete session debug test lines --- GameEngine/Session.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/GameEngine/Session.php b/GameEngine/Session.php index 3ccd2366..8d4d0235 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -1,16 +1,6 @@