From 645793dde2584ea8c7f203562d8be92ea555be45 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 20 Nov 2017 10:10:29 +0100 Subject: [PATCH] refactor: s1_vdata queries cached and reused #313 --- Admin/Templates/deletion.tpl | 4 +- Admin/Templates/server_info.tpl | 7 +- GameEngine/Admin/database.php | 11 +- GameEngine/Admin/function.php | 11 +- GameEngine/Automation.php | 6 +- GameEngine/Database.php | 262 ++++++++++------ GameEngine/Technology.php | 24 +- Templates/Build/37_revive.tpl | 33 +- Templates/Build/37_train.tpl | 539 ++++++++++++++++++-------------- Templates/Build/avaliable.tpl | 12 +- create_account.php | 20 +- winner.php | 7 +- 12 files changed, 548 insertions(+), 388 deletions(-) diff --git a/Admin/Templates/deletion.tpl b/Admin/Templates/deletion.tpl index 362a7c65..b1dab1c0 100644 --- a/Admin/Templates/deletion.tpl +++ b/Admin/Templates/deletion.tpl @@ -49,8 +49,8 @@ if($_GET['uid']) Villages: diff --git a/Admin/Templates/server_info.tpl b/Admin/Templates/server_info.tpl index a224fbd6..328c9b9a 100644 --- a/Admin/Templates/server_info.tpl +++ b/Admin/Templates/server_info.tpl @@ -51,9 +51,10 @@ $users = mysqli_num_rows(mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM Villages settled + $result = mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."vdata"); + $num_rows = mysqli_fetch_array($result, MYSQLI_ASSOC)['Total']; + echo $num_rows; + ?> diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php index 51f27867..c3a08562 100755 --- a/GameEngine/Admin/database.php +++ b/GameEngine/Admin/database.php @@ -448,11 +448,12 @@ class adm_DB { } function search_village($village){ - global $database; - $village = $database->escape($village); - $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'"; - $result = mysqli_query($this->connection, $q); - return $this->mysqli_fetch_all($result); + global $database; + + $village = $database->escape($village); + $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'"; + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function search_alliance($alliance){ diff --git a/GameEngine/Admin/function.php b/GameEngine/Admin/function.php index 9d192877..94f7164b 100755 --- a/GameEngine/Admin/function.php +++ b/GameEngine/Admin/function.php @@ -85,7 +85,7 @@ class funct { } if (!$killhero){ $killhero=$database->FindHeroInOasis($get['uid']); - } + } if ($killhero) { $database->KillMyHero($get['uid']); $error="&kc=1"; @@ -109,14 +109,17 @@ class funct { case "addHero": $user = $database->getUserArray($get['uid'],1); $vilarray=$database->getVrefCapital($get['uid']); - + if (!$vilarray) { + return; + } + $database->query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES (".(int) $get['uid'].", " . (int) $vilarray['wref'] . ", '0', ".(int) $get['u'].", '".addslashes($user['username'])."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".time()."', '50', '0')"); - + $database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".(int) $vilarray['wref']); - + header("Location: admin.php?p=player&uid=".$get['uid']."&ac=1"); exit; } diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 47631816..9198c321 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1528,12 +1528,12 @@ class Automation { $stonemason = 0; } - $varray = $database->getProfileVillages($to['owner'], false); + $varray = $database->getProfileVillages($to['owner'], 0, false); if ($to['owner'] == $from['owner']) { $varray1 = $varray; } else { - $varray1 = $database->getProfileVillages($from['owner'], false); + $varray1 = $database->getProfileVillages($from['owner'], 0, false); } //fix by ronix @@ -5178,7 +5178,7 @@ class Automation { $villages = $database->getVillagesID2($leader); $max = 0; foreach($villages as $village){ - $field = $database->getResourceLevel($village['wref']); + $field = $database->getResourceLevel($village['wref'], false); for($i=19;$i<=40;$i++){ if($field['f'.$i.'t'] == 18){ $level = $field['f'.$i]; diff --git a/GameEngine/Database.php b/GameEngine/Database.php index f4debf06..48ffbcc7 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -1010,18 +1010,20 @@ class MYSQLi_DB implements IDbConnection { // no need to cache this method function getVrefCapital($ref) { - list($ref) = $this->escape_input((int) $ref); - $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = $ref and capital = 1 LIMIT 1"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray; + $vdata = $this->getProfileVillages($ref); + + foreach ($vdata as $village) { + if ($village['capital']) { + return $village; + } + } + + return false; } // no need to cache this method function getStarvation() { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0 and owner != 3"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); + return $this->getProfileVillages(0, 2); } // no need to cache this method @@ -1583,48 +1585,6 @@ class MYSQLi_DB implements IDbConnection { } } - function getProfileVillages($uid, $use_cache = true) { - $arrayPassed = is_array($uid); - - if (!$arrayPassed) { - $uid = [(int) $uid]; - } else { - foreach ($uid as $index => $uidValue) { - $uid[$index] = (int) $uidValue; - } - } - - if (!count($uid)) { - return []; - } - - // first of all, check if we should be using cache - if ($use_cache && !$arrayPassed && ($cachedValue = self::returnCachedContent(self::$userVillagesCache, $uid[0])) && !is_null($cachedValue)) { - return $cachedValue; - } - - $q = "SELECT * from " . TB_PREFIX . "vdata where owner IN(".implode(', ', $uid).") ORDER BY capital DESC,pop DESC"; - $result = mysqli_query($this->dblink,$q); - - if (!$arrayPassed) { - $result = $this->mysqli_fetch_all($result); - self::$userVillagesCache[ $uid[0] ] = $result; - } else { - // we're preloading, cache all the data individually - if (mysqli_num_rows($result)) { - while ( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) ) { - if ( ! isset( self::$userVillagesCache[ $row['owner'] ] ) ) { - self::$userVillagesCache[ $row['owner'] ] = []; - } - - self::$userVillagesCache[ $row['owner'] ][] = $row; - } - } - } - - return $result; - } - // no need to refactor this method function getProfileMedal($uid) { list($uid) = $this->escape_input((int) $uid); @@ -1659,9 +1619,7 @@ class MYSQLi_DB implements IDbConnection { return $cachedValue; } - $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; - $result = mysqli_query($this->dblink,$q); - $array = $this->mysqli_fetch_all($result); + $array = $this->getProfileVillages($uid, 0, $use_cache); $newarray = array(); for($i = 0; $i < count($array); $i++) { @@ -1681,30 +1639,162 @@ class MYSQLi_DB implements IDbConnection { return $cachedValue; } - $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; - $result = mysqli_query($this->dblink,$q); - $array = $this->mysqli_fetch_all($result); - + $array = $this->getProfileVillages($uid, 0, $use_cache); self::$villageIDsCacheSimple[$uid] = $array; + return self::$villageIDsCacheSimple[$uid]; } - function getVillage($vid, $mode = 0, $use_cache = true) { - list($vid) = $this->escape_input((int) $vid); + function findAlreadyCachedVillageData($vid, $mode) { + // check if we don't actually have this data cached already in one of the other modes + for ($i = 0; $i <= 4; $i++) { + if ($mode !== $i && isset(self::$villageFieldsCache[$vid.$i])) { + // loop through cached values + foreach (self::$villageFieldsCache[$vid.$i] as $index => $value) { + // check for existing record with our requested ID/name/owner... + switch ($mode) { + case 0: if ($value['wref'] == $vid) { + return $value; + } + break; - // first of all, check if we should be using cache and whether the field + case 1: if ($value['name'] == $vid) { + return $value; + } + break; + + case 2: if ($value['owner'] == $vid) { + return $value; + } + break; + + case 3: if ($value['owner'] == $vid && $value['capital'] == 1) { + return $value; + } + break; + + case 4: if ($value['owner'] == 4) { + return $value; + } + break; + } + } + } + } + + return false; + } + + function getVillage($vid, $mode = 0, $use_cache = true) { + // 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::$villageFieldsCache, $vid)) && !is_null($cachedValue)) { + if ($use_cache && ($cachedValue = self::returnCachedContent(self::$villageFieldsCache, $vid.$mode)) && !is_null($cachedValue)) { return $cachedValue; } - $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid LIMIT 1"; + if ($use_cache && ($altCachedContentSearch = $this->findAlreadyCachedVillageData($vid, $mode))) { + return $altCachedContentSearch; + } + + switch ($mode) { + // by WREF + case 0: $vid = (int) $vid; + $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE wref = $vid LIMIT 1"; + break; + + // by name + case 1: $name = $this->escape($vid); + $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE `name` = '$name' LIMIT 1"; + break; + + // by owner ID + case 2: $vid = (int) $vid; + $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE owner = $vid LIMIT 1"; + break; + + // by owner ID and capital = 1 + case 3: $vid = (int) $vid; + $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE owner = $vid capital = 1 LIMIT 1"; + break; + + // by owner = Taskmaster + case 4: $vid = (int) $vid; + $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE owner = 4 LIMIT 1"; + break; + } + $result = mysqli_query($this->dblink,$q); - self::$villageFieldsCache[$vid] = mysqli_fetch_array($result, MYSQLI_ASSOC); - return self::$villageFieldsCache[$vid]; + self::$villageFieldsCache[$vid.$mode] = mysqli_fetch_array($result, MYSQLI_ASSOC); + return self::$villageFieldsCache[$vid.$mode]; } + function getProfileVillages($uid, $mode = 0, $use_cache = true) { + $arrayPassed = is_array($uid); + + if (!$arrayPassed) { + $uid = [(int) $uid]; + } else { + foreach ($uid as $index => $uidValue) { + $uid[$index] = (int) $uidValue; + } + } + + if (!count($uid)) { + return []; + } + + // first of all, check if we should be using cache + if ($use_cache && !$arrayPassed && ($cachedValue = self::returnCachedContent(self::$userVillagesCache, $uid[0])) && !is_null($cachedValue)) { + return $cachedValue; + } + + switch ($mode) { + // by owner ID + case 0: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE owner IN(".implode(', ', $uid).") ORDER BY capital DESC,pop DESC"; + break; + + // villages where owner is a real player (i.e. not Natars etc.) + case 1: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE capital = 1 and owner > 5"; + break; + + // villages with starvation data + case 2: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE starv != 0 and owner != 3"; + break; + + // field distance calculator query + case 3: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE owner > 4 and wref != ".$uid[0]; + break; + + // villages in need of celebration data update + case 4: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE celebration < ".$uid[0]." AND celebration != 0"; + break; + } + + $result = mysqli_query($this->dblink,$q); + + if (!$arrayPassed) { + $result = $this->mysqli_fetch_all($result); + self::$userVillagesCache[ $uid[0] ] = $result; + } else { + // we're preloading, cache all the data individually + if (mysqli_num_rows($result)) { + while ( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) ) { + if ( ! isset( self::$userVillagesCache[ $row['owner'] ] ) ) { + self::$userVillagesCache[ $row['owner'] ] = []; + } + + self::$userVillagesCache[ $row['owner'] ][] = $row; + } + + // just return the full cache if we've given an array of IDs to load villages for + $result = self::$userVillagesCache; + } + } + + return $result; + } + function getVillageByWorldID($vid, $use_cache = true) { $vid = (int) $vid; @@ -3524,14 +3614,12 @@ class MYSQLi_DB implements IDbConnection { function getFieldDistance($wid) { list($wid) = $this->escape_input((int) $wid); - $q = "SELECT wref FROM " . TB_PREFIX . "vdata where owner > 4 and wref != $wid"; - $array = $this->query_return($q); + $array = $this->getProfileVillages($wid, 3); $coor = $this->getCoor($wid); $x1 = intval($coor['x']); $y1 = intval($coor['y']); $prevdist = 0; - $q2 = "SELECT wref FROM " . TB_PREFIX . "vdata where owner = 4 LIMIT 1"; - $array2 = mysqli_fetch_array(mysqli_query($this->dblink,$q2)); + $array2 = $this->getVillage(0, 4); $vill = $array2['wref']; if(mysqli_num_rows(mysqli_query($this->dblink,$q)) > 0){ @@ -3681,10 +3769,7 @@ class MYSQLi_DB implements IDbConnection { // no need to cache this method function getCel() { - $time = time(); - $q = "SELECT * FROM " . TB_PREFIX . "vdata where celebration < $time AND celebration != 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); + return $this->getProfileVillages(time(), 4); } function clearCel($ref) { @@ -4799,14 +4884,8 @@ References: User ID/Message ID, Mode return mysqli_query($this->dblink,$q); } - // no need to cache this method - function getVillageByName($name) { - list($name) = $this->escape_input($name); - - $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE `name` = '$name' LIMIT 1"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['wref']; + function getVillageByName($name, $use_cache = true) { + return $this->getVillage($name, 1, $use_cache)['wref']; } function getVillageByOwner($uid, $use_cache = true) { @@ -6181,27 +6260,25 @@ References: User ID/Message ID, Mode // no need to cache, not used in any loops or more than once for each page load public function getAvailableExpansionTraining() { 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; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - $maxslots = $row[0]; + + $vilData = $this->getVillage($village->wid); + $maxslots = (($vilData['exp1'] == 0 ? 1 : 0) + ($vilData['exp2'] == 0 ? 1 : 0) + ($vilData['exp3'] == 0 ? 1 : 0)); $residence = $building->getTypeLevel(25); $palace = $building->getTypeLevel(26); + if($residence > 0) { $maxslots -= (3 - floor($residence / 10)); } + if($palace > 0) { $maxslots -= (3 - floor(($palace - 5) / 5)); } - $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "units WHERE vref = ". (int) $village->wid; + $q = "SELECT (u10+u20+u30) as R1, (u9+u19+u29) as R2 FROM " . TB_PREFIX . "units WHERE vref = ". (int) $village->wid; $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - $settlers = $row[0]; - $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "units WHERE vref = ". (int) $village->wid; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - $chiefs = $row[0]; + $row = mysqli_fetch_array($result, MYSQLI_ASSOC); + $settlers = $row['R1']; + $chiefs = $row['R2']; $settlers += 3 * count($this->getMovement(5, $village->wid, 0)); $current_movement = $this->getMovement(3, $village->wid, 0); @@ -6232,6 +6309,7 @@ References: User ID/Message ID, Mode $chiefs += $build['t9']; } } + $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = ".(int) $village->wid; $result = mysqli_query($this->dblink,$q); $row = mysqli_fetch_row($result); @@ -6240,6 +6318,7 @@ References: User ID/Message ID, Mode $settlers += $reinf[0]; } } + $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = ".(int) $village->wid; $result = mysqli_query($this->dblink,$q); $row = mysqli_fetch_row($result); @@ -6248,6 +6327,7 @@ References: User ID/Message ID, Mode $chiefs += $reinf[0]; } } + $trainlist = $technology->getTrainingList(4); if(!empty($trainlist)) { foreach($trainlist as $train) { diff --git a/GameEngine/Technology.php b/GameEngine/Technology.php index 11051081..45589430 100755 --- a/GameEngine/Technology.php +++ b/GameEngine/Technology.php @@ -187,11 +187,11 @@ class Technology { } public function maxUnit($unit,$great=false) { + global $village,$$unit,$database; + $unit = "u".$unit; - global $village,$$unit; $unitarray = $$unit; - $res = array(); - $res = mysqli_fetch_assoc(mysqli_query($GLOBALS['link'],"SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".(int) $village->wid)) or die(mysqli_error($database->dblink)); + $res = $database->getVillage($village->wid); if ($res['wood'] > $res['maxstore']){$res['wood'] = $res['maxstore'];} if ($res['clay'] > $res['maxstore']){$res['clay'] = $res['maxstore'];} if ($res['iron'] > $res['maxstore']){$res['iron'] = $res['maxstore'];} @@ -213,11 +213,11 @@ class Technology { } public function maxUnitPlus($unit,$great=false) { + global $village,$$unit,$database; + $unit = "u".$unit; - global $village,$$unit; $unitarray = $$unit; - $res = array(); - $res = mysqli_fetch_assoc(mysqli_query($GLOBALS['link'],"SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".(int) $village->wid)) or die(mysqli_error($database->dblink)); + $res = $database->getVillage($village->wid); $totalres = $res['wood']+$res['clay']+$res['iron']+$res['crop']; $totalresunit = ($unitarray['wood'] * ($great?3:1))+($unitarray['clay'] * ($great?3:1))+($unitarray['iron'] * ($great?3:1))+($unitarray['crop'] * ($great?3:1)); $max =round($totalres/$totalresunit); @@ -273,8 +273,8 @@ class Technology { } $ownunit['hero'] += $enforce['hero']; } - } - + } + $prisoners = $database->getPrisoners($base,1); if(!empty($prisoners)) { foreach($prisoners as $prisoner){ @@ -498,10 +498,10 @@ class Technology { switch ($i) { case 4: $upkeepDecrement = 2; break; - + case 5: $upkeepDecrement = 3; break; - + case 6: $upkeepDecrement = 4; break; } @@ -522,10 +522,10 @@ class Technology { switch ($i) { case 4: $upkeepDecrement = 2; break; - + case 5: $upkeepDecrement = 3; break; - + case 6: $upkeepDecrement = 4; break; } diff --git a/Templates/Build/37_revive.tpl b/Templates/Build/37_revive.tpl index 485f2b4e..d8378058 100644 --- a/Templates/Build/37_revive.tpl +++ b/Templates/Build/37_revive.tpl @@ -105,7 +105,7 @@ ".HERO_READY." " . $timeleft . ""; ?> - + @@ -115,7 +115,7 @@ $name ($name1) " ?> - + @@ -140,7 +140,7 @@ ?> - +
awood < $wood OR $village->aclay < $clay OR $village->airon < $iron OR $village->acrop < $crop) { @@ -148,12 +148,12 @@ }else { echo "".REVIVE.""; } - + ?>
- - + + checkIfResearched($village->wid, 't'.$hero_datarow['unit']) != 0){ ?> @@ -176,7 +176,7 @@ ?> - +
awood < $wood OR $village->aclay < $clay OR $village->airon < $iron OR $village->acrop < $crop) { @@ -184,7 +184,7 @@ }else { echo "".REVIVE.""; } - + ?>
@@ -195,21 +195,26 @@ if(isset($_GET['revive']) && $_GET['revive'] == 1 && isset($_GET['hid']) && $_GET['hid'] == $hero_datarow['heroid'] && $hero_datarow['inrevive'] == 0 && $hero_datarow['intraining'] == 0 && $hero_datarow['dead'] == 1){ if($session->access != BANNED){ mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `heroid` = ".(int) $_GET['hid']." AND `uid` = '".(int) $session->uid."'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $wood." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $clay." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $iron ." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $crop." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $wood.", + `clay` = `clay` - ".(int) $clay.", + `iron` = `iron` - ".(int) $iron .", + `crop` = `crop` - ".(int) $crop." + WHERE + `wref` = '" . (int) $village->wid . "'"); header("Location: build.php?id=".$id.""); exit; } else { header("Location: banned.php"); - exit; + exit; } } } ?> - + diff --git a/Templates/Build/37_train.tpl b/Templates/Build/37_train.tpl index 3e3b72c0..7d16acc8 100644 --- a/Templates/Build/37_train.tpl +++ b/Templates/Build/37_train.tpl @@ -48,7 +48,7 @@ $output=""; - + if($session->tribe == 1) { $output.=" "; - - - - if($database->checkIfResearched($village->wid, 't2') != 0){ + + + + if($database->checkIfResearched($village->wid, 't2') != 0){ $output.=""; - } - + } + if($database->checkIfResearched($village->wid, 't3') != 0){ - + $output.=" - " ; - } - - if($database->checkIfResearched($village->wid, 't5') != 0){ + " ; + } + + if($database->checkIfResearched($village->wid, 't5') != 0){ $output.= ""; - } - - if($database->checkIfResearched($village->wid, 't6') != 0){ + } + + if($database->checkIfResearched($village->wid, 't6') != 0){ $output.=""; - } -} + } +} if($session->tribe == 2) { @@ -251,29 +251,29 @@ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u11['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - - - if($database->checkIfResearched($village->wid, 't12') != 0){ + + + if($database->checkIfResearched($village->wid, 't12') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u12['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } + } - - if($database->checkIfResearched($village->wid, 't13') != 0){ + + if($database->checkIfResearched($village->wid, 't13') != 0){ $output.=""; - } - - if($database->checkIfResearched($village->wid, 't15') != 0){ + } + + if($database->checkIfResearched($village->wid, 't15') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u15['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } - - - if($database->checkIfResearched($village->wid, 't16') != 0){ + } + + + if($database->checkIfResearched($village->wid, 't16') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u16['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } + } } @@ -442,29 +442,29 @@ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u21['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - - - if($database->checkIfResearched($village->wid, 't22') != 0){ + + + if($database->checkIfResearched($village->wid, 't22') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u22['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } + } - - if($database->checkIfResearched($village->wid, 't24') != 0){ + + if($database->checkIfResearched($village->wid, 't24') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u24['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } - - if($database->checkIfResearched($village->wid, 't25') != 0){ + } + + if($database->checkIfResearched($village->wid, 't25') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u25['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } - - - if($database->checkIfResearched($village->wid, 't26') != 0){ + } + + + if($database->checkIfResearched($village->wid, 't26') != 0){ $output.="\"Crop6| \"Duration\"". $generator->getTimeFormat(round($u26['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= " "; - } + } } @@ -624,10 +624,15 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '1', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u1` = `u1` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u1['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u1['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u1['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u1['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u1['wood'].", + `clay` = `clay` - ".(int) $u1['clay'].", + `iron` = `iron` - ".(int) $u1['iron'].", + `crop` = `crop` - ".(int) $u1['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; @@ -641,31 +646,41 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '2', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u2` = `u2` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u2['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u2['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u2['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u2['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u2['wood'].", + `clay` = `clay` - ".(int) $u2['clay'].", + `iron` = `iron` - ".(int) $u2['iron'].", + `crop` = `crop` - ".(int) $u2['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 3){ if($session->access != BANNED){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '3', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u3['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u3` = `u3` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u3['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u3['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u3['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u3['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u3['wood'].", + `clay` = `clay` - ".(int) $u3['clay'].", + `iron` = `iron` - ".(int) $u3['iron'].", + `crop` = `crop` - ".(int) $u3['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 5){ @@ -673,16 +688,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '5', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u5['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u5` = `u5` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u5['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u5['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u5['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u5['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u5['wood'].", + `clay` = `clay` - ".(int) $u5['clay'].", + `iron` = `iron` - ".(int) $u5['iron'].", + `crop` = `crop` - ".(int) $u5['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 6){ @@ -690,16 +710,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '6', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u6['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u6` = `u6` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u6['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u6['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u6['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u6['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u6['wood'].", + `clay` = `clay` - ".(int) $u6['clay'].", + `iron` = `iron` - ".(int) $u6['iron'].", + `crop` = `crop` - ".(int) $u6['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } } @@ -709,16 +734,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '11', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u11['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u11` = `u11` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u11['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u11['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u11['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u11['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u11['wood'].", + `clay` = `clay` - ".(int) $u11['clay'].", + `iron` = `iron` - ".(int) $u11['iron'].", + `crop` = `crop` - ".(int) $u11['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 12){ @@ -726,16 +756,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '12', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u12['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u12` = `u12` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u12['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u12['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u12['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u12['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u12['wood'].", + `clay` = `clay` - ".(int) $u12['clay'].", + `iron` = `iron` - ".(int) $u12['iron'].", + `crop` = `crop` - ".(int) $u12['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 13){ @@ -743,16 +778,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '13', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u13['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u13` = `u13` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u13['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u13['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u13['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u13['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u13['wood'].", + `clay` = `clay` - ".(int) $u13['clay'].", + `iron` = `iron` - ".(int) $u13['iron'].", + `crop` = `crop` - ".(int) $u13['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 15){ @@ -760,16 +800,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '15', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u15['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u15` = `u15` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u15['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u15['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u15['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u15['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u15['wood'].", + `clay` = `clay` - ".(int) $u15['clay'].", + `iron` = `iron` - ".(int) $u15['iron'].", + `crop` = `crop` - ".(int) $u15['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 16){ @@ -777,16 +822,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '16', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u16['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u16` = `u16` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u16['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u16['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u16['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u16['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u16['wood'].", + `clay` = `clay` - ".(int) $u16['clay'].", + `iron` = `iron` - ".(int) $u16['iron'].", + `crop` = `crop` - ".(int) $u16['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } } @@ -796,16 +846,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '21', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u21['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u21` = `u21` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u21['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u21['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u21['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u21['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u21['wood'].", + `clay` = `clay` - ".(int) $u21['clay'].", + `iron` = `iron` - ".(int) $u21['iron'].", + `crop` = `crop` - ".(int) $u21['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 22){ @@ -813,16 +868,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '22', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u22['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u22` = `u22` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u22['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u22['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u22['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u22['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u22['wood'].", + `clay` = `clay` - ".(int) $u22['clay'].", + `iron` = `iron` - ".(int) $u22['iron'].", + `crop` = `crop` - ".(int) $u22['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 24){ @@ -830,16 +890,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '24', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u24['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u24` = `u24` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u24['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u24['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u24['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u24['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u24['wood'].", + `clay` = `clay` - ".(int) $u24['clay'].", + `iron` = `iron` - ".(int) $u24['iron'].", + `crop` = `crop` - ".(int) $u24['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 25){ @@ -847,16 +912,21 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '25', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u25['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u25` = `u25` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u25['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u25['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u25['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u25['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u25['wood'].", + `clay` = `clay` - ".(int) $u25['clay'].", + `iron` = `iron` - ".(int) $u25['iron'].", + `crop` = `crop` - ".(int) $u25['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } if(isset($_GET['train']) && $_GET['train'] == 26){ @@ -864,24 +934,29 @@ $output.=" if($count_hero < 3){ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '26', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u26['time'] / SPEED)*3))."', '50', '1')"); mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u26` = `u26` - 1 WHERE `vref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u26['wood']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $u26['clay']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $u26['iron']." WHERE `wref` = '" . (int) $village->wid . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $u26['crop']." WHERE `wref` = '" . (int) $village->wid . "'"); + mysqli_query($GLOBALS['link']," + UPDATE " . TB_PREFIX . "vdata + SET + `wood` = `wood` - ".(int) $u26['wood'].", + `clay` = `clay` - ".(int) $u26['clay'].", + `iron` = `iron` - ".(int) $u26['iron'].", + `crop` = `crop` - ".(int) $u26['crop']." + WHERE + `wref` = '" . (int) $village->wid . "'"); } header("Location: build.php?id=".$id.""); exit; }else{ header("Location: banned.php"); - exit; + exit; } } } - - - - echo $output; + + + + echo $output; } ?>
".TRAIN_HERO."
@@ -72,20 +72,20 @@ if($session->tribe == 1) {
"; - - if($village->awood < $u1['wood'] || $village->aclay < $u1['clay'] || $village->airon < $u1['iron'] || $village->acrop < $u1['crop']) - $output.="".NOT."".ENOUGH_RESOURCES.""; - elseif($units['u1'] == 0) - $output.="".NOT_UNITS.""; + + if($village->awood < $u1['wood'] || $village->aclay < $u1['clay'] || $village->airon < $u1['iron'] || $village->acrop < $u1['crop']) + $output.="".NOT."".ENOUGH_RESOURCES.""; + elseif($units['u1'] == 0) + $output.="".NOT_UNITS.""; else $output.="".TRAIN.""; - - + + $output.="
@@ -100,29 +100,29 @@ if($session->tribe == 1) { \"Crop6| \"Duration\""; $output.=$generator->getTimeFormat(round($u2['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output.="
"; - - if($village->awood < $u2['wood'] OR $village->aclay < $u2['clay'] OR $village->airon < $u2['iron'] OR $village->acrop < $u2['crop']) - $output.="".NOT."".ENOUGH_RESOURCES.""; + + if($village->awood < $u2['wood'] OR $village->aclay < $u2['clay'] OR $village->airon < $u2['iron'] OR $village->acrop < $u2['crop']) + $output.="".NOT."".ENOUGH_RESOURCES.""; elseif($units['u2'] == 0) - $output.="".NOT_UNITS.""; - else + $output.="".NOT_UNITS.""; + else $output.="".TRAIN.""; - + $output.="
@@ -136,30 +136,30 @@ if($session->tribe == 1) { \"Crop\"".$u3['crop']."| \"Crop6| \"Duration\""; - + $output.= $generator->getTimeFormat(round($u3['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output.= "
"; - - if($village->awood < $u3['wood'] OR $village->aclay < $u3['clay'] OR $village->airon < $u3['iron'] OR $village->acrop < $u3['crop']) { - $output.="".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u3'] == 0){ - $output.="".NOT_UNITS.""; + + if($village->awood < $u3['wood'] OR $village->aclay < $u3['clay'] OR $village->airon < $u3['iron'] OR $village->acrop < $u3['crop']) { + $output.="".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u3'] == 0){ + $output.="".NOT_UNITS.""; }else { $output.="".TRAIN.""; - } + } "
@@ -174,29 +174,29 @@ if($session->tribe == 1) { \"Crop6| \"Duration\"". $generator->getTimeFormat(round($u5['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= "
"; - - if($village->awood < $u5['wood'] OR $village->aclay < $u5['clay'] OR $village->airon < $u5['iron'] OR $village->acrop < $u5['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u5'] == 0){ - $output.= "".NOT_UNITS.""; + + if($village->awood < $u5['wood'] OR $village->aclay < $u5['clay'] OR $village->airon < $u5['iron'] OR $village->acrop < $u5['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u5'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -211,29 +211,29 @@ if($session->tribe == 1) { \"Crop6| \"Duration\"". $generator->getTimeFormat(round($u6['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); - + if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { $output .= "|\"NPC"; } - + $output .= "
"; - - if($village->awood < $u6['wood'] OR $village->aclay < $u6['clay'] OR $village->airon < $u6['iron'] OR $village->acrop < $u6['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u6'] == 0){ - $output.= "".NOT_UNITS.""; + + if($village->awood < $u6['wood'] OR $village->aclay < $u6['clay'] OR $village->airon < $u6['iron'] OR $village->acrop < $u6['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u6'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } - + } + $output.="
"; - if($village->awood < $u11['wood'] OR $village->aclay < $u11['clay'] OR $village->airon < $u11['iron'] OR $village->acrop < $u11['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u11'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u11['wood'] OR $village->aclay < $u11['clay'] OR $village->airon < $u11['iron'] OR $village->acrop < $u11['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u11'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -288,30 +288,30 @@ $output.="
"; - if($village->awood < $u12['wood'] OR $village->aclay < $u12['clay'] OR $village->airon < $u12['iron'] OR $village->acrop < $u12['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u12'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u12['wood'] OR $village->aclay < $u12['clay'] OR $village->airon < $u12['iron'] OR $village->acrop < $u12['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u12'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -338,18 +338,18 @@ $output.="
"; - if($village->awood < $u13['wood'] OR $village->aclay < $u13['clay'] OR $village->airon < $u13['iron'] OR $village->acrop < $u13['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u13'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u13['wood'] OR $village->aclay < $u13['clay'] OR $village->airon < $u13['iron'] OR $village->acrop < $u13['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u13'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -364,30 +364,30 @@ $output.="
"; - if($village->awood < $u15['wood'] OR $village->aclay < $u15['clay'] OR $village->airon < $u15['iron'] OR $village->acrop < $u15['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u15'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u15['wood'] OR $village->aclay < $u15['clay'] OR $village->airon < $u15['iron'] OR $village->acrop < $u15['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u15'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -402,27 +402,27 @@ $output.="
"; - if($village->awood < $u16['wood'] OR $village->aclay < $u16['clay'] OR $village->airon < $u16['iron'] OR $village->acrop < $u16['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u16'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u16['wood'] OR $village->aclay < $u16['clay'] OR $village->airon < $u16['iron'] OR $village->acrop < $u16['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u16'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
"; - if($village->awood < $u21['wood'] OR $village->aclay < $u21['clay'] OR $village->airon < $u21['iron'] OR $village->acrop < $u21['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u21'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u21['wood'] OR $village->aclay < $u21['clay'] OR $village->airon < $u21['iron'] OR $village->acrop < $u21['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u21'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -479,30 +479,30 @@ $output.="
"; - if($village->awood < $u22['wood'] OR $village->aclay < $u22['clay'] OR $village->airon < $u22['iron'] OR $village->acrop < $u22['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u22'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u22['wood'] OR $village->aclay < $u22['clay'] OR $village->airon < $u22['iron'] OR $village->acrop < $u22['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u22'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -517,29 +517,29 @@ $output.="
"; - if($village->awood < $u24['wood'] OR $village->aclay < $u24['clay'] OR $village->airon < $u24['iron'] OR $village->acrop < $u24['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u24'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u24['wood'] OR $village->aclay < $u24['clay'] OR $village->airon < $u24['iron'] OR $village->acrop < $u24['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u24'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -554,30 +554,30 @@ $output.="
"; - if($village->awood < $u25['wood'] OR $village->aclay < $u25['clay'] OR $village->airon < $u25['iron'] OR $village->acrop < $u25['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u25'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u25['wood'] OR $village->aclay < $u25['clay'] OR $village->airon < $u25['iron'] OR $village->acrop < $u25['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u25'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
@@ -592,27 +592,27 @@ $output.="
"; - if($village->awood < $u26['wood'] OR $village->aclay < $u26['clay'] OR $village->airon < $u26['iron'] OR $village->acrop < $u26['crop']) { - $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u26'] == 0){ - $output.= "".NOT_UNITS.""; + if($village->awood < $u26['wood'] OR $village->aclay < $u26['clay'] OR $village->airon < $u26['iron'] OR $village->acrop < $u26['crop']) { + $output.= "".NOT."".ENOUGH_RESOURCES.""; + }else if($units['u26'] == 0){ + $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; - } + } $output.="
diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index 4670eaec..2aecbb5d 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -178,8 +178,8 @@ $user = $session->uid; //loop search village user -$query = mysqli_query($GLOBALS['link'],"SELECT wref FROM ".TB_PREFIX."vdata WHERE owner = ".(int) $user.""); -while($villaggi_array = mysqli_fetch_array($query)){ +$villages = $database->getProfileVillages($user); +foreach ($villages as $villaggi_array){ //loop structure village $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".(int) $villaggi_array['wref'].""); @@ -189,7 +189,7 @@ while($villaggi_array = mysqli_fetch_array($query)){ //search Castle in array structure village $test = in_array(26,$strutture); -if ($test){ +if ($test){ break; } @@ -302,8 +302,8 @@ $user = $session->uid; //mysqli_select_db(SQL_DB); //loop search village user -$query = mysqli_query($GLOBALS['link'],"SELECT wref FROM ".TB_PREFIX."vdata WHERE owner = ".(int) $user.""); -while($villaggi_array = mysqli_fetch_array($query)){ +$villages = $database->getProfileVillages($user); +foreach ($villages as $villaggi_array){ //loop structure village $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".(int) $villaggi_array['wref'].""); @@ -314,7 +314,7 @@ while($villaggi_array = mysqli_fetch_array($query)){ $test = in_array(26,$strutture); else $test = in_array(26,[]); -if ($test){ +if ($test){ break; } diff --git a/create_account.php b/create_account.php index a3e24728..598a30e9 100644 --- a/create_account.php +++ b/create_account.php @@ -6,16 +6,16 @@ $start_timer = $generator->pageLoadTimeStart(); ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## --------------------------------------------------------------------------- ## ## Project: TravianZ ## -## Version: 22.06.2015 ## +## Version: 22.06.2015 ## ## Filename create_account.php ## -## Developed by: Dzoki , Advocaite , Donnchadh , yi12345 , Shadow , MisterX ## +## Developed by: Dzoki , Advocaite , Donnchadh , yi12345 , Shadow , MisterX ## ## Fixed by: Shadow & MisterX - Scouting all players , artefact names. ## ## Fixed by: InCube - double troops ## ## Fixed by: ronix ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2015. All rights reserved. ## ## URLs: http://travian.shadowss.ro ## -## Source code: https://github.com/Shadowss/TravianZ ## +## Source code: https://github.com/Shadowss/TravianZ ## ## ## ################################################################################# @@ -115,7 +115,7 @@ if(isset($_POST['password']) && $_POST['password'] != ""){ /** * Creating account & capital village - Fixed by Shadow - cata7007@gmail.com / Skype : cata7007 - */ + */ $username = "Natars"; $password = password_hash($_POST['password'], PASSWORD_BCRYPT,['cost' => 12]); @@ -172,8 +172,8 @@ if(isset($_POST['password']) && $_POST['password'] != ""){ $database->addABTech($wid); $database->updateUserField($uid, "access", USER, 1); } - - $wid = mysqli_fetch_assoc(mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "vdata WHERE owner = ".(int) $uid)); + + $wid = $database->getVillage($uid, 2); $q = "UPDATE " . TB_PREFIX . "vdata SET pop = 834 WHERE owner = ".(int) $uid; mysqli_query($GLOBALS['link'],$q) or die(mysqli_error($database->dblink)); $q2 = "UPDATE " . TB_PREFIX . "users SET access = 2 WHERE id = ".(int) $uid; @@ -187,15 +187,13 @@ if(isset($_POST['password']) && $_POST['password'] != ""){ mysqli_query($GLOBALS['link'],$q3) or die(mysqli_error($database->dblink)); $q4 = "UPDATE " . TB_PREFIX . "users SET desc2 = '$desc' WHERE id = ".(int) $uid; mysqli_query($GLOBALS['link'],$q4) or die(mysqli_error($database->dblink)); - + /** * SCOUTING ALL PLAYERS FIX BY MisterX */ - - $natar = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "vdata WHERE owner = ".(int) $uid." and capital = 1")); + $natar = $database->getVillage($uid, 3); $multiplier = NATARS_UNITS; - $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE capital = '1' and owner > '5'"; - $array = $database->query_return($q); + $array = $database->getProfileVillages(0, 1); $sendspytroops = 1500 * $multiplier; $refs = []; $vils = []; diff --git a/winner.php b/winner.php index 3af3375b..6362aa17 100644 --- a/winner.php +++ b/winner.php @@ -141,11 +141,8 @@ else { $sql = mysqli_query($GLOBALS['link'],"SELECT vref FROM ".TB_PREFIX."fdata WHERE f99 = '100' and f99t = '40'"); $vref = mysqli_result($sql, 0); - $sql = mysqli_query($GLOBALS['link'],"SELECT name FROM ".TB_PREFIX."vdata WHERE wref = '$vref'")or die(mysqli_error($database->dblink)); - $winningvillagename = mysqli_result($sql, 0); - - $sql = mysqli_query($GLOBALS['link'],"SELECT owner FROM ".TB_PREFIX."vdata WHERE wref = '$vref'")or die(mysqli_error($database->dblink)); - $owner = mysqli_result($sql, 0); + $winningvillagename = $database->getVillage($vref)['name']; + $owner = $database->getVillage($vref)['owner']; $sql = mysqli_query($GLOBALS['link'],"SELECT username FROM ".TB_PREFIX."users WHERE id = '$owner'")or die(mysqli_error($database->dblink)); $username = mysqli_result($sql, 0);