mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Merge pull request #44 from osztenkurden/master
Fixes for multiple bugs
This commit is contained in:
+15
-13
@@ -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, '' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user