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, '' ); } } diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 290a2a14..60b109d5 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]; } @@ -5659,6 +5660,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 = []; @@ -6016,6 +6019,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 = ""; @@ -6205,6 +6209,7 @@ References: User ID/Message ID, Mode } function addTech($vid) { + if(empty($vid)) return; if (!is_array($vid)) { $vid = [$vid]; } @@ -6218,6 +6223,7 @@ References: User ID/Message ID, Mode } function addABTech($vid) { + if(empty($vid)) return; if (!is_array($vid)) { $vid = [$vid]; } @@ -7060,9 +7066,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 @@ -7077,6 +7087,7 @@ References: User ID/Message ID, Mode return false; } } catch (\Exception $e) { + echo($e); return -1; } 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); } diff --git a/GameEngine/Session.php b/GameEngine/Session.php index 080abf4a..8d4d0235 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -80,7 +80,9 @@ class Session { global $database; //TienTN fix $this->time = time(); - if (!isset($_SESSION)) session_start(); + if (!isset($_SESSION)) { + session_start(); + } $this->logged_in = $this->checkLogin(); 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) {