mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-24 12:07:15 +00:00
+222
-77
@@ -189,6 +189,51 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
*/
|
*/
|
||||||
$unitsCache = [],
|
$unitsCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of reinforcements in a village.
|
||||||
|
*/
|
||||||
|
$villageReinforcementsCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of reinforcements by from ID and village ID.
|
||||||
|
*/
|
||||||
|
$villageFromReinforcementsCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of reinforcements by ID.
|
||||||
|
*/
|
||||||
|
$reinforcementsCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of oasis reinforcements by conquered & from ID.
|
||||||
|
*/
|
||||||
|
$oasisReinforcementsCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of oasis reinforcements by ID.
|
||||||
|
*/
|
||||||
|
$oasisArrayReinforcementsCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of prisoners.
|
||||||
|
*/
|
||||||
|
$prisonersCache = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of prisoners by ID.
|
||||||
|
*/
|
||||||
|
$prisonersCacheByID = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of prisoners by village ID and from ID.
|
||||||
|
*/
|
||||||
|
$prisonersCacheByVillageAndFromIDs = [],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Cache of resource levels.
|
||||||
|
*/
|
||||||
|
$resourceLevelsCache = [],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Cache of messages to be sent out to players,
|
* @var array Cache of messages to be sent out to players,
|
||||||
* so we can collect them and send them out together
|
* so we can collect them and send them out together
|
||||||
@@ -623,9 +668,25 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getUserField($ref, $field, $mode, $use_cache = true) {
|
function getUserField($ref, $field, $mode, $use_cache = true) {
|
||||||
|
// update for Multihunter's username and ID
|
||||||
|
if (($mode && $ref == '') || (!$mode && $ref == 0)) {
|
||||||
|
$ref = 'Multihunter';
|
||||||
|
$mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// return all data, don't waste time by selecting fields one by one
|
// return all data, don't waste time by selecting fields one by one
|
||||||
$userArray = $this->getUserArray($ref, !$mode, $use_cache);
|
$userArray = $this->getUserArray($ref, !$mode, $use_cache);
|
||||||
return (isset($userArray[$field]) ? $userArray[$field] : null);
|
$result = (isset($userArray[$field]) ? $userArray[$field] : null);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
// will return the result
|
||||||
|
} elseif($field=="username") {
|
||||||
|
$result = "??";
|
||||||
|
} else {
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
/*list($ref, $field, $mode) = $this->escape_input($ref, $field, $mode);
|
/*list($ref, $field, $mode) = $this->escape_input($ref, $field, $mode);
|
||||||
|
|
||||||
@@ -665,6 +726,12 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getUserFields($ref, $fields, $mode, $use_cache = true) {
|
function getUserFields($ref, $fields, $mode, $use_cache = true) {
|
||||||
|
// update for Multihunter's username and ID
|
||||||
|
if (($mode && $ref == '') || (!$mode && $ref == 0)) {
|
||||||
|
$ref = 'Multihunter';
|
||||||
|
$mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// return all data, don't waste time by selecting fields one by one
|
// return all data, don't waste time by selecting fields one by one
|
||||||
return $this->getUserArray($ref, !$mode, $use_cache);
|
return $this->getUserArray($ref, !$mode, $use_cache);
|
||||||
|
|
||||||
@@ -1472,8 +1539,20 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return mysqli_fetch_assoc($result);
|
return mysqli_fetch_assoc($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVillageField($ref, $field) {
|
function getVillageField($ref, $field, $use_cache = true) {
|
||||||
list($ref, $field) = $this->escape_input((int) $ref, $field);
|
// return all data, don't waste time by selecting fields one by one
|
||||||
|
$villageArray = $this->getVillage($ref, $use_cache);
|
||||||
|
$result = (isset($villageArray[$field]) ? $villageArray[$field] : null);
|
||||||
|
|
||||||
|
if($result){
|
||||||
|
// will return the result
|
||||||
|
}elseif($field=="name"){
|
||||||
|
$result = "??";
|
||||||
|
}else $result = 0;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
/*list($ref, $field) = $this->escape_input((int) $ref, $field);
|
||||||
|
|
||||||
$q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref";
|
$q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
@@ -1482,17 +1561,20 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return $dbarray[$field];
|
return $dbarray[$field];
|
||||||
}elseif($field=="name"){
|
}elseif($field=="name"){
|
||||||
return "??";
|
return "??";
|
||||||
}else return 0;
|
}else return 0;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVillageFields($ref, $fields) {
|
function getVillageFields($ref, $fields, $use_cache = true) {
|
||||||
list($ref, $field) = $this->escape_input((int) $ref, $fields);
|
// return all data, don't waste time by selecting fields one by one
|
||||||
|
return $this->getVillage($ref, $use_cache);
|
||||||
|
|
||||||
|
/*list($ref, $field) = $this->escape_input((int) $ref, $fields);
|
||||||
|
|
||||||
$q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref";
|
$q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
if($result) {
|
if($result) {
|
||||||
return mysqli_fetch_array($result, MYSQLI_ASSOC);
|
return mysqli_fetch_array($result, MYSQLI_ASSOC);
|
||||||
} else return 0;
|
} else return 0;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOasisField($ref, $field) {
|
function getOasisField($ref, $field) {
|
||||||
@@ -1558,12 +1640,20 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return mysqli_query($this->dblink,$q);
|
return mysqli_query($this->dblink,$q);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResourceLevel($vid) {
|
function getResourceLevel($vid, $use_cache = true) {
|
||||||
list($vid) = $this->escape_input((int) $vid);
|
list($vid) = $this->escape_input((int) $vid);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$resourceLevelsCache, $vid)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
$q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid";
|
$q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return mysqli_fetch_assoc($result);
|
|
||||||
|
self::$resourceLevelsCache[$vid] = mysqli_fetch_assoc($result);
|
||||||
|
return self::$resourceLevelsCache[$vid];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAdminLog() {
|
function getAdminLog() {
|
||||||
@@ -4844,42 +4934,44 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
}
|
}
|
||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
$uid = $this->getVillageField($vid, "owner");
|
$uid = $this->getVillageField( $vid, "owner" );
|
||||||
$artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0));
|
$artefact = count( $this->getOwnUniqueArtefactInfo2( $uid, 5, 3, 0 ) );
|
||||||
$artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1));
|
$artefact1 = count( $this->getOwnUniqueArtefactInfo2( $vid, 5, 1, 1 ) );
|
||||||
$artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0));
|
$artefact2 = count( $this->getOwnUniqueArtefactInfo2( $uid, 5, 2, 0 ) );
|
||||||
if($artefact > 0){
|
if ( $artefact > 0 ) {
|
||||||
$time = $now+round(($time-$now)/2);
|
$time = $now + round( ( $time - $now ) / 2 );
|
||||||
$each /= 2;
|
$each /= 2;
|
||||||
$each = round($each);
|
$each = round( $each );
|
||||||
}else if($artefact1 > 0){
|
} else if ( $artefact1 > 0 ) {
|
||||||
$time = $now+round(($time-$now)/2);
|
$time = $now + round( ( $time - $now ) / 2 );
|
||||||
$each /= 2;
|
$each /= 2;
|
||||||
$each = round($each);
|
$each = round( $each );
|
||||||
}else if($artefact2 > 0){
|
} else if ( $artefact2 > 0 ) {
|
||||||
$time = $now+round(($time-$now)/4*3);
|
$time = $now + round( ( $time - $now ) / 4 * 3 );
|
||||||
$each /= 4;
|
$each /= 4;
|
||||||
$each = round($each);
|
$each = round( $each );
|
||||||
$each *= 3;
|
$each *= 3;
|
||||||
$each = round($each);
|
$each = round( $each );
|
||||||
}
|
}
|
||||||
$foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid);
|
$foolartefact = $this->getFoolArtefactInfo( 5, $vid, $uid );
|
||||||
if(count($foolartefact) > 0){
|
if ( count( $foolartefact ) > 0 ) {
|
||||||
foreach($foolartefact as $arte){
|
foreach ( $foolartefact as $arte ) {
|
||||||
if($arte['bad_effect'] == 1){
|
if ( $arte['bad_effect'] == 1 ) {
|
||||||
$each *= $arte['effect2'];
|
$each *= $arte['effect2'];
|
||||||
}else{
|
} else {
|
||||||
$each /= $arte['effect2'];
|
$each /= $arte['effect2'];
|
||||||
$each = round($each);
|
$each = round( $each );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($each == 0){ $each = 1; }
|
if ( $each == 0 ) {
|
||||||
$time2 = $now+$each;
|
$each = 1;
|
||||||
if(count($queued) > 0) {
|
}
|
||||||
$time += $queued[count($queued) - 1]['timestamp'] - $now;
|
$time2 = $now + $each;
|
||||||
$time2 += $queued[count($queued) - 1]['timestamp'] - $now;
|
if ( count( $queued ) > 0 ) {
|
||||||
}
|
$time += $queued[ count( $queued ) - 1 ]['timestamp'] - $now;
|
||||||
|
$time2 += $queued[ count( $queued ) - 1 ]['timestamp'] - $now;
|
||||||
|
}
|
||||||
// TROOPS MAKE SUM IN BARAKS , ETC
|
// TROOPS MAKE SUM IN BARAKS , ETC
|
||||||
//if($queued[count($queued) - 1]['unit'] == $unit){
|
//if($queued[count($queued) - 1]['unit'] == $unit){
|
||||||
//$time = $amt*$queued[count($queued) - 1]['eachtime'];
|
//$time = $amt*$queued[count($queued) - 1]['eachtime'];
|
||||||
@@ -4922,16 +5014,30 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return mysqli_query($this->dblink,$q);
|
return mysqli_query($this->dblink,$q);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnforce($vid, $from) {
|
function getEnforce($vid, $from, $use_cache = true) {
|
||||||
list($vid, $from) = $this->escape_input((int) $vid, (int) $from);
|
list($vid, $from) = $this->escape_input((int) $vid, (int) $from);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$villageFromReinforcementsCache, $vid.$from)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
$q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid";
|
$q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return mysqli_fetch_assoc($result);
|
|
||||||
|
self::$villageFromReinforcementsCache[$vid.$from] = mysqli_fetch_assoc($result);
|
||||||
|
return self::$villageFromReinforcementsCache[$vid.$from];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOasisEnforce($ref, $mode=0) {
|
function getOasisEnforce($ref, $mode=0, $use_cache = true) {
|
||||||
list($ref, $mode) = $this->escape_input((int) $ref, $mode);
|
list($ref, $mode) = $this->escape_input((int) $ref, $mode);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$oasisReinforcementsCache, $ref.$mode)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$mode) {
|
if (!$mode) {
|
||||||
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.conqured = $ref AND e.from !=$ref";
|
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.conqured = $ref AND e.from !=$ref";
|
||||||
@@ -4939,11 +5045,19 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.conqured = $ref";
|
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.conqured = $ref";
|
||||||
}
|
}
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return $this->mysqli_fetch_all($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOasisEnforceArray($id, $mode=0) {
|
self::$oasisReinforcementsCache[$ref.$mode] = $this->mysqli_fetch_all($result);
|
||||||
list($id, $mode) = $this->escape_input((int) $id, $mode);
|
return self::$oasisReinforcementsCache[$ref.$mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOasisEnforceArray($id, $mode=0, $use_cache = true) {
|
||||||
|
list($id, $mode) = $this->escape_input((int) $id, $mode);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$oasisArrayReinforcementsCache, $id.$mode)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$mode) {
|
if (!$mode) {
|
||||||
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where e.id = $id";
|
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where e.id = $id";
|
||||||
@@ -4951,16 +5065,10 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.from=o.wref where e.id =$id";
|
$q = "SELECT e.*,o.conqured FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.from=o.wref where e.id =$id";
|
||||||
}
|
}
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return mysqli_fetch_assoc($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEnforceControllTroops($vid) {
|
self::$oasisArrayReinforcementsCache[$id.$mode] = mysqli_fetch_assoc($result);
|
||||||
list($vid) = $this->escape_input((int) $vid);
|
return self::$oasisArrayReinforcementsCache[$id.$mode];
|
||||||
|
}
|
||||||
$q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $vid";
|
|
||||||
$result = mysqli_query($this->dblink,$q);
|
|
||||||
return mysqli_fetch_assoc($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addEnforce($data) {
|
function addEnforce($data) {
|
||||||
list($data) = $this->escape_input($data);
|
list($data) = $this->escape_input($data);
|
||||||
@@ -5028,28 +5136,44 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
mysqli_query($this->dblink,$q);
|
mysqli_query($this->dblink,$q);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnforceArray($id, $mode) {
|
function getEnforceArray($id, $mode, $use_cache = true) {
|
||||||
list($id, $mode) = $this->escape_input((int) $id, $mode);
|
list($id, $mode) = $this->escape_input((int) $id, $mode);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$reinforcementsCache, $id.$mode)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$mode) {
|
if(!$mode) {
|
||||||
$q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id";
|
$q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id";
|
||||||
} else {
|
} else {
|
||||||
$q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
|
$q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
|
||||||
}
|
}
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return mysqli_fetch_assoc($result);
|
|
||||||
|
self::$reinforcementsCache[$id.$mode] = mysqli_fetch_assoc($result);
|
||||||
|
return self::$reinforcementsCache[$id.$mode];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnforceVillage($id, $mode) {
|
function getEnforceVillage($id, $mode, $use_cache = true) {
|
||||||
list($id, $mode) = $this->escape_input((int) $id, $mode);
|
list($id, $mode) = $this->escape_input((int) $id, $mode);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$villageReinforcementsCache, $id.$mode)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$mode) {
|
if(!$mode) {
|
||||||
$q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id";
|
$q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id";
|
||||||
} else {
|
} else {
|
||||||
$q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
|
$q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
|
||||||
}
|
}
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return $this->mysqli_fetch_all($result);
|
|
||||||
|
self::$villageReinforcementsCache[$id.$mode] = $this->mysqli_fetch_all($result);
|
||||||
|
return self::$villageReinforcementsCache[$id.$mode];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVillageMovement($id) {
|
function getVillageMovement($id) {
|
||||||
@@ -5520,6 +5644,7 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no need to cache, not used in any loops or more than once for each page load
|
||||||
public function getAvailableExpansionTraining() {
|
public function getAvailableExpansionTraining() {
|
||||||
global $building, $session, $technology, $village;
|
global $building, $session, $technology, $village;
|
||||||
$q = "SELECT (IF(exp1=0,1,0)+IF(exp2=0,1,0)+IF(exp3=0,1,0)) FROM " . TB_PREFIX . "vdata WHERE wref = ".(int) $village->wid;
|
$q = "SELECT (IF(exp1=0,1,0)+IF(exp2=0,1,0)+IF(exp3=0,1,0)) FROM " . TB_PREFIX . "vdata WHERE wref = ".(int) $village->wid;
|
||||||
@@ -6110,40 +6235,60 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return mysqli_query($this->dblink,$q) or die(mysqli_error($this->dblink));
|
return mysqli_query($this->dblink,$q) or die(mysqli_error($this->dblink));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrisoners($wid,$mode=0) {
|
function getPrisoners($wid,$mode=0, $use_cache = true) {
|
||||||
list($wid,$mode) = $this->escape_input((int) $wid,$mode);
|
list($wid,$mode) = $this->escape_input((int) $wid,$mode);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$prisonersCache, $wid.$mode)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$mode) {
|
if(!$mode) {
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid";
|
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid";
|
||||||
}else {
|
}else {
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where `from` = $wid";
|
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where `from` = $wid";
|
||||||
}
|
}
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return $this->mysqli_fetch_all($result);
|
|
||||||
|
self::$prisonersCache[$wid.$mode] = $this->mysqli_fetch_all($result);
|
||||||
|
return self::$prisonersCache[$wid.$mode];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrisoners2($wid,$from) {
|
function getPrisoners2($wid,$from, $use_cache = true) {
|
||||||
list($wid,$from) = $this->escape_input((int) $wid,(int) $from);
|
list($wid,$from) = $this->escape_input((int) $wid,(int) $from);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$prisonersCacheByVillageAndFromIDs, $wid.$from)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from";
|
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return $this->mysqli_fetch_all($result);
|
|
||||||
|
self::$prisonersCacheByVillageAndFromIDs[$wid.$from] = $this->mysqli_fetch_all($result);
|
||||||
|
return self::$prisonersCacheByVillageAndFromIDs[$wid.$from];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrisonersByID($id) {
|
function getPrisonersByID($id, $use_cache = true) {
|
||||||
list($id) = $this->escape_input((int) $id);
|
list($id) = $this->escape_input((int) $id);
|
||||||
|
|
||||||
|
// first of all, check if we should be using cache and whether the field
|
||||||
|
// required is already cached
|
||||||
|
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$prisonersCacheByID, $id)) && !is_null($cachedValue)) {
|
||||||
|
return $cachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id";
|
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
return mysqli_fetch_array($result);
|
|
||||||
|
self::$prisonersCacheByID[$id] = mysqli_fetch_array($result);
|
||||||
|
return self::$prisonersCacheByID[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrisoners3($from) {
|
function getPrisoners3($from) {
|
||||||
list($from) = $this->escape_input((int) $from);
|
return $this->getPrisoners($from, 1);
|
||||||
|
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "prisoners where " . TB_PREFIX . "prisoners.from = $from";
|
|
||||||
$result = mysqli_query($this->dblink,$q);
|
|
||||||
return $this->mysqli_fetch_all($result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletePrisoners($id) {
|
function deletePrisoners($id) {
|
||||||
|
|||||||
@@ -787,11 +787,11 @@ private function trainUnit($unit,$amt,$great=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function finishTech() {
|
public function finishTech() {
|
||||||
global $database,$village;
|
global $database,$village;
|
||||||
$q = "UPDATE ".TB_PREFIX."research SET timestamp=".(time()-1)." WHERE vref = ".(int) $village->wid;
|
$q = "UPDATE ".TB_PREFIX."research SET timestamp=".(time()-1)." WHERE vref = ".(int) $village->wid;
|
||||||
$result = $database->query($q);
|
$result = $database->query($q);
|
||||||
return mysqli_affected_rows($database->dblink);
|
return mysqli_affected_rows($database->dblink);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateAvaliable($id,$resarray=array()) {
|
public function calculateAvaliable($id,$resarray=array()) {
|
||||||
global $village,$generator,${'r'.$id};
|
global $village,$generator,${'r'.$id};
|
||||||
|
|||||||
Reference in New Issue
Block a user