From 1aa5c253b667e8bf2197105d443dd59a17aa71d7 Mon Sep 17 00:00:00 2001 From: TienTN Date: Tue, 6 Sep 2016 22:05:13 +0700 Subject: [PATCH 01/73] add variable validate for functions: addResourceFields addVillage setFieldTaken register activate --- GameEngine/Database/db_MYSQL.php | 45 +++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 1b9d9e08..c324f3ec 100755 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -45,10 +45,15 @@ class MYSQL_DB { } function register($username, $password, $email, $tribe, $act) { + //TienTN add validation + if (strlen($username) > 100 || strlen($password) > 100 || !is_numeric($tribe) || strlen($act) > 10) { + throw new Exception('register: wrong param'); + return false; + } $time = time(); - $stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME); + $stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME); if($stime > time()){ - $time = $stime; + $time = $stime; } $timep = $time + PROTECTION; $time = time(); @@ -61,6 +66,11 @@ class MYSQL_DB { } function activate($username, $password, $email, $tribe, $locate, $act, $act2) { + //TienTN add validation + if (strlen($username) > 100 || strlen($password) > 100 || !is_numeric($tribe) || strlen($act) > 10 || strlen($act2) > 10) { + throw new Exception('register: wrong param'); + return false; + } $time = time(); $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')"; if(mysql_query($q, $this->connection)) { @@ -378,17 +388,17 @@ class MYSQL_DB { } switch($sector) { case 1: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x- y+ - break; + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x- y+ + break; case 2: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x+ y+ - break; + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x+ y+ + break; case 3: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x- y- - break; + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x- y- + break; case 4: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- - break; + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- + break; } $result = mysql_query($q, $this->connection); $num_rows = mysql_num_rows($result); @@ -400,6 +410,11 @@ class MYSQL_DB { } function setFieldTaken($id) { + //TienTN add validation + if (!is_numeric($id)) { + throw new Exception('setFieldTaken: wrong param'); + return null; + } $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id"; return mysql_query($q, $this->connection); } @@ -412,11 +427,21 @@ class MYSQL_DB { $vname = $username . "\'s village"; } $time = time(); + //TienTN add validation + if (!is_numeric($wid) || !is_numeric($uid) || strlen($vname) > 100 || is_bool($capital) === false) { + throw new Exception('addVillage: wrong param'); + return null; + } $q = "INSERT into " . TB_PREFIX . "vdata (wref, owner, name, capital, pop, cp, celebration, wood, clay, iron, maxstore, crop, maxcrop, lastupdate, created) values ('$wid', '$uid', '$vname', '$capital', 2, 1, 0, 750, 750, 750, ".STORAGE_BASE.", 750, ".STORAGE_BASE.", '$time', '$time')"; return mysql_query($q, $this->connection) or die(mysql_error()); } function addResourceFields($vid, $type) { + //TienTN add validation + if (!is_numeric($vid)) { + throw new Exception('addResourceFields: Invalid param'); + return null; + } switch($type) { case 1: $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,4,4,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; From 2cf2f3c343a1bded30cc51ee73c85c215ad0e6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Kajdi=C4=8D?= Date: Tue, 13 Sep 2016 15:38:14 +0200 Subject: [PATCH 02/73] Trying to fix this monstrosity #1 --- GameEngine/Account.php | 15 +- GameEngine/Admin/database.php | 145 +- GameEngine/Automation.php | 422 ++-- GameEngine/Database.php | 13 +- GameEngine/Database/db_MYSQL.php | 3716 ----------------------------- GameEngine/Database/db_MYSQLi.php | 1020 ++++---- GameEngine/Protection.php | 6 +- GameEngine/Ranking.php | 181 +- GameEngine/Session.php | 37 +- GameEngine/Technology.php | 10 +- GameEngine/Units.php | 4 - Templates/Map/mapview.tpl | 4 +- Templates/Map/vilview.tpl | 50 +- Templates/links.tpl | 6 +- index.php | 12 +- install/data/constant_format.tpl | 8 - install/include/database.php | 36 +- install/include/multihunter.php | 6 +- install/include/oasis.php | 4 +- install/index.php | 1 - install/process.php | 1 - install/templates/config.tpl | 5 +- 22 files changed, 969 insertions(+), 4733 deletions(-) delete mode 100755 GameEngine/Database/db_MYSQL.php diff --git a/GameEngine/Account.php b/GameEngine/Account.php index 951f0783..cce70708 100755 --- a/GameEngine/Account.php +++ b/GameEngine/Account.php @@ -20,7 +20,7 @@ include("Session.php"); class Account { - function Account() { + function __construct() { global $session; if(isset($_POST['ft'])) { switch($_POST['ft']) { @@ -140,8 +140,8 @@ class Account { { global $database; $q = "SELECT * FROM ".TB_PREFIX."activate where act = '".$_POST['id']."'"; - $result = mysql_query($q, $database->connection); - $dbarray = mysql_fetch_array($result); + $result = mysqli_query($q, $database->connection); + $dbarray = mysqli_fetch_array($result); if($dbarray['act'] == $_POST['id']) { $uid = $database->register($dbarray['username'],$dbarray['password'],$dbarray['email'],$dbarray['tribe'],""); if($uid) { @@ -165,8 +165,8 @@ class Account { private function Unreg() { global $database; $q = "SELECT * FROM ".TB_PREFIX."activate where id = '".$_POST['id']."'"; - $result = mysql_query($q, $database->connection); - $dbarray = mysql_fetch_array($result); + $result = mysqli_query($database->connection,$q); + $dbarray = mysqli_fetch_array($result); if(md5($_POST['pw']) == $dbarray['password']) { $database->unreg($dbarray['username']); header("Location: anmelden.php"); @@ -178,9 +178,10 @@ class Account { private function Login() { global $database,$session,$form; - $_POST['user'] = mysql_real_escape_string($_POST['user']); + $user = $_POST['user']; + $user = mysqli_real_escape_string($link, $user); if(!isset($_POST['user']) || $_POST['user'] == "") { - $form->addError("user",LOGIN_USR_EMPTY); + $form->addError("user",$user); } else if(!$database->checkExist($_POST['user'],0)) { $form->addError("user",USR_NT_FOUND); diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php index 188ac53f..89ad1bf9 100755 --- a/GameEngine/Admin/database.php +++ b/GameEngine/Admin/database.php @@ -24,25 +24,26 @@ include_once("../GameEngine/Data/unitdata.php"); include_once("../GameEngine/Technology.php"); include_once("../GameEngine/Data/buidata.php"); } +include_once("../../GameEngine/Database.php"); class adm_DB { - var $connection; - - function adm_DB(){ - global $database; - $this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); + + var $connection; + function adm_DB(){ + global $database; + $database = new MYSQLi_DB; + $this->connection = $database->return_link(); } function Login($username,$password){ $q = "SELECT password FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER; - $result = mysql_query($q, $this->connection); - $dbarray = mysql_fetch_array($result); + $result = mysqli_query($q, $this->connection); + $dbarray = mysqli_fetch_array($result); if($dbarray['password'] == md5($password)) { - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP: ".$_SERVER['REMOTE_ADDR'].")',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP: ".$_SERVER['REMOTE_ADDR'].")',".time().")"); return true; } else { - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username $username but access was denied!',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,'X','IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username $username but access was denied!',".time().")"); return false; } } @@ -70,7 +71,7 @@ class adm_DB { } $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } function recountCP($vid){ @@ -85,7 +86,7 @@ class adm_DB { } } $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } function buildingPOP($f,$lvl){ @@ -114,8 +115,8 @@ class adm_DB { function getWref($x,$y) { $q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y"; - $result = mysql_query($q, $this->connection); - $r = mysql_fetch_array($result); + $result = mysqli_query($q, $this->connection); + $r = mysqli_fetch_array($result); return $r['id']; } @@ -126,7 +127,7 @@ class adm_DB { $status = $database->getVillageState($wid); $status = 0; if($status == 0){ - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Added new village $wid to user $uid',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Added new village $wid to user $uid',".time().")"); $database->setFieldTaken($wid); $database->addVillage($wid,$uid,'new village','0'); $database->addResourceFields($wid,$database->getVillageType($wid)); @@ -164,23 +165,23 @@ class adm_DB { if($post['clean_ware']){ $time = time(); $q = "UPDATE ".TB_PREFIX."vdata SET `wood` = '0', `clay` = '0', `iron` = '0', `crop` = '0', `lastupdate` = '$time' WHERE wref = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } } - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Punished user: ".$post['uid']." with -".$post['punish']."% population',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Punished user: ".$post['uid']." with -".$post['punish']."% population',".time().")"); } function PunishBuilding($vid,$proc,$pop){ global $database; $q = "UPDATE ".TB_PREFIX."vdata set pop = $pop where wref = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $fdata = $database->getResourceLevel($vid); for ($i = 1; $i <= 40; $i++) { if($fdata['f'.$i]>1){ $zm = ($fdata['f'.$i]/100)*$proc; if($zm < 1){$zm = 1;}else{$zm = floor($zm);} $q = "UPDATE ".TB_PREFIX."fdata SET `f$i` = '$zm' WHERE `vref` = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } } } @@ -193,7 +194,7 @@ class adm_DB { function DelUnits2($vid,$unit){ $q = "UPDATE ".TB_PREFIX."units SET `u$unit` = '0' WHERE `vref` = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } function DelPlayer($uid,$pass){ @@ -205,26 +206,26 @@ class adm_DB { $this->DelVillage($villages[$i]['wref'], 1); } $q = "DELETE FROM ".TB_PREFIX."hero where uid = $uid"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $name = $database->getUserField($uid,"username",0); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user $name',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user $name',".time().")"); $q = "DELETE FROM ".TB_PREFIX."users WHERE `id` = $uid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } } function getUserActive() { $time = time() - (60*5); $q = "SELECT * FROM ".TB_PREFIX."users where timestamp > $time and username != 'support'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function CheckPass($password,$uid){ $q = "SELECT password FROM ".TB_PREFIX."users where id = '$uid' and access = ".ADMIN; - $result = mysql_query($q, $this->connection); - $dbarray = mysql_fetch_array($result); + $result = mysqli_query($q, $this->connection); + $dbarray = mysqli_fetch_array($result); if($dbarray['password'] == md5($password)) { return true; }else{ @@ -239,37 +240,37 @@ class adm_DB { }else{ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref"; } - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result) > 0){ - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village $wref',".time().")"); + $result = mysqli_query($q, $this->connection); + if(mysqli_num_rows($result) > 0){ + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village $wref',".time().")"); $database->clearExpansionSlot($wref); $q = "DELETE FROM ".TB_PREFIX."abdata where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."bdata where wid = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."market where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."odata where wref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."research where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."tdata where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."fdata where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."training where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."units where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."farmlist where wref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."raidlist where towref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "DELETE FROM ".TB_PREFIX."movement where `from` = $wref and proc=0"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $getmovement = $database->getMovement(3,$wref,1); foreach($getmovement as $movedata) { @@ -284,11 +285,11 @@ class adm_DB { $this->returnTroops($wref); $q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); - if (mysql_affected_rows()>0) { + if (mysqli_affected_rows()>0) { $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = $wref"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $getprisoners = $database->getPrisoners($wref); foreach($getprisoners as $pris) { @@ -315,83 +316,83 @@ class adm_DB { function DelBan($uid,$id){ global $database; $name = addslashes($database->getUserField($uid,"username",0)); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user $name',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user $name',".time().")"); $q = "UPDATE ".TB_PREFIX."users SET `access` = '".USER."' WHERE `id` = $uid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $q = "UPDATE ".TB_PREFIX."banlist SET `active` = '0' WHERE `id` = $id;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } function AddBan($uid,$end,$reason){ global $database; $name = addslashes($database->getUserField($uid,"username",0)); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user $name',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user $name',".time().")"); $q = "UPDATE ".TB_PREFIX."users SET `access` = '0' WHERE `id` = $uid;"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); $time = time(); $admin = $_SESSION['id']; //$database->getUserField($_SESSION['username'],'id',1); $name = addslashes($database->getUserField($uid,'username',0)); $q = "INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES ($uid, '$name' , '$reason', '$time', '$end', '$admin', '1');"; - mysql_query($q, $this->connection); + mysqli_query($q, $this->connection); } function search_player($player){ $q = "SELECT id,username FROM ".TB_PREFIX."users WHERE `username` LIKE '%$player%' and username != 'support'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function search_email($email){ $q = "SELECT id,email FROM ".TB_PREFIX."users WHERE `email` LIKE '%$email%' and username != 'support'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function search_village($village){ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function search_alliance($alliance){ $q = "SELECT * FROM ".TB_PREFIX."alidata WHERE `name` LIKE '%$alliance%' or `tag` LIKE '%$alliance%' or `id` LIKE '%$alliance%'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function search_ip($ip){ $q = "SELECT * FROM ".TB_PREFIX."login_log WHERE `ip` LIKE '%$ip%'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function search_banned(){ $q = "SELECT * FROM ".TB_PREFIX."banlist where active = '1'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } function Del_banned(){ //$q = "SELECT * FROM ".TB_PREFIX."banlist"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } /*************************** Function to process MYSQLi->fetch_all (Only exist in MYSQL) References: Result ***************************/ - function mysql_fetch_all($result) { + function mysqli_fetch_all($result) { $all = array(); if($result) { - while ($row = mysql_fetch_assoc($result)){ $all[] = $row; } + while ($row = mysqli_fetch_assoc($result)){ $all[] = $row; } return $all; } } function query_return($q) { - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($q, $this->connection); + return $this->mysqli_fetch_all($result); } /*************************** @@ -399,7 +400,7 @@ class adm_DB { References: Query ***************************/ function query($query) { - return mysql_query($query, $this->connection); + return mysqli_query($query, $this->connection); } public function getTypeLevel($tid,$vid) { @@ -519,8 +520,8 @@ class adm_DB { if( intval($enforce['hero']) > 0){ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $result = mysql_query($q); - $hero_f=mysql_fetch_array($result); + $result = mysqli_query($q); + $hero_f=mysqli_fetch_array($result); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } else { diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 792486f8..11399405 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -31,8 +31,8 @@ class Automation { private $bountyOpop = 1; public function isWinner() { - $q = mysql_query("SELECT vref FROM ".TB_PREFIX."fdata WHERE f99 = '100' and f99t = '40'"); - $isThere = mysql_num_rows($q); + $q = mysqli_query($GLOBALS['link'],"SELECT vref FROM ".TB_PREFIX."fdata WHERE f99 = '100' and f99t = '40'"); + $isThere = mysqli_num_rows($q); if($isThere > 0) { header('Location: /winner.php'); @@ -41,7 +41,7 @@ class Automation { } } - public function procResType($ref,$mode=0,$isoasis=0) { + public function procResType($ref,$mode=0,$isoasis=0) { global $session; switch($ref) { case 1: $build = "Woodcutter"; break; @@ -113,7 +113,7 @@ class Automation { } $this->recountCP($vid); $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid"; - mysql_query($q); + mysqli_query($GLOBALS['link'],$q); $owner = $database->getVillageField($vid,"owner"); $this->procClimbers($owner); @@ -135,7 +135,7 @@ class Automation { } $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid"; - mysql_query($q); + mysqli_query($GLOBALS['link'],$q); return $popTot; @@ -634,7 +634,7 @@ class Automation { } private function buildComplete() { - if(file_exists("GameEngine/Prevention/build.txt")) { + if(file_exists("GameEngine/Prevention/build.txt")) { unlink("GameEngine/Prevention/build.txt"); } global $database,$bid18,$bid10,$bid11,$bid38,$bid39; @@ -644,11 +644,11 @@ class Automation { $array = $database->query_return($q); foreach($array as $indi) { $level = $database->getFieldLevel($indi['wid'],$indi['field']); - if (($level+1) == $indi['level']){ - $q = "UPDATE ".TB_PREFIX."fdata set f".$indi['field']." = ".$indi['level'].", f".$indi['field']."t = ".$indi['type']." where vref = ".$indi['wid']; - }else{ $indi['level']=($level+1); - $q = "UPDATE ".TB_PREFIX."fdata set f".$indi['field']." = ".$indi['level'].", f".$indi['field']."t = ".$indi['type']." where vref = ".$indi['wid']; - } + if (($level+1) == $indi['level']){ + $q = "UPDATE ".TB_PREFIX."fdata set f".$indi['field']." = ".$indi['level'].", f".$indi['field']."t = ".$indi['type']." where vref = ".$indi['wid']; + }else{ $indi['level']=($level+1); + $q = "UPDATE ".TB_PREFIX."fdata set f".$indi['field']." = ".$indi['level'].", f".$indi['field']."t = ".$indi['type']." where vref = ".$indi['wid']; + } if($database->query($q)) { $level = $database->getFieldLevel($indi['wid'],$indi['field']); $this->recountPop($indi['wid']); @@ -711,7 +711,7 @@ class Automation { $this->startNatarAttack($indi['level'], $indi['wid'], $indi['timestamp']); } if($indi['type'] == 40 && $indi['level'] == 100){ //now can't be more than one winners if ww to level 100 is build by 2 users or more on same time - mysql_query("TRUNCATE ".TB_PREFIX."bdata"); + mysqli_query($GLOBALS['link'],"TRUNCATE ".TB_PREFIX."bdata"); } if($database->getUserField($database->getVillageField($indi['wid'],"owner"),"tribe",0) != 1){ $q4 = "UPDATE ".TB_PREFIX."bdata set loopcon = 0 where loopcon = 1 and master = 0 and wid = ".$indi['wid']; @@ -882,15 +882,15 @@ class Automation { } // get the capital village from the natars - $query = mysql_query('SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysql_error()); - $row = mysql_fetch_assoc($query); + $query = mysqli_query($GLOBALS['link'],'SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysqli_error()); + $row = mysqli_fetch_assoc($query); // start the attacks $endtime = $time + round((60 * 60 * 24) / INCREASE_SPEED); // -.- - mysql_query('INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . $endtime . ')'); - mysql_query('INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . ($endtime + 1) . ')'); + mysqli_query($GLOBALS['link'],'INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . $endtime . ')'); + mysqli_query($GLOBALS['link'],'INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . ($endtime + 1) . ')'); // wave 1 $ref = $database->addAttack($row['wref'], 0, $units[0][0], $units[0][1], 0, $units[0][2], $units[0][3], $units[0][4], $units[0][5], 0, 0, 0, 3, 0, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20); @@ -902,11 +902,11 @@ class Automation { } private function checkWWAttacks() { - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'ww_attacks` WHERE `attack_time` <= ' . time()); - while ($row = mysql_fetch_assoc($query)) + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'ww_attacks` WHERE `attack_time` <= ' . time()); + while ($row = mysqli_fetch_assoc($query)) { // delete the attack - $query3 = mysql_query('DELETE FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . $row['vid'] . ' AND `attack_time` = ' . $row['attack_time']); + $query3 = mysqli_query($GLOBALS['link'],'DELETE FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . $row['vid'] . ' AND `attack_time` = ' . $row['attack_time']); } } @@ -1826,8 +1826,8 @@ class Automation { } if ($herosend_att>0){ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $resulth = mysql_query($qh); - $hero_f=mysql_fetch_array($resulth); + $resulth = mysqli_query($GLOBALS['link'],$qh); + $hero_f=mysqli_fetch_array($resulth); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } @@ -1896,8 +1896,8 @@ class Automation { if ($data['ctar2']==0) { - $bdo2=mysql_query("select * from " . TB_PREFIX . "fdata where vref = $basearray"); - $bdo=mysql_fetch_array($bdo2); + $bdo2=mysqli_query($GLOBALS['link'],"select * from " . TB_PREFIX . "fdata where vref = $basearray"); + $bdo=mysqli_fetch_array($bdo2); $rand=$data['ctar1']; @@ -1958,16 +1958,16 @@ class Automation { if($tbid>=19 && $tbid!=99) { $database->setVillageLevel($data['to'],"f".$tbid."t",'0'); } $buildarray = $GLOBALS["bid".$tbgid]; if ($tbgid==10 || $tbgid==38) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxstore=$t_sql['maxstore']-$buildarray[$tblevel]['attri']; if ($tmaxstore<800) $tmaxstore=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."'*32 WHERE wref=".$data['to']; $database->query($q); } if ($tbgid==11 || $tbgid==39) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxcrop=$t_sql['maxcrop']-$buildarray[$tblevel]['attri']; if ($tmaxcrop<800) $tmaxcrop=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."'*32 WHERE wref=".$data['to']; @@ -2001,16 +2001,16 @@ class Automation { $info_cata=" damaged from level ".$tblevel." to level ".$totallvl."."; $buildarray = $GLOBALS["bid".$tbgid]; if ($tbgid==10 || $tbgid==38) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxstore=$t_sql['maxstore']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri']; if ($tmaxstore<800) $tmaxstore=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to']; $database->query($q); } if ($tbgid==11 || $tbgid==39) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxcrop=$t_sql['maxcrop']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri']; if ($tmaxcrop<800) $tmaxcrop=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; @@ -2027,8 +2027,8 @@ class Automation { } else { - $bdo2=mysql_query("select * from " . TB_PREFIX . "fdata where vref = $basearray"); - $bdo=mysql_fetch_array($bdo2); + $bdo2=mysqli_query($GLOBALS['link'],"select * from " . TB_PREFIX . "fdata where vref = $basearray"); + $bdo=mysqli_fetch_array($bdo2); $rand=$data['ctar1']; if ($rand != 0) { @@ -2087,16 +2087,16 @@ class Automation { if($tbid>=19 && $tbid!=99) { $database->setVillageLevel($data['to'],"f".$tbid."t",'0'); } $buildarray = $GLOBALS["bid".$tbgid]; if ($tbgid==10 || $tbgid==38) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxstore=$t_sql['maxstore']-$buildarray[$tblevel]['attri']; if ($tmaxstore<800) $tmaxstore=800*32; $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to']; $database->query($q); } if ($tbgid==11 || $tbgid==39) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxcrop=$t_sql['maxcrop']-$buildarray[$tblevel]['attri']; if ($tmaxcrop<800) $tmaxcrop=800*32; $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; @@ -2132,16 +2132,16 @@ class Automation { $info_cata=" damaged from level ".$tblevel." to level ".$totallvl."."; $buildarray = $GLOBALS["bid".$tbgid]; if ($tbgid==10 || $tbgid==38) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxstore=$t_sql['maxstore']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri']; if ($tmaxstore<800) $tmaxstore=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to']; $database->query($q); } if ($tbgid==11 || $tbgid==39) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxcrop=$t_sql['maxcrop']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri']; if ($tmaxcrop<800) $tmaxcrop=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; @@ -2155,8 +2155,8 @@ class Automation { $info_cat = "".$catp_pic.",".$this->procResType($tbgid,$can_destroy,$isoasis).$info_cata; $database->setVillageLevel($data['to'],"f".$tbid."",$totallvl); } - $bdo2=mysql_query("select * from " . TB_PREFIX . "fdata where vref = $basearray"); - $bdo=mysql_fetch_array($bdo2); + $bdo2=mysqli_query($GLOBALS['link'],"select * from " . TB_PREFIX . "fdata where vref = $basearray"); + $bdo=mysqli_fetch_array($bdo2); $rand=$data['ctar2']; if ($rand != 99) { @@ -2216,16 +2216,16 @@ class Automation { if($tbid>=19 && $tbid!=99) { $database->setVillageLevel($data['to'],"f".$tbid."t",'0'); } $buildarray = $GLOBALS["bid".$tbgid]; if ($tbgid==10 || $tbgid==38) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxstore=$t_sql['maxstore']-$buildarray[$tblevel]['attri']; if ($tmaxstore<800) $tmaxstore=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to']; $database->query($q); } if ($tbgid==11 || $tbgid==39) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxcrop=$t_sql['maxcrop']-$buildarray[$tblevel]['attri']; if ($tmaxcrop<800) $tmaxcrop=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; @@ -2260,16 +2260,16 @@ class Automation { $info_cata=" damaged from level ".$tblevel." to level ".$totallvl."."; $buildarray = $GLOBALS["bid".$tbgid]; if ($tbgid==10 || $tbgid==38) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxstore=$t_sql['maxstore']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri']; if ($tmaxstore<800) $tmaxstore=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to']; $database->query($q); } if ($tbgid==11 || $tbgid==39) { - $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); - $t_sql=mysql_fetch_array($tsql); + $tsql=mysqli_query($GLOBALS['link'],"select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to'].""); + $t_sql=mysqli_fetch_array($tsql); $tmaxcrop=$t_sql['maxcrop']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri']; if ($tmaxcrop<800) $tmaxcrop=800; $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; @@ -2673,7 +2673,7 @@ $wallimg = "0){ $p_qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$p_owner.""; $p_resulth = $database->query($p_qh); - $p_hero_f=mysql_fetch_array($p_resulth); + $p_hero_f=mysqli_fetch_array($p_resulth); $p_hero_unit=$p_hero_f['unit']; $p_speeds[] = $GLOBALS['u'.$p_hero_unit]['speed']; } @@ -2846,8 +2846,8 @@ $wallimg = "0){ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $resulth = mysql_query($qh); - $hero_f=mysql_fetch_array($resulth); + $resulth = mysqli_query($GLOBALS['link'],$qh); + $hero_f=mysqli_fetch_array($resulth); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } @@ -3015,7 +3015,7 @@ $wallimg = "query($q); - if (mysql_affected_rows()>0) { + if (mysqli_affected_rows()>0) { $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = $wref"; $database->query($q); @@ -3071,13 +3071,13 @@ $wallimg = " $enforce['hero']) { $form->addError("error","You can't send more units than you have"); - break; + } if($post['t11']<0) { $form->addError("error","You can't send negative units."); - break; + } } else { $post['t11']='0'; @@ -3124,8 +3124,8 @@ $wallimg = " 0){ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $resulth = mysql_query($qh); - $hero_f=mysql_fetch_array($resulth); + $resulth = mysqli_query($GLOBALS['link'],$qh); + $hero_f=mysqli_fetch_array($resulth); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } else { @@ -4123,20 +4123,20 @@ $wallimg = "= $hero_levels[$i]){ - mysql_query("UPDATE " . TB_PREFIX ."hero SET level = $i WHERE heroid = '".$hdata['heroid']."'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX ."hero SET level = $i WHERE heroid = '".$hdata['heroid']."'"); if($i < 99){ - mysql_query("UPDATE " . TB_PREFIX ."hero SET points = points + 5 WHERE heroid = '".$hdata['heroid']."'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX ."hero SET points = points + 5 WHERE heroid = '".$hdata['heroid']."'"); } } } $villunits = $database->getUnit($hdata['wref']); if($villunits['hero'] == 0 && $hdata['trainingtime'] < time() && $hdata['inrevive'] == 1){ - mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref'].""); - mysql_query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".$hdata['trainingtime']." WHERE `uid` = '".$hdata['uid']."'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref'].""); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".$hdata['trainingtime']." WHERE `uid` = '".$hdata['uid']."'"); } if($villunits['hero'] == 0 && $hdata['trainingtime'] < time() && $hdata['intraining'] == 1){ - mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref'].""); - mysql_query("UPDATE ".TB_PREFIX."hero SET `intraining` = '0', `lastupdate` = ".$hdata['trainingtime']." WHERE `uid` = '".$hdata['uid']."'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref'].""); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `intraining` = '0', `lastupdate` = ".$hdata['trainingtime']." WHERE `uid` = '".$hdata['uid']."'"); } } } @@ -4151,8 +4151,8 @@ $wallimg = "query_return($q); foreach($array as $user) { - $numusers = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$user['invited']); - if(mysql_num_rows($numusers) > 0){ + $numusers = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE id = ".$user['invited']); + if(mysqli_num_rows($numusers) > 0){ $varray = count($database->getProfileVillages($user['id'])); if($varray > 1){ $usergold = $database->getUserField($user['invited'],"gold",0); @@ -4247,7 +4247,7 @@ $wallimg = "query_return($q); foreach($array as $general) { if(time() - (86400*8) > $general['time']){ - mysql_query("UPDATE ".TB_PREFIX."general SET shown = 0 WHERE id = ".$general['id'].""); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."general SET shown = 0 WHERE id = ".$general['id'].""); } } } @@ -4553,14 +4553,14 @@ $wallimg = "procRankArray(); $climbers = $ranking->getRank(); if(count($ranking->getRank()) > 0){ $q = "SELECT * FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1"; - $result = mysql_query($q); - if(mysql_num_rows($result)) { - $row=mysql_fetch_assoc($result); + $result = mysqli_query($GLOBALS['link'],$q); + if(mysqli_num_rows($result)) { + $row=mysqli_fetch_assoc($result); $week=($row['week']+1); } else { $week='1'; @@ -4607,9 +4607,9 @@ $wallimg = "getRank(); if(count($ranking->getRank()) > 0){ $q = "SELECT * FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1"; - $result = mysql_query($q); - if(mysql_num_rows($result)) { - $row=mysql_fetch_assoc($result); + $result = mysqli_query($GLOBALS['link'],$q); + if(mysqli_num_rows($result)) { + $row=mysqli_fetch_assoc($result); $week=($row['week']+1); } else { $week='1'; @@ -4691,8 +4691,8 @@ $wallimg = "query_return($q); foreach($array as $banlist) { - mysql_query("UPDATE ".TB_PREFIX."banlist SET active = 0 WHERE id = ".$banlist['id'].""); - mysql_query("UPDATE ".TB_PREFIX."users SET access = 2 WHERE id = ".$banlist['uid'].""); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."banlist SET active = 0 WHERE id = ".$banlist['id'].""); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users SET access = 2 WHERE id = ".$banlist['uid'].""); } } @@ -4710,8 +4710,8 @@ $wallimg = " 0){ + $q = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader"); + if(mysqli_num_rows($q) > 0){ $villages = $database->getVillagesID2($leader); $max = 0; foreach($villages as $village){ @@ -4735,13 +4735,13 @@ $wallimg = "getHero($session->uid,1); if ($herodata[0]['dead']==1){ - mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".$session->villages[0].""); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".$session->villages[0].""); } if($herodata[0]['trainingtime'] <= time()) { if($herodata[0]['trainingtime'] != 0) { if($herodata[0]['dead'] == 0) { - mysql_query("UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE uid = " . $session->uid . ""); - mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$session->villages[0].""); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE uid = " . $session->uid . ""); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$session->villages[0].""); } } } @@ -4759,9 +4759,9 @@ $wallimg = " diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php deleted file mode 100755 index 1b9d9e08..00000000 --- a/GameEngine/Database/db_MYSQL.php +++ /dev/null @@ -1,3716 +0,0 @@ -connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); - mysql_query("SET NAMES 'UTF8'"); //Fix utf8 phpmyadmin by gm4st3r - } - - function safe_mysql_fetch_all($result) { - //fix for Warning: mysql_fetch_all() expects parameter 1 to be resource, boolean given - //by tientn 20160821 - if ($result) { - return $this->mysql_fetch_all($result); - } - return null; - } - - function safe_mysql_fetch_array($result) { - //fix for Warning: $this->safe_mysql_fetch_array() expects parameter 1 to be resource, boolean given - //by tientn 20160821 - if ($result) { - return mysql_fetch_array($result); - } - return null; - } - - function register($username, $password, $email, $tribe, $act) { - $time = time(); - $stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME); - if($stime > time()){ - $time = $stime; - } - $timep = $time + PROTECTION; - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)"; - if(mysql_query($q, $this->connection)) { - return mysql_insert_id($this->connection); - } else { - return false; - } - } - - function activate($username, $password, $email, $tribe, $locate, $act, $act2) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')"; - if(mysql_query($q, $this->connection)) { - return mysql_insert_id($this->connection); - } else { - return false; - } - } - - function unreg($username) { - $q = "DELETE from " . TB_PREFIX . "activate where username = '$username'"; - return mysql_query($q, $this->connection); - } - function deleteReinf($id) { - $q = "DELETE from " . TB_PREFIX . "enforcement where id = '$id'"; - mysql_query($q, $this->connection); - } - function updateResource($vid, $what, $number) { - - $q = "UPDATE " . TB_PREFIX . "vdata set " . $what . "=" . $number . " where wref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_query($q, $this->connection); - } - - function checkExist($ref, $mode) { - - if(!$mode) { - $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1"; - } else { - $q = "SELECT email FROM " . TB_PREFIX . "users where email = '$ref' LIMIT 1"; - } - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function checkExist_activate($ref, $mode) { - - if(!$mode) { - $q = "SELECT username FROM " . TB_PREFIX . "activate where username = '$ref' LIMIT 1"; - } else { - $q = "SELECT email FROM " . TB_PREFIX . "activate where email = '$ref' LIMIT 1"; - } - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - public function hasBeginnerProtection($vid) { - $q = "SELECT u.protect FROM ".TB_PREFIX."users u,".TB_PREFIX."vdata v WHERE u.id=v.owner AND v.wref=".$vid; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - if(!empty($dbarray)) { - if(time()<$dbarray[0]) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - function updateUserField($ref, $field, $value, $switch) { - if(!$switch) { - $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where username = '$ref'"; - } else { - $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where id = '$ref'"; - } - return mysql_query($q, $this->connection); - } - - function getSitee($uid) { - $q = "SELECT id from " . TB_PREFIX . "users where sit1 = $uid or sit2 = $uid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getVilWref($x, $y) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where x = $x AND y = $y"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['id']; - } - - function removeMeSit($uid, $uid2) { - $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2"; - mysql_query($q, $this->connection); - $q2 = "UPDATE " . TB_PREFIX . "users set sit2 = 0 where id = $uid and sit2 = $uid2"; - mysql_query($q2, $this->connection); - } - - function getUserField($ref, $field, $mode) { - if(!$mode) { - $q = "SELECT $field FROM " . TB_PREFIX . "users where id = '$ref'"; - } else { - $q = "SELECT $field FROM " . TB_PREFIX . "users where username = '$ref'"; - } - $result = mysql_query($q, $this->connection) or die(mysql_error()); - if($result) { - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - }elseif($field=="username"){ - return "??"; - }else return 0; - } - - function getInvitedUser($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "users where invited = $uid order by regtime desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getVrefField($ref, $field){ - $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - } - - function getVrefCapital($ref){ - $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray; - } - - function getStarvation(){ - $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0 and owner != 3"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getActivateField($ref, $field, $mode) { - if(!$mode) { - $q = "SELECT $field FROM " . TB_PREFIX . "activate where id = '$ref'"; - } else { - $q = "SELECT $field FROM " . TB_PREFIX . "activate where username = '$ref'"; - } - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - } - - function login($username, $password) { - $q = "SELECT password,sessid FROM " . TB_PREFIX . "users where username = '$username'"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - if($dbarray['password'] == md5($password)) { - return true; - } else { - return false; - } - } - - function sitterLogin($username, $password) { - $q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - if($dbarray['sit1'] != 0) { - $q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED; - $result2 = mysql_query($q2, $this->connection); - $dbarray2 = $this->safe_mysql_fetch_array($result2); - } - if($dbarray['sit2'] != 0) { - $q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED; - $result3 = mysql_query($q3, $this->connection); - $dbarray3 = $this->safe_mysql_fetch_array($result3); - } - if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) { - if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - function setDeleting($uid, $mode) { - $time = time() + 72 * 3600; - if(!$mode) { - $q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)"; - } else { - $q = "DELETE FROM " . TB_PREFIX . "deleting where uid = $uid"; - } - mysql_query($q, $this->connection); - } - - function isDeleting($uid) { - $q = "SELECT timestamp from " . TB_PREFIX . "deleting where uid = $uid"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['timestamp']; - } - - function modifyGold($userid, $amt, $mode) { - if(!$mode) { - $q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid"; - } else { - $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid"; - } - return mysql_query($q, $this->connection); - } - - /***************************************** - Function to retrieve user array via Username or ID - Mode 0: Search by Username - Mode 1: Search by ID - References: Alliance ID - *****************************************/ - - function getUserArray($ref, $mode) { - if(!$mode) { - $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref'"; - } else { - $q = "SELECT * FROM " . TB_PREFIX . "users where id = $ref"; - } - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function activeModify($username, $mode) { - $time = time(); - if(!$mode) { - $q = "INSERT into " . TB_PREFIX . "active VALUES ('$username',$time)"; - } else { - $q = "DELETE FROM " . TB_PREFIX . "active where username = '$username'"; - } - return mysql_query($q, $this->connection); - } - - function addActiveUser($username, $time) { - $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; - if(mysql_query($q, $this->connection)) { - return true; - } else { - return false; - } - } - - function updateActiveUser($username, $time) { - $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; - $q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'"; - $exec1 = mysql_query($q, $this->connection); - $exec2 = mysql_query($q2, $this->connection); - if($exec1 && $exec2) { - return true; - } else { - return false; - } - } - - function submitProfile($uid, $gender, $location, $birthday, $des1, $des2) { - $q = "UPDATE " . TB_PREFIX . "users set gender = $gender, location = '$location', birthday = '$birthday', desc1 = '$des1', desc2 = '$des2' where id = $uid"; - return mysql_query($q, $this->connection); - } - - function gpack($uid, $gpack) { - $q = "UPDATE " . TB_PREFIX . "users set gpack = '$gpack' where id = $uid"; - return mysql_query($q, $this->connection); - } - - function GetOnline($uid) { - $q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['sit']; - } - - function UpdateOnline($mode, $name = "", $time = "", $uid = 0) { - global $session; - if($mode == "login") { - $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)"; - return mysql_query($q, $this->connection); - } else if($mode == "sitter") { - $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)"; - return mysql_query($q, $this->connection); - } else { - $q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . addslashes($session->username) . "'"; - return mysql_query($q, $this->connection); - } - } - - function generateBase($sector, $mode=1) { - $num_rows = 0; - $count_while = 0; - while (!$num_rows){ - if (!$mode) { - $gamesday=time()-COMMENCE; - if ($gamesday<3600*24*10 && $count_while==0) { //10 day - $wide1=1; - $wide2=20; - } elseif ($gamesday<3600*24*20 && $count_while==1) { //20 day - $wide1=20; - $wide2=40; - } elseif ($gamesday<3600*24*30 && $count_while==2) { //30 day - $wide1=40; - $wide2=80; - } else { // over 30 day - $wide1=80; - $wide2=WORLD_MAX; - } - } - else { - $wide1=1; - $wide2=WORLD_MAX; - } - switch($sector) { - case 1: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x- y+ - break; - case 2: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x+ y+ - break; - case 3: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x- y- - break; - case 4: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- - break; - } - $result = mysql_query($q, $this->connection); - $num_rows = mysql_num_rows($result); - $count_while++; - } - $result = $this->mysql_fetch_all($result); - $base = rand(0, ($num_rows-1)); - return $result[$base]['id']; - } - - function setFieldTaken($id) { - $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id"; - return mysql_query($q, $this->connection); - } - - function addVillage($wid, $uid, $username, $capital) { - $total = count($this->getVillagesID($uid)); - if($total >= 1) { - $vname = $username . "\'s village " . ($total + 1); - } else { - $vname = $username . "\'s village"; - } - $time = time(); - $q = "INSERT into " . TB_PREFIX . "vdata (wref, owner, name, capital, pop, cp, celebration, wood, clay, iron, maxstore, crop, maxcrop, lastupdate, created) values ('$wid', '$uid', '$vname', '$capital', 2, 1, 0, 750, 750, 750, ".STORAGE_BASE.", 750, ".STORAGE_BASE.", '$time', '$time')"; - return mysql_query($q, $this->connection) or die(mysql_error()); - } - - function addResourceFields($vid, $type) { - switch($type) { - case 1: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,4,4,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 2: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 3: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 4: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 5: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 6: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,3,4,4,4,4,4,4,4,4,4,4,4,2,4,4,1,15)"; - break; - case 7: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 8: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 9: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 10: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 11: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,1,1,3,1,4,4,3,3,2,2,3,1,4,4,2,4,4,1,15)"; - break; - case 12: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - } - return mysql_query($q, $this->connection); - } - function isVillageOases($wref) { - $q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - if($result){ - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['oasistype']; - }else return 0; - } - - public function VillageOasisCount($vref) { - $q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - return $row[0]; - } - - public function countOasisTroops($vref){ - //count oasis troops: $troops_o - $troops_o=0; - $o_unit2=mysql_query("select * from ".TB_PREFIX."units where `vref`='".$vref."'"); - $o_unit=$this->safe_mysql_fetch_array($o_unit2); - - for ($i=1;$i<51;$i++) - { - $troops_o+=$o_unit[$i]; - } - $troops_o+=$o_unit['hero']; - - $o_unit2=mysql_query("select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'"); - while ($o_unit=@$this->safe_mysql_fetch_array($o_unit2)) - { - for ($i=1;$i<51;$i++) - { - $troops_o+=$o_unit[$i]; - } - $troops_o+=$o_unit['hero']; - } - return $troops_o; - } - - public function canConquerOasis($vref,$wref) { - $AttackerFields = $this->getResourceLevel($vref); - for($i=19;$i<=38;$i++) { - if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; } - } - if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) { - $OasisInfo = $this->getOasisInfo($wref); - //fix by ronix - if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && intval($OasisInfo['loyalty']) < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))){ - $CoordsVillage = $this->getCoor($vref); - $CoordsOasis = $this->getCoor($wref); - $max = 2 * WORLD_MAX + 1; - $x1 = intval($CoordsOasis['x']); - $y1 = intval($CoordsOasis['y']); - $x2 = intval($CoordsVillage['x']); - $y2 = intval($CoordsVillage['y']); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - if ($distanceX<=3 && $distanceY<=3) { - return 1; //can - } else { - return 2; //can but not in 7x7 field - } - } else { - return 3; //loyalty >0 - } - } else { - return 0; //req level hero mansion - } - } - - public function conquerOasis($vref,$wref) { - $vinfo = $this->getVillage($vref); - $uid = $vinfo['owner']; - $q = "UPDATE `".TB_PREFIX."odata` SET conqured=$vref,loyalty=100,lastupdated=".time().",owner=$uid,name='Occupied Oasis' WHERE wref=$wref"; - return mysql_query($q, $this->connection); - } - - public function modifyOasisLoyalty($wref) { - if($this->isVillageOases($wref) != 0) { - $OasisInfo = $this->getOasisInfo($wref); - if($OasisInfo['conqured'] != 0) { - $LoyaltyAmendment = floor(100 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))); - $q = "UPDATE `".TB_PREFIX."odata` SET loyalty=loyalty-$LoyaltyAmendment, lastupdated=".time()." WHERE wref=$wref"; - $result=mysql_query($q, $this->connection); - return $OasisInfo['loyalty']-$LoyaltyAmendment; - } - } - } - - function populateOasis() { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result = mysql_query($q, $this->connection); - while($row = $this->safe_mysql_fetch_array($result)) { - $wid = $row['id']; - - $this->addUnits($wid); - - } - } - - function populateOasisUnits($wid, $high) { - $basearray = $this->getOasisInfo($wid); - if($high == 0){ - $max = rand(15,30); - }elseif($high == 1){ - $max = rand(50,70); - }elseif($high == 2){ - $max = rand(90,120); - } - $max2 = 0; - $rand = rand(0,3); - if($rand == 1){ - $max2 = 3; - } - //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less - switch($basearray['type']) { - case 1: - case 2: - //+25% lumber per hour - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u35 <= ".$max." OR u36 <= ".$max." OR u37 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 3: - //+25% lumber and +25% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 4: - case 5: - //+25% clay per hour - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 6: - //+25% clay and +25% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 7: - case 8: - //+25% iron per hour - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 9: - //+25% iron and +25% crop - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 10: - case 11: - //+25% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - case 12: - //+50% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max." OR u39 <= ".$max.")"; - $result = mysql_query($q, $this->connection); - break; - } - } - - function populateOasisUnits2() { - $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result2 = mysql_query($q2, $this->connection); - while($row = $this->safe_mysql_fetch_array($result2)) { - $wid = $row['id']; - switch($row['oasistype']) { - case 1: - case 2: - //+25% lumber oasis - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,10)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <= '10'"; - $result = mysql_query($q, $this->connection); - break; - case 3: - //+25% lumber and +25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,15)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <='10'"; - $result = mysql_query($q, $this->connection); - break; - case 4: - case 5: - //+25% clay oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <= '10'"; - $result = mysql_query($q, $this->connection); - break; - case 6: - //+25% clay and +25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <='10'"; - $result = mysql_query($q, $this->connection); - break; - case 7: - case 8: - //+25% iron oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <= '10'"; - $result = mysql_query($q, $this->connection); - break; - case 9: - //+25% iron and +25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <='10'"; - $result = mysql_query($q, $this->connection); - break; - case 10: - case 11: - //+25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(5,15)."', u33 = u33 + '".rand(5,10)."', u37 = u37 + '".rand(0,10)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u37 <='10' AND u39 <='10'"; - $result = mysql_query($q, $this->connection); - break; - case 12: - //+50% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u33 = u33 + '".rand(5,10)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u38 <='10'AND u39 <='10'"; - $result = mysql_query($q, $this->connection); - break; - } - } - } - - function removeOases($wref) { - $q = "UPDATE ".TB_PREFIX."odata SET conqured = 0, owner = 2, name = 'Unoccupied Oasis' WHERE wref = $wref"; - return mysql_query($q, $this->connection); - } - - - /*************************** - Function to retrieve type of village via ID - References: Village ID - ***************************/ - function getVillageType($wref) { - $q = "SELECT id, fieldtype FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['fieldtype']; - } - - - - /***************************************** - Function to retrieve if is ocuped via ID - References: Village ID - *****************************************/ - function getVillageState($wref) { - $q = "SELECT oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - if($dbarray['occupied'] != 0 || $dbarray['oasistype'] != 0) { - return true; - } else { - return false; - } - } - - function getProfileVillages($uid) { - $q = "SELECT capital,wref,name,pop,created from " . TB_PREFIX . "vdata where owner = $uid order by pop desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getProfileMedal($uid) { - $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "medal where userid = $uid and del = 0 order by id desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - - } - - function getProfileMedalAlly($uid) { - $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "allimedal where allyid = $uid and del = 0 order by id desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - - } - - function getVillageID($uid) { - $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE owner = $uid"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['wref']; - } - - - function getVillagesID($uid) { - $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; - $result = mysql_query($q, $this->connection); - $array = $this->mysql_fetch_all($result); - $newarray = array(); - for($i = 0; $i < count($array); $i++) { - array_push($newarray, $array[$i]['wref']); - } - return $newarray; - } - - function getVillagesID2($uid) { - $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; - $result = mysql_query($q, $this->connection); - $array = $this->mysql_fetch_all($result); - return $array; - } - - function getVillage($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getOasisV($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $vid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getMInfo($id) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "vdata ON " . TB_PREFIX . "vdata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getOMInfo($id) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "odata ON " . TB_PREFIX . "odata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getOasis($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = $vid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getOasisInfo($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $wid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function getVillageField($ref, $field) { - $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref"; - $result = mysql_query($q, $this->connection); - if($result){ - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - }elseif($field=="name"){ - return "??"; - }else return 0; - } - - function getOasisField($ref, $field) { - $q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - } - - function setVillageField($ref, $field, $value) { - $q = "UPDATE " . TB_PREFIX . "vdata set $field = '$value' where wref = $ref"; - return mysql_query($q, $this->connection); - } - - function setVillageLevel($ref, $field, $value) { - $q = "UPDATE " . TB_PREFIX . "fdata set " . $field . " = '" . $value . "' where vref = " . $ref . ""; - return mysql_query($q, $this->connection); - } - - function getResourceLevel($vid) { - $q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function getAdminLog() { - $q = "SELECT id,user,log,time from " . TB_PREFIX . "admin_log where id != 0 ORDER BY id ASC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getCoor($wref) { - if ($wref !=""){ - $q = "SELECT x,y FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - } - - function CheckForum($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CountCat($id) { - $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - return $row[0]; - } - - function LastTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' order by post_date"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function CheckLastTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CheckLastPost($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function LastPost($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function CountTopic($id) { - $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where owner = '$id'"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - - $qs = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where owner = '$id'"; - $results = mysql_query($qs, $this->connection); - $rows = mysql_fetch_row($results); - return $row[0] + $rows[0]; - } - - function CountPost($id) { - $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - return $row[0]; - } - - function ForumCat($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id' ORDER BY id"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function ForumCatEdit($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_cat where id = '$id'"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function ForumCatAlliance($id) { - $q = "SELECT alliance from " . TB_PREFIX . "forum_cat where id = $id"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['alliance']; - } - - function ForumCatName($id) { - $q = "SELECT forum_name from " . TB_PREFIX . "forum_cat where id = $id"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['forum_name']; - } - - function CheckCatTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CheckResultEdit($alli) { - $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CheckCloseTopic($id) { - $q = "SELECT close from " . TB_PREFIX . "forum_topic where id = '$id'"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['close']; - } - - function CheckEditRes($alli) { - $q = "SELECT result from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['result']; - } - - function CreatResultEdit($alli, $result) { - $q = "INSERT into " . TB_PREFIX . "forum_edit values (0,'$alli','$result')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function UpdateResultEdit($alli, $result) { - $date = time(); - $q = "UPDATE " . TB_PREFIX . "forum_edit set result = '$result' where alliance = '$alli'"; - return mysql_query($q, $this->connection); - } - - function getVillageType2($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['oasistype']; - } - - function getVillageType3($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray; - } - - function getFLData($id) { - $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function checkVilExist($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function checkOasisExist($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function UpdateEditTopic($id, $title, $cat) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set title = '$title', cat = '$cat' where id = $id"; - return mysql_query($q, $this->connection); - } - - function UpdateEditForum($id, $name, $des) { - $q = "UPDATE " . TB_PREFIX . "forum_cat set forum_name = '$name', forum_des = '$des' where id = $id"; - return mysql_query($q, $this->connection); - } - - function StickTopic($id, $mode) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set stick = '$mode' where id = '$id'"; - return mysql_query($q, $this->connection); - } - - function ForumCatTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '' ORDER BY post_date desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function ForumCatTopicStick($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '1' ORDER BY post_date desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function ShowTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where id = '$id'"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function ShowPost($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function ShowPostEdit($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where id = '$id'"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function CreatForum($owner, $alli, $name, $des, $area) { - $q = "INSERT into " . TB_PREFIX . "forum_cat values (0,'$owner','$alli','$name','$des','$area')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - /************************* - FORUM SUREY - *************************/ - - function createSurvey($topic, $title, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $ends) { - $q = "INSERT into " . TB_PREFIX . "forum_survey (topic,title,option1,option2,option3,option4,option5,option6,option7,option8,ends) values ('$topic','$title','$option1','$option2','$option3','$option4','$option5','$option6','$option7','$option8','$ends')"; - return mysql_query($q, $this->connection); - } - - function getSurvey($topic) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function checkSurvey($topic) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function Vote($topic, $num, $text) { - $q = "UPDATE " . TB_PREFIX . "forum_survey set vote".$num." = vote".$num." + 1, voted = '$text' where topic = ".$topic.""; - return mysql_query($q, $this->connection); - } - - function checkVote($topic, $uid) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysql_query($q, $this->connection); - $array = $this->safe_mysql_fetch_array($result); - $text = $array['voted']; - if(preg_match('/,'.$uid.',/',$text)) { - return true; - } else { - return false; - } - } - - function getVoteSum($topic) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysql_query($q, $this->connection); - $array = $this->safe_mysql_fetch_array($result); - $sum = 0; - for($i=1;$i<=8;$i++){ - $sum += $array['vote'.$i]; - } - return $sum; - } - - - /************************* - FORUM SUREY - *************************/ - - function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function UpdatePostDate($id) { - $date = time(); - $q = "UPDATE " . TB_PREFIX . "forum_topic set post_date = '$date' where id = $id"; - return mysql_query($q, $this->connection); - } - - function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; - return mysql_query($q, $this->connection); - } - - function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) { - $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; - return mysql_query($q, $this->connection); - } - - function LockTopic($id, $mode) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'"; - return mysql_query($q, $this->connection); - } - - function DeleteCat($id) { - $qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'"; - $q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $q2="SELECT id from ".TB_PREFIX."forum_topic where cat ='$id'"; - $result = mysql_query($q2, $this->connection); - if (!empty($result)) { - $array=$this->mysql_fetch_all($result); - foreach($array as $ss) { - $this->DeleteSurvey($ss['id']); - } - } - mysql_query($qs, $this->connection); - return mysql_query($q, $this->connection); - } - - function DeleteSurvey($id) { - $qs = "DELETE from " . TB_PREFIX . "forum_survey where topic = '$id'"; - return mysql_query($qs, $this->connection); - } - - function DeleteTopic($id) { - $qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'"; - // $q = "DELETE from ".TB_PREFIX."forum_post where topic = '$id'";// - return mysql_query($qs, $this->connection); // - // mysql_query($q,$this->connection); - } - - function DeletePost($id) { - $q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'"; - return mysql_query($q, $this->connection); - } - - function getAllianceName($id) { - $q = "SELECT tag from " . TB_PREFIX . "alidata where id = $id"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['tag']; - } - - function getAlliancePermission($ref, $field, $mode) { - if(!$mode) { - $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where uid = '$ref'"; - } else { - $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where username = '$ref'"; - } - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - } - - function getAlliance($id) { - $q = "SELECT * from " . TB_PREFIX . "alidata where id = $id"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function setAlliName($aid, $name, $tag) { - $q = "UPDATE " . TB_PREFIX . "alidata set name = '$name', tag = '$tag' where id = $aid"; - return mysql_query($q, $this->connection); - } - - function isAllianceOwner($id) { - $q = "SELECT * from " . TB_PREFIX . "alidata where leader = '$id'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function aExist($ref, $type) { - $q = "SELECT $type FROM " . TB_PREFIX . "alidata where $type = '$ref'"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - function modifyPoints($aid, $points, $amt) { - $q = "UPDATE " . TB_PREFIX . "users set $points = $points + $amt where id = $aid"; - return mysql_query($q, $this->connection); - } - - function modifyPointsAlly($aid, $points, $amt) { - $q = "UPDATE " . TB_PREFIX . "alidata set $points = $points + $amt where id = $aid"; - return mysql_query($q, $this->connection); - } - - /***************************************** - Function to create an alliance - References: - *****************************************/ - function createAlliance($tag, $name, $uid, $max) { - $q = "INSERT into " . TB_PREFIX . "alidata values (0,'$name','$tag',$uid,0,0,0,'','',$max,'','','','','','','','','')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function procAllyPop($aid) { - $ally = $this->getAlliance($aid); - $memberlist = $this->getAllMember($ally['id']); - $oldrank = 0; - foreach($memberlist as $member) { - $oldrank += $this->getVSumField($member['id'],"pop"); - } - if($ally['oldrank'] != $oldrank){ - if($ally['oldrank'] < $oldrank) { - $totalpoints = $oldrank - $ally['oldrank']; - $this->addclimberrankpopAlly($ally['id'], $totalpoints); - $this->updateoldrankAlly($ally['id'], $oldrank); - } else - if($ally['oldrank'] > $oldrank) { - $totalpoints = $ally['oldrank'] - $oldrank; - $this->removeclimberrankpopAlly($ally['id'], $totalpoints); - $this->updateoldrankAlly($ally['id'], $oldrank); - } - } - } - - /***************************************** - Function to insert an alliance new - References: - *****************************************/ - function insertAlliNotice($aid, $notice) { - $time = time(); - $q = "INSERT into " . TB_PREFIX . "ali_log values (0,'$aid','$notice',$time)"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - /***************************************** - Function to delete alliance if empty - References: - *****************************************/ - function deleteAlliance($aid) { - $result = mysql_query("SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"); - $num_rows = mysql_num_rows($result); - if($num_rows == 0) { - $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid"; - } - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - /***************************************** - Function to read all alliance news - References: - *****************************************/ - function readAlliNotice($aid) { - $q = "SELECT * from " . TB_PREFIX . "ali_log where aid = $aid ORDER BY date DESC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - /***************************************** - Function to create alliance permissions - References: ID, notice, description - *****************************************/ - function createAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) { - - $q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - /***************************************** - Function to update alliance permissions - References: - *****************************************/ - function deleteAlliPermissions($uid) { - $q = "DELETE from " . TB_PREFIX . "ali_permission where uid = '$uid'"; - return mysql_query($q, $this->connection); - } - /***************************************** - Function to update alliance permissions - References: - *****************************************/ - function updateAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7) { - - $q = "UPDATE " . TB_PREFIX . "ali_permission SET rank = '$rank', opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' where uid = $uid && alliance =$aid"; - return mysql_query($q, $this->connection); - } - - /***************************************** - Function to read alliance permissions - References: ID, notice, description - *****************************************/ - function getAlliPermissions($uid, $aid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_permission where uid = $uid && alliance = $aid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - /***************************************** - Function to update an alliance description and notice - References: ID, notice, description - *****************************************/ - function submitAlliProfile($aid, $notice, $desc) { - - $q = "UPDATE " . TB_PREFIX . "alidata SET `notice` = '$notice', `desc` = '$desc' where id = $aid"; - return mysql_query($q, $this->connection); - } - - function diplomacyInviteAdd($alli1, $alli2, $type) { - $q = "INSERT INTO " . TB_PREFIX . "diplomacy (alli1,alli2,type,accepted) VALUES ($alli1,$alli2," . (int)intval($type) . ",0)"; - return mysql_query($q, $this->connection); - } - - function diplomacyOwnOffers($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getAllianceID($name) { - $q = "SELECT id FROM " . TB_PREFIX . "alidata WHERE tag ='" . $this->RemoveXSS($name) . "'"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['id']; - } - - function diplomacyCancelOffer($id) { - $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id"; - return mysql_query($q, $this->connection); - } - - function diplomacyInviteAccept($id, $session_alliance) { - $q = "UPDATE " . TB_PREFIX . "diplomacy SET accepted = 1 WHERE id = $id AND alli2 = $session_alliance"; - return mysql_query($q, $this->connection); - } - - function diplomacyInviteDenied($id, $session_alliance) { - $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance"; - return mysql_query($q, $this->connection); - } - - function diplomacyInviteCheck($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function diplomacyInviteCheck2($ally1, $ally2) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getAllianceDipProfile($aid, $type){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'"; - $array = $this->query_return($q); - foreach($array as $row){ - if($row['alli1'] == $aid){ - $alliance = $this->getAlliance($row['alli2']); - }elseif($row['alli2'] == $aid){ - $alliance = $this->getAlliance($row['alli1']); - } - $text .= ""; - $text .= "".$alliance['tag']."
"; - } - if(strlen($text) == 0){ - $text = "-
"; - } - return $text; - } - - function getAllianceWar($aid){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; - $array = $this->query_return($q); - foreach($array as $row){ - if($row['alli1'] == $aid){ - $alliance = $this->getAlliance($row['alli2']); - }elseif($row['alli2'] == $aid){ - $alliance = $this->getAlliance($row['alli1']); - } - $text .= ""; - $text .= "".$alliance['tag']."
"; - } - if(strlen($text) == 0){ - $text = "-
"; - } - return $text; - } - - function getAllianceAlly($aid, $type){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE (alli1 = '$aid' or alli2 = '$aid') AND (type = '$type' AND accepted = '1')"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getAllianceWar2($aid){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function diplomacyExistingRelationships($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function diplomacyExistingRelationships2($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 1"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function diplomacyCancelExistingRelationship($id, $session_alliance) { - $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance"; - return mysql_query($q, $this->connection); - } - - function checkDiplomacyInviteAccept($aid, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1"; - $result = mysql_query($q, $this->connection); - if($type == 3){ - return true; - }else{ - if(mysql_num_rows($result) < 4) { - return true; - } else { - return false; - } - } - } - - function setAlliForumLink($aid, $link) { - $q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid"; - return mysql_query($q, $this->connection); - } - - function getUserAlliance($id) { - $q = "SELECT " . TB_PREFIX . "alidata.tag from " . TB_PREFIX . "users join " . TB_PREFIX . "alidata where " . TB_PREFIX . "users.alliance = " . TB_PREFIX . "alidata.id and " . TB_PREFIX . "users.id = $id"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - if($dbarray['tag'] == "") { - return "-"; - } else { - return $dbarray['tag']; - } - } - - /////////////ADDED BY BRAINIAC - THANK YOU - - function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) { - $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "vdata where wref = ".$vid.""; - $result = mysql_query($q, $this->connection); - $checkres= $this->mysql_fetch_all($result); - if(!$mode){ - $nwood=$checkres[0]['wood']-$wood; - $nclay=$checkres[0]['clay']-$clay; - $niron=$checkres[0]['iron']-$iron; - $ncrop=$checkres[0]['crop']-$crop; - if($nwood<0 or $nclay<0 or $niron<0 or $ncrop<0){$shit=true;} - $dwood=($nwood<0)?0:$nwood; - $dclay=($nclay<0)?0:$nclay; - $diron=($niron<0)?0:$niron; - $dcrop=($ncrop<0)?0:$ncrop; - }else{ - $nwood=$checkres[0]['wood']+$wood; - $nclay=$checkres[0]['clay']+$clay; - $niron=$checkres[0]['iron']+$iron; - $ncrop=$checkres[0]['crop']+$crop; - $dwood=($nwood>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nwood; - $dclay=($nclay>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nclay; - $diron=($niron>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$niron; - $dcrop=($ncrop>$checkres[0]['maxcrop'])?$checkres[0]['maxcrop']:$ncrop; - } - if(!$shit){ - $q = "UPDATE " . TB_PREFIX . "vdata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; - return mysql_query($q, $this->connection); }else{return false;} - } - - function modifyOasisResource($vid, $wood, $clay, $iron, $crop, $mode) { - $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "odata where wref = ".$vid.""; - $result = mysql_query($q, $this->connection); - $checkres= $this->mysql_fetch_all($result); - if(!$mode){ - $nwood=$checkres[0]['wood']-$wood; - $nclay=$checkres[0]['clay']-$clay; - $niron=$checkres[0]['iron']-$iron; - $ncrop=$checkres[0]['crop']-$crop; - if($nwood<0 or $nclay<0 or $niron<0 or $ncrop<0){$shit=true;} - $dwood=($nwood<0)?0:$nwood; - $dclay=($nclay<0)?0:$nclay; - $diron=($niron<0)?0:$niron; - $dcrop=($ncrop<0)?0:$ncrop; - }else{ - $nwood=$checkres[0]['wood']+$wood; - $nclay=$checkres[0]['clay']+$clay; - $niron=$checkres[0]['iron']+$iron; - $ncrop=$checkres[0]['crop']+$crop; - $dwood=($nwood>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nwood; - $dclay=($nclay>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nclay; - $diron=($niron>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$niron; - $dcrop=($ncrop>$checkres[0]['maxcrop'])?$checkres[0]['maxcrop']:$ncrop; - } - if(!$shit){ - $q = "UPDATE " . TB_PREFIX . "odata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; - return mysql_query($q, $this->connection); }else{return false;} - } - - function getFieldLevel($vid, $field) { - $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_result($result, 0); - } - - function getFieldType($vid, $field) { - $q = "SELECT f" . $field . "t from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_result($result, 0); - } - - function getFieldDistance($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner > 4 and wref != $wid"; - $array = $this->query_return($q); - $coor = $this->getCoor($wid); - $x1 = intval($coor['x']); - $y1 = intval($coor['y']); - $prevdist = 0; - $q2 = "SELECT * FROM " . TB_PREFIX . "vdata where owner = 4"; - $array2 = $this->safe_mysql_fetch_array(mysql_query($q2)); - $vill = $array2['wref']; - if(mysql_num_rows(mysql_query($q)) > 0){ - foreach($array as $village){ - $coor2 = $this->getCoor($village['wref']); - $max = 2 * WORLD_MAX + 1; - $x2 = intval($coor2['x']); - $y2 = intval($coor2['y']); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - if($dist < $prevdist or $prevdist == 0){ - $prevdist = $dist; - $vill = $village['wref']; - } - } - } - return $vill; - } - - function getVSumField($uid, $field) { - if($field != "cp"){ - $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid"; - }else{ - $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid and natar = 0"; - } - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - return $row[0]; - } - - function updateVillage($vid) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid"; - return mysql_query($q, $this->connection); - } - - - function updateOasis($vid) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid"; - return mysql_query($q, $this->connection); - } - - function updateOasis2($vid, $time) { - $time = time(); - $time2 = NATURE_REGTIME; - $q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time + $time2 where wref = $vid"; - return mysql_query($q, $this->connection); - } - - function setVillageName($vid, $name) { - if(!empty($name)) - { - $q = "UPDATE " . TB_PREFIX . "vdata set name = '$name' where wref = $vid"; - return mysql_query($q, $this->connection); - } - } - - function modifyPop($vid, $pop, $mode) { - if(!$mode) { - $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop + $pop where wref = $vid"; - } else { - $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop - $pop where wref = $vid"; - } - return mysql_query($q, $this->connection); - } - - function addCP($ref, $cp) { - $q = "UPDATE " . TB_PREFIX . "vdata set cp = cp + $cp where wref = $ref"; - return mysql_query($q, $this->connection); - } - - function addCel($ref, $cel, $type) { - $q = "UPDATE " . TB_PREFIX . "vdata set celebration = $cel, type= $type where wref = $ref"; - return mysql_query($q, $this->connection); - } - function getCel() { - $time = time(); - $q = "SELECT * FROM " . TB_PREFIX . "vdata where celebration < $time AND celebration != 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function clearCel($ref) { - $q = "UPDATE " . TB_PREFIX . "vdata set celebration = 0, type = 0 where wref = $ref"; - return mysql_query($q, $this->connection); - } - function setCelCp($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp where id = $user"; - return mysql_query($q, $this->connection); - } - - function clearExpansionSlot($id) { - for($i = 1; $i <= 3; $i++) { - $q = "UPDATE " . TB_PREFIX . "vdata SET exp" . $i . "=0 WHERE exp" . $i . "=" . $id; - mysql_query($q, $this->connection); - } - } - - function getInvitation($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getInvitation2($uid, $aid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid and alliance = $aid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getAliInvitations($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where alliance = $aid && accept = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function sendInvitation($uid, $alli, $sender) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "ali_invite values (0,$uid,$alli,$sender,$time,0)"; - return mysql_query($q, $this->connection) or die(mysql_error()); - } - - function removeInvitation($id) { - $q = "DELETE FROM " . TB_PREFIX . "ali_invite where id = $id"; - return mysql_query($q, $this->connection); - } - - function sendMessage($client, $owner, $topic, $message, $send, $alliance, $player, $coor, $report) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "mdata values (0,$client,$owner,'$topic',\"$message\",0,0,$send,$time,0,0,$alliance,$player,$coor,$report)"; - return mysql_query($q, $this->connection); - } - - function setArchived($id) { - $q = "UPDATE " . TB_PREFIX . "mdata set archived = 1 where id = $id"; - return mysql_query($q, $this->connection); - } - - function setNorm($id) { - $q = "UPDATE " . TB_PREFIX . "mdata set archived = 0 where id = $id"; - return mysql_query($q, $this->connection); - } - - /*************************** - Function to get messages - Mode 1: Get inbox - Mode 2: Get sent - Mode 3: Get message - Mode 4: Set viewed - Mode 5: Remove message - Mode 6: Retrieve archive - References: User ID/Message ID, Mode - ***************************/ - function getMessage($id, $mode) { - global $session; - switch($mode) { - case 1: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 ORDER BY time DESC"; - break; - case 2: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id ORDER BY time DESC"; - break; - case 3: - $q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id"; - break; - case 4: - $q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target = $session->uid"; - break; - case 5: - $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id = $id"; - break; - case 6: - $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1"; - break; - case 7: - $q = "UPDATE " . TB_PREFIX . "mdata set delowner = 1 where id = $id"; - break; - case 8: - $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where id = $id"; - break; - case 9: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC"; - break; - case 10: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id and delowner = 0 ORDER BY time DESC"; - break; - case 11: - $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1 and deltarget = 0"; - break; - } - if($mode <= 3 || $mode == 6 || $mode > 8) { - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } else { - return mysql_query($q, $this->connection); - } - } - - function unarchiveNotice($id) { - $q = "UPDATE " . TB_PREFIX . "ndata set ntype = archive, archive = 0 where id = $id"; - return mysql_query($q, $this->connection); - } - - function archiveNotice($id) { - $q = "update " . TB_PREFIX . "ndata set archive = ntype, ntype = 9 where id = $id"; - return mysql_query($q, $this->connection); - } - - function removeNotice($id) { - $q = "UPDATE " . TB_PREFIX . "ndata set del = 1,viewed = 1 where id = $id"; - return mysql_query($q, $this->connection); - } - - function noticeViewed($id) { - $q = "UPDATE " . TB_PREFIX . "ndata set viewed = 1 where id = $id"; - return mysql_query($q, $this->connection); - } - - function addNotice($uid, $toWref, $ally, $type, $topic, $data, $time = 0) { - if($time == 0) { - $time = time(); - } - $q = "INSERT INTO " . TB_PREFIX . "ndata (id, uid, toWref, ally, topic, ntype, data, time, viewed) values (0,'$uid','$toWref','$ally','$topic',$type,'$data',$time,0)"; - return mysql_query($q, $this->connection) or die(mysql_error()); - } - - function getNotice($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getNotice2($id, $field) { - $q = "SELECT ".$field." FROM " . TB_PREFIX . "ndata where `id` = '$id'"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - } - - function getNotice3($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getNotice4($id) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where id = $id ORDER BY time DESC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - function getUnViewNotice($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid AND viewed=0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) { - $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid.""; - mysql_query($x, $this->connection); - $timeleft = time()+604800; - $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)"; - return mysql_query($q, $this->connection); - } - - function getTradeRoute($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getTradeRoute2($id) { - $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray; - } - - function getTradeRouteUid($id) { - $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['uid']; - } - - function editTradeRoute($id,$column,$value,$mode) { - if(!$mode){ - $q = "UPDATE " . TB_PREFIX . "route set $column = $value where id = $id"; - }else{ - $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id"; - } - return mysql_query($q, $this->connection); - } - - function deleteTradeRoute($id) { - $q = "DELETE FROM " . TB_PREFIX . "route where id = $id"; - return mysql_query($q, $this->connection); - } - - function addBuilding($wid, $field, $type, $loop, $time, $master, $level) { - $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid; - mysql_query($x, $this->connection) or die(mysql_error()); - $q = "INSERT into " . TB_PREFIX . "bdata values (0,$wid,$field,$type,$loop,$time,$master,$level)"; - return mysql_query($q, $this->connection); - } - - function removeBuilding($d) { - global $building, $village; - $jobLoopconID = -1; - $SameBuildCount = 0; - $jobs = $building->buildArray; - for($i = 0; $i < sizeof($jobs); $i++) { - if($jobs[$i]['id'] == $d) { - $jobDeleted = $i; - } - if($jobs[$i]['loopcon'] == 1) { - $jobLoopconID = $i; - } - if($jobs[$i]['master'] == 1) { - $jobMaster = $i; - } - } - if(count($jobs) > 1 && ($jobs[0]['field'] == $jobs[1]['field'])) { - $SameBuildCount = 1; - } - if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[2]['field'])) { - $SameBuildCount = 2; - } - if(count($jobs) > 2 && ($jobs[1]['field'] == $jobs[2]['field'])) { - $SameBuildCount = 3; - } - if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 8; - } - if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 9; - } - if(count($jobs) > 3 && ($jobs[2]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 10; - } - if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[2]['field'])) { - $SameBuildCount = 4; - } - if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 5; - } - if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 6; - } - if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 7; - } - if($SameBuildCount > 0) { - if($SameBuildCount > 3){ - if($SameBuildCount == 4 or $SameBuildCount == 5){ - if($jobDeleted == 0){ - $uprequire = $building->resourceRequired($jobs[1]['field'],$jobs[1]['type'],1); - $time = $uprequire['time']; - $timestamp = $time+time(); - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[1]['id'].""; - mysql_query($q, $this->connection); - } - }else if($SameBuildCount == 6){ - if($jobDeleted == 0){ - $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1); - $time = $uprequire['time']; - $timestamp = $time+time(); - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; - mysql_query($q, $this->connection); - } - }else if($SameBuildCount == 7){ - if($jobDeleted == 1){ - $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1); - $time = $uprequire['time']; - $timestamp = $time+time(); - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; - mysql_query($q, $this->connection); - } - } - if($SameBuildCount < 8){ - $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],2); - $time1 = $uprequire1['time']; - $timestamp1 = $time1; - $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; - mysql_query($q1, $this->connection); - }else{ - $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],1); - $time1 = $uprequire1['time']; - $timestamp1 = $time1; - $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; - mysql_query($q1, $this->connection); - } - }else if($d == $jobs[floor($SameBuildCount / 3)]['id'] || $d == $jobs[floor($SameBuildCount / 2) + 1]['id']) { - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=" . $jobs[floor($SameBuildCount / 3)]['timestamp'] . " WHERE master = 0 AND id > ".$d." and (ID=" . $jobs[floor($SameBuildCount / 3)]['id'] . " OR ID=" . $jobs[floor($SameBuildCount / 2) + 1]['id'] . ")"; - mysql_query($q, $this->connection); - } - } else { - if($jobs[$jobDeleted]['field'] >= 19) { - $x = "SELECT f" . $jobs[$jobDeleted]['field'] . " FROM " . TB_PREFIX . "fdata WHERE vref=" . $jobs[$jobDeleted]['wid']; - $result = mysql_query($x, $this->connection) or die(mysql_error()); - $fieldlevel = mysql_fetch_row($result); - if($fieldlevel[0] == 0) { - if ($village->natar==1 && $jobs[$jobDeleted]['field']==99) { //fix by ronix - }else{ - $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $jobs[$jobDeleted]['field'] . "t=0 WHERE vref=" . $jobs[$jobDeleted]['wid']; - mysql_query($x, $this->connection) or die(mysql_error()); - } - } - } - if(($jobLoopconID >= 0) && ($jobs[$jobDeleted]['loopcon'] != 1)) { - if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) { - $uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']); - $x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0"; - mysql_query($x, $this->connection) or die(mysql_error()); - } - } - } - $q = "DELETE FROM " . TB_PREFIX . "bdata where id = $d"; - return mysql_query($q, $this->connection); - } - - function addDemolition($wid, $field) { - global $building, $village; - $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid"; - mysql_query($q, $this->connection); - $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0); - $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($this->getFieldLevel($wid,$field)-1).",".(time()+floor($uprequire['time']/2)).")"; - return mysql_query($q, $this->connection); - } - - - function getDemolition($wid = 0) { - if($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; - } else { - $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE timetofinish<=" . time(); - } - $result = mysql_query($q, $this->connection); - if(!empty($result)) { - return $this->safe_mysql_fetch_all($result); - } else { - return NULL; - } - } - - function finishDemolition($wid) { - $q = "UPDATE " . TB_PREFIX . "demolition SET timetofinish=" . time() . " WHERE vref=" . $wid; - $result= mysql_query($q, $this->connection); - return mysql_affected_rows(); - } - - function delDemolition($wid) { - $q = "DELETE FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; - return mysql_query($q, $this->connection); - } - - function getJobs($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function FinishWoodcutter($wid) { - $time = time()-1; - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by master,timestamp ASC"; - $result = mysql_query($q); - $dbarray = $this->safe_mysql_fetch_array($result); - $q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'"; - $this->query($q); - $tribe = $this->getUserField($this->getVillageField($wid, "owner"), "tribe", 0); - if($tribe == 1){ - $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 and field >= 19 order by master,timestamp ASC"; - }else{ - $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 order by master,timestamp ASC"; - } - $result2 = mysql_query($q2); - if(mysql_num_rows($result2) > 0){ - $dbarray2 = $this->safe_mysql_fetch_array($result2); - $wc_time = $dbarray['timestamp']; - $q2 = "UPDATE ".TB_PREFIX."bdata SET timestamp = timestamp - $wc_time WHERE id = '".$dbarray2['id']."'"; - $this->query($q2); - } - } - - function getMasterJobs($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getMasterJobsByField($wid,$field) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 1 order by master,timestamp ASC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getBuildingByField($wid,$field) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getBuildingByField2($wid,$field) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; - $result = mysql_query($q, $this->connection); - return mysql_num_rows($result); - } - - function getBuildingByType($wid,$type) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getBuildingByType2($wid,$type) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; - $result = mysql_query($q, $this->connection); - return mysql_num_rows($result); - } - - function getDorf1Building($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field < 19 and master = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getDorf2Building($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field > 18 and master = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function updateBuildingWithMaster($id, $time,$loop) { - $q = "UPDATE " . TB_PREFIX . "bdata SET master = 0, timestamp = ".$time.",loopcon = ".$loop." WHERE id = ".$id.""; - return mysql_query($q, $this->connection); - } - - function getVillageByName($name) { - $q = "SELECT wref FROM " . TB_PREFIX . "vdata where name = '$name' limit 1"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['wref']; - } - - /*************************** - Function to set accept flag on market - References: id - ***************************/ - function setMarketAcc($id) { - $q = "UPDATE " . TB_PREFIX . "market set accept = 1 where id = $id"; - return mysql_query($q, $this->connection); - } - - /*************************** - Function to send resource to other village - Mode 0: Send - Mode 1: Cancel - References: Wood/ID, Clay, Iron, Crop, Mode - ***************************/ - function sendResource($ref, $clay, $iron, $crop, $merchant, $mode) { - if(!$mode) { - $q = "INSERT INTO " . TB_PREFIX . "send values (0,$ref,$clay,$iron,$crop,$merchant)"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } else { - $q = "DELETE FROM " . TB_PREFIX . "send where id = $ref"; - return mysql_query($q, $this->connection); - } - } - - /*************************** - Function to get resources back if you delete offer - References: VillageRef (vref) - Made by: Dzoki - ***************************/ - - function getResourcesBack($vref, $gtype, $gamt) { - //Xtype (1) = wood, (2) = clay, (3) = iron, (4) = crop - if($gtype == 1) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + '$gamt' WHERE wref = $vref"; - return mysql_query($q, $this->connection); - } else - if($gtype == 2) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` + '$gamt' WHERE wref = $vref"; - return mysql_query($q, $this->connection); - } else - if($gtype == 3) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` + '$gamt' WHERE wref = $vref"; - return mysql_query($q, $this->connection); - } else - if($gtype == 4) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` + '$gamt' WHERE wref = $vref"; - return mysql_query($q, $this->connection); - } - } - - /*************************** - Function to get info about offered resources - References: VillageRef (vref) - Made by: Dzoki - ***************************/ - - function getMarketField($vref, $field) { - $q = "SELECT $field FROM " . TB_PREFIX . "market where vref = '$vref'"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$field]; - } - - function removeAcceptedOffer($id) { - $q = "DELETE FROM " . TB_PREFIX . "market where id = $id"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - /*************************** - Function to add market offer - Mode 0: Add - Mode 1: Cancel - References: Village, Give, Amt, Want, Amt, Time, Alliance, Mode - ***************************/ - function addMarket($vid, $gtype, $gamt, $wtype, $wamt, $time, $alliance, $merchant, $mode) { - if(!$mode) { - $q = "INSERT INTO " . TB_PREFIX . "market values (0,$vid,$gtype,$gamt,$wtype,$wamt,0,$time,$alliance,$merchant)"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } else { - $q = "DELETE FROM " . TB_PREFIX . "market where id = $gtype and vref = $vid"; - return mysql_query($q, $this->connection); - } - } - - /*************************** - Function to get market offer - References: Village, Mode - ***************************/ - function getMarket($vid, $mode) { - $alliance = $this->getUserField($this->getVillageField($vid, "owner"), "alliance", 0); - if(!$mode) { - $q = "SELECT * FROM " . TB_PREFIX . "market where vref = $vid and accept = 0"; - } else { - $q = "SELECT * FROM " . TB_PREFIX . "market where vref != $vid and alliance = $alliance or vref != $vid and alliance = 0 and accept = 0"; - } - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - /*************************** - Function to get market offer - References: ID - ***************************/ - function getMarketInfo($id) { - $q = "SELECT * FROM " . TB_PREFIX . "market where id = $id"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function setMovementProc($moveid) { - $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where moveid = $moveid"; - return mysql_query($q, $this->connection); - } - - /*************************** - Function to retrieve used merchant - References: Village - ***************************/ - function totalMerchantUsed($vid) { - $time = time(); - $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = $vid and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = $vid and proc = 0"; - $result2 = mysql_query($q2, $this->connection); - $row2 = mysql_fetch_row($result2); - $q3 = "SELECT sum(merchant) from " . TB_PREFIX . "market where vref = $vid and accept = 0"; - $result3 = mysql_query($q3, $this->connection); - $row3 = mysql_fetch_row($result3); - return $row[0] + $row2[0] + $row3[0]; - } - - function getMovement($type, $village, $mode) { - $time = time(); - if(!$mode) { - $where = "from"; - } else { - $where = "to"; - } - switch($type) { - case 0: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC"; - break; - case 1: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC"; - break; - case 2: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC"; - break; - case 3: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; - break; - case 4: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; - break; - case 5: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 5 and proc = 0 ORDER BY endtime ASC"; - break; - case 6: - $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = $village and " . TB_PREFIX . "movement.to = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; - //$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; - break; - case 7: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC"; - break; - case 8: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; - break; - case 34: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; - break; - } - $result = mysql_query($q, $this->connection); - $array = $this->mysql_fetch_all($result); - return $array; - } - - function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) { - $q = "INSERT INTO " . TB_PREFIX . "a2b (ckey,time_check,to_vid,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,type) VALUES ('$ckey', '$timestamp', '$to', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10', '$t11', '$type')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function getA2b($ckey, $check) { - $q = "SELECT * from " . TB_PREFIX . "a2b where ckey = '" . $ckey . "' AND time_check = '" . $check . "'"; - $result = mysql_query($q, $this->connection); - if($result) { - return mysql_fetch_assoc($result); - } else { - return false; - } - } - - function addMovement($type, $from, $to, $ref, $time, $endtime, $send = 1, $wood = 0, $clay = 0, $iron = 0, $crop = 0, $ref2 = 0) { - $q = "INSERT INTO " . TB_PREFIX . "movement values (0,$type,$from,$to,$ref,$ref2,$time,$endtime,0,$send,$wood,$clay,$iron,$crop)"; - return mysql_query($q, $this->connection); - } - - function addAttack($vid, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type, $ctar1, $ctar2, $spy,$b1=0,$b2=0,$b3=0,$b4=0,$b5=0,$b6=0,$b7=0,$b8=0) { - $q = "INSERT INTO " . TB_PREFIX . "attacks values (0,$vid,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$type,$ctar1,$ctar2,$spy,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8)"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function modifyAttack($aid, $unit, $amt) { - $unit = 't' . $unit; - $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit - $amt where id = $aid"; - return mysql_query($q, $this->connection); - } - - function modifyAttack2($aid, $unit, $amt) { - $unit = 't' . $unit; - $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit + $amt where id = $aid"; - return mysql_query($q, $this->connection); - } - - function modifyAttack3($aid, $units) { - $q = "UPDATE ".TB_PREFIX."attacks set $units WHERE id = $aid"; - return mysql_query($q, $this->connection); - } - - function getRanking() { - $q = "SELECT id,username,alliance,ap,apall,dp,dpall,access FROM " . TB_PREFIX . "users WHERE tribe<=3 AND access<" . (INCLUDE_ADMIN ? "10" : "8"); - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getVRanking() { - $q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe<=3 AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8"); - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getARanking() { - $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getUserByTribe($tribe){ - $q = "SELECT * FROM " . TB_PREFIX . "users where tribe = $tribe"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getUserByAlliance($aid){ - $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getHeroRanking() { - $q = "SELECT * FROM " . TB_PREFIX . "hero WHERE dead = 0"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getAllMember($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getAllMember2($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function addUnits($vid) { - $q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)"; - return mysql_query($q, $this->connection); - } - - function getUnit($vid) { - $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; - $result = mysql_query($q, $this->connection); - if (!empty($result)) { - return mysql_fetch_assoc($result); - } else { - return NULL; - } - } - - function getUnitsNumber($vid) { - $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; - $result = mysql_query($q, $this->connection); - $dbarray = mysql_fetch_assoc($result); - $totalunits = 0; - $movingunits = $this->getVillageMovement($vid); - for($i=1;$i<=50;$i++){ - $totalunits += $dbarray['u'.$i]; - } - $totalunits += $dbarray['hero']; - $movingunits = $this->getVillageMovement($vid); - $reinforcingunits = $this->getEnforceArray($vid,1); - $owner = $this->getVillageField($vid,"owner"); - $ownertribe = $this->getUserField($owner,"tribe",0); - $start = ($ownertribe-1)*10+1; - $end = ($ownertribe*10); - for($i=$start;$i<=$end;$i++){ - $totalunits += $movingunits['u'.$i]; - $totalunits += $reinforcingunits['u'.$i]; - } - $totalunits += $movingunits['hero']; - $totalunits += $reinforcingunits['hero']; - return $totalunits; - } - - function getHero($uid=0,$all=0) { - if ($all) { - $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid=$uid"; - } elseif (!$uid) { - $q = "SELECT * FROM ".TB_PREFIX."hero"; - } else { - $q = "SELECT * FROM ".TB_PREFIX."hero WHERE dead=0 AND uid=$uid LIMIT 1"; - } - $result = mysql_query($q, $this->connection); - if (!empty($result)) { - return $this->safe_mysql_fetch_all($result); - } else { - return NULL; - } - } - - function getHeroField($uid,$field){ - $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid"; - $result = mysql_query($q,$this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function modifyHero($column,$value,$heroid,$mode=0) { - if(!$mode) { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE heroid = $heroid"; - } elseif($mode=1) { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE heroid = $heroid"; - } else { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE heroid = $heroid"; - } - return mysql_query($q, $this->connection); - } - - function modifyHeroXp($column,$value,$heroid) { - $q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid"; - return mysql_query($q, $this->connection); - } - - function addTech($vid) { - $q = "INSERT into " . TB_PREFIX . "tdata (vref) values ($vid)"; - return mysql_query($q, $this->connection); - } - - function addABTech($vid) { - $q = "INSERT into " . TB_PREFIX . "abdata (vref) values ($vid)"; - return mysql_query($q, $this->connection); - } - - function getABTech($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "abdata where vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function addResearch($vid, $tech, $time) { - $q = "INSERT into " . TB_PREFIX . "research values (0,$vid,'$tech',$time)"; - return mysql_query($q, $this->connection); - } - - function getResearching($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "research where vref = $vid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function checkIfResearched($vref, $unit) { - $q = "SELECT $unit FROM " . TB_PREFIX . "tdata WHERE vref = $vref"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray[$unit]; - } - - function getTech($vid) { - $q = "SELECT * from " . TB_PREFIX . "tdata where vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function getTraining($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "training where vref = $vid ORDER BY id"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function trainUnit($vid, $unit, $amt, $pop, $each, $time, $mode) { - global $village, $building, $session, $technology; - - if(!$mode) { - $barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44); - // fix by brainiac - THANK YOU - $greatbarracks = array(61,62,63,71,72,73,74,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104); - $stables = array(4,5,6,15,16,23,24,25,26,45,46); - $greatstables = array(64,65,66,75,76,83,84,85,86,105,106); - $workshop = array(7,8,17,18,27,28,47,48); - $greatworkshop = array(67,68,77,78,87,88,107,108); - $residence = array(9,10,19,20,29,30,49,50); - $trapper = array(99); - - if(in_array($unit, $barracks)) { - $queued = $technology->getTrainingList(1); - } elseif(in_array($unit, $stables)) { - $queued = $technology->getTrainingList(2); - } elseif(in_array($unit, $workshop)) { - $queued = $technology->getTrainingList(3); - } elseif(in_array($unit, $residence)) { - $queued = $technology->getTrainingList(4); - } elseif(in_array($unit, $greatstables)) { - $queued = $technology->getTrainingList(6); - } elseif(in_array($unit, $greatbarracks)) { - $queued = $technology->getTrainingList(5); - } elseif(in_array($unit, $greatworkshop)) { - $queued = $technology->getTrainingList(7); - } elseif(in_array($unit, $trapper)) { - $queued = $technology->getTrainingList(8); - } - $now = time(); - - $uid = $this->getVillageField($vid, "owner"); - $artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0)); - $artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1)); - $artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0)); - if($artefact > 0){ - $time = $now+round(($time-$now)/2); - $each /= 2; - $each = round($each); - }else if($artefact1 > 0){ - $time = $now+round(($time-$now)/2); - $each /= 2; - $each = round($each); - }else if($artefact2 > 0){ - $time = $now+round(($time-$now)/4*3); - $each /= 4; - $each = round($each); - $each *= 3; - $each = round($each); - } - $foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid); - if(count($foolartefact) > 0){ - foreach($foolartefact as $arte){ - if($arte['bad_effect'] == 1){ - $each *= $arte['effect2']; - }else{ - $each /= $arte['effect2']; - $each = round($each); - } - } - } - if($each == 0){ $each = 1; } - $time2 = $now+$each; - if(count($queued) > 0) { - $time += $queued[count($queued) - 1]['timestamp'] - $now; - $time2 += $queued[count($queued) - 1]['timestamp'] - $now; - } - // TROOPS MAKE SUM IN BARAKS , ETC - //if($queued[count($queued) - 1]['unit'] == $unit){ - //$time = $amt*$queued[count($queued) - 1]['eachtime']; - //$q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id'].""; - //}else{ - $q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)"; - //} - } else { - $q = "DELETE FROM " . TB_PREFIX . "training where id = $vid"; - } - return mysql_query($q, $this->connection); - } - - function updateTraining($id, $trained, $each) { - $q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id"; - return mysql_query($q, $this->connection); - } - - function modifyUnit($vref, $array_unit, $array_amt, $array_mode){ - $i = -1; - $units=''; - $number = count($array_unit); - foreach($array_unit as $unit){ - if($unit == 230){$unit = 30;} - if($unit == 231){$unit = 31;} - if($unit == 120){$unit = 20;} - if($unit == 121){$unit = 21;} - if($unit =="hero"){$unit = 'hero';} - else{$unit = 'u' . $unit;} - ++$i; - //Fixed part of negativ troops (double troops) - by InCube - $array_amt[$i] = $array_amt[$i] < 0 ? 0 : $array_amt[$i]; - //Fixed part of negativ troops (double troops) - by InCube - $units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.$array_amt[$i].(($number > $i+1) ? ', ' : ''); - } - $q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref"; - return mysql_query($q, $this->connection); - } - - function getEnforce($vid, $from) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function getOasisEnforce($ref, $mode=0) { - 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"; - }else{ - $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 = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getOasisEnforceArray($id, $mode=0) { - 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"; - }else{ - $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 = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function getEnforceControllTroops($vid) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $vid"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function addEnforce($data) { - $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; - mysql_query($q, $this->connection); - $id = mysql_insert_id($this->connection); - $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); - $start = ($owntribe - 1) * 10 + 1; - $end = ($owntribe * 10); - //add unit - $j = '1'; - for($i = $start; $i <= $end; $i++) { - $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1); - $j++; - } - $this->modifyEnforce($id,'hero',$data['t11'],1); - return mysql_insert_id($this->connection); - } - - function addEnforce2($data,$tribe,$dead1,$dead2,$dead3,$dead4,$dead5,$dead6,$dead7,$dead8,$dead9,$dead10,$dead11) { - $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; - mysql_query($q, $this->connection); - $id = mysql_insert_id($this->connection); - $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); - $start = ($owntribe - 1) * 10 + 1; - $end = ($owntribe * 10); - $start2 = ($tribe - 1) * 10 + 1; - $start3 = ($tribe - 1) * 10; - if($start3 == 0){ - $start3 = ""; - } - $end2 = ($tribe * 10); - //add unit - $j = '1'; - for($i = $start; $i <= $end; $i++) { - $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1); - $this->modifyEnforce($id, $i, ${dead.$j}, 0); - $j++; - } - $this->modifyEnforce($id,'hero',$data['t11'],1); - $this->modifyEnforce($id,'hero',$dead11,0); - return mysql_insert_id($this->connection); - } - - function modifyEnforce($id, $unit, $amt, $mode) { - if($unit != 'hero') { $unit = 'u' . $unit; } - if(!$mode) { - $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit - $amt where id = $id"; - } else { - $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit + $amt where id = $id"; - } - mysql_query($q, $this->connection); - } - - function getEnforceArray($id, $mode) { - if(!$mode) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id"; - } else { - $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; - } - $result = mysql_query($q, $this->connection); - return mysql_fetch_assoc($result); - } - - function getEnforceVillage($id, $mode) { - if(!$mode) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id"; - } else { - $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; - } - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getVillageMovement($id) { - $vinfo = $this->getVillage($id); - $vtribe = $this->getUserField($vinfo['owner'], "tribe", 0); - $movingunits = array(); - $outgoingarray = $this->getMovement(3, $id, 0); - if(!empty($outgoingarray)) { - foreach($outgoingarray as $out) { - for($i = 1; $i <= 10; $i++) { - $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $out['t' . $i]; - } - $movingunits['hero'] += $out['t11']; - } - } - $returningarray = $this->getMovement(4, $id, 1); - if(!empty($returningarray)) { - foreach($returningarray as $ret) { - if($ret['attack_type'] != 1) { - for($i = 1; $i <= 10; $i++) { - $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $ret['t' . $i]; - } - $movingunits['hero'] += $ret['t11']; - } - } - } - $settlerarray = $this->getMovement(5, $id, 0); - if(!empty($settlerarray)) { - $movingunits['u' . ($vtribe * 10)] += 3 * count($settlerarray); - } - return $movingunits; - } - - ################# -START- ################## - ## WORLD WONDER STATISTICS FUNCTIONS! ## - ############################################ - - /*************************** - Function to get all World Wonders - Made by: Dzoki - ***************************/ - - function getWW() { - $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - /*************************** - Function to get user alliance name! - Made by: Dzoki - ***************************/ - - function getUserAllianceID($id) { - $q = "SELECT alliance FROM " . TB_PREFIX . "users where id = $id"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['alliance']; - } - - /*************************** - Function to get WW name - Made by: Dzoki - ***************************/ - - function getWWName($vref) { - $q = "SELECT wwname FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['wwname']; - } - - /*************************** - Function to change WW name - Made by: Dzoki - ***************************/ - - function submitWWname($vref, $name) { - $q = "UPDATE " . TB_PREFIX . "fdata SET `wwname` = '$name' WHERE " . TB_PREFIX . "fdata.`vref` = $vref"; - return mysql_query($q, $this->connection); - } - - //medal functions - function addclimberrankpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set clp = clp + '$cp' where id = $user"; - return mysql_query($q, $this->connection); - } - function removeclimberrankpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set clp = clp - '$cp' where id = $user"; - return mysql_query($q, $this->connection); - } - function setclimberrankpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set clp = '$cp' where id = $user"; - return mysql_query($q, $this->connection); - } - function updateoldrank($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set oldrank = '$cp' where id = $user"; - return mysql_query($q, $this->connection); - } - // ALLIANCE MEDAL FUNCTIONS - function addclimberrankpopAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp + '$cp' where id = $user"; - return mysql_query($q, $this->connection); - } - function removeclimberrankpopAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp - '$cp'' where id = $user"; - return mysql_query($q, $this->connection); - } - function updateoldrankAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set oldrank = '$cp' where id = $user"; - return mysql_query($q, $this->connection); - } - - function getTrainingList() { - $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getNeedDelete() { - $time = time(); - $q = "SELECT uid FROM " . TB_PREFIX . "deleting where timestamp < $time"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function countUser() { - $q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - return $row[0]; - } - - function countAlli() { - $q = "SELECT count(id) FROM " . TB_PREFIX . "alidata where id != 0"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - return $row[0]; - } - - /*************************** - Function to process MYSQLi->fetch_all (Only exist in MYSQL) - References: Result - ***************************/ - function mysql_fetch_all($result) { - $all = array(); - if($result) { - while($row = mysql_fetch_assoc($result)) { - $all[] = $row; - } - return $all; - } - } - - function query_return($q) { - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - /*************************** - Function to do free query - References: Query - ***************************/ - function query($query) { - return mysql_query($query, $this->connection); - } - - function RemoveXSS($val) { - return htmlspecialchars($val, ENT_QUOTES); - } - - //MARKET FIXES - function getWoodAvailable($wref) { - $q = "SELECT wood FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['wood']; - } - - function getClayAvailable($wref) { - $q = "SELECT clay FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['clay']; - } - - function getIronAvailable($wref) { - $q = "SELECT iron FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['iron']; - } - - function getCropAvailable($wref) { - $q = "SELECT crop FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - return $dbarray['crop']; - } - - function populateOasisdata() { - $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result2 = mysql_query($q2, $this->connection); - while($row = $this->safe_mysql_fetch_array($result2)) { - $wid = $row['id']; - $basearray = $this->getOMInfo($wid); - if($basearray['oasistype'] < 4) { - $high = 1; - } else if ($basearray['oasistype'] < 10){ - $high = 2; - }else { - $high = 0; - } - //We switch type of oasis and instert record with apropriate infomation. - $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . "," . time() . ",100,2,'Unoccupied Oasis',".$high.")"; - $result = mysql_query($q, $this->connection); - } - } - - 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 = $village->wid"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - $maxslots = $row[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 = $village->wid"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - $settlers = $row[0]; - $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "units WHERE vref = $village->wid"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - $chiefs = $row[0]; - - $settlers += 3 * count($this->getMovement(5, $village->wid, 0)); - $current_movement = $this->getMovement(3, $village->wid, 0); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $current_movement = $this->getMovement(3, $village->wid, 1); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $current_movement = $this->getMovement(4, $village->wid, 0); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $current_movement = $this->getMovement(4, $village->wid, 1); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - if(!empty($row)) { - foreach($row as $reinf) { - $settlers += $reinf[0]; - } - } - $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; - $result = mysql_query($q, $this->connection); - $row = mysql_fetch_row($result); - if(!empty($row)) { - foreach($row as $reinf) { - $chiefs += $reinf[0]; - } - } - $trainlist = $technology->getTrainingList(4); - if(!empty($trainlist)) { - foreach($trainlist as $train) { - if($train['unit'] % 10 == 0) { - $settlers += $train['amt']; - } - if($train['unit'] % 10 == 9) { - $chiefs += $train['amt']; - } - } - } - // trapped settlers/chiefs calculation required - - $settlerslots = $maxslots * 3 - $settlers - $chiefs * 3; - $chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3); - - if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) { - $chiefslots = 0; - } - $slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots); - return $slots; - } - - function addArtefact($vref, $owner, $type, $size, $name, $desc, $effect, $img) { - $q = "INSERT INTO `" . TB_PREFIX . "artefacts` (`vref`, `owner`, `type`, `size`, `conquered`, `name`, `desc`, `effect`, `img`, `active`) VALUES ('$vref', '$owner', '$type', '$size', '" . time() . "', '$name', '$desc', '$effect', '$img', '0')"; - return mysql_query($q, $this->connection); - } - - function getOwnArtefactInfo($vref) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getOwnArtefactInfo3($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $uid"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getOwnArtefactInfoByType($vref, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type order by size"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getOwnArtefactInfoByType2($vref, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getOwnUniqueArtefactInfo($id, $type, $size) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getOwnUniqueArtefactInfo2($id, $type, $size, $mode) { - if(!$mode){ - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND active = 1 AND type = $type AND size=$size"; - }else{ - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND active = 1 AND type = $type AND size=$size"; - } - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getFoolArtefactInfo($type,$vid,$uid) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function claimArtefact($vref, $ovref, $id) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time, active = 1 WHERE vref = $ovref"; - return mysql_query($q, $this->connection); - } - - public function canClaimArtifact($from,$vref,$size,$type) { - //fix by Ronix - global $session, $form; - $size1 = $size2 = $size3 = 0; - - $artifact = $this->getOwnArtefactInfo($from); - if (!empty($artifact)) { - $form->addError("error","Treasury is full. Your hero could not claim the artefact"); - return false; - } - $uid=$session->uid; - $q="SELECT Count(size) AS totals, - SUM(IF(size = '1',1,0)) small, - SUM(IF(size = '2',1,0)) great, - SUM(IF(size = '3',1,0)) `unique` - FROM ".TB_PREFIX."artefacts WHERE owner = ".$uid; - $result = mysql_query($q, $this->connection); - $artifact= $this->mysql_fetch_all($result); - - if($artifact['totals'] < 3 || $type==11) { - $DefenderFields = $this->getResourceLevel($vref); - $defcanclaim = TRUE; - for($i=19;$i<=38;$i++) { - if($DefenderFields['f'.$i.'t'] == 27) { - $defTresuaryLevel = $DefenderFields['f'.$i]; - if($defTresuaryLevel > 0) { - $defcanclaim = FALSE; - $form->addError("error","Treasury has not been destroyed. Your hero could not claim the artefact"); - return false; - } else { - $defcanclaim = TRUE; - } - } - } - $AttackerFields = $this->getResourceLevel($from,2); - for($i=19;$i<=38;$i++) { - if($AttackerFields['f'.$i.'t'] == 27) { - $attTresuaryLevel = $AttackerFields['f'.$i]; - if ($attTresuaryLevel >= 10) { - $villageartifact = TRUE; - } else { - $villageartifact = FALSE; - } - if ($attTresuaryLevel >= 20){ - $accountartifact = TRUE; - } else { - $accountartifact = FALSE; - } - } - } - if (($artifact['great']>0 || $artifact['unique']>0) && $size>1) { - $form->addError("error","Max num. of great/unique artefacts. Your hero could not claim the artefact"); - return FALSE; - } - if (($size == 1 && ($villageartifact || $accountartifact)) || (($size == 2 || $size == 3)&& $accountartifact)) { - return true; -/* - if($this->getVillageField($from,"capital")==1 && $type==11) { - $form->addError("error","Ancient Construction Plan cannot kept in capital village"); - return FALSE; - }else{ - return TRUE; - } -*/ - } else { - $form->addError("error","Your level treasury is low. Your hero could not claim the artefact"); - return FALSE; - } - } else { - $form->addError("error","Max num. of artefacts. Your hero could not claim the artefact"); - return FALSE; - } -} - - function getArtefactDetails($id) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . ""; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getMovementById($id){ - $q = "SELECT * FROM ".TB_PREFIX."movement WHERE moveid = ".$id.""; - $result = mysql_query($q); - $array = $this->mysql_fetch_all($result); - return $array; - } - - function getLinks($id){ - $q = 'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . $id . ' ORDER BY `pos` ASC'; - return mysql_query($q, $this->connection); - } - - function removeLinks($id,$uid){ - $q = "DELETE FROM " . TB_PREFIX . "links WHERE `id` = ".$id." and `userid` = ".$uid.""; - return mysql_query($q, $this->connection); - } - - function getVilFarmlist($wref){ - $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC'; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - - if($dbarray['id']!=0) { - return true; - } else { - return false; - } - - } - - function getRaidList($id) { - $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id.""; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function delFarmList($id, $owner) { - $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner"; - return mysql_query($q, $this->connection); - } - - function delSlotFarm($id) { - $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id"; - return mysql_query($q, $this->connection); - } - - function createFarmList($wref, $owner, $name) { - $q = "INSERT INTO " . TB_PREFIX . "farmlist (`wref`, `owner`, `name`) VALUES ('$wref', '$owner', '$name')"; - return mysql_query($q, $this->connection); - } - - function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { - $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')"; - return mysql_query($q, $this->connection); - } - - function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { - $q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid"; - return mysql_query($q, $this->connection); - } - - function getArrayMemberVillage($uid){ - $q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC'; - $result = mysql_query($q, $this->connection); - $array = $this->mysql_fetch_all($result); - return $array; - } - - function addPassword($uid, $npw, $cpw){ - $q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')"; - mysql_query($q, $this->connection) or die(mysql_error()); - } - - function resetPassword($uid, $cpw){ - $q = "SELECT npw FROM `" . TB_PREFIX . "password` WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; - $result = mysql_query($q, $this->connection) or die(mysql_error()); - $dbarray = $this->safe_mysql_fetch_array($result); - - if(!empty($dbarray)) { - if(!$this->updateUserField($uid, 'password', md5($dbarray['npw']), 1)) return false; - $q = "UPDATE `" . TB_PREFIX . "password` SET used = 1 WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; - mysql_query($q, $this->connection) or die(mysql_error()); - return true; - } - - return false; - } - - function getCropProdstarv($wref) { - global $bid4,$bid8,$bid9,$sesion,$technology; - - $basecrop = $grainmill = $bakery = 0; - $owner = $this->getVrefField($wref, 'owner'); - $bonus = $this->getUserField($owner, 'b4', 0); - - $buildarray = $this->getResourceLevel($wref); - $cropholder = array(); - for($i=1;$i<=38;$i++) { - if($buildarray['f'.$i.'t'] == 4) { - array_push($cropholder,'f'.$i); - } - if($buildarray['f'.$i.'t'] == 8) { - $grainmill = $buildarray['f'.$i]; - } - if($buildarray['f'.$i.'t'] == 9) { - $bakery = $buildarray['f'.$i]; - } - } - $q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = $wref"; - $oasis = $this->query_return($q); - foreach($oasis as $oa){ - switch($oa['type']) { - case 1: - case 2: - $wood += 1; - break; - case 3: - $wood += 1; - $cropo += 1; - break; - case 4: - case 5: - $clay += 1; - break; - case 6: - $clay += 1; - $cropo += 1; - break; - case 7: - case 8: - $iron += 1; - break; - case 9: - $iron += 1; - $cropo += 1; - break; - case 10: - case 11: - $cropo += 1; - break; - case 12: - $cropo += 2; - break; - } - } - for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$buildarray[$cropholder[$i]]]['prod']; } - $crop = $basecrop + $basecrop * 0.25 * $cropo; - if($grainmill >= 1 || $bakery >= 1) { - $crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']); - } - if($bonus > time()) { - $crop *= 1.25; - } - $crop *= SPEED; - return $crop; - } - - //general statistics - - function addGeneralAttack($casualties) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)"; - return mysql_query($q, $this->connection) or die(mysql_error()); - } - - function getAttackByDate($time) { - $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1"; - $result = $this->query_return($q); - $attack = 0; - foreach($result as $general){ - if(date("j. M",$time) == date("j. M",$general['time'])){ - $attack += 1; - } - } - return $attack; - } - - function getAttackCasualties($time) { - $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1"; - $result = $this->query_return($q); - $casualties = 0; - foreach($result as $general){ - if(date("j. M",$time) == date("j. M",$general['time'])){ - $casualties += $general['casualties']; - } - } - return $casualties; - } - - //end general statistics - - function addFriend($uid, $column, $friend) { - $q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid"; - return mysql_query($q, $this->connection); - } - - function deleteFriend($uid, $column) { - $q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid"; - return mysql_query($q, $this->connection); - } - - function checkFriends($uid) { - $user = $this->getUserArray($uid, 1); - for($i=0;$i<=19;$i++) { - if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){ - for($j=$i+1;$j<=19;$j++) { - $k = $j-1; - if($user['friend'.$j] != 0){ - $friend = $this->getUserField($uid, "friend".$j, 0); - $this->addFriend($uid,"friend".$k,$friend); - $this->deleteFriend($uid,"friend".$j); - } - if($user['friend'.$j.'wait'] == 0){ - $friendwait = $this->getUserField($uid, "friend".$j."wait", 0); - $this->addFriend($sessionuid,"friend".$k."wait",$friendwait); - $this->deleteFriend($uid,"friend".$j."wait"); - } - } - } - } - } - - function setVillageEvasion($vid) { - $village = $this->getVillage($vid); - if($village['evasion'] == 0){ - $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 1 WHERE wref = $vid"; - }else{ - $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid"; - } - return mysql_query($q, $this->connection); - } - - function addPrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { - $q = "INSERT INTO " . TB_PREFIX . "prisoners values (0,$wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11)"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } - - function updatePrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { - $q = "UPDATE " . TB_PREFIX . "prisoners set t1 = t1 + $t1, t2 = t2 + $t2, t3 = t3 + $t3, t4 = t4 + $t4, t5 = t5 + $t5, t6 = t6 + $t6, t7 = t7 + $t7, t8 = t8 + $t8, t9 = t9 + $t9, t10 = t10 + $t10, t11 = t11 + $t11 where wref = $wid and ".TB_PREFIX."prisoners.from = $from"; - return mysql_query($q, $this->connection) or die(mysql_error()); - } - - function getPrisoners($wid,$mode=0) { - if(!$mode) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid"; - }else { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where `from` = $wid"; - } - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getPrisoners2($wid,$from) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function getPrisonersByID($id) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_array($result); - } - - function getPrisoners3($from) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where " . TB_PREFIX . "prisoners.from = $from"; - $result = mysql_query($q, $this->connection); - return $this->safe_mysql_fetch_all($result); - } - - function deletePrisoners($id) { - $q = "DELETE from " . TB_PREFIX . "prisoners where id = '$id'"; - mysql_query($q, $this->connection); - } - -/***************************************** -Function to vacation mode - by advocaite -References: -*****************************************/ - - function setvacmode($uid,$days){ - $days1 =60*60*24*$days; - $time =time()+$days1; - $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '1' , vac_time=".$time." WHERE id=".$uid.""; - $result =mysql_query($q,$this->connection); - } - - function removevacationmode($uid){ - $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '0' , vac_time='0' WHERE id=".$uid.""; - $result =mysql_query($q,$this->connection); - } - - function getvacmodexy($wref){ - $q = "SELECT id,oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysql_query($q, $this->connection); - $dbarray = $this->safe_mysql_fetch_array($result); - if($dbarray['occupied'] != 0 && $dbarray['oasistype'] == 0) { - $q1 = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = ".$dbarray['id'].""; - $result1 = mysql_query($q1, $this->connection); - $dbarray1 = $this->safe_mysql_fetch_array($result1); - if($dbarray1['owner'] != 0){ - $q2 = "SELECT vac_mode,vac_time FROM " . TB_PREFIX . "users where id = ".$dbarray1['owner'].""; - $result2 = mysql_query($q2, $this->connection); - $dbarray2 = $this->safe_mysql_fetch_array($result2); - if($dbarray2['vac_mode'] ==1){ - return true; - }else{ - return false; - } - } - } else { - return false; - } - } - - /***************************************** - Function to vacation mode - by advocaite - References: - *****************************************/ - - /*************************** - Function to get Hero Dead - Made by: Shadow and brainiacX - ***************************/ - - function getHeroDead($id) { - $q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysql_query($q, $this->connection); - $notend= $this->safe_mysql_fetch_array($result); - return $notend['dead']; - } - - /*************************** - Function to get Hero In Revive - Made by: Shadow - ***************************/ - - function getHeroInRevive($id) { - $q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysql_query($q, $this->connection); - $notend= $this->safe_mysql_fetch_array($result); - return $notend['inrevive']; - } - - /*************************** - Function to get Hero In Training - Made by: Shadow - ***************************/ - - function getHeroInTraining($id) { - $q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysql_query($q, $this->connection); - $notend= $this->safe_mysql_fetch_array($result); - return $notend['intraining']; - } - - /*************************** - Function to check Hero Not in Village - Made by: Shadow and brainiacX - ***************************/ - - function HeroNotInVil($id) { - $heronum=0; - $outgoingarray = $this->getMovement(3, $id, 0); - if(!empty($outgoingarray)) { - foreach($outgoingarray as $out) { - $heronum += $out['t11']; - } - } - $returningarray = $this->getMovement(4, $id, 1); - if(!empty($returningarray)) { - foreach($returningarray as $ret) { - if($ret['attack_type'] != 1) { - $heronum += $ret['t11']; - } - } - } - return $heronum; - } - - /*************************** - Function to Kill hero if not found - Made by: Shadow and brainiacX - ***************************/ - - function KillMyHero($id) { - $q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id; - return mysql_query($q, $this->connection); - } - - /*************************** - Function to find Hero place - Made by: ronix - ***************************/ - function FindHeroInVil($wid) { - $result = $this->query("SELECT * FROM ".TB_PREFIX."units WHERE hero>0 AND vref='".$wid."'"); - if (!empty($result)) { - $dbarray = $this->safe_mysql_fetch_array($result); - if(isset($dbarray['hero'])) { - $this->query("UPDATE ".TB_PREFIX."units SET hero=0 WHERE vref='".$wid."'"); - unset($dbarray); - return true; - } - } - return false; - } - function FindHeroInDef($wid) { - $delDef=true; - $result = $this->query_return("SELECT * FROM ".TB_PREFIX."enforcement WHERE hero>0 AND `from` = ".$wid); - if (!empty($result)) { - $dbarray = $this->safe_mysql_fetch_array($result); - if(isset($dbarray['hero'])) { - $this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$wid); - for ($i=0;$i<50;$i++) { - if($dbarray['u'.$i]>0) { - $delDef=false; - break; - } - } - if ($delDef) $this->deleteReinf($wid); - unset($dbarray); - return true; - } - } - return false; - } - function FindHeroInOasis($uid) { - $delDef=true; - $dbarray = $this->query_return("SELECT e.*,o.conqured,o.owner FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.owner=".$uid." AND e.hero>0"); - if(!empty($dbarray)) { - foreach($dbarray as $defoasis) { - if($defoasis['hero']>0) { - $this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$defoasis['from']); - for ($i=0;$i<50;$i++) { - if($dbarray['u'.$i]>0) { - $delDef=false; - break; - } - } - if ($delDef) $this->deleteReinf($defoasis['from']); - unset($dbarray); - return true; - } - } - } - return 0; - } - - function FindHeroInMovement($wid) { - $outgoingarray = $this->getMovement(3, $wid, 0); - if(!empty($outgoingarray)) { - foreach($outgoingarray as $out) { - if ($out['t11']>0) { - $dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$out['ref']); - return true; - break; - } - } - } - $returningarray = $this->getMovement(4, $wid, 1); - if(!empty($returningarray)) { - foreach($returningarray as $ret) { - if($ret['attack_type'] != 1 && $ret['t11']>0) { - $dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$ret['ref']); - return true; - break; - } - } - } - return false; - } - - /*************************** - Function checkAttack - Made by: Shadow - ***************************/ - - function checkAttack($wref, $toWref){ - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and (" . TB_PREFIX . "attacks.attack_type = 3 or " . TB_PREFIX . "attacks.attack_type = 4) ORDER BY endtime ASC"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - } else { - return false; - } - } - - /*************************** - Function checkEnforce - Made by: Shadow - ***************************/ - - function checkEnforce($wref, $toWref) { - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 2 ORDER BY endtime ASC"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - }else{ - return false; - } - } - - /*************************** - Function checkScout - Made by: yi12345 - ***************************/ - - function checkScout($wref, $toWref) { - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result)) { - return true; - }else{ - return false; - } - } - -}; - -$database = new MYSQL_DB; - -?> diff --git a/GameEngine/Database/db_MYSQLi.php b/GameEngine/Database/db_MYSQLi.php index 9366ee4f..36307a2f 100755 --- a/GameEngine/Database/db_MYSQLi.php +++ b/GameEngine/Database/db_MYSQLi.php @@ -19,11 +19,15 @@ class MYSQLi_DB { - var $connection; - function MYSQL_DB() { - $this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); - mysqli_query("SET NAMES 'UTF8'"); //Fix utf8 phpmyadmin by gm4st3r + var $dblink; + function mysqli_DB() { + $this->dblink = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); + mysqli_select_db($this->dblink, SQL_DB); + mysqli_query($this->dblink,"SET NAMES 'UTF8'"); + } + + function return_link() { + return $this->dblink; } function register($username, $password, $email, $tribe, $act) { @@ -35,8 +39,8 @@ class MYSQLi_DB { $timep = $time + PROTECTION; $time = time(); $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)"; - if(mysqli_query($q, $this->connection)) { - return mysqli_insert_id($this->connection); + if(mysqli_query($this->dblink,$q)) { + return mysqli_insert_id($this->dblink); } else { return false; } @@ -45,8 +49,8 @@ class MYSQLi_DB { function activate($username, $password, $email, $tribe, $locate, $act, $act2) { $time = time(); $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')"; - if(mysqli_query($q, $this->connection)) { - return mysqli_insert_id($this->connection); + if(mysqli_query($this->dblink,$q)) { + return mysqli_insert_id($this->dblink); } else { return false; } @@ -54,17 +58,17 @@ class MYSQLi_DB { function unreg($username) { $q = "DELETE from " . TB_PREFIX . "activate where username = '$username'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function deleteReinf($id) { $q = "DELETE from " . TB_PREFIX . "enforcement where id = '$id'"; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } function updateResource($vid, $what, $number) { $q = "UPDATE " . TB_PREFIX . "vdata set " . $what . "=" . $number . " where wref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); + return mysqli_query($this->dblink,$q); } function checkExist($ref, $mode) { @@ -74,7 +78,7 @@ class MYSQLi_DB { } else { $q = "SELECT email FROM " . TB_PREFIX . "users where email = '$ref' LIMIT 1"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if(mysqli_num_rows($result)) { return true; } else { @@ -89,7 +93,7 @@ class MYSQLi_DB { } else { $q = "SELECT email FROM " . TB_PREFIX . "activate where email = '$ref' LIMIT 1"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if(mysqli_num_rows($result)) { return true; } else { @@ -99,7 +103,7 @@ class MYSQLi_DB { public function hasBeginnerProtection($vid) { $q = "SELECT u.protect FROM ".TB_PREFIX."users u,".TB_PREFIX."vdata v WHERE u.id=v.owner AND v.wref=".$vid; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if(!empty($dbarray)) { if(time()<$dbarray[0]) { @@ -118,18 +122,18 @@ class MYSQLi_DB { } else { $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where id = '$ref'"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getSitee($uid) { $q = "SELECT id from " . TB_PREFIX . "users where sit1 = $uid or sit2 = $uid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getVilWref($x, $y) { $q = "SELECT * FROM " . TB_PREFIX . "wdata where x = $x AND y = $y"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['id']; } @@ -147,9 +151,9 @@ class MYSQLi_DB { function removeMeSit($uid, $uid2) { $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2"; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); $q2 = "UPDATE " . TB_PREFIX . "users set sit2 = 0 where id = $uid and sit2 = $uid2"; - mysqli_query($q2, $this->connection); + mysqli_query($q2, $this->dblink); } function getUserField($ref, $field, $mode) { @@ -158,7 +162,7 @@ class MYSQLi_DB { } else { $q = "SELECT $field FROM " . TB_PREFIX . "users where username = '$ref'"; } - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); if($result) { $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; @@ -169,33 +173,33 @@ class MYSQLi_DB { function getInvitedUser($uid) { $q = "SELECT * FROM " . TB_PREFIX . "users where invited = $uid order by regtime desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getVrefField($ref, $field){ $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; } function getVrefCapital($ref){ $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray; } function getStarvation(){ $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0 and owner != 3"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getUnstarvation(){ $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv = 0 and starvupdate = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -205,14 +209,14 @@ class MYSQLi_DB { } else { $q = "SELECT $field FROM " . TB_PREFIX . "activate where username = '$ref'"; } - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; } function login($username, $password) { $q = "SELECT password,sessid FROM " . TB_PREFIX . "users where username = '$username'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if($dbarray['password'] == md5($password)) { return true; @@ -223,7 +227,7 @@ class MYSQLi_DB { function checkActivate($act) { $q = "SELECT * FROM " . TB_PREFIX . "activate where act = '$act'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray; @@ -231,16 +235,16 @@ class MYSQLi_DB { function sitterLogin($username, $password) { $q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if($dbarray['sit1'] != 0) { $q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED; - $result2 = mysqli_query($q2, $this->connection); + $result2 = mysqli_query($q2, $this->dblink); $dbarray2 = mysqli_fetch_array($result2); } if($dbarray['sit2'] != 0) { $q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED; - $result3 = mysqli_query($q3, $this->connection); + $result3 = mysqli_query($q3, $this->dblink); $dbarray3 = mysqli_fetch_array($result3); } if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) { @@ -261,12 +265,12 @@ class MYSQLi_DB { } else { $q = "DELETE FROM " . TB_PREFIX . "deleting where uid = $uid"; } - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } function isDeleting($uid) { $q = "SELECT timestamp from " . TB_PREFIX . "deleting where uid = $uid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['timestamp']; } @@ -277,7 +281,7 @@ class MYSQLi_DB { } else { $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /***************************************** @@ -291,9 +295,9 @@ class MYSQLi_DB { if(!$mode) { $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref'"; } else { - $q = "SELECT * FROM " . TB_PREFIX . "users where id = $ref"; + $q = "SELECT * FROM " . TB_PREFIX . "users where id = '$ref'"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } @@ -304,12 +308,12 @@ class MYSQLi_DB { } else { $q = "DELETE FROM " . TB_PREFIX . "active where username = '$username'"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addActiveUser($username, $time) { $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; - if(mysqli_query($q, $this->connection)) { + if(mysqli_query($this->dblink,$q)) { return true; } else { return false; @@ -319,8 +323,8 @@ class MYSQLi_DB { function updateActiveUser($username, $time) { $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; $q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'"; - $exec1 = mysqli_query($q, $this->connection); - $exec2 = mysqli_query($q2, $this->connection); + $exec1 = mysqli_query($this->dblink,$q); + $exec2 = mysqli_query($q2, $this->dblink); if($exec1 && $exec2) { return true; } else { @@ -330,8 +334,8 @@ class MYSQLi_DB { function checkactiveSession($username, $sessid) { $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$username' and sessid = '$sessid' LIMIT 1"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result) != 0) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result) != 0) { return true; } else { return false; @@ -340,17 +344,17 @@ class MYSQLi_DB { function submitProfile($uid, $gender, $location, $birthday, $des1, $des2) { $q = "UPDATE " . TB_PREFIX . "users set gender = $gender, location = '$location', birthday = '$birthday', desc1 = '$des1', desc2 = '$des2' where id = $uid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function gpack($uid, $gpack) { $q = "UPDATE " . TB_PREFIX . "users set gpack = '$gpack' where id = $uid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function GetOnline($uid) { $q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['sit']; } @@ -359,13 +363,13 @@ class MYSQLi_DB { global $session; if($mode == "login") { $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } else if($mode == "sitter") { $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } else { $q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . addslashes($session->username) . "'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } } @@ -407,8 +411,8 @@ class MYSQLi_DB { $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- break; } - $result = mysqli_query($q, $this->connection); - $num_rows = mysql_num_rows($result); + $result = mysqli_query($this->dblink,$q); + $num_rows = mysqli_num_rows($result); $count_while++; } $result = $this->mysqli_fetch_all($result); @@ -418,7 +422,7 @@ class MYSQLi_DB { function setFieldTaken($id) { $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addVillage($wid, $uid, $username, $capital) { @@ -430,7 +434,7 @@ class MYSQLi_DB { } $time = time(); $q = "INSERT into " . TB_PREFIX . "vdata (wref, owner, name, capital, pop, cp, celebration, wood, clay, iron, maxstore, crop, maxcrop, lastupdate, created) values ('$wid', '$uid', '$vname', '$capital', 2, 1, 0, 750, 750, 750, ".STORAGE_BASE.", 750, ".STORAGE_BASE.", '$time', '$time')"; - return mysqli_query($q, $this->connection) or die(mysql_error()); + return mysqli_query($this->dblink,$q) or die(mysqli_error()); } function addResourceFields($vid, $type) { @@ -472,11 +476,11 @@ class MYSQLi_DB { $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; break; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function isVillageOases($wref) { $q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if($result){ $dbarray = mysqli_fetch_array($result); return $dbarray['oasistype']; @@ -485,8 +489,8 @@ class MYSQLi_DB { public function VillageOasisCount($vref) { $q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } @@ -549,7 +553,7 @@ class MYSQLi_DB { $vinfo = $this->getVillage($vref); $uid = $vinfo['owner']; $q = "UPDATE `".TB_PREFIX."odata` SET conqured=$vref,loyalty=100,lastupdated=".time().",owner=$uid,name='Occupied Oasis' WHERE wref=$wref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } public function modifyOasisLoyalty($wref) { @@ -558,7 +562,7 @@ class MYSQLi_DB { if($OasisInfo['conqured'] != 0) { $LoyaltyAmendment = floor(100 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))); $q = "UPDATE `".TB_PREFIX."odata` SET loyalty=loyalty-$LoyaltyAmendment, lastupdated=".time()." WHERE wref=$wref"; - $result=mysqli_query($q, $this->connection); + $result=mysqli_query($this->dblink,$q); return $OasisInfo['loyalty']-$LoyaltyAmendment; } } @@ -566,7 +570,7 @@ class MYSQLi_DB { function populateOasis() { $q = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); while($row = mysqli_fetch_array($result)) { $wid = $row['id']; @@ -595,52 +599,52 @@ class MYSQLi_DB { case 2: //+25% lumber per hour $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u35 <= ".$max." OR u36 <= ".$max." OR u37 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 3: //+25% lumber and +25% crop per hour $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 4: case 5: //+25% clay per hour $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 6: //+25% clay and +25% crop per hour $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 7: case 8: //+25% iron per hour $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 9: //+25% iron and +25% crop $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 10: case 11: //+25% crop per hour $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 12: //+50% crop per hour $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max." OR u39 <= ".$max.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; } } function populateOasisUnits2() { $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result2 = mysqli_query($q2, $this->connection); + $result2 = mysqli_query($q2, $this->dblink); while($row = mysqli_fetch_array($result2)) { $wid = $row['id']; switch($row['oasistype']) { @@ -648,45 +652,45 @@ class MYSQLi_DB { case 2: //+25% lumber oasis $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,10)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <= '10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 3: //+25% lumber and +25% crop oasis $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,15)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <='10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 4: case 5: //+25% clay oasis $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <= '10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 6: //+25% clay and +25% crop oasis $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <='10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 7: case 8: //+25% iron oasis $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <= '10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 9: //+25% iron and +25% crop oasis $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <='10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 10: case 11: //+25% crop oasis $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(5,15)."', u33 = u33 + '".rand(5,10)."', u37 = u37 + '".rand(0,10)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u37 <='10' AND u39 <='10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; case 12: //+50% crop oasis $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u33 = u33 + '".rand(5,10)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u38 <='10'AND u39 <='10'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); break; } } @@ -694,7 +698,7 @@ class MYSQLi_DB { function removeOases($wref) { $q = "UPDATE ".TB_PREFIX."odata SET conqured = 0, owner = 2, name = 'Unoccupied Oasis' WHERE wref = $wref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } @@ -704,7 +708,7 @@ class MYSQLi_DB { ***************************/ function getVillageType($wref) { $q = "SELECT id, fieldtype FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['fieldtype']; } @@ -717,7 +721,7 @@ class MYSQLi_DB { *****************************************/ function getVillageState($wref) { $q = "SELECT oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if($dbarray['occupied'] != 0 || $dbarray['oasistype'] != 0) { return true; @@ -728,27 +732,27 @@ class MYSQLi_DB { function getProfileVillages($uid) { $q = "SELECT capital,wref,name,pop,created from " . TB_PREFIX . "vdata where owner = $uid order by pop desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getProfileMedal($uid) { $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "medal where userid = $uid and del = 0 order by id desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getProfileMedalAlly($uid) { $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "allimedal where allyid = $uid and del = 0 order by id desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getVillageID($uid) { $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE owner = $uid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['wref']; } @@ -756,7 +760,7 @@ class MYSQLi_DB { function getVillagesID($uid) { $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $array = $this->mysqli_fetch_all($result); $newarray = array(); for($i = 0; $i < count($array); $i++) { @@ -767,63 +771,63 @@ class MYSQLi_DB { function getVillagesID2($uid) { $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $array = $this->mysqli_fetch_all($result); return $array; } function getVillage($vid) { $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } public function getVillageBattleData($vid) { $q = "SELECT u.id,u.tribe,v.capital,f.f40 AS wall FROM ".TB_PREFIX."users u,".TB_PREFIX."fdata f,".TB_PREFIX."vdata v WHERE u.id=v.owner AND f.vref=v.wref AND v.wref=".$vid; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } public function getPopulation($uid) { $q = "SELECT sum(pop) AS pop FROM ".TB_PREFIX."vdata WHERE owner=".$uid; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['pop']; } function getOasisV($vid) { $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $vid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function getMInfo($id) { $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "vdata ON " . TB_PREFIX . "vdata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function getOMInfo($id) { $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "odata ON " . TB_PREFIX . "odata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function getOasis($vid) { $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = $vid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getOasisInfo($wid) { $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $wid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function getVillageField($ref, $field) { $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if($result){ $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; @@ -834,47 +838,47 @@ class MYSQLi_DB { function getOasisField($ref, $field) { $q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; } function setVillageField($ref, $field, $value) { $q = "UPDATE " . TB_PREFIX . "vdata set $field = '$value' where wref = $ref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function setVillageLevel($ref, $field, $value) { $q = "UPDATE " . TB_PREFIX . "fdata set " . $field . " = '" . $value . "' where vref = " . $ref . ""; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getResourceLevel($vid) { $q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function getAdminLog() { $q = "SELECT id,user,log,time from " . TB_PREFIX . "admin_log where id != 0 ORDER BY id ASC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } //fix market log function getMarketLog() { $q = "SELECT id,wid,log from " . TB_PREFIX . "market_log where id != 0 ORDER BY id ASC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getMarketLogVillage($village) { $q = "SELECT wref,owner,name from " . TB_PREFIX . "vdata where wref =$village "; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getMarketLogUsers($id_user) { $q = "SELECT id,username from " . TB_PREFIX . "users where id =$id_user "; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } //end fix @@ -882,15 +886,15 @@ class MYSQLi_DB { function getCoor($wref) { if ($wref !=""){ $q = "SELECT x,y FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } } function CheckForum($id) { $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -899,21 +903,21 @@ class MYSQLi_DB { function CountCat($id) { $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } function LastTopic($id) { $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' order by post_date"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function CheckLastTopic($id) { $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -922,8 +926,8 @@ class MYSQLi_DB { function CheckLastPost($id) { $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -932,58 +936,58 @@ class MYSQLi_DB { function LastPost($id) { $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function CountTopic($id) { $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where owner = '$id'"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); $qs = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where owner = '$id'"; - $results = mysqli_query($qs, $this->connection); - $rows = mysql_fetch_row($results); + $results = mysqli_query($qs, $this->dblink); + $rows = mysqli_fetch_row($results); return $row[0] + $rows[0]; } function CountPost($id) { $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } function ForumCat($id) { $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id' ORDER BY id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function ForumCatEdit($id) { $q = "SELECT * from " . TB_PREFIX . "forum_cat where id = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function ForumCatAlliance($id) { $q = "SELECT alliance from " . TB_PREFIX . "forum_cat where id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['alliance']; } function ForumCatName($id) { $q = "SELECT forum_name from " . TB_PREFIX . "forum_cat where id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['forum_name']; } function CheckCatTopic($id) { $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -992,8 +996,8 @@ class MYSQLi_DB { function CheckResultEdit($alli) { $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -1002,54 +1006,54 @@ class MYSQLi_DB { function CheckCloseTopic($id) { $q = "SELECT close from " . TB_PREFIX . "forum_topic where id = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['close']; } function CheckEditRes($alli) { $q = "SELECT result from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['result']; } function CreatResultEdit($alli, $result) { $q = "INSERT into " . TB_PREFIX . "forum_edit values (0,'$alli','$result')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function UpdateResultEdit($alli, $result) { $date = time(); $q = "UPDATE " . TB_PREFIX . "forum_edit set result = '$result' where alliance = '$alli'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getVillageType2($wref) { $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['oasistype']; } function getVillageType3($wref) { $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray; } function getFLData($id) { $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function checkVilExist($wref) { $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -1058,8 +1062,8 @@ class MYSQLi_DB { function checkOasisExist($wref) { $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -1068,60 +1072,60 @@ class MYSQLi_DB { function UpdateEditTopic($id, $title, $cat) { $q = "UPDATE " . TB_PREFIX . "forum_topic set title = '$title', cat = '$cat' where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function UpdateEditForum($id, $name, $des) { $q = "UPDATE " . TB_PREFIX . "forum_cat set forum_name = '$name', forum_des = '$des' where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function StickTopic($id, $mode) { $q = "UPDATE " . TB_PREFIX . "forum_topic set stick = '$mode' where id = '$id'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function ForumCatTopic($id) { $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '' ORDER BY post_date desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function ForumCatTopicStick($id) { $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '1' ORDER BY post_date desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function ShowTopic($id) { $q = "SELECT * from " . TB_PREFIX . "forum_topic where id = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function ShowPost($id) { $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function ShowPostEdit($id) { $q = "SELECT * from " . TB_PREFIX . "forum_post where id = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function CreatForum($owner, $alli, $name, $des, $area) { $q = "INSERT into " . TB_PREFIX . "forum_cat values (0,'$owner','$alli','$name','$des','$area')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) { $date = time(); $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } /************************* @@ -1130,19 +1134,19 @@ class MYSQLi_DB { function createSurvey($topic, $title, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $ends) { $q = "INSERT into " . TB_PREFIX . "forum_survey (topic,title,option1,option2,option3,option4,option5,option6,option7,option8,ends) values ('$topic','$title','$option1','$option2','$option3','$option4','$option5','$option6','$option7','$option8','$ends')"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getSurvey($topic) { $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function checkSurvey($topic) { $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -1151,12 +1155,12 @@ class MYSQLi_DB { function Vote($topic, $num, $text) { $q = "UPDATE " . TB_PREFIX . "forum_survey set vote".$num." = vote".$num." + 1, voted = '$text' where topic = ".$topic.""; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function checkVote($topic, $uid) { $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $array = mysqli_fetch_array($result); $text = $array['voted']; if(preg_match('/,'.$uid.',/',$text)) { @@ -1168,7 +1172,7 @@ class MYSQLi_DB { function getVoteSum($topic) { $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $array = mysqli_fetch_array($result); $sum = 0; for($i=1;$i<=8;$i++){ @@ -1185,66 +1189,66 @@ class MYSQLi_DB { function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) { $date = time(); $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function UpdatePostDate($id) { $date = time(); $q = "UPDATE " . TB_PREFIX . "forum_topic set post_date = '$date' where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) { $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) { $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function LockTopic($id, $mode) { $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function DeleteCat($id) { $qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'"; $q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'"; $q2="SELECT id from ".TB_PREFIX."forum_topic where cat ='$id'"; - $result = mysqli_query($q2, $this->connection); + $result = mysqli_query($q2, $this->dblink); if (!empty($result)) { $array=$this->mysqli_fetch_all($result); foreach($array as $ss) { $this->DeleteSurvey($ss['id']); } } - mysqli_query($qs, $this->connection); - return mysqli_query($q, $this->connection); + mysqli_query($qs, $this->dblink); + return mysqli_query($this->dblink,$q); } function DeleteSurvey($id) { $qs = "DELETE from " . TB_PREFIX . "forum_survey where topic = '$id'"; - return mysqli_query($qs, $this->connection); + return mysqli_query($qs, $this->dblink); } function DeleteTopic($id) { $qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'"; // $q = "DELETE from ".TB_PREFIX."forum_post where topic = '$id'";// - return mysqli_query($qs, $this->connection); // - // mysqli_query($q,$this->connection); + return mysqli_query($qs, $this->dblink); // + // mysqli_query($this->dblink,$q); } function DeletePost($id) { $q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getAllianceName($id) { $q = "SELECT tag from " . TB_PREFIX . "alidata where id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['tag']; } @@ -1255,26 +1259,26 @@ class MYSQLi_DB { } else { $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where username = '$ref'"; } - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; } function getAlliance($id) { $q = "SELECT * from " . TB_PREFIX . "alidata where id = $id"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function setAlliName($aid, $name, $tag) { $q = "UPDATE " . TB_PREFIX . "alidata set name = '$name', tag = '$tag' where id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function isAllianceOwner($id) { $q = "SELECT * from " . TB_PREFIX . "alidata where leader = '$id'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -1283,8 +1287,8 @@ class MYSQLi_DB { function aExist($ref, $type) { $q = "SELECT $type FROM " . TB_PREFIX . "alidata where $type = '$ref'"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -1293,12 +1297,12 @@ class MYSQLi_DB { function modifyPoints($aid, $points, $amt) { $q = "UPDATE " . TB_PREFIX . "users set $points = $points + $amt where id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function modifyPointsAlly($aid, $points, $amt) { $q = "UPDATE " . TB_PREFIX . "alidata set $points = $points + $amt where id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /***************************************** @@ -1307,8 +1311,8 @@ class MYSQLi_DB { *****************************************/ function createAlliance($tag, $name, $uid, $max) { $q = "INSERT into " . TB_PREFIX . "alidata values (0,'$name','$tag',$uid,0,0,0,'','',$max,'','','','','','','','','')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function procAllyPop($aid) { @@ -1339,8 +1343,8 @@ class MYSQLi_DB { function insertAlliNotice($aid, $notice) { $time = time(); $q = "INSERT into " . TB_PREFIX . "ali_log values (0,'$aid','$notice',$time)"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } /***************************************** @@ -1349,12 +1353,12 @@ class MYSQLi_DB { *****************************************/ function deleteAlliance($aid) { $result = mysqli_query("SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"); - $num_rows = mysql_num_rows($result); + $num_rows = mysqli_num_rows($result); if($num_rows == 0) { $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid"; } - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } /***************************************** @@ -1363,7 +1367,7 @@ class MYSQLi_DB { *****************************************/ function readAlliNotice($aid) { $q = "SELECT * from " . TB_PREFIX . "ali_log where aid = $aid ORDER BY date DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -1374,8 +1378,8 @@ class MYSQLi_DB { function createAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) { $q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } /***************************************** @@ -1384,7 +1388,7 @@ class MYSQLi_DB { *****************************************/ function deleteAlliPermissions($uid) { $q = "DELETE from " . TB_PREFIX . "ali_permission where uid = '$uid'"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /***************************************** Function to update alliance permissions @@ -1393,7 +1397,7 @@ class MYSQLi_DB { function updateAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7) { $q = "UPDATE " . TB_PREFIX . "ali_permission SET rank = '$rank', opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' where uid = $uid && alliance =$aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /***************************************** @@ -1402,8 +1406,8 @@ class MYSQLi_DB { *****************************************/ function getAlliPermissions($uid, $aid) { $q = "SELECT * FROM " . TB_PREFIX . "ali_permission where uid = $uid && alliance = $aid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } /***************************************** @@ -1413,57 +1417,57 @@ class MYSQLi_DB { function submitAlliProfile($aid, $notice, $desc) { $q = "UPDATE " . TB_PREFIX . "alidata SET `notice` = '$notice', `desc` = '$desc' where id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function diplomacyInviteAdd($alli1, $alli2, $type) { $q = "INSERT INTO " . TB_PREFIX . "diplomacy (alli1,alli2,type,accepted) VALUES ($alli1,$alli2," . (int)intval($type) . ",0)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function diplomacyOwnOffers($session_alliance) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getAllianceID($name) { $q = "SELECT id FROM " . TB_PREFIX . "alidata WHERE tag ='" . $this->RemoveXSS($name) . "'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['id']; } function getDiplomacy($aid) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE id = $aid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function diplomacyCancelOffer($id) { $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function diplomacyInviteAccept($id, $session_alliance) { $q = "UPDATE " . TB_PREFIX . "diplomacy SET accepted = 1 WHERE id = $id AND alli2 = $session_alliance"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function diplomacyInviteDenied($id, $session_alliance) { $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function diplomacyInviteCheck($session_alliance) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function diplomacyInviteCheck2($ally1, $ally2) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -1505,40 +1509,40 @@ class MYSQLi_DB { function getAllianceAlly($aid, $type){ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE (alli1 = '$aid' or alli2 = '$aid') AND (type = '$type' AND accepted = '1')"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getAllianceWar2($aid){ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function diplomacyExistingRelationships($session_alliance) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function diplomacyExistingRelationships2($session_alliance) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 1"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function diplomacyCancelExistingRelationship($id, $session_alliance) { $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function checkDiplomacyInviteAccept($aid, $type) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if($type == 3){ return true; }else{ - if(mysql_num_rows($result) < 4) { + if(mysqli_num_rows($result) < 4) { return true; } else { return false; @@ -1546,14 +1550,14 @@ class MYSQLi_DB { } } - function setAlliForumLink($aid, $link) { - $q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid"; - return mysqli_query($q, $this->connection); + function setAlliForumdblink($aid, $dblink) { + $q = "UPDATE " . TB_PREFIX . "alidata SET `forumdblink` = '$dblink' WHERE id = $aid"; + return mysqli_query($this->dblink,$q); } function getUserAlliance($id) { $q = "SELECT " . TB_PREFIX . "alidata.tag from " . TB_PREFIX . "users join " . TB_PREFIX . "alidata where " . TB_PREFIX . "users.alliance = " . TB_PREFIX . "alidata.id and " . TB_PREFIX . "users.id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if($dbarray['tag'] == "") { return "-"; @@ -1566,7 +1570,7 @@ class MYSQLi_DB { function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) { $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "vdata where wref = ".$vid.""; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $checkres= $this->mysqli_fetch_all($result); if(!$mode){ $nwood=$checkres[0]['wood']-$wood; @@ -1590,12 +1594,12 @@ class MYSQLi_DB { } if(!$shit){ $q = "UPDATE " . TB_PREFIX . "vdata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; - return mysqli_query($q, $this->connection); }else{return false;} + return mysqli_query($this->dblink,$q); }else{return false;} } function modifyOasisResource($vid, $wood, $clay, $iron, $crop, $mode) { $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "odata where wref = ".$vid.""; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $checkres= $this->mysqli_fetch_all($result); if(!$mode){ $nwood=$checkres[0]['wood']-$wood; @@ -1619,19 +1623,20 @@ class MYSQLi_DB { } if(!$shit){ $q = "UPDATE " . TB_PREFIX . "odata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; - return mysqli_query($q, $this->connection); }else{return false;} + return mysqli_query($this->dblink,$q); }else{return false;} } function getFieldLevel($vid, $field) { - $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_result($result, 0); + $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid LIMIT 1"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_array($result); + return $row["f" . $field]; } function getFieldType($vid, $field) { $q = "SELECT f" . $field . "t from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_result($result, 0); + $result = mysqli_query($this->dblink,$q); + return mysqli_result($result, 0); } function getFieldDistance($wid) { @@ -1644,7 +1649,7 @@ class MYSQLi_DB { $q2 = "SELECT * FROM " . TB_PREFIX . "vdata where owner = 4"; $array2 = mysqli_fetch_array(mysqli_query($q2)); $vill = $array2['wref']; - if(mysql_num_rows(mysqli_query($q)) > 0){ + if(mysqli_num_rows(mysqli_query($q)) > 0){ foreach($array as $village){ $coor2 = $this->getCoor($village['wref']); $max = 2 * WORLD_MAX + 1; @@ -1668,36 +1673,36 @@ class MYSQLi_DB { }else{ $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid and natar = 0"; } - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } function updateVillage($vid) { $time = time(); $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function updateOasis($vid) { $time = time(); $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function updateOasis2($vid, $time) { $time = time(); $time2 = NATURE_REGTIME; $q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time + $time2 where wref = $vid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function setVillageName($vid, $name) { if(!empty($name)) { $q = "UPDATE " . TB_PREFIX . "vdata set name = '$name' where wref = $vid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } } @@ -1707,84 +1712,84 @@ class MYSQLi_DB { } else { $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop - $pop where wref = $vid"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addCP($ref, $cp) { $q = "UPDATE " . TB_PREFIX . "vdata set cp = cp + $cp where wref = $ref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addCel($ref, $cel, $type) { $q = "UPDATE " . TB_PREFIX . "vdata set celebration = $cel, type= $type where wref = $ref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getCel() { $time = time(); $q = "SELECT * FROM " . TB_PREFIX . "vdata where celebration < $time AND celebration != 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function clearCel($ref) { $q = "UPDATE " . TB_PREFIX . "vdata set celebration = 0, type = 0 where wref = $ref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function setCelCp($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function clearExpansionSlot($id) { for($i = 1; $i <= 3; $i++) { $q = "UPDATE " . TB_PREFIX . "vdata SET exp" . $i . "=0 WHERE exp" . $i . "=" . $id; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } } function getInvitation($uid) { $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getInvitation2($uid, $aid) { $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid and alliance = $aid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getAliInvitations($aid) { $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where alliance = $aid && accept = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function sendInvitation($uid, $alli, $sender) { $time = time(); $q = "INSERT INTO " . TB_PREFIX . "ali_invite values (0,$uid,$alli,$sender,$time,0)"; - return mysqli_query($q, $this->connection) or die(mysql_error()); + return mysqli_query($this->dblink,$q) or die(mysqli_error()); } function removeInvitation($id) { $q = "DELETE FROM " . TB_PREFIX . "ali_invite where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function sendMessage($client, $owner, $topic, $message, $send, $alliance, $player, $coor, $report) { $time = time(); $q = "INSERT INTO " . TB_PREFIX . "mdata values (0,$client,$owner,'$topic',\"$message\",0,0,$send,$time,0,0,$alliance,$player,$coor,$report)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function setArchived($id) { $q = "UPDATE " . TB_PREFIX . "mdata set archived = 1 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function setNorm($id) { $q = "UPDATE " . TB_PREFIX . "mdata set archived = 0 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /*************************** @@ -1835,49 +1840,49 @@ class MYSQLi_DB { break; } if($mode <= 3 || $mode == 6 || $mode > 8) { - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } else { - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } } function getDelSent($uid) { $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $uid and delowner = 1 ORDER BY time DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getDelInbox($uid) { $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and deltarget = 1 ORDER BY time DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getDelArchive($uid) { $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and archived = 1 and deltarget = 1 OR owner = $uid and archived = 1 and delowner = 1 ORDER BY time DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function unarchiveNotice($id) { $q = "UPDATE " . TB_PREFIX . "ndata set ntype = archive, archive = 0 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function archiveNotice($id) { $q = "update " . TB_PREFIX . "ndata set archive = ntype, ntype = 9 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeNotice($id) { $q = "UPDATE " . TB_PREFIX . "ndata set del = 1,viewed = 1 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function noticeViewed($id) { $q = "UPDATE " . TB_PREFIX . "ndata set viewed = 1 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addNotice($uid, $toWref, $ally, $type, $topic, $data, $time = 0) { @@ -1885,62 +1890,62 @@ class MYSQLi_DB { $time = time(); } $q = "INSERT INTO " . TB_PREFIX . "ndata (id, uid, toWref, ally, topic, ntype, data, time, viewed) values (0,'$uid','$toWref','$ally','$topic',$type,'$data',$time,0)"; - return mysqli_query($q, $this->connection) or die(mysql_error()); + return mysqli_query($this->dblink,$q) or die(mysqli_error()); } function getNotice($uid) { $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getNotice2($id, $field) { $q = "SELECT ".$field." FROM " . TB_PREFIX . "ndata where `id` = '$id'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; } function getNotice3($uid) { $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getNotice4($id) { $q = "SELECT * FROM " . TB_PREFIX . "ndata where id = $id ORDER BY time DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getUnViewNotice($uid) { $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid AND viewed=0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) { $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid.""; - mysqli_query($x, $this->connection); + mysqli_query($x, $this->dblink); $timeleft = time()+604800; $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getTradeRoute($uid) { $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getTradeRoute2($id) { $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray; } function getTradeRouteUid($id) { $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['uid']; } @@ -1951,19 +1956,19 @@ class MYSQLi_DB { }else{ $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function deleteTradeRoute($id) { $q = "DELETE FROM " . TB_PREFIX . "route where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addBuilding($wid, $field, $type, $loop, $time, $master, $level) { $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid; - mysqli_query($x, $this->connection) or die(mysql_error()); + mysqli_query($this->dblink,$x) or die(mysqli_error()); $q = "INSERT into " . TB_PREFIX . "bdata values (0,$wid,$field,$type,$loop,$time,$master,$level)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeBuilding($d) { @@ -2020,7 +2025,7 @@ class MYSQLi_DB { $time = $uprequire['time']; $timestamp = $time+time(); $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[1]['id'].""; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } }else if($SameBuildCount == 6){ if($jobDeleted == 0){ @@ -2028,7 +2033,7 @@ class MYSQLi_DB { $time = $uprequire['time']; $timestamp = $time+time(); $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } }else if($SameBuildCount == 7){ if($jobDeleted == 1){ @@ -2036,7 +2041,7 @@ class MYSQLi_DB { $time = $uprequire['time']; $timestamp = $time+time(); $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } } if($SameBuildCount < 8){ @@ -2044,28 +2049,28 @@ class MYSQLi_DB { $time1 = $uprequire1['time']; $timestamp1 = $time1; $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; - mysqli_query($q1, $this->connection); + mysqli_query($q1, $this->dblink); }else{ $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],1); $time1 = $uprequire1['time']; $timestamp1 = $time1; $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; - mysqli_query($q1, $this->connection); + mysqli_query($q1, $this->dblink); } }else if($d == $jobs[floor($SameBuildCount / 3)]['id'] || $d == $jobs[floor($SameBuildCount / 2) + 1]['id']) { $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=" . $jobs[floor($SameBuildCount / 3)]['timestamp'] . " WHERE master = 0 AND id > ".$d." and (ID=" . $jobs[floor($SameBuildCount / 3)]['id'] . " OR ID=" . $jobs[floor($SameBuildCount / 2) + 1]['id'] . ")"; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } } else { if($jobs[$jobDeleted]['field'] >= 19) { $x = "SELECT f" . $jobs[$jobDeleted]['field'] . " FROM " . TB_PREFIX . "fdata WHERE vref=" . $jobs[$jobDeleted]['wid']; - $result = mysqli_query($x, $this->connection) or die(mysql_error()); - $fieldlevel = mysql_fetch_row($result); + $result = mysqli_query($x, $this->dblink) or die(mysqli_error()); + $fieldlevel = mysqli_fetch_row($result); if($fieldlevel[0] == 0) { if ($village->natar==1 && $jobs[$jobDeleted]['field']==99) { //fix by ronix }else{ $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $jobs[$jobDeleted]['field'] . "t=0 WHERE vref=" . $jobs[$jobDeleted]['wid']; - mysqli_query($x, $this->connection) or die(mysql_error()); + mysqli_query($x, $this->dblink) or die(mysqli_error()); } } } @@ -2073,21 +2078,21 @@ class MYSQLi_DB { if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) { $uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']); $x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0"; - mysqli_query($x, $this->connection) or die(mysql_error()); + mysqli_query($x, $this->dblink) or die(mysqli_error()); } } } $q = "DELETE FROM " . TB_PREFIX . "bdata where id = $d"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addDemolition($wid, $field) { global $building, $village; $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid"; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0); $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($this->getFieldLevel($wid,$field)-1).",".(time()+floor($uprequire['time']/2)).")"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } @@ -2097,7 +2102,7 @@ class MYSQLi_DB { } else { $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE timetofinish<=" . time(); } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if(!empty($result)) { return $this->mysqli_fetch_all($result); } else { @@ -2107,18 +2112,18 @@ class MYSQLi_DB { function finishDemolition($wid) { $q = "UPDATE " . TB_PREFIX . "demolition SET timetofinish=" . time() . " WHERE vref=" . $wid; - $result= mysqli_query($q, $this->connection); - return mysql_affected_rows(); + $result= mysqli_query($this->dblink,$q); + return mysqli_affected_rows(); } function delDemolition($wid) { $q = "DELETE FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getJobs($wid) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -2136,7 +2141,7 @@ class MYSQLi_DB { $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 order by master,timestamp ASC"; } $result2 = mysqli_query($q2); - if(mysql_num_rows($result2) > 0){ + if(mysqli_num_rows($result2) > 0){ $dbarray2 = mysqli_fetch_array($result2); $wc_time = $dbarray['timestamp']; $q2 = "UPDATE ".TB_PREFIX."bdata SET timestamp = timestamp - $wc_time WHERE id = '".$dbarray2['id']."'"; @@ -2146,60 +2151,60 @@ class MYSQLi_DB { function getMasterJobs($wid) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getMasterJobsByField($wid,$field) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 1 order by master,timestamp ASC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getBuildingByField($wid,$field) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getBuildingByField2($wid,$field) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; - $result = mysqli_query($q, $this->connection); - return mysql_num_rows($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_num_rows($result); } function getBuildingByType($wid,$type) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getBuildingByType2($wid,$type) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; - $result = mysqli_query($q, $this->connection); - return mysql_num_rows($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_num_rows($result); } function getDorf1Building($wid) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field < 19 and master = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getDorf2Building($wid) { $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field > 18 and master = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function updateBuildingWithMaster($id, $time,$loop) { $q = "UPDATE " . TB_PREFIX . "bdata SET master = 0, timestamp = ".$time.",loopcon = ".$loop." WHERE id = ".$id.""; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getVillageByName($name) { $q = "SELECT wref FROM " . TB_PREFIX . "vdata where name = '$name' limit 1"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); return $dbarray['wref']; } @@ -2210,7 +2215,7 @@ class MYSQLi_DB { ***************************/ function setMarketAcc($id) { $q = "UPDATE " . TB_PREFIX . "market set accept = 1 where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /*************************** @@ -2222,11 +2227,11 @@ class MYSQLi_DB { function sendResource($ref, $clay, $iron, $crop, $merchant, $mode) { if(!$mode) { $q = "INSERT INTO " . TB_PREFIX . "send values (0,$ref,$clay,$iron,$crop,$merchant)"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } else { $q = "DELETE FROM " . TB_PREFIX . "send where id = $ref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } } @@ -2240,19 +2245,19 @@ class MYSQLi_DB { //Xtype (1) = wood, (2) = clay, (3) = iron, (4) = crop if($gtype == 1) { $q = "UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + '$gamt' WHERE wref = $vref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } else if($gtype == 2) { $q = "UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` + '$gamt' WHERE wref = $vref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } else if($gtype == 3) { $q = "UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` + '$gamt' WHERE wref = $vref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } else if($gtype == 4) { $q = "UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` + '$gamt' WHERE wref = $vref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } } @@ -2264,15 +2269,15 @@ class MYSQLi_DB { function getMarketField($vref, $field) { $q = "SELECT $field FROM " . TB_PREFIX . "market where vref = '$vref'"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray[$field]; } function removeAcceptedOffer($id) { $q = "DELETE FROM " . TB_PREFIX . "market where id = $id"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } /*************************** @@ -2284,11 +2289,11 @@ class MYSQLi_DB { function addMarket($vid, $gtype, $gamt, $wtype, $wamt, $time, $alliance, $merchant, $mode) { if(!$mode) { $q = "INSERT INTO " . TB_PREFIX . "market values (0,$vid,$gtype,$gamt,$wtype,$wamt,0,$time,$alliance,$merchant)"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } else { $q = "DELETE FROM " . TB_PREFIX . "market where id = $gtype and vref = $vid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } } @@ -2303,7 +2308,7 @@ class MYSQLi_DB { } else { $q = "SELECT * FROM " . TB_PREFIX . "market where vref != $vid and alliance = $alliance or vref != $vid and alliance = 0 and accept = 0"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -2313,13 +2318,13 @@ class MYSQLi_DB { ***************************/ function getMarketInfo($id) { $q = "SELECT * FROM " . TB_PREFIX . "market where id = $id"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function setMovementProc($moveid) { $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where moveid = $moveid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /*************************** @@ -2328,15 +2333,15 @@ class MYSQLi_DB { ***************************/ function totalMerchantUsed($vid) { $time = time(); - $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = $vid and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); - $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = $vid and proc = 0"; - $result2 = mysqli_query($q2, $this->connection); - $row2 = mysql_fetch_row($result2); + $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = '$vid' and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = '$vid' and proc = 0"; + $result2 = mysqli_query($this->dblink,$q2); + $row2 = mysqli_fetch_row($result2); $q3 = "SELECT sum(merchant) from " . TB_PREFIX . "market where vref = $vid and accept = 0"; - $result3 = mysqli_query($q3, $this->connection); - $row3 = mysql_fetch_row($result3); + $result3 = mysqli_query($this->dblink,$q3); + $row3 = mysqli_fetch_row($result3); return $row[0] + $row2[0] + $row3[0]; } @@ -2349,53 +2354,55 @@ class MYSQLi_DB { } switch($type) { case 0: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC"; break; case 1: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC"; break; case 2: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC"; break; case 3: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; break; case 4: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; break; case 5: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 5 and proc = 0 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 5 and proc = 0 ORDER BY endtime ASC"; break; case 6: - $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = $village and " . TB_PREFIX . "movement.to = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = '$village' and " . TB_PREFIX . "movement.to = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; //$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; break; case 7: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC"; break; case 8: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; break; case 34: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; break; + default: + return null; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $array = $this->mysqli_fetch_all($result); return $array; } function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) { $q = "INSERT INTO " . TB_PREFIX . "a2b (ckey,time_check,to_vid,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,type) VALUES ('$ckey', '$timestamp', '$to', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10', '$t11', '$type')"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function getA2b($ckey, $check) { $q = "SELECT * from " . TB_PREFIX . "a2b where ckey = '" . $ckey . "' AND time_check = '" . $check . "'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if($result) { - return mysql_fetch_assoc($result); + return mysqli_fetch_assoc($result); } else { return false; } @@ -2403,90 +2410,90 @@ class MYSQLi_DB { function addMovement($type, $from, $to, $ref, $time, $endtime, $send = 1, $wood = 0, $clay = 0, $iron = 0, $crop = 0, $ref2 = 0) { $q = "INSERT INTO " . TB_PREFIX . "movement values (0,$type,$from,$to,$ref,$ref2,$time,$endtime,0,$send,$wood,$clay,$iron,$crop)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addAttack($vid, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type, $ctar1, $ctar2, $spy,$b1=0,$b2=0,$b3=0,$b4=0,$b5=0,$b6=0,$b7=0,$b8=0) { $q = "INSERT INTO " . TB_PREFIX . "attacks values (0,$vid,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$type,$ctar1,$ctar2,$spy,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8)"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function modifyAttack($aid, $unit, $amt) { $unit = 't' . $unit; $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit - $amt where id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function modifyAttack2($aid, $unit, $amt) { $unit = 't' . $unit; $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit + $amt where id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function modifyAttack3($aid, $units) { $q = "UPDATE ".TB_PREFIX."attacks set $units WHERE id = $aid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getRanking() { $q = "SELECT id,username,alliance,ap,apall,dp,dpall,access FROM " . TB_PREFIX . "users WHERE tribe<=3 AND access<" . (INCLUDE_ADMIN ? "10" : "8"); - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getVRanking() { $q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe<=3 AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8"); - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getARanking() { $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getUserByTribe($tribe){ $q = "SELECT * FROM " . TB_PREFIX . "users where tribe = $tribe"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getUserByAlliance($aid){ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getHeroRanking() { $q = "SELECT * FROM " . TB_PREFIX . "hero WHERE dead = 0"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getAllMember($aid) { $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getAllMember2($aid) { $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function addUnits($vid) { $q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getUnit($vid) { $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if (!empty($result)) { - return mysql_fetch_assoc($result); + return mysqli_fetch_assoc($result); } else { return NULL; } @@ -2494,8 +2501,8 @@ class MYSQLi_DB { function getUnitsNumber($vid) { $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; - $result = mysqli_query($q, $this->connection); - $dbarray = mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_assoc($result); $totalunits = 0; $movingunits = $this->getVillageMovement($vid); for($i=1;$i<=50;$i++){ @@ -2525,7 +2532,7 @@ class MYSQLi_DB { } else { $q = "SELECT * FROM ".TB_PREFIX."hero WHERE dead=0 AND uid=$uid LIMIT 1"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); if (!empty($result)) { return $this->mysqli_fetch_all($result); } else { @@ -2535,7 +2542,7 @@ class MYSQLi_DB { function getHeroField($uid,$field){ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid"; - $result = mysqli_query($q,$this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -2547,7 +2554,7 @@ class MYSQLi_DB { } else { $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE heroid = $heroid"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function modifyHeroByOwner($column,$value,$uid,$mode=0) { @@ -2558,64 +2565,64 @@ class MYSQLi_DB { } else { $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE uid = $uid"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function modifyHeroXp($column,$value,$heroid) { $q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addTech($vid) { $q = "INSERT into " . TB_PREFIX . "tdata (vref) values ($vid)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addABTech($vid) { $q = "INSERT into " . TB_PREFIX . "abdata (vref) values ($vid)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getABTech($vid) { $q = "SELECT * FROM " . TB_PREFIX . "abdata where vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function addResearch($vid, $tech, $time) { $q = "INSERT into " . TB_PREFIX . "research values (0,$vid,'$tech',$time)"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getResearching($vid) { $q = "SELECT * FROM " . TB_PREFIX . "research where vref = $vid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function checkIfResearched($vref, $unit) { $q = "SELECT $unit FROM " . TB_PREFIX . "tdata WHERE vref = $vref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray[$unit]; } function getTech($vid) { $q = "SELECT * from " . TB_PREFIX . "tdata where vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function getTraining($vid) { $q = "SELECT * FROM " . TB_PREFIX . "training where vref = $vid ORDER BY id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function countTraining($vid) { $q = "SELECT * FROM " . TB_PREFIX . "training WHERE vref = $vid"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } @@ -2698,12 +2705,12 @@ class MYSQLi_DB { } else { $q = "DELETE FROM " . TB_PREFIX . "training where id = $vid"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function updateTraining($id, $trained, $each) { $q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function modifyUnit($vref, $array_unit, $array_amt, $array_mode){ @@ -2724,13 +2731,13 @@ class MYSQLi_DB { $units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.$array_amt[$i].(($number > $i+1) ? ', ' : ''); } $q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getEnforce($vid, $from) { $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function getOasisEnforce($ref, $mode=0) { @@ -2739,7 +2746,7 @@ class MYSQLi_DB { }else{ $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($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -2749,20 +2756,20 @@ class MYSQLi_DB { }else{ $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($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function getEnforceControllTroops($vid) { $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $vid"; - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function addEnforce($data) { $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; - mysqli_query($q, $this->connection); - $id = mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + $id = mysqli_insert_id($this->dblink); $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); $start = ($owntribe - 1) * 10 + 1; $end = ($owntribe * 10); @@ -2773,13 +2780,13 @@ class MYSQLi_DB { $j++; } $this->modifyEnforce($id,'hero',$data['t11'],1); - return mysql_insert_id($this->connection); + return mysqli_insert_id($this->dblink); } function addEnforce2($data,$tribe,$dead1,$dead2,$dead3,$dead4,$dead5,$dead6,$dead7,$dead8,$dead9,$dead10,$dead11) { $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; - mysqli_query($q, $this->connection); - $id = mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + $id = mysqli_insert_id($this->dblink); $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); $start = ($owntribe - 1) * 10 + 1; $end = ($owntribe * 10); @@ -2798,7 +2805,7 @@ class MYSQLi_DB { } $this->modifyEnforce($id,'hero',$data['t11'],1); $this->modifyEnforce($id,'hero',$dead11,0); - return mysql_insert_id($this->connection); + return mysqli_insert_id($this->dblink); } function modifyEnforce($id, $unit, $amt, $mode) { @@ -2808,7 +2815,7 @@ class MYSQLi_DB { } else { $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit + $amt where id = $id"; } - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } function getEnforceArray($id, $mode) { @@ -2817,8 +2824,8 @@ class MYSQLi_DB { } else { $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; } - $result = mysqli_query($q, $this->connection); - return mysql_fetch_assoc($result); + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); } function getEnforceVillage($id, $mode) { @@ -2827,7 +2834,7 @@ class MYSQLi_DB { } else { $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -2873,8 +2880,8 @@ class MYSQLi_DB { function getWW() { $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -2888,7 +2895,7 @@ class MYSQLi_DB { function getWWLevel($vref) { $q = "SELECT f99 FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['f99']; } @@ -2900,7 +2907,7 @@ class MYSQLi_DB { function getWWOwnerID($vref) { $q = "SELECT owner FROM " . TB_PREFIX . "vdata WHERE wref = $vref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['owner']; } @@ -2912,7 +2919,7 @@ class MYSQLi_DB { function getUserAllianceID($id) { $q = "SELECT alliance FROM " . TB_PREFIX . "users where id = $id"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['alliance']; } @@ -2924,7 +2931,7 @@ class MYSQLi_DB { function getWWName($vref) { $q = "SELECT wwname FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['wwname']; } @@ -2936,80 +2943,80 @@ class MYSQLi_DB { function submitWWname($vref, $name) { $q = "UPDATE " . TB_PREFIX . "fdata SET `wwname` = '$name' WHERE " . TB_PREFIX . "fdata.`vref` = $vref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } //medal functions function addclimberpop($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc + '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addclimberrankpop($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set clp = clp + '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeclimberrankpop($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set clp = clp - '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function setclimberrankpop($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set clp = '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function updateoldrank($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set oldrank = '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeclimberpop($user, $cp) { $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc - '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } // ALLIANCE MEDAL FUNCTIONS function addclimberpopAlly($user, $cp) { $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc + '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addclimberrankpopAlly($user, $cp) { $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp + '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeclimberrankpopAlly($user, $cp) { $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp - '$cp'' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function updateoldrankAlly($user, $cp) { $q = "UPDATE " . TB_PREFIX . "alidata set oldrank = '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeclimberpopAlly($user, $cp) { $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc - '$cp' where id = $user"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getTrainingList() { $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getNeedDelete() { $time = time(); $q = "SELECT uid FROM " . TB_PREFIX . "deleting where timestamp < $time"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function countUser() { $q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } function countAlli() { $q = "SELECT count(id) FROM " . TB_PREFIX . "alidata where id != 0"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); return $row[0]; } @@ -3020,7 +3027,7 @@ class MYSQLi_DB { function mysqli_fetch_all($result) { $all = array(); if($result) { - while($row = mysql_fetch_assoc($result)) { + while($row = mysqli_fetch_assoc($result)) { $all[] = $row; } return $all; @@ -3028,7 +3035,7 @@ class MYSQLi_DB { } function query_return($q) { - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } @@ -3037,7 +3044,7 @@ class MYSQLi_DB { References: Query ***************************/ function query($query) { - return mysqli_query($query, $this->connection); + return mysqli_query($this->dblink,$query); } function RemoveXSS($val) { @@ -3047,43 +3054,43 @@ class MYSQLi_DB { //MARKET FIXES function getWoodAvailable($wref) { $q = "SELECT wood FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['wood']; } function getClayAvailable($wref) { $q = "SELECT clay FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['clay']; } function getIronAvailable($wref) { $q = "SELECT iron FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['iron']; } function getCropAvailable($wref) { $q = "SELECT crop FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); return $dbarray['crop']; } function Getowner($vid) { $s = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = $vid"; - $result1 = mysqli_query($s, $this->connection); - $row1 = mysql_fetch_row($result1); + $result1 = mysqli_query($s, $this->dblink); + $row1 = mysqli_fetch_row($result1); return $row1[0]; } public function debug($time, $uid, $debug_info) { $q = "INSERT INTO " . TB_PREFIX . "debug_info (time,uid,debug_info) VALUES ($time,$uid,$debug_info)"; - if(mysqli_query($q, $this->connection)) { - return mysql_insert_id($this->connection); + if(mysqli_query($this->dblink,$q)) { + return mysqli_insert_id($this->dblink); } else { return false; } @@ -3091,7 +3098,7 @@ class MYSQLi_DB { function populateOasisdata() { $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result2 = mysqli_query($q2, $this->connection); + $result2 = mysqli_query($q2, $this->dblink); while($row = mysqli_fetch_array($result2)) { $wid = $row['id']; $basearray = $this->getOMInfo($wid); @@ -3104,15 +3111,15 @@ class MYSQLi_DB { } //We switch type of oasis and instert record with apropriate infomation. $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . "," . time() . ",100,2,'Unoccupied Oasis',".$high.")"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); } } 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 = $village->wid"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); $maxslots = $row[0]; $residence = $building->getTypeLevel(25); $palace = $building->getTypeLevel(26); @@ -3124,12 +3131,12 @@ class MYSQLi_DB { } $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "units WHERE vref = $village->wid"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $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 = $village->wid"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); $chiefs = $row[0]; $settlers += 3 * count($this->getMovement(5, $village->wid, 0)); @@ -3162,16 +3169,16 @@ class MYSQLi_DB { } } $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); if(!empty($row)) { foreach($row as $reinf) { $settlers += $reinf[0]; } } $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; - $result = mysqli_query($q, $this->connection); - $row = mysql_fetch_row($result); + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); if(!empty($row)) { foreach($row as $reinf) { $chiefs += $reinf[0]; @@ -3202,42 +3209,42 @@ class MYSQLi_DB { function addArtefact($vref, $owner, $type, $size, $name, $desc, $effect, $img) { $q = "INSERT INTO `" . TB_PREFIX . "artefacts` (`vref`, `owner`, `type`, `size`, `conquered`, `name`, `desc`, `effect`, `img`, `active`) VALUES ('$vref', '$owner', '$type', '$size', '" . time() . "', '$name', '$desc', '$effect', '$img', '0')"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getOwnArtefactInfo($vref) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function getOwnArtefactInfo2($vref) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getOwnArtefactInfo3($uid) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $uid"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getOwnArtefactInfoByType($vref, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type order by size"; - $result = mysqli_query($q, $this->connection); + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = '$vref' AND type = '$type' order by size"; + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function getOwnArtefactInfoByType2($vref, $type) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getOwnUniqueArtefactInfo($id, $type, $size) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } @@ -3247,20 +3254,20 @@ class MYSQLi_DB { }else{ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND active = 1 AND type = $type AND size=$size"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getFoolArtefactInfo($type,$vid,$uid) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function claimArtefact($vref, $ovref, $id) { $time = time(); $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time, active = 1 WHERE vref = $ovref"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } public function canClaimArtifact($from,$vref,$size,$type) { @@ -3279,7 +3286,7 @@ class MYSQLi_DB { SUM(IF(size = '2',1,0)) great, SUM(IF(size = '3',1,0)) `unique` FROM ".TB_PREFIX."artefacts WHERE owner = ".$uid; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $artifact= $this->mysqli_fetch_all($result); if($artifact['totals'] < 3 || $type==11) { @@ -3339,7 +3346,7 @@ class MYSQLi_DB { function getArtefactDetails($id) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . ""; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } @@ -3352,17 +3359,17 @@ class MYSQLi_DB { function getLinks($id){ $q = 'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . $id . ' ORDER BY `pos` ASC'; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function removeLinks($id,$uid){ $q = "DELETE FROM " . TB_PREFIX . "links WHERE `id` = ".$id." and `userid` = ".$uid.""; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getVilFarmlist($wref){ $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC'; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if($dbarray['id']!=0) { @@ -3375,56 +3382,56 @@ class MYSQLi_DB { function getRaidList($id) { $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id.""; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function delFarmList($id, $owner) { $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function delSlotFarm($id) { $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function createFarmList($wref, $owner, $name) { $q = "INSERT INTO " . TB_PREFIX . "farmlist (`wref`, `owner`, `name`) VALUES ('$wref', '$owner', '$name')"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { $q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function getArrayMemberVillage($uid){ $q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC'; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $array = $this->mysqli_fetch_all($result); return $array; } function addPassword($uid, $npw, $cpw){ $q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')"; - mysqli_query($q, $this->connection) or die(mysql_error()); + mysqli_query($this->dblink,$q) or die(mysqli_error()); } function resetPassword($uid, $cpw){ $q = "SELECT npw FROM `" . TB_PREFIX . "password` WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; - $result = mysqli_query($q, $this->connection) or die(mysql_error()); + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); $dbarray = mysqli_fetch_array($result); if(!empty($dbarray)) { if(!$this->updateUserField($uid, 'password', md5($dbarray['npw']), 1)) return false; $q = "UPDATE `" . TB_PREFIX . "password` SET used = 1 WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; - mysqli_query($q, $this->connection) or die(mysql_error()); + mysqli_query($this->dblink,$q) or die(mysqli_error()); return true; } @@ -3505,7 +3512,7 @@ class MYSQLi_DB { function addGeneralAttack($casualties) { $time = time(); $q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)"; - return mysqli_query($q, $this->connection) or die(mysql_error()); + return mysqli_query($this->dblink,$q) or die(mysqli_error()); } function getAttackByDate($time) { @@ -3536,12 +3543,12 @@ class MYSQLi_DB { function addFriend($uid, $column, $friend) { $q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function deleteFriend($uid, $column) { $q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid"; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function checkFriends($uid) { @@ -3572,18 +3579,18 @@ class MYSQLi_DB { }else{ $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid"; } - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } function addPrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { $q = "INSERT INTO " . TB_PREFIX . "prisoners values (0,$wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11)"; - mysqli_query($q, $this->connection); - return mysql_insert_id($this->connection); + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); } function updatePrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { $q = "UPDATE " . TB_PREFIX . "prisoners set t1 = t1 + $t1, t2 = t2 + $t2, t3 = t3 + $t3, t4 = t4 + $t4, t5 = t5 + $t5, t6 = t6 + $t6, t7 = t7 + $t7, t8 = t8 + $t8, t9 = t9 + $t9, t10 = t10 + $t10, t11 = t11 + $t11 where wref = $wid and ".TB_PREFIX."prisoners.from = $from"; - return mysqli_query($q, $this->connection) or die(mysql_error()); + return mysqli_query($this->dblink,$q) or die(mysqli_error()); } function getPrisoners($wid,$mode=0) { @@ -3592,31 +3599,31 @@ class MYSQLi_DB { }else { $q = "SELECT * FROM " . TB_PREFIX . "prisoners where `from` = $wid"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getPrisoners2($wid,$from) { $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function getPrisonersByID($id) { $q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } function getPrisoners3($from) { $q = "SELECT * FROM " . TB_PREFIX . "prisoners where " . TB_PREFIX . "prisoners.from = $from"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } function deletePrisoners($id) { $q = "DELETE from " . TB_PREFIX . "prisoners where id = '$id'"; - mysqli_query($q, $this->connection); + mysqli_query($this->dblink,$q); } /***************************************** @@ -3628,25 +3635,25 @@ References: $days1 =60*60*24*$days; $time =time()+$days1; $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '1' , vac_time=".$time." WHERE id=".$uid.""; - $result =mysqli_query($q,$this->connection); + $result =mysqli_query($this->dblink,$q); } function removevacationmode($uid){ $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '0' , vac_time='0' WHERE id=".$uid.""; - $result =mysqli_query($q,$this->connection); + $result =mysqli_query($this->dblink,$q); } function getvacmodexy($wref){ $q = "SELECT id,oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); if($dbarray['occupied'] != 0 && $dbarray['oasistype'] == 0) { $q1 = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = ".$dbarray['id'].""; - $result1 = mysqli_query($q1, $this->connection); + $result1 = mysqli_query($q1, $this->dblink); $dbarray1 = mysqli_fetch_array($result1); if($dbarray1['owner'] != 0){ $q2 = "SELECT vac_mode,vac_time FROM " . TB_PREFIX . "users where id = ".$dbarray1['owner'].""; - $result2 = mysqli_query($q2, $this->connection); + $result2 = mysqli_query($q2, $this->dblink); $dbarray2 = mysqli_fetch_array($result2); if($dbarray2['vac_mode'] ==1){ return true; @@ -3671,7 +3678,7 @@ References: function getHeroDead($id) { $q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $notend= mysqli_fetch_array($result); return $notend['dead']; } @@ -3683,7 +3690,7 @@ References: function getHeroInRevive($id) { $q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $notend= mysqli_fetch_array($result); return $notend['inrevive']; } @@ -3695,7 +3702,7 @@ References: function getHeroInTraining($id) { $q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->dblink,$q); $notend= mysqli_fetch_array($result); return $notend['intraining']; } @@ -3731,7 +3738,7 @@ References: function KillMyHero($id) { $q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id; - return mysqli_query($q, $this->connection); + return mysqli_query($this->dblink,$q); } /*************************** @@ -3823,8 +3830,8 @@ References: function checkAttack($wref, $toWref){ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and (" . TB_PREFIX . "attacks.attack_type = 3 or " . TB_PREFIX . "attacks.attack_type = 4) ORDER BY endtime ASC"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; } else { return false; @@ -3838,8 +3845,8 @@ References: function checkEnforce($wref, $toWref) { $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 2 ORDER BY endtime ASC"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; }else{ return false; @@ -3853,8 +3860,8 @@ References: function checkScout($wref, $toWref) { $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; - $result = mysqli_query($q, $this->connection); - if(mysql_num_rows($result)) { + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { return true; }else{ return false; @@ -3862,7 +3869,8 @@ References: } }; - $database = new MYSQLi_DB; - +$link = $database->return_link(); +$GLOBALS['db'] = $database; +$GLOBALS['link'] = $database->return_link(); ?> diff --git a/GameEngine/Protection.php b/GameEngine/Protection.php index 0d4fac97..3e89a199 100755 --- a/GameEngine/Protection.php +++ b/GameEngine/Protection.php @@ -13,14 +13,14 @@ //heef npc uitzondering omdat die met speciaal $_post werken if(isset($_POST)){ if(!isset($_POST['ft'])){ - $_POST = @array_map('mysql_real_escape_string', $_POST); + //$_POST = @array_map('mysqli_real_escape_string', $_POST); $_POST = array_map('htmlspecialchars', $_POST); } } $rsargs=$_GET['rsargs']; -$_GET = array_map('mysql_real_escape_string', $_GET); +//$_GET = array_map('mysqli_real_escape_string', $_GET); $_GET = array_map('htmlspecialchars', $_GET); $_GET['rsargs']=$rsargs; -$_COOKIE = array_map('mysql_real_escape_string', $_COOKIE); +//$_COOKIE = array_map('mysqli_real_escape_string', $_COOKIE); $_COOKIE = array_map('htmlspecialchars', $_COOKIE); ?> \ No newline at end of file diff --git a/GameEngine/Ranking.php b/GameEngine/Ranking.php index b5cd3ad2..5ce47d57 100755 --- a/GameEngine/Ranking.php +++ b/GameEngine/Ranking.php @@ -19,25 +19,24 @@ } public function getUserRank($id) { - $ranking = $this->getRank(); - $users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . ""; - $users2 = mysql_num_rows(mysql_query($users)); - $users3 = $users2+1; - if(count($ranking) > 0) { - for($i=0;$i<($users3);$i++) { - if( isset( $ranking[$i]['userid'] ) ) - { - if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") { - $myrank = $i; + $ranking = $this->getRank(); + $users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . ""; + $users2 = mysqli_num_rows(mysqli_query($GLOBALS['link'],$users)); + $users3 = $users2+1; + if(count($ranking) > 0) { + for($i=0;$i<($users3);$i++) { + if( isset( $ranking[$i]['userid'] ) ) { + if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") { + $myrank = $i; + } + } } } - } - } return $myrank; } public function procRankReq($get) { - global $village, $session, $database; + global $village, $session; if(isset($get['id'])) { switch($get['id']) { case 1: @@ -219,55 +218,55 @@ } public function procRankArray() { - global $database, $multisort; - if($database->countUser() > 0){ - $holder = array(); - if(SHOW_NATARS == True){ - $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.oldrank oldrank, " . TB_PREFIX . "users.alliance alliance, ( + global $multisort; + if($GLOBALS['db']->countUser() > 0){ + $holder = array(); + if(SHOW_NATARS == True){ + $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.oldrank oldrank, " . TB_PREFIX . "users.alliance alliance, ( - SELECT SUM( " . TB_PREFIX . "vdata.pop ) - FROM " . TB_PREFIX . "vdata - WHERE " . TB_PREFIX . "vdata.owner = userid - )totalpop, ( + SELECT SUM( " . TB_PREFIX . "vdata.pop ) + FROM " . TB_PREFIX . "vdata + WHERE " . TB_PREFIX . "vdata.owner = userid + )totalpop, ( - SELECT COUNT( " . TB_PREFIX . "vdata.wref ) - FROM " . TB_PREFIX . "vdata - WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99 - )totalvillages, ( + SELECT COUNT( " . TB_PREFIX . "vdata.wref ) + FROM " . TB_PREFIX . "vdata + WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99 + )totalvillages, ( - SELECT " . TB_PREFIX . "alidata.tag - FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users - WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance - AND " . TB_PREFIX . "users.id = userid - )allitag - FROM " . TB_PREFIX . "users - WHERE " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " - AND " . TB_PREFIX . "users.tribe <= 5 ORDER BY totalpop DESC, totalvillages DESC, userid DESC"; - }else{ - $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.oldrank oldrank, " . TB_PREFIX . "users.alliance alliance, ( + SELECT " . TB_PREFIX . "alidata.tag + FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users + WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance + AND " . TB_PREFIX . "users.id = userid + )allitag + FROM " . TB_PREFIX . "users + WHERE " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " + AND " . TB_PREFIX . "users.tribe <= 5 ORDER BY totalpop DESC, totalvillages DESC, userid DESC"; + } else { + $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.oldrank oldrank, " . TB_PREFIX . "users.alliance alliance, ( - SELECT SUM( " . TB_PREFIX . "vdata.pop ) - FROM " . TB_PREFIX . "vdata - WHERE " . TB_PREFIX . "vdata.owner = userid - )totalpop, ( + SELECT SUM( " . TB_PREFIX . "vdata.pop ) + FROM " . TB_PREFIX . "vdata + WHERE " . TB_PREFIX . "vdata.owner = userid + )totalpop, ( - SELECT COUNT( " . TB_PREFIX . "vdata.wref ) - FROM " . TB_PREFIX . "vdata - WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99 - )totalvillages, ( + SELECT COUNT( " . TB_PREFIX . "vdata.wref ) + FROM " . TB_PREFIX . "vdata + WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99 + )totalvillages, ( - SELECT " . TB_PREFIX . "alidata.tag - FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users - WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance - AND " . TB_PREFIX . "users.id = userid - )allitag - FROM " . TB_PREFIX . "users - WHERE " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " - AND " . TB_PREFIX . "users.tribe <= 3 ORDER BY totalpop DESC, totalvillages DESC, userid DESC"; - } + SELECT " . TB_PREFIX . "alidata.tag + FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users + WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance + AND " . TB_PREFIX . "users.id = userid + )allitag + FROM " . TB_PREFIX . "users + WHERE " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " + AND " . TB_PREFIX . "users.tribe <= 3 ORDER BY totalpop DESC, totalvillages DESC, userid DESC"; + } - $result = (mysql_query($q)); - while($row = mysql_fetch_assoc($result)) { + $result = (mysqli_query($GLOBALS['link'],$q)); + while($row = mysqli_fetch_assoc($result)) { $datas[] = $row; } @@ -291,13 +290,13 @@ } public function procRankRaceArray($race) { - global $database, $multisort; - //$array = $database->getRanking(); + global $multisort; + //$array = $GLOBALS['db']->getRanking(); $holder = array(); - //$value['totalvillage'] = count($database->getVillagesID($value['id'])); - //$value['totalvillage'] = count($database->getVillagesID($value['id'])); - //$value['totalpop'] = $database->getVSumField($value['id'],"pop"); - //$value['aname'] = $database->getAllianceName($value['alliance']); + //$value['totalvillage'] = count($GLOBALS['db']->getVillagesID($value['id'])); + //$value['totalvillage'] = count($GLOBALS['db']->getVillagesID($value['id'])); + //$value['totalpop'] = $GLOBALS['db']->getVSumField($value['id'],"pop"); + //$value['aname'] = $GLOBALS['db']->getAllianceName($value['alliance']); $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.tribe tribe, " . TB_PREFIX . "users.username username," . TB_PREFIX . "users.alliance alliance, ( SELECT SUM( " . TB_PREFIX . "vdata.pop ) @@ -320,12 +319,12 @@ ORDER BY totalpop DESC, totalvillages DESC, userid DESC"; - $result = (mysql_query($q)); - while($row = mysql_fetch_assoc($result)) { + $result = (mysqli_query($GLOBALS['link'],$q)); + while($row = mysqli_fetch_assoc($result)) { $datas[] = $row; } - if(mysql_num_rows($result)) { + if(mysqli_num_rows($result)) { foreach($datas as $result) { @@ -356,12 +355,12 @@ } public function procAttRankArray() { - global $database, $multisort; - //$array = $database->getRanking(); + global $multisort; + //$array = $GLOBALS['db']->getRanking(); $holder = array(); - //$value['totalvillage'] = count($database->getVillagesID($value['id'])); - //$value['totalpop'] = $database->getVSumField($value['id'],"pop"); + //$value['totalvillage'] = count($GLOBALS['db']->getVillagesID($value['id'])); + //$value['totalpop'] = $GLOBALS['db']->getVSumField($value['id'],"pop"); $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.apall, ( SELECT COUNT( " . TB_PREFIX . "vdata.wref ) @@ -376,8 +375,8 @@ FROM " . TB_PREFIX . "users WHERE " . TB_PREFIX . "users.apall >=0 AND " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND " . TB_PREFIX . "users.tribe <= 3 ORDER BY " . TB_PREFIX . "users.apall DESC, pop DESC, userid DESC"; - $result = mysql_query($q) or die(mysql_error()); - while($row = mysql_Fetch_assoc($result)) { + $result = mysqli_query($GLOBALS['link'],$q) or die(mysqli_error()); + while($row = mysqli_Fetch_assoc($result)) { $datas[] = $row; } @@ -401,8 +400,8 @@ } public function procDefRankArray() { - //global $database, $multisort; - //$array = $database->getRanking(); + //global $GLOBALS['db'], $multisort; + //$array = $GLOBALS['db']->getRanking(); $holder = array(); $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.dpall, ( @@ -418,8 +417,8 @@ FROM " . TB_PREFIX . "users WHERE " . TB_PREFIX . "users.dpall >=0 AND " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND " . TB_PREFIX . "users.tribe <= 3 ORDER BY " . TB_PREFIX . "users.dpall DESC, pop DESC, userid DESC"; - $result = mysql_query($q) or die(mysql_error()); - while($row = mysql_Fetch_assoc($result)) { + $result = mysqli_query($GLOBALS['link'],$q) or die(mysqli_error()); + while($row = mysqli_Fetch_assoc($result)) { $datas[] = $row; } @@ -443,14 +442,14 @@ } public function procVRankArray() { - global $database, $multisort; - $array = $database->getVRanking(); + global $multisort; + $array = $GLOBALS['db']->getVRanking(); $holder = array(); foreach($array as $value) { - $coor = $database->getCoor($value['wref']); + $coor = $GLOBALS['db']->getCoor($value['wref']); $value['x'] = $coor['x']; $value['y'] = $coor['y']; - $value['user'] = $database->getUserField($value['owner'], "username", 0); + $value['user'] = $GLOBALS['db']->getUserField($value['owner'], "username", 0); array_push($holder, $value); } @@ -463,15 +462,15 @@ } public function procARankArray() { - global $database, $multisort; - $array = $database->getARanking(); + global $multisort; + $array = $GLOBALS['db']->getARanking(); $holder = array(); foreach($array as $value) { - $memberlist = $database->getAllMember($value['id']); + $memberlist = $GLOBALS['db']->getAllMember($value['id']); $totalpop = 0; foreach($memberlist as $member) { - $totalpop += $database->getVSumField($member['id'], "pop"); + $totalpop += $GLOBALS['db']->getVSumField($member['id'], "pop"); } $value['players'] = count($memberlist); $value['totalpop'] = $totalpop; @@ -492,11 +491,11 @@ } public function procHeroRankArray() { - global $database, $multisort; - $array = $database->getHeroRanking(); + global $multisort; + $array = $GLOBALS['db']->getHeroRanking(); $holder = array(); foreach($array as $value) { - $value['owner'] = $database->getUserField($value['uid'], "username", 0); + $value['owner'] = $GLOBALS['db']->getUserField($value['uid'], "username", 0); $value['level']; $value['name']; $value['uid']; @@ -512,11 +511,11 @@ } public function procAAttRankArray() { - global $database, $multisort; - $array = $database->getARanking(); + global $multisort; + $array = $GLOBALS['db']->getARanking(); $holder = array(); foreach($array as $value) { - $memberlist = $database->getAllMember($value['id']); + $memberlist = $GLOBALS['db']->getAllMember($value['id']); $totalap = 0; foreach($memberlist as $member) { $totalap += $member['ap']; @@ -540,11 +539,11 @@ } public function procADefRankArray() { - global $database, $multisort; - $array = $database->getARanking(); + global $multisort; + $array = $GLOBALS['db']->getARanking(); $holder = array(); foreach($array as $value) { - $memberlist = $database->getAllMember($value['id']); + $memberlist = $GLOBALS['db']->getAllMember($value['id']); $totaldp = 0; foreach($memberlist as $member) { $totaldp += $member['dp']; diff --git a/GameEngine/Session.php b/GameEngine/Session.php index fb5ab71b..2f53f787 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -60,7 +60,7 @@ class Session { private $userarray = array(); var $villages = array(); - function Session() { + function __construct() { global $database; //TienTN fix $this->time = time(); @@ -88,25 +88,25 @@ class Session { $_SESSION['checker'] = $generator->generateRandStr(3); $_SESSION['mchecker'] = $generator->generateRandStr(5); $_SESSION['qst'] = $database->getUserField($_SESSION['username'], "quest", 1); - $result = mysql_query("SELECT village_select FROM `". TB_PREFIX."users` WHERE `username`='".$_SESSION['username']."'"); - $dbarray = mysql_fetch_assoc($result); + $result = mysqli_query($link,"SELECT village_select FROM `". TB_PREFIX."users` WHERE `username`='".$_SESSION['username']."'"); + $dbarray = mysqli_fetch_assoc($result); $selected_village=$dbarray['village_select']; if(!isset($_SESSION['wid'])) { if($selected_village!='') { - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); + $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); }else{ - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); + $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); } - $data = mysql_fetch_assoc($query); + $data = mysqli_fetch_assoc($query); $_SESSION['wid'] = $data['wref']; } else if($_SESSION['wid'] == '') { if($selected_village!='') { - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); + $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); }else{ - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); + $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); } - $data = mysql_fetch_assoc($query); + $data = mysqli_fetch_assoc($query); $_SESSION['wid'] = $data['wref']; } $this->PopulateVar(); @@ -157,20 +157,23 @@ class Session { ***************************/ function CheckHeroReal () { - global $database; + global $database,$link; $hero=0; foreach($this->villages as $myvill){ $q1 = "SELECT SUM(hero) from " . TB_PREFIX . "enforcement where `from` = ".$myvill; // check if hero is send as reinforcement - $result1 = mysql_query($q1, $database->connection); - $he1=mysql_fetch_array($result1); - $hero+=$he1[0]; + $result1 = mysqli_query($link,$q1); + if(mysqli_num_rows($result1) != 0) { + $he1=mysqli_fetch_array($result1); + $hero+=$he1[0]; + } + $q2 = "SELECT SUM(hero) from " . TB_PREFIX . "units where `vref` = ".$myvill; // check if hero is on my account (all villages) - $result2 = mysql_query($q2, $database->connection); - $he2=mysql_fetch_array($result2); + $result2 = mysqli_query($link,$q2); + $he2=mysqli_fetch_array($result2); $hero+=$he2[0]; $q3 = "SELECT SUM(t11) from " . TB_PREFIX . "prisoners where `from` = ".$myvill; // check if hero is prisoner - $result3 = mysql_query($q3, $database->connection); - $he3=mysql_fetch_array($result3); + $result3 = mysqli_query($link,$q3); + $he3=mysqli_fetch_array($result3); $hero+=$he3[0]; $hero+=$database->HeroNotInVil($myvill); // check if hero is not in village (come back from attack , raid , etc.) } diff --git a/GameEngine/Technology.php b/GameEngine/Technology.php index 5756532f..8afa1530 100755 --- a/GameEngine/Technology.php +++ b/GameEngine/Technology.php @@ -148,13 +148,13 @@ class Technology { $controlloTruppeInRinforzo = $database->getEnforceControllTroops($village->wid); for($i=1;$i<=50;$i++) { if($controlloTruppeInRinforzo['u'.$i] >= "30000000") - mysql_query("UPDATE ".TB_PREFIX."enforcement set u".$i." = '0' where vref = $village->wid"); + mysqli_query("UPDATE ".TB_PREFIX."enforcement set u".$i." = '0' where vref = $village->wid"); } //FIX BY Shadow and made by NIKO28 $controlloTruppe = $database->getUnit($village->wid); for($i=1;$i<=50;$i++) { if($controlloTruppe['u'.$i] >= "10000000") - mysql_query("UPDATE ".TB_PREFIX."units set u".$i." = '0' where vref = $village->wid"); + mysqli_query("UPDATE ".TB_PREFIX."units set u".$i." = '0' where vref = $village->wid"); } */ // END FIX @@ -182,7 +182,7 @@ class Technology { global $village,$$unit; $unitarray = $$unit; $res = array(); - $res = mysql_fetch_assoc(mysql_query("SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".$village->wid)) or die(mysql_error()); + $res = mysqli_fetch_assoc(mysqli_query($GLOBALS['link'],"SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".$village->wid)) or die(mysqli_error()); 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'];} @@ -208,7 +208,7 @@ class Technology { global $village,$$unit; $unitarray = $$unit; $res = array(); - $res = mysql_fetch_assoc(mysql_query("SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".$village->wid)) or die(mysql_error()); + $res = mysqli_fetch_assoc(mysqli_query($GLOBALS['link'],"SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".$village->wid)) or die(mysqli_error()); $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); @@ -724,7 +724,7 @@ private function trainUnit($unit,$amt,$great=false) { global $database,$village; $q = "UPDATE ".TB_PREFIX."research SET timestamp=".(time()-1)." WHERE vref = ".$village->wid; $result = $database->query($q); - return mysql_affected_rows(); + return mysqli_affected_rows(); } public function calculateAvaliable($id,$resarray=array()) { diff --git a/GameEngine/Units.php b/GameEngine/Units.php index a913334d..dbde4da1 100755 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -354,13 +354,11 @@ class Units { if ($data['u11'] > $village->unitarray['hero']) { $form->addError("error","You can't send more units than you have"); - break; } if($data['u11']<0) { $form->addError("error","You can't send negative units."); - break; } if($form->returnErrors() > 0) { $_SESSION['errorarray'] = $form->getErrors(); @@ -566,13 +564,11 @@ if($session->access != BANNED){ if ($post['t11'] > $enforce['hero']) { $form->addError("error","You can't send more units than you have"); - break; } if($post['t11']<0) { $form->addError("error","You can't send negative units."); - break; } } else { $post['t11']='0'; diff --git a/Templates/Map/mapview.tpl b/Templates/Map/mapview.tpl index 09e2c8fe..19a5b213 100644 --- a/Templates/Map/mapview.tpl +++ b/Templates/Map/mapview.tpl @@ -111,7 +111,7 @@ $query2 = "SELECT //$query2; -$result2 = mysql_query($query2) or die(mysql_error()); +$result2 = mysqli_query($GLOBALS['link'],$query2) or die(mysqli_error()); $targetalliance = array(); $neutralarray = array(); @@ -129,7 +129,7 @@ $map_js =''; $map_gen=''; $map_content=''; -while ($donnees = mysql_fetch_assoc($result2)){ +while ($donnees = mysqli_fetch_assoc($result2)){ $targetalliance=$donnees["aliance_id"]; $friendarray=$database->getAllianceAlly($donnees["aliance_id"],1); diff --git a/Templates/Map/vilview.tpl b/Templates/Map/vilview.tpl index e81d48ca..97b312b1 100644 --- a/Templates/Map/vilview.tpl +++ b/Templates/Map/vilview.tpl @@ -2,8 +2,8 @@ getMInfo($_GET['d']); $uinfo = $database->getVillage($basearray['id']); -$oasis1 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'odata` WHERE `wref` = ' . mysql_real_escape_string($_GET['d'])); -$oasis = mysql_fetch_assoc($oasis1); +$oasis1 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'odata` WHERE `wref` = ' . mysqli_real_escape_string($GLOBALS['link'],$_GET['d'])); +$oasis = mysqli_fetch_assoc($oasis1); $access=$session->access; ?>

uid == $database->getVillage($_GET['d'])){ } $toWref = $_GET['d']; if($session->alliance!=0){ -$result = mysql_query("SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); -$query = mysql_num_rows($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$query = mysqli_num_rows($result); if($query != 0){ -while($row = mysql_fetch_array($result)){ +while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; @@ -183,10 +183,10 @@ if($type==18 or $type==19 or $type==20 or $type==21){ uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); -$query = mysql_num_rows($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."ndata WHERE uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$query = mysqli_num_rows($result); if($query != 0){ -while($row = mysql_fetch_array($result)){ +while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; @@ -258,10 +258,10 @@ if($session->uid == $database->getVillage($_GET['d'])){ } $toWref = $_GET['d']; if($session->alliance!=0){ -$result = mysql_query("SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); -$query = mysql_num_rows($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$query = mysqli_num_rows($result); if($query != 0){ -while($row = mysql_fetch_array($result)){ +while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; @@ -282,10 +282,10 @@ if($type==18 or $type==19 or $type==20 or $type==21){ uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); -$query = mysql_num_rows($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."ndata WHERE uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$query = mysqli_num_rows($result); if($query != 0){ -while($row = mysql_fetch_array($result)){ +while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; @@ -384,10 +384,10 @@ if($session->uid == $database->getVillage($_GET['d'])){ } $toWref = $_GET['d']; if($session->alliance!=0){ -$result = mysql_query("SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); -$query = mysql_num_rows($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$query = mysqli_num_rows($result); if($query != 0){ -while($row = mysql_fetch_array($result)){ +while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; @@ -408,10 +408,10 @@ if($type==18 or $type==19 or $type==20 or $type==21 or $type==22){ uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); -$query = mysql_num_rows($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."ndata WHERE $limit AND uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$query = mysqli_num_rows($result); if($query != 0){ -while($row = mysql_fetch_array($result)){ +while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; @@ -485,13 +485,13 @@ if($type==18 or $type==19 or $type==20 or $type==21){ getLinks($session->uid); -if (mysql_num_rows($query) > 0){ +$query = $database->getLinks($session->uid); +if (mysqli_num_rows($query) > 0){ $links = array(); -while($data = mysql_fetch_assoc($query)) { +while($data = mysqli_fetch_assoc($query)) { $links[] = $data; } diff --git a/index.php b/index.php index b2ed79bd..ebc41a59 100644 --- a/index.php +++ b/index.php @@ -124,8 +124,8 @@ include ("GameEngine/Lang/".LANG.".php"); @@ -139,8 +139,8 @@ include ("GameEngine/Lang/".LANG.".php"); @@ -155,8 +155,8 @@ include ("GameEngine/Lang/".LANG.".php"); diff --git a/install/data/constant_format.tpl b/install/data/constant_format.tpl index 942588b7..e3da2048 100755 --- a/install/data/constant_format.tpl +++ b/install/data/constant_format.tpl @@ -206,14 +206,6 @@ define("SQL_DB", "%SDB%"); // ***** Database - Table Prefix define("TB_PREFIX", "%PREFIX%"); -// ***** Database type -// 0 = MYSQL -// 1 = MYSQLi -// default: 1 -define("DB_TYPE", %CONNECTT%); - - - //////////////////////////////////// // **** EXTRA SETTINGS **** // //////////////////////////////////// diff --git a/install/include/database.php b/install/include/database.php index cc7ce341..55670d9a 100755 --- a/install/include/database.php +++ b/install/include/database.php @@ -17,39 +17,5 @@ class MYSQLi_DB { return mysqli_query($this->connection, $query); } }; -class MYSQL_DB { - var $connection; - function MYSQL_DB() { - $this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); - } - - function mysql_exec_batch ($p_query, $p_transaction_safe = true) { - if ($p_transaction_safe) { - $p_query = 'START TRANSACTION;' . $p_query . '; COMMIT;'; - }; - $query_split = preg_split ("/[;]+/", $p_query); - foreach ($query_split as $command_line) { - $command_line = trim($command_line); - if ($command_line != '') { - $query_result = mysql_query($command_line); - if ($query_result == 0) { - break; - }; - }; - }; - return $query_result; -} - - function query($query) { - return mysql_query($query, $this->connection); - } -}; - -if(DB_TYPE) { - $database = new MYSQLi_DB; -} -else { - $database = new MYSQL_DB; -} +$database = new MYSQLi_DB; ?> diff --git a/install/include/multihunter.php b/install/include/multihunter.php index 3fee7536..dd7bc8bd 100755 --- a/install/include/multihunter.php +++ b/install/include/multihunter.php @@ -6,12 +6,12 @@ $gameinstall = 1; include ("../../GameEngine/Admin/database.php"); include ("../../GameEngine/Lang/" . LANG . ".php"); - mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); - mysql_select_db(SQL_DB); + mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); + mysqli_select_db(SQL_DB); if(isset($_POST['mhpw'])) { $password = $_POST['mhpw']; - mysql_query("UPDATE " . TB_PREFIX . "users SET password = '" . md5($password) . "' WHERE username = 'Multihunter'"); + mysqli_query("UPDATE " . TB_PREFIX . "users SET password = '" . md5($password) . "' WHERE username = 'Multihunter'"); $wid = $admin->getWref(0, 0); $uid = 5; $status = $database->getVillageState($wid); diff --git a/install/include/oasis.php b/install/include/oasis.php index e5b9417c..82939353 100755 --- a/install/include/oasis.php +++ b/install/include/oasis.php @@ -8,8 +8,8 @@ include ("../../GameEngine/Admin/database.php"); - mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); - mysql_select_db(SQL_DB); + mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); + mysqli_select_db(SQL_DB); $database->populateOasisdata(); $database->populateOasis(); diff --git a/install/index.php b/install/index.php index 892ad921..ecfcf437 100755 --- a/install/index.php +++ b/install/index.php @@ -1,5 +1,4 @@ Error creating constant.php Password: DB name: Prefix: - Type: + Type:MYSQLi (MYSQL is deprecated)

From 2d26af7c46b464910f08ff72c7927b43091ddb76 Mon Sep 17 00:00:00 2001 From: evader1337 Date: Tue, 13 Sep 2016 18:54:25 +0200 Subject: [PATCH 03/73] Trying to fix this monstrosity #2 --- GameEngine/Account.php | 8 +- GameEngine/Alliance.php | 4 +- GameEngine/Battle.php | 30 +- GameEngine/Chat.php | 6 +- GameEngine/Database.php | 3874 ++++++++++++++++++++- GameEngine/Database/db_MYSQLi.php | 3876 ---------------------- GameEngine/Database/index.php | 19 - GameEngine/Message.php | 18 +- GameEngine/Profile.php | 2 +- GameEngine/Session.php | 16 +- GameEngine/Units.php | 30 +- Templates/Ajax/mapscroll.tpl | 8 +- Templates/Ajax/mapscroll2.tpl | 8 +- Templates/Ajax/quest_core.tpl | 8 +- Templates/Ajax/quest_core25.tpl | 8 +- Templates/Alliance/Forum/forum_2.tpl | 16 +- Templates/Alliance/attack-attacker.tpl | 6 +- Templates/Alliance/attack-defender.tpl | 6 +- Templates/Alliance/attacks.tpl | 6 +- Templates/Build/16_incomming.tpl | 4 +- Templates/Build/26.tpl | 28 +- Templates/Build/27_1.tpl | 10 +- Templates/Build/27_2.tpl | 38 +- Templates/Build/27_3.tpl | 62 +- Templates/Build/37.tpl | 10 +- Templates/Build/37_hero.tpl | 38 +- Templates/Build/37_revive.tpl | 10 +- Templates/Build/37_train.tpl | 216 +- Templates/Build/avaliable.tpl | 23 +- Templates/Map/mapviewlarge.tpl | 4 +- Templates/Message/inbox.tpl | 4 +- Templates/Message/sent.tpl | 4 +- Templates/News/newsbox1.tpl | 4 +- Templates/News/newsbox2.tpl | 2 +- Templates/Notice/all.tpl | 4 +- Templates/Plus/10.tpl | 28 +- Templates/Plus/11.tpl | 28 +- Templates/Plus/12.tpl | 28 +- Templates/Plus/13.tpl | 14 +- Templates/Plus/14.tpl | 24 +- Templates/Plus/15.tpl | 2 +- Templates/Plus/3.tpl | 48 +- Templates/Plus/8.tpl | 28 +- Templates/Plus/9.tpl | 28 +- Templates/Plus/getplus.tpl | 22 +- Templates/Profile/preference.tpl | 26 +- Templates/Ranking/ally_top10.tpl | 49 +- Templates/Ranking/general.tpl | 14 +- Templates/Ranking/player_top10.tpl | 42 +- Templates/Ranking/ww.tpl | 8 +- Templates/a2b/attack.tpl | 4 +- Templates/a2b/sendback_1.tpl | 4 +- Templates/a2b/sendback_2.tpl | 4 +- Templates/a2b/sendback_3.tpl | 4 +- Templates/a2b/sendback_4.tpl | 4 +- Templates/a2b/sendback_5.tpl | 4 +- Templates/a2b/startRaid.tpl | 2 +- Templates/goldClub/farmlist.tpl | 30 +- Templates/goldClub/farmlist_addraid.tpl | 6 +- Templates/goldClub/farmlist_editraid.tpl | 6 +- a2b.php | 6 +- a2b2.php | 54 +- allianz.php | 8 +- build.php | 6 +- create_account.php | 40 +- crop_finder.php | 12 +- massmessage.php | 12 +- statistiken.php | 64 +- winner.php | 30 +- 69 files changed, 4516 insertions(+), 4583 deletions(-) delete mode 100755 GameEngine/Database/db_MYSQLi.php delete mode 100755 GameEngine/Database/index.php diff --git a/GameEngine/Account.php b/GameEngine/Account.php index cce70708..d86b3b39 100755 --- a/GameEngine/Account.php +++ b/GameEngine/Account.php @@ -140,7 +140,7 @@ class Account { { global $database; $q = "SELECT * FROM ".TB_PREFIX."activate where act = '".$_POST['id']."'"; - $result = mysqli_query($q, $database->connection); + $result = mysqli_query($GLOBALS['link'],$q); $dbarray = mysqli_fetch_array($result); if($dbarray['act'] == $_POST['id']) { $uid = $database->register($dbarray['username'],$dbarray['password'],$dbarray['email'],$dbarray['tribe'],""); @@ -165,7 +165,7 @@ class Account { private function Unreg() { global $database; $q = "SELECT * FROM ".TB_PREFIX."activate where id = '".$_POST['id']."'"; - $result = mysqli_query($database->connection,$q); + $result = mysqli_query($GLOBALS['link'],$q); $dbarray = mysqli_fetch_array($result); if(md5($_POST['pw']) == $dbarray['password']) { $database->unreg($dbarray['username']); @@ -179,7 +179,7 @@ class Account { private function Login() { global $database,$session,$form; $user = $_POST['user']; - $user = mysqli_real_escape_string($link, $user); + $user = mysqli_real_escape_string($GLOBALS['link'], $user); if(!isset($_POST['user']) || $_POST['user'] == "") { $form->addError("user",$user); } @@ -225,7 +225,7 @@ class Account { global $session,$database; unset($_SESSION['wid']); $database->activeModify(addslashes($session->username),1); - $database->UpdateOnline("logout") or die(mysql_error()); + $database->UpdateOnline("logout") or die(mysqli_error()); $session->Logout(); } diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php index 63fdd1ba..9fd16bc6 100755 --- a/GameEngine/Alliance.php +++ b/GameEngine/Alliance.php @@ -454,8 +454,8 @@ private function updateMax($leader) { global $bid18, $database; - $q = mysql_query("SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader"); - if(mysql_num_rows($q) > 0){ + $q = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader"); + if(mysqli_num_rows($q) > 0){ $villages = $database->getVillagesID2($leader); $max = 0; foreach($villages as $village){ diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php index 89cb6dbd..35127e8b 100755 --- a/GameEngine/Battle.php +++ b/GameEngine/Battle.php @@ -652,8 +652,8 @@ class Battle { if (isset($units['Att_unit']['hero']) && $units['Att_unit']['hero'] >0){ - $_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$atkhero['heroid']."'"); - $fdb = mysql_fetch_array($_result); + $_result=mysqli_query($GLOBALS['link'],"select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$atkhero['heroid']."'"); + $fdb = mysqli_fetch_array($_result); $hero_id=$fdb['heroid']; $hero_health=$fdb['health']; $damage_health=round(100*$result[1]); @@ -661,10 +661,10 @@ class Battle { if ($hero_health<=$damage_health or $damage_health>90){ //hero die $result['casualties_attacker']['11'] = 1; - mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'"); - mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'"); }else{ - mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'"); } } unset($_result,$fdb,$hero_id,$hero_health,$damage_health); @@ -672,19 +672,19 @@ class Battle { if (isset($units['Def_unit']['hero']) && $units['Def_unit']['hero'] >0){ - $_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$defenderhero['heroid']."'"); - $fdb = mysql_fetch_array($_result); + $_result=mysqli_query($GLOBALS['link'],"select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$defenderhero['heroid']."'"); + $fdb = mysqli_fetch_array($_result); $hero_id=$fdb['heroid']; $hero_health=$fdb['health']; $damage_health=round(100*$result[2]); if ($hero_health<=$damage_health or $damage_health>90){ //hero die $result['deadherodef'] = 1; - mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'"); - mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'"); }else{ $result['deadherodef'] = 0; - mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'"); } } unset($_result,$fdb,$hero_id,$hero_health,$damage_health); @@ -696,19 +696,19 @@ class Battle { if(!empty($heroarray)) { reset($heroarray); } $Reinforcer = $database->getVillageField($defenders['from'],"owner"); $heroarraydefender = $this->getBattleHero($Reinforcer); - $_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$heroarraydefender['heroid']."'"); - $fdb = mysql_fetch_array($_result); + $_result=mysqli_query($GLOBALS['link'],"select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$heroarraydefender['heroid']."'"); + $fdb = mysqli_fetch_array($_result); $hero_id=$fdb['heroid']; $hero_health=$fdb['health']; $damage_health=round(100*$result[2]); if ($hero_health<=$damage_health or $damage_health>90){ //hero die $result['deadheroref'][$defenders['id']] = 1; - mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'"); - mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'"); }else{ $result['deadheroref'][$defenders['id']] = 0; - mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'"); + mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'"); } } } diff --git a/GameEngine/Chat.php b/GameEngine/Chat.php index 4dc5655d..297063b9 100755 --- a/GameEngine/Chat.php +++ b/GameEngine/Chat.php @@ -362,7 +362,7 @@ if (!isset($SAJAX_INCLUDED)) { $alliance = $session->alliance; $now = time(); echo $q = "INSERT into ".TB_PREFIX."chat (id_user,name,alli,date,msg) values ('$id_user','$name','$alliance','$now','$msg')"; - mysql_query($q, $database->connection); + mysqli_query($GLOBALS['link'],$q); } } @@ -370,8 +370,8 @@ if (!isset($SAJAX_INCLUDED)) { global $session,$database; $alliance = $session->alliance; - $query = mysql_query("select * from ".TB_PREFIX."chat where alli='$alliance' order by id desc limit 0,13"); - while ($r = mysql_fetch_array($query)) { + $query = mysqli_query($GLOBALS['link'],"select * from ".TB_PREFIX."chat where alli='$alliance' order by id desc limit 0,13"); + while ($r = mysqli_fetch_array($query)) { $dates = date("g:i",$r[date]); $data .= "[{$dates}] {$r['name']}: {$r[msg]}
"; } diff --git a/GameEngine/Database.php b/GameEngine/Database.php index f6724e2b..90ee317e 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -1,18 +1,3876 @@ dblink = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); + mysqli_select_db($this->dblink, SQL_DB); + mysqli_query($this->dblink,"SET NAMES 'UTF8'"); + } + + function return_link() { + return $this->dblink; + } + + function register($username, $password, $email, $tribe, $act) { + $time = time(); + $stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME); + if($stime > time()){ + $time = $stime; + } + $timep = $time + PROTECTION; + $time = time(); + $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)"; + if(mysqli_query($this->dblink,$q)) { + return mysqli_insert_id($this->dblink); + } else { + return false; + } + } + + function activate($username, $password, $email, $tribe, $locate, $act, $act2) { + $time = time(); + $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')"; + if(mysqli_query($this->dblink,$q)) { + return mysqli_insert_id($this->dblink); + } else { + return false; + } + } + + function unreg($username) { + $q = "DELETE from " . TB_PREFIX . "activate where username = '$username'"; + return mysqli_query($this->dblink,$q); + } + function deleteReinf($id) { + $q = "DELETE from " . TB_PREFIX . "enforcement where id = '$id'"; + mysqli_query($this->dblink,$q); + } + function updateResource($vid, $what, $number) { + + $q = "UPDATE " . TB_PREFIX . "vdata set " . $what . "=" . $number . " where wref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_query($this->dblink,$q); + } + + function checkExist($ref, $mode) { + + if(!$mode) { + $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1"; + } else { + $q = "SELECT email FROM " . TB_PREFIX . "users where email = '$ref' LIMIT 1"; + } + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function checkExist_activate($ref, $mode) { + + if(!$mode) { + $q = "SELECT username FROM " . TB_PREFIX . "activate where username = '$ref' LIMIT 1"; + } else { + $q = "SELECT email FROM " . TB_PREFIX . "activate where email = '$ref' LIMIT 1"; + } + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + public function hasBeginnerProtection($vid) { + $q = "SELECT u.protect FROM ".TB_PREFIX."users u,".TB_PREFIX."vdata v WHERE u.id=v.owner AND v.wref=".$vid; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + if(!empty($dbarray)) { + if(time()<$dbarray[0]) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + function updateUserField($ref, $field, $value, $switch) { + if(!$switch) { + $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where username = '$ref'"; + } else { + $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where id = '$ref'"; + } + return mysqli_query($this->dblink,$q); + } + + function getSitee($uid) { + $q = "SELECT id from " . TB_PREFIX . "users where sit1 = $uid or sit2 = $uid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getVilWref($x, $y) { + $q = "SELECT * FROM " . TB_PREFIX . "wdata where x = $x AND y = $y"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['id']; + } + + function caststruc($user) { + //loop search village user + $query = mysqli_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); + while($villaggi_array = mysqli_fetch_array($query)) + + //loop structure village + $query1 = mysqli_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); + $strutture= mysqli_fetch_array($query1); + return $strutture; + } + + function removeMeSit($uid, $uid2) { + $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2"; + mysqli_query($this->dblink,$q); + $q2 = "UPDATE " . TB_PREFIX . "users set sit2 = 0 where id = $uid and sit2 = $uid2"; + mysqli_query($this->dblink,$q2); + } + + function getUserField($ref, $field, $mode) { + if(!$mode) { + $q = "SELECT $field FROM " . TB_PREFIX . "users where id = '$ref'"; + } else { + $q = "SELECT $field FROM " . TB_PREFIX . "users where username = '$ref'"; + } + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + if($result) { + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + }elseif($field=="username"){ + return "??"; + }else return 0; + } + + function getInvitedUser($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "users where invited = $uid order by regtime desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getVrefField($ref, $field){ + $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + } + + function getVrefCapital($ref){ + $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray; + } + + 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); + } + + function getUnstarvation(){ + $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv = 0 and starvupdate = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getActivateField($ref, $field, $mode) { + if(!$mode) { + $q = "SELECT $field FROM " . TB_PREFIX . "activate where id = '$ref'"; + } else { + $q = "SELECT $field FROM " . TB_PREFIX . "activate where username = '$ref'"; + } + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + } + + function login($username, $password) { + $q = "SELECT password,sessid FROM " . TB_PREFIX . "users where username = '$username'"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + if($dbarray['password'] == md5($password)) { + return true; + } else { + return false; + } + } + + function checkActivate($act) { + $q = "SELECT * FROM " . TB_PREFIX . "activate where act = '$act'"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + + return $dbarray; + } + + function sitterLogin($username, $password) { + $q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + if($dbarray['sit1'] != 0) { + $q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED; + $result2 = mysqli_query($this->dblink,$q2); + $dbarray2 = mysqli_fetch_array($result2); + } + if($dbarray['sit2'] != 0) { + $q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED; + $result3 = mysqli_query($this->dblink,$q3); + $dbarray3 = mysqli_fetch_array($result3); + } + if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) { + if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + function setDeleting($uid, $mode) { + $time = time() + 72 * 3600; + if(!$mode) { + $q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)"; + } else { + $q = "DELETE FROM " . TB_PREFIX . "deleting where uid = $uid"; + } + mysqli_query($this->dblink,$q); + } + + function isDeleting($uid) { + $q = "SELECT timestamp from " . TB_PREFIX . "deleting where uid = $uid"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['timestamp']; + } + + function modifyGold($userid, $amt, $mode) { + if(!$mode) { + $q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid"; + } else { + $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid"; + } + return mysqli_query($this->dblink,$q); + } + + /***************************************** + Function to retrieve user array via Username or ID + Mode 0: Search by Username + Mode 1: Search by ID + References: Alliance ID + *****************************************/ + + function getUserArray($ref, $mode) { + if(!$mode) { + $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref'"; + } else { + $q = "SELECT * FROM " . TB_PREFIX . "users where id = '$ref'"; + } + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function activeModify($username, $mode) { + $time = time(); + if(!$mode) { + $q = "INSERT into " . TB_PREFIX . "active VALUES ('$username',$time)"; + } else { + $q = "DELETE FROM " . TB_PREFIX . "active where username = '$username'"; + } + return mysqli_query($this->dblink,$q); + } + + function addActiveUser($username, $time) { + $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; + if(mysqli_query($this->dblink,$q)) { + return true; + } else { + return false; + } + } + + function updateActiveUser($username, $time) { + $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; + $q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'"; + $exec1 = mysqli_query($this->dblink,$q); + $exec2 = mysqli_query($this->dblink,$q2); + if($exec1 && $exec2) { + return true; + } else { + return false; + } + } + + function checkactiveSession($username, $sessid) { + $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$username' and sessid = '$sessid' LIMIT 1"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result) != 0) { + return true; + } else { + return false; + } + } + + function submitProfile($uid, $gender, $location, $birthday, $des1, $des2) { + $q = "UPDATE " . TB_PREFIX . "users set gender = $gender, location = '$location', birthday = '$birthday', desc1 = '$des1', desc2 = '$des2' where id = $uid"; + return mysqli_query($this->dblink,$q); + } + + function gpack($uid, $gpack) { + $q = "UPDATE " . TB_PREFIX . "users set gpack = '$gpack' where id = $uid"; + return mysqli_query($this->dblink,$q); + } + + function GetOnline($uid) { + $q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['sit']; + } + + function UpdateOnline($mode, $name = "", $time = "", $uid = 0) { + global $session; + if($mode == "login") { + $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)"; + return mysqli_query($this->dblink,$q); + } else if($mode == "sitter") { + $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)"; + return mysqli_query($this->dblink,$q); + } else { + $q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . addslashes($session->username) . "'"; + return mysqli_query($this->dblink,$q); + } + } + + function generateBase($sector, $mode=1) { + $num_rows = 0; + $count_while = 0; + while (!$num_rows){ + if (!$mode) { + $gamesday=time()-COMMENCE; + if ($gamesday<3600*24*10 && $count_while==0) { //10 day + $wide1=1; + $wide2=20; + } elseif ($gamesday<3600*24*20 && $count_while==1) { //20 day + $wide1=20; + $wide2=40; + } elseif ($gamesday<3600*24*30 && $count_while==2) { //30 day + $wide1=40; + $wide2=80; + } else { // over 30 day + $wide1=80; + $wide2=WORLD_MAX; + } + } + else { + $wide1=1; + $wide2=WORLD_MAX; + } + switch($sector) { + case 1: + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x- y+ + break; + case 2: + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x+ y+ + break; + case 3: + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x- y- + break; + case 4: + $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- + break; + } + $result = mysqli_query($this->dblink,$q); + $num_rows = mysqli_num_rows($result); + $count_while++; + } + $result = $this->mysqli_fetch_all($result); + $base = rand(0, ($num_rows-1)); + return $result[$base]['id']; + } + + function setFieldTaken($id) { + $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function addVillage($wid, $uid, $username, $capital) { + $total = count($this->getVillagesID($uid)); + if($total >= 1) { + $vname = $username . "\'s village " . ($total + 1); + } else { + $vname = $username . "\'s village"; + } + $time = time(); + $q = "INSERT into " . TB_PREFIX . "vdata (wref, owner, name, capital, pop, cp, celebration, wood, clay, iron, maxstore, crop, maxcrop, lastupdate, created) values ('$wid', '$uid', '$vname', '$capital', 2, 1, 0, 750, 750, 750, ".STORAGE_BASE.", 750, ".STORAGE_BASE.", '$time', '$time')"; + return mysqli_query($this->dblink,$q) or die(mysqli_error()); + } + + function addResourceFields($vid, $type) { + switch($type) { + case 1: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,4,4,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 2: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 3: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 4: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 5: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 6: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,3,4,4,4,4,4,4,4,4,4,4,4,2,4,4,1,15)"; + break; + case 7: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 8: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 9: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 10: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + case 11: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,1,1,3,1,4,4,3,3,2,2,3,1,4,4,2,4,4,1,15)"; + break; + case 12: + $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; + break; + } + return mysqli_query($this->dblink,$q); + } + function isVillageOases($wref) { + $q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + if($result){ + $dbarray = mysqli_fetch_array($result); + return $dbarray['oasistype']; + }else return 0; + } + + public function VillageOasisCount($vref) { + $q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + public function countOasisTroops($vref){ + //count oasis troops: $troops_o + $troops_o=0; + $o_unit2=mysqli_query("select * from ".TB_PREFIX."units where `vref`='".$vref."'"); + $o_unit=mysqli_fetch_array($o_unit2); + + for ($i=1;$i<51;$i++) + { + $troops_o+=$o_unit[$i]; + } + $troops_o+=$o_unit['hero']; + + $o_unit2=mysqli_query("select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'"); + while ($o_unit=@mysqli_fetch_array($o_unit2)) + { + for ($i=1;$i<51;$i++) + { + $troops_o+=$o_unit[$i]; + } + $troops_o+=$o_unit['hero']; + } + return $troops_o; + } + + public function canConquerOasis($vref,$wref) { + $AttackerFields = $this->getResourceLevel($vref); + for($i=19;$i<=38;$i++) { + if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; } + } + if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) { + $OasisInfo = $this->getOasisInfo($wref); + //fix by ronix + if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && intval($OasisInfo['loyalty']) < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))){ + $CoordsVillage = $this->getCoor($vref); + $CoordsOasis = $this->getCoor($wref); + $max = 2 * WORLD_MAX + 1; + $x1 = intval($CoordsOasis['x']); + $y1 = intval($CoordsOasis['y']); + $x2 = intval($CoordsVillage['x']); + $y2 = intval($CoordsVillage['y']); + $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); + $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); + if ($distanceX<=3 && $distanceY<=3) { + return 1; //can + } else { + return 2; //can but not in 7x7 field + } + } else { + return 3; //loyalty >0 + } + } else { + return 0; //req level hero mansion + } + } + + public function conquerOasis($vref,$wref) { + $vinfo = $this->getVillage($vref); + $uid = $vinfo['owner']; + $q = "UPDATE `".TB_PREFIX."odata` SET conqured=$vref,loyalty=100,lastupdated=".time().",owner=$uid,name='Occupied Oasis' WHERE wref=$wref"; + return mysqli_query($this->dblink,$q); + } + + public function modifyOasisLoyalty($wref) { + if($this->isVillageOases($wref) != 0) { + $OasisInfo = $this->getOasisInfo($wref); + if($OasisInfo['conqured'] != 0) { + $LoyaltyAmendment = floor(100 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))); + $q = "UPDATE `".TB_PREFIX."odata` SET loyalty=loyalty-$LoyaltyAmendment, lastupdated=".time()." WHERE wref=$wref"; + $result=mysqli_query($this->dblink,$q); + return $OasisInfo['loyalty']-$LoyaltyAmendment; + } + } + } + + function populateOasis() { + $q = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; + $result = mysqli_query($this->dblink,$q); + while($row = mysqli_fetch_array($result)) { + $wid = $row['id']; + + $this->addUnits($wid); + + } + } + + function populateOasisUnits($wid, $high) { + $basearray = $this->getOasisInfo($wid); + if($high == 0){ + $max = rand(15,30); + }elseif($high == 1){ + $max = rand(50,70); + }elseif($high == 2){ + $max = rand(90,120); + } + $max2 = 0; + $rand = rand(0,3); + if($rand == 1){ + $max2 = 3; + } + //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less + switch($basearray['type']) { + case 1: + case 2: + //+25% lumber per hour + $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u35 <= ".$max." OR u36 <= ".$max." OR u37 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 3: + //+25% lumber and +25% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 4: + case 5: + //+25% clay per hour + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 6: + //+25% clay and +25% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 7: + case 8: + //+25% iron per hour + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 9: + //+25% iron and +25% crop + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 10: + case 11: + //+25% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + case 12: + //+50% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max." OR u39 <= ".$max.")"; + $result = mysqli_query($this->dblink,$q); + break; + } + } + + function populateOasisUnits2() { + $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; + $result2 = mysqli_query($this->dblink,$q2); + while($row = mysqli_fetch_array($result2)) { + $wid = $row['id']; + switch($row['oasistype']) { + case 1: + case 2: + //+25% lumber oasis + $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,10)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <= '10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 3: + //+25% lumber and +25% crop oasis + $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,15)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <='10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 4: + case 5: + //+25% clay oasis + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <= '10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 6: + //+25% clay and +25% crop oasis + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <='10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 7: + case 8: + //+25% iron oasis + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <= '10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 9: + //+25% iron and +25% crop oasis + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <='10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 10: + case 11: + //+25% crop oasis + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(5,15)."', u33 = u33 + '".rand(5,10)."', u37 = u37 + '".rand(0,10)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u37 <='10' AND u39 <='10'"; + $result = mysqli_query($this->dblink,$q); + break; + case 12: + //+50% crop oasis + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u33 = u33 + '".rand(5,10)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u38 <='10'AND u39 <='10'"; + $result = mysqli_query($this->dblink,$q); + break; + } + } + } + + function removeOases($wref) { + $q = "UPDATE ".TB_PREFIX."odata SET conqured = 0, owner = 2, name = 'Unoccupied Oasis' WHERE wref = $wref"; + return mysqli_query($this->dblink,$q); + } + + + /*************************** + Function to retrieve type of village via ID + References: Village ID + ***************************/ + function getVillageType($wref) { + $q = "SELECT id, fieldtype FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['fieldtype']; + } + + + + /***************************************** + Function to retrieve if is ocuped via ID + References: Village ID + *****************************************/ + function getVillageState($wref) { + $q = "SELECT oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + if($dbarray['occupied'] != 0 || $dbarray['oasistype'] != 0) { + return true; + } else { + return false; + } + } + + function getProfileVillages($uid) { + $q = "SELECT capital,wref,name,pop,created from " . TB_PREFIX . "vdata where owner = $uid order by pop desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getProfileMedal($uid) { + $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "medal where userid = $uid and del = 0 order by id desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + + } + + function getProfileMedalAlly($uid) { + $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "allimedal where allyid = $uid and del = 0 order by id desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + + } + + function getVillageID($uid) { + $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE owner = $uid"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['wref']; + } + + + function getVillagesID($uid) { + $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); + $newarray = array(); + for($i = 0; $i < count($array); $i++) { + array_push($newarray, $array[$i]['wref']); + } + return $newarray; + } + + function getVillagesID2($uid) { + $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); + return $array; + } + + function getVillage($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + public function getVillageBattleData($vid) { + $q = "SELECT u.id,u.tribe,v.capital,f.f40 AS wall FROM ".TB_PREFIX."users u,".TB_PREFIX."fdata f,".TB_PREFIX."vdata v WHERE u.id=v.owner AND f.vref=v.wref AND v.wref=".$vid; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + public function getPopulation($uid) { + $q = "SELECT sum(pop) AS pop FROM ".TB_PREFIX."vdata WHERE owner=".$uid; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['pop']; + } + + function getOasisV($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getMInfo($id) { + $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "vdata ON " . TB_PREFIX . "vdata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getOMInfo($id) { + $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "odata ON " . TB_PREFIX . "odata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getOasis($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = $vid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getOasisInfo($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $wid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function getVillageField($ref, $field) { + $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref"; + $result = mysqli_query($this->dblink,$q); + if($result){ + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + }elseif($field=="name"){ + return "??"; + }else return 0; + } + + function getOasisField($ref, $field) { + $q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + } + + function setVillageField($ref, $field, $value) { + $q = "UPDATE " . TB_PREFIX . "vdata set $field = '$value' where wref = $ref"; + return mysqli_query($this->dblink,$q); + } + + function setVillageLevel($ref, $field, $value) { + $q = "UPDATE " . TB_PREFIX . "fdata set " . $field . " = '" . $value . "' where vref = " . $ref . ""; + return mysqli_query($this->dblink,$q); + } + + function getResourceLevel($vid) { + $q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function getAdminLog() { + $q = "SELECT id,user,log,time from " . TB_PREFIX . "admin_log where id != 0 ORDER BY id ASC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + //fix market log + function getMarketLog() { + $q = "SELECT id,wid,log from " . TB_PREFIX . "market_log where id != 0 ORDER BY id ASC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + function getMarketLogVillage($village) { + $q = "SELECT wref,owner,name from " . TB_PREFIX . "vdata where wref =$village "; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + function getMarketLogUsers($id_user) { + $q = "SELECT id,username from " . TB_PREFIX . "users where id =$id_user "; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + //end fix + + function getCoor($wref) { + if ($wref !=""){ + $q = "SELECT x,y FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + } + + function CheckForum($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function CountCat($id) { + $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where cat = '$id'"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + function LastTopic($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' order by post_date"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function CheckLastTopic($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function CheckLastPost($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function LastPost($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function CountTopic($id) { + $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where owner = '$id'"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + + $qs = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where owner = '$id'"; + $results = mysqli_query($this->dblink,$qs); + $rows = mysqli_fetch_row($results); + return $row[0] + $rows[0]; + } + + function CountPost($id) { + $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where topic = '$id'"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + function ForumCat($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id' ORDER BY id"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function ForumCatEdit($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_cat where id = '$id'"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function ForumCatAlliance($id) { + $q = "SELECT alliance from " . TB_PREFIX . "forum_cat where id = $id"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['alliance']; + } + + function ForumCatName($id) { + $q = "SELECT forum_name from " . TB_PREFIX . "forum_cat where id = $id"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['forum_name']; + } + + function CheckCatTopic($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function CheckResultEdit($alli) { + $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function CheckCloseTopic($id) { + $q = "SELECT close from " . TB_PREFIX . "forum_topic where id = '$id'"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['close']; + } + + function CheckEditRes($alli) { + $q = "SELECT result from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['result']; + } + + function CreatResultEdit($alli, $result) { + $q = "INSERT into " . TB_PREFIX . "forum_edit values (0,'$alli','$result')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function UpdateResultEdit($alli, $result) { + $date = time(); + $q = "UPDATE " . TB_PREFIX . "forum_edit set result = '$result' where alliance = '$alli'"; + return mysqli_query($this->dblink,$q); + } + + function getVillageType2($wref) { + $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['oasistype']; + } + + function getVillageType3($wref) { + $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray; + } + + function getFLData($id) { + $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function checkVilExist($wref) { + $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function checkOasisExist($wref) { + $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function UpdateEditTopic($id, $title, $cat) { + $q = "UPDATE " . TB_PREFIX . "forum_topic set title = '$title', cat = '$cat' where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function UpdateEditForum($id, $name, $des) { + $q = "UPDATE " . TB_PREFIX . "forum_cat set forum_name = '$name', forum_des = '$des' where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function StickTopic($id, $mode) { + $q = "UPDATE " . TB_PREFIX . "forum_topic set stick = '$mode' where id = '$id'"; + return mysqli_query($this->dblink,$q); + } + + function ForumCatTopic($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '' ORDER BY post_date desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function ForumCatTopicStick($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '1' ORDER BY post_date desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function ShowTopic($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_topic where id = '$id'"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function ShowPost($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function ShowPostEdit($id) { + $q = "SELECT * from " . TB_PREFIX . "forum_post where id = '$id'"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function CreatForum($owner, $alli, $name, $des, $area) { + $q = "INSERT into " . TB_PREFIX . "forum_cat values (0,'$owner','$alli','$name','$des','$area')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) { + $date = time(); + $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + /************************* + FORUM SUREY + *************************/ + + function createSurvey($topic, $title, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $ends) { + $q = "INSERT into " . TB_PREFIX . "forum_survey (topic,title,option1,option2,option3,option4,option5,option6,option7,option8,ends) values ('$topic','$title','$option1','$option2','$option3','$option4','$option5','$option6','$option7','$option8','$ends')"; + return mysqli_query($this->dblink,$q); + } + + function getSurvey($topic) { + $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function checkSurvey($topic) { + $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function Vote($topic, $num, $text) { + $q = "UPDATE " . TB_PREFIX . "forum_survey set vote".$num." = vote".$num." + 1, voted = '$text' where topic = ".$topic.""; + return mysqli_query($this->dblink,$q); + } + + function checkVote($topic, $uid) { + $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; + $result = mysqli_query($this->dblink,$q); + $array = mysqli_fetch_array($result); + $text = $array['voted']; + if(preg_match('/,'.$uid.',/',$text)) { + return true; + } else { + return false; + } + } + + function getVoteSum($topic) { + $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; + $result = mysqli_query($this->dblink,$q); + $array = mysqli_fetch_array($result); + $sum = 0; + for($i=1;$i<=8;$i++){ + $sum += $array['vote'.$i]; + } + return $sum; + } + + + /************************* + FORUM SUREY + *************************/ + + function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) { + $date = time(); + $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function UpdatePostDate($id) { + $date = time(); + $q = "UPDATE " . TB_PREFIX . "forum_topic set post_date = '$date' where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) { + $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) { + $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function LockTopic($id, $mode) { + $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'"; + return mysqli_query($this->dblink,$q); + } + + function DeleteCat($id) { + $qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'"; + $q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'"; + $q2="SELECT id from ".TB_PREFIX."forum_topic where cat ='$id'"; + $result = mysqli_query($this->dblink,$q2); + if (!empty($result)) { + $array=$this->mysqli_fetch_all($result); + foreach($array as $ss) { + $this->DeleteSurvey($ss['id']); + } + } + mysqli_query($this->dblink,$qs); + return mysqli_query($this->dblink,$q); + } + + function DeleteSurvey($id) { + $qs = "DELETE from " . TB_PREFIX . "forum_survey where topic = '$id'"; + return mysqli_query($this->dblink,$qs); + } + + function DeleteTopic($id) { + $qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'"; + // $q = "DELETE from ".TB_PREFIX."forum_post where topic = '$id'";// + return mysqli_query($this->dblink,$qs); // + // mysqli_query($this->dblink,$q); + } + + function DeletePost($id) { + $q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'"; + return mysqli_query($this->dblink,$q); + } + + function getAllianceName($id) { + $q = "SELECT tag from " . TB_PREFIX . "alidata where id = $id"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['tag']; + } + + function getAlliancePermission($ref, $field, $mode) { + if(!$mode) { + $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where uid = '$ref'"; + } else { + $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where username = '$ref'"; + } + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + } + + function getAlliance($id) { + $q = "SELECT * from " . TB_PREFIX . "alidata where id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function setAlliName($aid, $name, $tag) { + $q = "UPDATE " . TB_PREFIX . "alidata set name = '$name', tag = '$tag' where id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function isAllianceOwner($id) { + $q = "SELECT * from " . TB_PREFIX . "alidata where leader = '$id'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function aExist($ref, $type) { + $q = "SELECT $type FROM " . TB_PREFIX . "alidata where $type = '$ref'"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + function modifyPoints($aid, $points, $amt) { + $q = "UPDATE " . TB_PREFIX . "users set $points = $points + $amt where id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function modifyPointsAlly($aid, $points, $amt) { + $q = "UPDATE " . TB_PREFIX . "alidata set $points = $points + $amt where id = $aid"; + return mysqli_query($this->dblink,$q); + } + + /***************************************** + Function to create an alliance + References: + *****************************************/ + function createAlliance($tag, $name, $uid, $max) { + $q = "INSERT into " . TB_PREFIX . "alidata values (0,'$name','$tag',$uid,0,0,0,'','',$max,'','','','','','','','','')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function procAllyPop($aid) { + $ally = $this->getAlliance($aid); + $memberlist = $this->getAllMember($ally['id']); + $oldrank = 0; + foreach($memberlist as $member) { + $oldrank += $this->getVSumField($member['id'],"pop"); + } + if($ally['oldrank'] != $oldrank){ + if($ally['oldrank'] < $oldrank) { + $totalpoints = $oldrank - $ally['oldrank']; + $this->addclimberrankpopAlly($ally['id'], $totalpoints); + $this->updateoldrankAlly($ally['id'], $oldrank); + } else + if($ally['oldrank'] > $oldrank) { + $totalpoints = $ally['oldrank'] - $oldrank; + $this->removeclimberrankpopAlly($ally['id'], $totalpoints); + $this->updateoldrankAlly($ally['id'], $oldrank); + } + } + } + + /***************************************** + Function to insert an alliance new + References: + *****************************************/ + function insertAlliNotice($aid, $notice) { + $time = time(); + $q = "INSERT into " . TB_PREFIX . "ali_log values (0,'$aid','$notice',$time)"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + /***************************************** + Function to delete alliance if empty + References: + *****************************************/ + function deleteAlliance($aid) { + $result = mysqli_query("SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"); + $num_rows = mysqli_num_rows($result); + if($num_rows == 0) { + $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid"; + } + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + /***************************************** + Function to read all alliance news + References: + *****************************************/ + function readAlliNotice($aid) { + $q = "SELECT * from " . TB_PREFIX . "ali_log where aid = $aid ORDER BY date DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + /***************************************** + Function to create alliance permissions + References: ID, notice, description + *****************************************/ + function createAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) { + + $q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + /***************************************** + Function to update alliance permissions + References: + *****************************************/ + function deleteAlliPermissions($uid) { + $q = "DELETE from " . TB_PREFIX . "ali_permission where uid = '$uid'"; + return mysqli_query($this->dblink,$q); + } + /***************************************** + Function to update alliance permissions + References: + *****************************************/ + function updateAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7) { + + $q = "UPDATE " . TB_PREFIX . "ali_permission SET rank = '$rank', opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' where uid = $uid && alliance =$aid"; + return mysqli_query($this->dblink,$q); + } + + /***************************************** + Function to read alliance permissions + References: ID, notice, description + *****************************************/ + function getAlliPermissions($uid, $aid) { + $q = "SELECT * FROM " . TB_PREFIX . "ali_permission where uid = $uid && alliance = $aid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + /***************************************** + Function to update an alliance description and notice + References: ID, notice, description + *****************************************/ + function submitAlliProfile($aid, $notice, $desc) { + + $q = "UPDATE " . TB_PREFIX . "alidata SET `notice` = '$notice', `desc` = '$desc' where id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function diplomacyInviteAdd($alli1, $alli2, $type) { + $q = "INSERT INTO " . TB_PREFIX . "diplomacy (alli1,alli2,type,accepted) VALUES ($alli1,$alli2," . (int)intval($type) . ",0)"; + return mysqli_query($this->dblink,$q); + } + + function diplomacyOwnOffers($session_alliance) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getAllianceID($name) { + $q = "SELECT id FROM " . TB_PREFIX . "alidata WHERE tag ='" . $this->RemoveXSS($name) . "'"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray['id']; + } + + function getDiplomacy($aid) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE id = $aid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function diplomacyCancelOffer($id) { + $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id"; + return mysqli_query($this->dblink,$q); + } + + function diplomacyInviteAccept($id, $session_alliance) { + $q = "UPDATE " . TB_PREFIX . "diplomacy SET accepted = 1 WHERE id = $id AND alli2 = $session_alliance"; + return mysqli_query($this->dblink,$q); + } + + function diplomacyInviteDenied($id, $session_alliance) { + $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance"; + return mysqli_query($this->dblink,$q); + } + + function diplomacyInviteCheck($session_alliance) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function diplomacyInviteCheck2($ally1, $ally2) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getAllianceDipProfile($aid, $type){ + $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'"; + $array = $this->query_return($q); + foreach($array as $row){ + if($row['alli1'] == $aid){ + $alliance = $this->getAlliance($row['alli2']); + }elseif($row['alli2'] == $aid){ + $alliance = $this->getAlliance($row['alli1']); + } + $text .= ""; + $text .= "".$alliance['tag']."
"; + } + if(strlen($text) == 0){ + $text = "-
"; + } + return $text; + } + + function getAllianceWar($aid){ + $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; + $array = $this->query_return($q); + foreach($array as $row){ + if($row['alli1'] == $aid){ + $alliance = $this->getAlliance($row['alli2']); + }elseif($row['alli2'] == $aid){ + $alliance = $this->getAlliance($row['alli1']); + } + $text .= ""; + $text .= "".$alliance['tag']."
"; + } + if(strlen($text) == 0){ + $text = "-
"; + } + return $text; + } + + function getAllianceAlly($aid, $type){ + $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE (alli1 = '$aid' or alli2 = '$aid') AND (type = '$type' AND accepted = '1')"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getAllianceWar2($aid){ + $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function diplomacyExistingRelationships($session_alliance) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function diplomacyExistingRelationships2($session_alliance) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 1"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function diplomacyCancelExistingRelationship($id, $session_alliance) { + $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance"; + return mysqli_query($this->dblink,$q); + } + + function checkDiplomacyInviteAccept($aid, $type) { + $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1"; + $result = mysqli_query($this->dblink,$q); + if($type == 3){ + return true; + }else{ + if(mysqli_num_rows($result) < 4) { + return true; + } else { + return false; + } + } + } + + function setAlliForumdblink($aid, $dblink) { + $q = "UPDATE " . TB_PREFIX . "alidata SET `forumdblink` = '$dblink' WHERE id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function getUserAlliance($id) { + $q = "SELECT " . TB_PREFIX . "alidata.tag from " . TB_PREFIX . "users join " . TB_PREFIX . "alidata where " . TB_PREFIX . "users.alliance = " . TB_PREFIX . "alidata.id and " . TB_PREFIX . "users.id = $id"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + if($dbarray['tag'] == "") { + return "-"; + } else { + return $dbarray['tag']; + } + } + + /////////////ADDED BY BRAINIAC - THANK YOU + + function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) { + $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "vdata where wref = ".$vid.""; + $result = mysqli_query($this->dblink,$q); + $checkres= $this->mysqli_fetch_all($result); + if(!$mode){ + $nwood=$checkres[0]['wood']-$wood; + $nclay=$checkres[0]['clay']-$clay; + $niron=$checkres[0]['iron']-$iron; + $ncrop=$checkres[0]['crop']-$crop; + if($nwood<0 or $nclay<0 or $niron<0 or $ncrop<0){$shit=true;} + $dwood=($nwood<0)?0:$nwood; + $dclay=($nclay<0)?0:$nclay; + $diron=($niron<0)?0:$niron; + $dcrop=($ncrop<0)?0:$ncrop; + }else{ + $nwood=$checkres[0]['wood']+$wood; + $nclay=$checkres[0]['clay']+$clay; + $niron=$checkres[0]['iron']+$iron; + $ncrop=$checkres[0]['crop']+$crop; + $dwood=($nwood>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nwood; + $dclay=($nclay>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nclay; + $diron=($niron>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$niron; + $dcrop=($ncrop>$checkres[0]['maxcrop'])?$checkres[0]['maxcrop']:$ncrop; + } + if(!$shit){ + $q = "UPDATE " . TB_PREFIX . "vdata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; + return mysqli_query($this->dblink,$q); }else{return false;} + } + + function modifyOasisResource($vid, $wood, $clay, $iron, $crop, $mode) { + $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "odata where wref = ".$vid.""; + $result = mysqli_query($this->dblink,$q); + $checkres= $this->mysqli_fetch_all($result); + if(!$mode){ + $nwood=$checkres[0]['wood']-$wood; + $nclay=$checkres[0]['clay']-$clay; + $niron=$checkres[0]['iron']-$iron; + $ncrop=$checkres[0]['crop']-$crop; + if($nwood<0 or $nclay<0 or $niron<0 or $ncrop<0){$shit=true;} + $dwood=($nwood<0)?0:$nwood; + $dclay=($nclay<0)?0:$nclay; + $diron=($niron<0)?0:$niron; + $dcrop=($ncrop<0)?0:$ncrop; + }else{ + $nwood=$checkres[0]['wood']+$wood; + $nclay=$checkres[0]['clay']+$clay; + $niron=$checkres[0]['iron']+$iron; + $ncrop=$checkres[0]['crop']+$crop; + $dwood=($nwood>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nwood; + $dclay=($nclay>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nclay; + $diron=($niron>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$niron; + $dcrop=($ncrop>$checkres[0]['maxcrop'])?$checkres[0]['maxcrop']:$ncrop; + } + if(!$shit){ + $q = "UPDATE " . TB_PREFIX . "odata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; + return mysqli_query($this->dblink,$q); }else{return false;} + } + + function getFieldLevel($vid, $field) { + $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid LIMIT 1"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_array($result); + return $row["f" . $field]; + } + + function getFieldType($vid, $field) { + $q = "SELECT f" . $field . "t from " . TB_PREFIX . "fdata where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_result($result, 0); + } + + function getFieldDistance($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner > 4 and wref != $wid"; + $array = $this->query_return($q); + $coor = $this->getCoor($wid); + $x1 = intval($coor['x']); + $y1 = intval($coor['y']); + $prevdist = 0; + $q2 = "SELECT * FROM " . TB_PREFIX . "vdata where owner = 4"; + $array2 = mysqli_fetch_array(mysqli_query($q2)); + $vill = $array2['wref']; + if(mysqli_num_rows(mysqli_query($q)) > 0){ + foreach($array as $village){ + $coor2 = $this->getCoor($village['wref']); + $max = 2 * WORLD_MAX + 1; + $x2 = intval($coor2['x']); + $y2 = intval($coor2['y']); + $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); + $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); + $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); + if($dist < $prevdist or $prevdist == 0){ + $prevdist = $dist; + $vill = $village['wref']; + } + } + } + return $vill; + } + + function getVSumField($uid, $field) { + if($field != "cp"){ + $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid"; + }else{ + $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid and natar = 0"; + } + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + function updateVillage($vid) { + $time = time(); + $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid"; + return mysqli_query($this->dblink,$q); + } + + + function updateOasis($vid) { + $time = time(); + $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid"; + return mysqli_query($this->dblink,$q); + } + + function updateOasis2($vid, $time) { + $time = time(); + $time2 = NATURE_REGTIME; + $q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time + $time2 where wref = $vid"; + return mysqli_query($this->dblink,$q); + } + + function setVillageName($vid, $name) { + if(!empty($name)) + { + $q = "UPDATE " . TB_PREFIX . "vdata set name = '$name' where wref = $vid"; + return mysqli_query($this->dblink,$q); + } + } + + function modifyPop($vid, $pop, $mode) { + if(!$mode) { + $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop + $pop where wref = $vid"; + } else { + $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop - $pop where wref = $vid"; + } + return mysqli_query($this->dblink,$q); + } + + function addCP($ref, $cp) { + $q = "UPDATE " . TB_PREFIX . "vdata set cp = cp + $cp where wref = $ref"; + return mysqli_query($this->dblink,$q); + } + + function addCel($ref, $cel, $type) { + $q = "UPDATE " . TB_PREFIX . "vdata set celebration = $cel, type= $type where wref = $ref"; + return mysqli_query($this->dblink,$q); + } + 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); + } + + function clearCel($ref) { + $q = "UPDATE " . TB_PREFIX . "vdata set celebration = 0, type = 0 where wref = $ref"; + return mysqli_query($this->dblink,$q); + } + function setCelCp($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp where id = $user"; + return mysqli_query($this->dblink,$q); + } + + function clearExpansionSlot($id) { + for($i = 1; $i <= 3; $i++) { + $q = "UPDATE " . TB_PREFIX . "vdata SET exp" . $i . "=0 WHERE exp" . $i . "=" . $id; + mysqli_query($this->dblink,$q); + } + } + + function getInvitation($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getInvitation2($uid, $aid) { + $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid and alliance = $aid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getAliInvitations($aid) { + $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where alliance = $aid && accept = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function sendInvitation($uid, $alli, $sender) { + $time = time(); + $q = "INSERT INTO " . TB_PREFIX . "ali_invite values (0,$uid,$alli,$sender,$time,0)"; + return mysqli_query($this->dblink,$q) or die(mysqli_error()); + } + + function removeInvitation($id) { + $q = "DELETE FROM " . TB_PREFIX . "ali_invite where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function sendMessage($client, $owner, $topic, $message, $send, $alliance, $player, $coor, $report) { + $time = time(); + $q = "INSERT INTO " . TB_PREFIX . "mdata values (0,$client,$owner,'$topic',\"$message\",0,0,$send,$time,0,0,$alliance,$player,$coor,$report)"; + return mysqli_query($this->dblink,$q); + } + + function setArchived($id) { + $q = "UPDATE " . TB_PREFIX . "mdata set archived = 1 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function setNorm($id) { + $q = "UPDATE " . TB_PREFIX . "mdata set archived = 0 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + /*************************** + Function to get messages + Mode 1: Get inbox + Mode 2: Get sent + Mode 3: Get message + Mode 4: Set viewed + Mode 5: Remove message + Mode 6: Retrieve archive + References: User ID/Message ID, Mode + ***************************/ + function getMessage($id, $mode) { + global $session; + switch($mode) { + case 1: + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 ORDER BY time DESC"; + break; + case 2: + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id ORDER BY time DESC"; + break; + case 3: + $q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id"; + break; + case 4: + $q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target = $session->uid"; + break; + case 5: + $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id = $id"; + break; + case 6: + $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1"; + break; + case 7: + $q = "UPDATE " . TB_PREFIX . "mdata set delowner = 1 where id = $id"; + break; + case 8: + $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where id = $id"; + break; + case 9: + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC"; + break; + case 10: + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id and delowner = 0 ORDER BY time DESC"; + break; + case 11: + $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1 and deltarget = 0"; + break; + } + if($mode <= 3 || $mode == 6 || $mode > 8) { + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } else { + return mysqli_query($this->dblink,$q); + } + } + + function getDelSent($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $uid and delowner = 1 ORDER BY time DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getDelInbox($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and deltarget = 1 ORDER BY time DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getDelArchive($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and archived = 1 and deltarget = 1 OR owner = $uid and archived = 1 and delowner = 1 ORDER BY time DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function unarchiveNotice($id) { + $q = "UPDATE " . TB_PREFIX . "ndata set ntype = archive, archive = 0 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function archiveNotice($id) { + $q = "update " . TB_PREFIX . "ndata set archive = ntype, ntype = 9 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function removeNotice($id) { + $q = "UPDATE " . TB_PREFIX . "ndata set del = 1,viewed = 1 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function noticeViewed($id) { + $q = "UPDATE " . TB_PREFIX . "ndata set viewed = 1 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function addNotice($uid, $toWref, $ally, $type, $topic, $data, $time = 0) { + if($time == 0) { + $time = time(); + } + $q = "INSERT INTO " . TB_PREFIX . "ndata (id, uid, toWref, ally, topic, ntype, data, time, viewed) values (0,'$uid','$toWref','$ally','$topic',$type,'$data',$time,0)"; + return mysqli_query($this->dblink,$q) or die(mysqli_error()); + } + + function getNotice($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getNotice2($id, $field) { + $q = "SELECT ".$field." FROM " . TB_PREFIX . "ndata where `id` = '$id'"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + } + + function getNotice3($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getNotice4($id) { + $q = "SELECT * FROM " . TB_PREFIX . "ndata where id = $id ORDER BY time DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + function getUnViewNotice($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid AND viewed=0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) { + $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid.""; + mysqli_query($this->dblink,$x); + $timeleft = time()+604800; + $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)"; + return mysqli_query($this->dblink,$q); + } + + function getTradeRoute($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getTradeRoute2($id) { + $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray; + } + + function getTradeRouteUid($id) { + $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['uid']; + } + + function editTradeRoute($id,$column,$value,$mode) { + if(!$mode){ + $q = "UPDATE " . TB_PREFIX . "route set $column = $value where id = $id"; + }else{ + $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id"; + } + return mysqli_query($this->dblink,$q); + } + + function deleteTradeRoute($id) { + $q = "DELETE FROM " . TB_PREFIX . "route where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function addBuilding($wid, $field, $type, $loop, $time, $master, $level) { + $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid; + mysqli_query($this->dblink,$x) or die(mysqli_error()); + $q = "INSERT into " . TB_PREFIX . "bdata values (0,$wid,$field,$type,$loop,$time,$master,$level)"; + return mysqli_query($this->dblink,$q); + } + + function removeBuilding($d) { + global $building, $village; + $jobLoopconID = -1; + $SameBuildCount = 0; + $jobs = $building->buildArray; + for($i = 0; $i < sizeof($jobs); $i++) { + if($jobs[$i]['id'] == $d) { + $jobDeleted = $i; + } + if($jobs[$i]['loopcon'] == 1) { + $jobLoopconID = $i; + } + if($jobs[$i]['master'] == 1) { + $jobMaster = $i; + } + } + if(count($jobs) > 1 && ($jobs[0]['field'] == $jobs[1]['field'])) { + $SameBuildCount = 1; + } + if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[2]['field'])) { + $SameBuildCount = 2; + } + if(count($jobs) > 2 && ($jobs[1]['field'] == $jobs[2]['field'])) { + $SameBuildCount = 3; + } + if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[3]['field'])) { + $SameBuildCount = 8; + } + if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[3]['field'])) { + $SameBuildCount = 9; + } + if(count($jobs) > 3 && ($jobs[2]['field'] == $jobs[3]['field'])) { + $SameBuildCount = 10; + } + if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[2]['field'])) { + $SameBuildCount = 4; + } + if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[3]['field'])) { + $SameBuildCount = 5; + } + if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) { + $SameBuildCount = 6; + } + if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) { + $SameBuildCount = 7; + } + if($SameBuildCount > 0) { + if($SameBuildCount > 3){ + if($SameBuildCount == 4 or $SameBuildCount == 5){ + if($jobDeleted == 0){ + $uprequire = $building->resourceRequired($jobs[1]['field'],$jobs[1]['type'],1); + $time = $uprequire['time']; + $timestamp = $time+time(); + $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[1]['id'].""; + mysqli_query($this->dblink,$q); + } + }else if($SameBuildCount == 6){ + if($jobDeleted == 0){ + $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1); + $time = $uprequire['time']; + $timestamp = $time+time(); + $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; + mysqli_query($this->dblink,$q); + } + }else if($SameBuildCount == 7){ + if($jobDeleted == 1){ + $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1); + $time = $uprequire['time']; + $timestamp = $time+time(); + $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; + mysqli_query($this->dblink,$q); + } + } + if($SameBuildCount < 8){ + $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],2); + $time1 = $uprequire1['time']; + $timestamp1 = $time1; + $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; + mysqli_query($this->dblink,$q1); + }else{ + $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],1); + $time1 = $uprequire1['time']; + $timestamp1 = $time1; + $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; + mysqli_query($this->dblink,$q1); + } + }else if($d == $jobs[floor($SameBuildCount / 3)]['id'] || $d == $jobs[floor($SameBuildCount / 2) + 1]['id']) { + $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=" . $jobs[floor($SameBuildCount / 3)]['timestamp'] . " WHERE master = 0 AND id > ".$d." and (ID=" . $jobs[floor($SameBuildCount / 3)]['id'] . " OR ID=" . $jobs[floor($SameBuildCount / 2) + 1]['id'] . ")"; + mysqli_query($this->dblink,$q); + } + } else { + if($jobs[$jobDeleted]['field'] >= 19) { + $x = "SELECT f" . $jobs[$jobDeleted]['field'] . " FROM " . TB_PREFIX . "fdata WHERE vref=" . $jobs[$jobDeleted]['wid']; + $result = mysqli_query($this->dblink,$x) or die(mysqli_error()); + $fieldlevel = mysqli_fetch_row($result); + if($fieldlevel[0] == 0) { + if ($village->natar==1 && $jobs[$jobDeleted]['field']==99) { //fix by ronix + }else{ + $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $jobs[$jobDeleted]['field'] . "t=0 WHERE vref=" . $jobs[$jobDeleted]['wid']; + mysqli_query($this->dblink,$x) or die(mysqli_error()); + } + } + } + if(($jobLoopconID >= 0) && ($jobs[$jobDeleted]['loopcon'] != 1)) { + if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) { + $uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']); + $x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0"; + mysqli_query($this->dblink,$x) or die(mysqli_error()); + } + } + } + $q = "DELETE FROM " . TB_PREFIX . "bdata where id = $d"; + return mysqli_query($this->dblink,$q); + } + + function addDemolition($wid, $field) { + global $building, $village; + $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid"; + mysqli_query($this->dblink,$q); + $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0); + $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($this->getFieldLevel($wid,$field)-1).",".(time()+floor($uprequire['time']/2)).")"; + return mysqli_query($this->dblink,$q); + } + + + function getDemolition($wid = 0) { + if($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; + } else { + $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE timetofinish<=" . time(); + } + $result = mysqli_query($this->dblink,$q); + if(!empty($result)) { + return $this->mysqli_fetch_all($result); + } else { + return NULL; + } + } + + function finishDemolition($wid) { + $q = "UPDATE " . TB_PREFIX . "demolition SET timetofinish=" . time() . " WHERE vref=" . $wid; + $result= mysqli_query($this->dblink,$q); + return mysqli_affected_rows(); + } + + function delDemolition($wid) { + $q = "DELETE FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; + return mysqli_query($this->dblink,$q); + } + + function getJobs($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function FinishWoodcutter($wid) { + $time = time()-1; + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by master,timestamp ASC"; + $result = mysqli_query($q); + $dbarray = mysqli_fetch_array($result); + $q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'"; + $this->query($q); + $tribe = $this->getUserField($this->getVillageField($wid, "owner"), "tribe", 0); + if($tribe == 1){ + $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 and field >= 19 order by master,timestamp ASC"; + }else{ + $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 order by master,timestamp ASC"; + } + $result2 = mysqli_query($q2); + if(mysqli_num_rows($result2) > 0){ + $dbarray2 = mysqli_fetch_array($result2); + $wc_time = $dbarray['timestamp']; + $q2 = "UPDATE ".TB_PREFIX."bdata SET timestamp = timestamp - $wc_time WHERE id = '".$dbarray2['id']."'"; + $this->query($q2); + } + } + + function getMasterJobs($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getMasterJobsByField($wid,$field) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 1 order by master,timestamp ASC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getBuildingByField($wid,$field) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getBuildingByField2($wid,$field) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; + $result = mysqli_query($this->dblink,$q); + return mysqli_num_rows($result); + } + + function getBuildingByType($wid,$type) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getBuildingByType2($wid,$type) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; + $result = mysqli_query($this->dblink,$q); + return mysqli_num_rows($result); + } + + function getDorf1Building($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field < 19 and master = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getDorf2Building($wid) { + $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field > 18 and master = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function updateBuildingWithMaster($id, $time,$loop) { + $q = "UPDATE " . TB_PREFIX . "bdata SET master = 0, timestamp = ".$time.",loopcon = ".$loop." WHERE id = ".$id.""; + return mysqli_query($this->dblink,$q); + } + + function getVillageByName($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 to set accept flag on market + References: id + ***************************/ + function setMarketAcc($id) { + $q = "UPDATE " . TB_PREFIX . "market set accept = 1 where id = $id"; + return mysqli_query($this->dblink,$q); + } + + /*************************** + Function to send resource to other village + Mode 0: Send + Mode 1: Cancel + References: Wood/ID, Clay, Iron, Crop, Mode + ***************************/ + function sendResource($ref, $clay, $iron, $crop, $merchant, $mode) { + if(!$mode) { + $q = "INSERT INTO " . TB_PREFIX . "send values (0,$ref,$clay,$iron,$crop,$merchant)"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } else { + $q = "DELETE FROM " . TB_PREFIX . "send where id = $ref"; + return mysqli_query($this->dblink,$q); + } + } + + /*************************** + Function to get resources back if you delete offer + References: VillageRef (vref) + Made by: Dzoki + ***************************/ + + function getResourcesBack($vref, $gtype, $gamt) { + //Xtype (1) = wood, (2) = clay, (3) = iron, (4) = crop + if($gtype == 1) { + $q = "UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + '$gamt' WHERE wref = $vref"; + return mysqli_query($this->dblink,$q); + } else + if($gtype == 2) { + $q = "UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` + '$gamt' WHERE wref = $vref"; + return mysqli_query($this->dblink,$q); + } else + if($gtype == 3) { + $q = "UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` + '$gamt' WHERE wref = $vref"; + return mysqli_query($this->dblink,$q); + } else + if($gtype == 4) { + $q = "UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` + '$gamt' WHERE wref = $vref"; + return mysqli_query($this->dblink,$q); + } + } + + /*************************** + Function to get info about offered resources + References: VillageRef (vref) + Made by: Dzoki + ***************************/ + + function getMarketField($vref, $field) { + $q = "SELECT $field FROM " . TB_PREFIX . "market where vref = '$vref'"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$field]; + } + + function removeAcceptedOffer($id) { + $q = "DELETE FROM " . TB_PREFIX . "market where id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + /*************************** + Function to add market offer + Mode 0: Add + Mode 1: Cancel + References: Village, Give, Amt, Want, Amt, Time, Alliance, Mode + ***************************/ + function addMarket($vid, $gtype, $gamt, $wtype, $wamt, $time, $alliance, $merchant, $mode) { + if(!$mode) { + $q = "INSERT INTO " . TB_PREFIX . "market values (0,$vid,$gtype,$gamt,$wtype,$wamt,0,$time,$alliance,$merchant)"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } else { + $q = "DELETE FROM " . TB_PREFIX . "market where id = $gtype and vref = $vid"; + return mysqli_query($this->dblink,$q); + } + } + + /*************************** + Function to get market offer + References: Village, Mode + ***************************/ + function getMarket($vid, $mode) { + $alliance = $this->getUserField($this->getVillageField($vid, "owner"), "alliance", 0); + if(!$mode) { + $q = "SELECT * FROM " . TB_PREFIX . "market where vref = $vid and accept = 0"; + } else { + $q = "SELECT * FROM " . TB_PREFIX . "market where vref != $vid and alliance = $alliance or vref != $vid and alliance = 0 and accept = 0"; + } + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + /*************************** + Function to get market offer + References: ID + ***************************/ + function getMarketInfo($id) { + $q = "SELECT * FROM " . TB_PREFIX . "market where id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function setMovementProc($moveid) { + $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where moveid = $moveid"; + return mysqli_query($this->dblink,$q); + } + + /*************************** + Function to retrieve used merchant + References: Village + ***************************/ + function totalMerchantUsed($vid) { + $time = time(); + $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = '$vid' and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = '$vid' and proc = 0"; + $result2 = mysqli_query($this->dblink,$q2); + $row2 = mysqli_fetch_row($result2); + $q3 = "SELECT sum(merchant) from " . TB_PREFIX . "market where vref = $vid and accept = 0"; + $result3 = mysqli_query($this->dblink,$q3); + $row3 = mysqli_fetch_row($result3); + return $row[0] + $row2[0] + $row3[0]; + } + + function getMovement($type, $village, $mode) { + $time = time(); + if(!$mode) { + $where = "from"; + } else { + $where = "to"; + } + switch($type) { + case 0: + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC"; + break; + case 1: + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC"; + break; + case 2: + $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC"; + break; + case 3: + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; + break; + case 4: + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; + break; + case 5: + $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 5 and proc = 0 ORDER BY endtime ASC"; + break; + case 6: + $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = '$village' and " . TB_PREFIX . "movement.to = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; + //$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; + break; + case 7: + $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC"; + break; + case 8: + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; + break; + case 34: + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; + break; + default: + return null; + } + $result = mysqli_query($this->dblink,$q); + $array = $this->mysqli_fetch_all($result); + return $array; + } + + function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) { + $q = "INSERT INTO " . TB_PREFIX . "a2b (ckey,time_check,to_vid,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,type) VALUES ('$ckey', '$timestamp', '$to', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10', '$t11', '$type')"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function getA2b($ckey, $check) { + $q = "SELECT * from " . TB_PREFIX . "a2b where ckey = '" . $ckey . "' AND time_check = '" . $check . "'"; + $result = mysqli_query($this->dblink,$q); + if($result) { + return mysqli_fetch_assoc($result); + } else { + return false; + } + } + + function addMovement($type, $from, $to, $ref, $time, $endtime, $send = 1, $wood = 0, $clay = 0, $iron = 0, $crop = 0, $ref2 = 0) { + $q = "INSERT INTO " . TB_PREFIX . "movement values (0,$type,$from,$to,$ref,$ref2,$time,$endtime,0,$send,$wood,$clay,$iron,$crop)"; + return mysqli_query($this->dblink,$q); + } + + function addAttack($vid, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type, $ctar1, $ctar2, $spy,$b1=0,$b2=0,$b3=0,$b4=0,$b5=0,$b6=0,$b7=0,$b8=0) { + $q = "INSERT INTO " . TB_PREFIX . "attacks values (0,$vid,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$type,$ctar1,$ctar2,$spy,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8)"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function modifyAttack($aid, $unit, $amt) { + $unit = 't' . $unit; + $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit - $amt where id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function modifyAttack2($aid, $unit, $amt) { + $unit = 't' . $unit; + $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit + $amt where id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function modifyAttack3($aid, $units) { + $q = "UPDATE ".TB_PREFIX."attacks set $units WHERE id = $aid"; + return mysqli_query($this->dblink,$q); + } + + function getRanking() { + $q = "SELECT id,username,alliance,ap,apall,dp,dpall,access FROM " . TB_PREFIX . "users WHERE tribe<=3 AND access<" . (INCLUDE_ADMIN ? "10" : "8"); + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getVRanking() { + $q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe<=3 AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8"); + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getARanking() { + $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getUserByTribe($tribe){ + $q = "SELECT * FROM " . TB_PREFIX . "users where tribe = $tribe"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getUserByAlliance($aid){ + $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getHeroRanking() { + $q = "SELECT * FROM " . TB_PREFIX . "hero WHERE dead = 0"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getAllMember($aid) { + $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getAllMember2($aid) { + $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function addUnits($vid) { + $q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)"; + return mysqli_query($this->dblink,$q); + } + + function getUnit($vid) { + $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + if (!empty($result)) { + return mysqli_fetch_assoc($result); + } else { + return NULL; + } + } + + function getUnitsNumber($vid) { + $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_assoc($result); + $totalunits = 0; + $movingunits = $this->getVillageMovement($vid); + for($i=1;$i<=50;$i++){ + $totalunits += $dbarray['u'.$i]; + } + $totalunits += $dbarray['hero']; + $movingunits = $this->getVillageMovement($vid); + $reinforcingunits = $this->getEnforceArray($vid,1); + $owner = $this->getVillageField($vid,"owner"); + $ownertribe = $this->getUserField($owner,"tribe",0); + $start = ($ownertribe-1)*10+1; + $end = ($ownertribe*10); + for($i=$start;$i<=$end;$i++){ + $totalunits += $movingunits['u'.$i]; + $totalunits += $reinforcingunits['u'.$i]; + } + $totalunits += $movingunits['hero']; + $totalunits += $reinforcingunits['hero']; + return $totalunits; + } + + function getHero($uid=0,$all=0) { + if ($all) { + $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid=$uid"; + } elseif (!$uid) { + $q = "SELECT * FROM ".TB_PREFIX."hero"; + } else { + $q = "SELECT * FROM ".TB_PREFIX."hero WHERE dead=0 AND uid=$uid LIMIT 1"; + } + $result = mysqli_query($this->dblink,$q); + if (!empty($result)) { + return $this->mysqli_fetch_all($result); + } else { + return NULL; + } + } + + function getHeroField($uid,$field){ + $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function modifyHero($column,$value,$heroid,$mode=0) { + if(!$mode) { + $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE heroid = $heroid"; + } elseif($mode=1) { + $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE heroid = $heroid"; + } else { + $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE heroid = $heroid"; + } + return mysqli_query($this->dblink,$q); + } + + function modifyHeroByOwner($column,$value,$uid,$mode=0) { + if(!$mode) { + $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE uid = $uid"; + } elseif($mode=1) { + $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE uid = $uid"; + } else { + $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE uid = $uid"; + } + return mysqli_query($this->dblink,$q); + } + + function modifyHeroXp($column,$value,$heroid) { + $q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid"; + return mysqli_query($this->dblink,$q); + } + + function addTech($vid) { + $q = "INSERT into " . TB_PREFIX . "tdata (vref) values ($vid)"; + return mysqli_query($this->dblink,$q); + } + + function addABTech($vid) { + $q = "INSERT into " . TB_PREFIX . "abdata (vref) values ($vid)"; + return mysqli_query($this->dblink,$q); + } + + function getABTech($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "abdata where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function addResearch($vid, $tech, $time) { + $q = "INSERT into " . TB_PREFIX . "research values (0,$vid,'$tech',$time)"; + return mysqli_query($this->dblink,$q); + } + + function getResearching($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "research where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function checkIfResearched($vref, $unit) { + $q = "SELECT $unit FROM " . TB_PREFIX . "tdata WHERE vref = $vref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray[$unit]; + } + + function getTech($vid) { + $q = "SELECT * from " . TB_PREFIX . "tdata where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function getTraining($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "training where vref = $vid ORDER BY id"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function countTraining($vid) { + $q = "SELECT * FROM " . TB_PREFIX . "training WHERE vref = $vid"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + function trainUnit($vid, $unit, $amt, $pop, $each, $time, $mode) { + global $village, $building, $session, $technology; + + if(!$mode) { + $barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44); + // fix by brainiac - THANK YOU + $greatbarracks = array(61,62,63,71,72,73,74,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104); + $stables = array(4,5,6,15,16,23,24,25,26,45,46); + $greatstables = array(64,65,66,75,76,83,84,85,86,105,106); + $workshop = array(7,8,17,18,27,28,47,48); + $greatworkshop = array(67,68,77,78,87,88,107,108); + $residence = array(9,10,19,20,29,30,49,50); + $trapper = array(99); + + if(in_array($unit, $barracks)) { + $queued = $technology->getTrainingList(1); + } elseif(in_array($unit, $stables)) { + $queued = $technology->getTrainingList(2); + } elseif(in_array($unit, $workshop)) { + $queued = $technology->getTrainingList(3); + } elseif(in_array($unit, $residence)) { + $queued = $technology->getTrainingList(4); + } elseif(in_array($unit, $greatstables)) { + $queued = $technology->getTrainingList(6); + } elseif(in_array($unit, $greatbarracks)) { + $queued = $technology->getTrainingList(5); + } elseif(in_array($unit, $greatworkshop)) { + $queued = $technology->getTrainingList(7); + } elseif(in_array($unit, $trapper)) { + $queued = $technology->getTrainingList(8); + } + $now = time(); + + $uid = $this->getVillageField($vid, "owner"); + $artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0)); + $artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1)); + $artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0)); + if($artefact > 0){ + $time = $now+round(($time-$now)/2); + $each /= 2; + $each = round($each); + }else if($artefact1 > 0){ + $time = $now+round(($time-$now)/2); + $each /= 2; + $each = round($each); + }else if($artefact2 > 0){ + $time = $now+round(($time-$now)/4*3); + $each /= 4; + $each = round($each); + $each *= 3; + $each = round($each); + } + $foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid); + if(count($foolartefact) > 0){ + foreach($foolartefact as $arte){ + if($arte['bad_effect'] == 1){ + $each *= $arte['effect2']; + }else{ + $each /= $arte['effect2']; + $each = round($each); + } + } + } + if($each == 0){ $each = 1; } + $time2 = $now+$each; + if(count($queued) > 0) { + $time += $queued[count($queued) - 1]['timestamp'] - $now; + $time2 += $queued[count($queued) - 1]['timestamp'] - $now; + } + // TROOPS MAKE SUM IN BARAKS , ETC + //if($queued[count($queued) - 1]['unit'] == $unit){ + //$time = $amt*$queued[count($queued) - 1]['eachtime']; + //$q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id'].""; + //}else{ + $q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)"; + //} + } else { + $q = "DELETE FROM " . TB_PREFIX . "training where id = $vid"; + } + return mysqli_query($this->dblink,$q); + } + + function updateTraining($id, $trained, $each) { + $q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function modifyUnit($vref, $array_unit, $array_amt, $array_mode){ + $i = -1; + $units=''; + $number = count($array_unit); + foreach($array_unit as $unit){ + if($unit == 230){$unit = 30;} + if($unit == 231){$unit = 31;} + if($unit == 120){$unit = 20;} + if($unit == 121){$unit = 21;} + if($unit =="hero"){$unit = 'hero';} + else{$unit = 'u' . $unit;} + ++$i; + //Fixed part of negativ troops (double troops) - by InCube + $array_amt[$i] = $array_amt[$i] < 0 ? 0 : $array_amt[$i]; + //Fixed part of negativ troops (double troops) - by InCube + $units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.$array_amt[$i].(($number > $i+1) ? ', ' : ''); + } + $q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref"; + return mysqli_query($this->dblink,$q); + } + + function getEnforce($vid, $from) { + $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function getOasisEnforce($ref, $mode=0) { + 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"; + }else{ + $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); + return $this->mysqli_fetch_all($result); + } + + function getOasisEnforceArray($id, $mode=0) { + 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"; + }else{ + $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); + return mysqli_fetch_assoc($result); + } + + function getEnforceControllTroops($vid) { + $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $vid"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function addEnforce($data) { + $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; + mysqli_query($this->dblink,$q); + $id = mysqli_insert_id($this->dblink); + $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); + $start = ($owntribe - 1) * 10 + 1; + $end = ($owntribe * 10); + //add unit + $j = '1'; + for($i = $start; $i <= $end; $i++) { + $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1); + $j++; + } + $this->modifyEnforce($id,'hero',$data['t11'],1); + return mysqli_insert_id($this->dblink); + } + + function addEnforce2($data,$tribe,$dead1,$dead2,$dead3,$dead4,$dead5,$dead6,$dead7,$dead8,$dead9,$dead10,$dead11) { + $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; + mysqli_query($this->dblink,$q); + $id = mysqli_insert_id($this->dblink); + $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); + $start = ($owntribe - 1) * 10 + 1; + $end = ($owntribe * 10); + $start2 = ($tribe - 1) * 10 + 1; + $start3 = ($tribe - 1) * 10; + if($start3 == 0){ + $start3 = ""; + } + $end2 = ($tribe * 10); + //add unit + $j = '1'; + for($i = $start; $i <= $end; $i++) { + $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1); + $this->modifyEnforce($id, $i, ${dead.$j}, 0); + $j++; + } + $this->modifyEnforce($id,'hero',$data['t11'],1); + $this->modifyEnforce($id,'hero',$dead11,0); + return mysqli_insert_id($this->dblink); + } + + function modifyEnforce($id, $unit, $amt, $mode) { + if($unit != 'hero') { $unit = 'u' . $unit; } + if(!$mode) { + $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit - $amt where id = $id"; + } else { + $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit + $amt where id = $id"; + } + mysqli_query($this->dblink,$q); + } + + function getEnforceArray($id, $mode) { + if(!$mode) { + $q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id"; + } else { + $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; + } + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_assoc($result); + } + + function getEnforceVillage($id, $mode) { + if(!$mode) { + $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id"; + } else { + $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; + } + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getVillageMovement($id) { + $vinfo = $this->getVillage($id); + $vtribe = $this->getUserField($vinfo['owner'], "tribe", 0); + $movingunits = array(); + $outgoingarray = $this->getMovement(3, $id, 0); + if(!empty($outgoingarray)) { + foreach($outgoingarray as $out) { + for($i = 1; $i <= 10; $i++) { + $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $out['t' . $i]; + } + $movingunits['hero'] += $out['t11']; + } + } + $returningarray = $this->getMovement(4, $id, 1); + if(!empty($returningarray)) { + foreach($returningarray as $ret) { + if($ret['attack_type'] != 1) { + for($i = 1; $i <= 10; $i++) { + $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $ret['t' . $i]; + } + $movingunits['hero'] += $ret['t11']; + } + } + } + $settlerarray = $this->getMovement(5, $id, 0); + if(!empty($settlerarray)) { + $movingunits['u' . ($vtribe * 10)] += 3 * count($settlerarray); + } + return $movingunits; + } + + ################# -START- ################## + ## WORLD WONDER STATISTICS FUNCTIONS! ## + ############################################ + + /*************************** + Function to get all World Wonders + Made by: Dzoki + ***************************/ + + function getWW() { + $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + /*************************** + Function to get world wonder level! + Made by: Dzoki + ***************************/ + + function getWWLevel($vref) { + $q = "SELECT f99 FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['f99']; + } + + /*************************** + Function to get world wonder owner ID! + Made by: Dzoki + ***************************/ + + function getWWOwnerID($vref) { + $q = "SELECT owner FROM " . TB_PREFIX . "vdata WHERE wref = $vref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['owner']; + } + + /*************************** + Function to get user alliance name! + Made by: Dzoki + ***************************/ + + function getUserAllianceID($id) { + $q = "SELECT alliance FROM " . TB_PREFIX . "users where id = $id"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['alliance']; + } + + /*************************** + Function to get WW name + Made by: Dzoki + ***************************/ + + function getWWName($vref) { + $q = "SELECT wwname FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['wwname']; + } + + /*************************** + Function to change WW name + Made by: Dzoki + ***************************/ + + function submitWWname($vref, $name) { + $q = "UPDATE " . TB_PREFIX . "fdata SET `wwname` = '$name' WHERE " . TB_PREFIX . "fdata.`vref` = $vref"; + return mysqli_query($this->dblink,$q); + } + + //medal functions + function addclimberpop($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc + '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function addclimberrankpop($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set clp = clp + '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function removeclimberrankpop($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set clp = clp - '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function setclimberrankpop($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set clp = '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function updateoldrank($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set oldrank = '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function removeclimberpop($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc - '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + // ALLIANCE MEDAL FUNCTIONS + function addclimberpopAlly($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc + '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function addclimberrankpopAlly($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp + '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function removeclimberrankpopAlly($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp - '$cp'' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function updateoldrankAlly($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "alidata set oldrank = '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + function removeclimberpopAlly($user, $cp) { + $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc - '$cp' where id = $user"; + return mysqli_query($this->dblink,$q); + } + + function getTrainingList() { + $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getNeedDelete() { + $time = time(); + $q = "SELECT uid FROM " . TB_PREFIX . "deleting where timestamp < $time"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function countUser() { + $q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + function countAlli() { + $q = "SELECT count(id) FROM " . TB_PREFIX . "alidata where id != 0"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + return $row[0]; + } + + /*************************** + Function to process MYSQLi->fetch_all (Only exist in MYSQL) + References: Result + ***************************/ + function mysqli_fetch_all($result) { + $all = array(); + if($result) { + while($row = mysqli_fetch_assoc($result)) { + $all[] = $row; + } + return $all; + } + } + + function query_return($q) { + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + /*************************** + Function to do free query + References: Query + ***************************/ + function query($query) { + return mysqli_query($this->dblink,$query); + } + + function RemoveXSS($val) { + return htmlspecialchars($val, ENT_QUOTES); + } + + //MARKET FIXES + function getWoodAvailable($wref) { + $q = "SELECT wood FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['wood']; + } + + function getClayAvailable($wref) { + $q = "SELECT clay FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['clay']; + } + + function getIronAvailable($wref) { + $q = "SELECT iron FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['iron']; + } + + function getCropAvailable($wref) { + $q = "SELECT crop FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + return $dbarray['crop']; + } + + function Getowner($vid) { + $s = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = $vid"; + $result1 = mysqli_query($this->dblink,$s); + $row1 = mysqli_fetch_row($result1); + return $row1[0]; + } + + public function debug($time, $uid, $debug_info) { + $q = "INSERT INTO " . TB_PREFIX . "debug_info (time,uid,debug_info) VALUES ($time,$uid,$debug_info)"; + if(mysqli_query($this->dblink,$q)) { + return mysqli_insert_id($this->dblink); + } else { + return false; + } + } + + function populateOasisdata() { + $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; + $result2 = mysqli_query($this->dblink,$q2); + while($row = mysqli_fetch_array($result2)) { + $wid = $row['id']; + $basearray = $this->getOMInfo($wid); + if($basearray['oasistype'] < 4) { + $high = 1; + } else if ($basearray['oasistype'] < 10){ + $high = 2; + }else { + $high = 0; + } + //We switch type of oasis and instert record with apropriate infomation. + $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . "," . time() . ",100,2,'Unoccupied Oasis',".$high.")"; + $result = mysqli_query($this->dblink,$q); + } + } + + 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 = $village->wid"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + $maxslots = $row[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 = $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 = $village->wid"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + $chiefs = $row[0]; + + $settlers += 3 * count($this->getMovement(5, $village->wid, 0)); + $current_movement = $this->getMovement(3, $village->wid, 0); + if(!empty($current_movement)) { + foreach($current_movement as $build) { + $settlers += $build['t10']; + $chiefs += $build['t9']; + } + } + $current_movement = $this->getMovement(3, $village->wid, 1); + if(!empty($current_movement)) { + foreach($current_movement as $build) { + $settlers += $build['t10']; + $chiefs += $build['t9']; + } + } + $current_movement = $this->getMovement(4, $village->wid, 0); + if(!empty($current_movement)) { + foreach($current_movement as $build) { + $settlers += $build['t10']; + $chiefs += $build['t9']; + } + } + $current_movement = $this->getMovement(4, $village->wid, 1); + if(!empty($current_movement)) { + foreach($current_movement as $build) { + $settlers += $build['t10']; + $chiefs += $build['t9']; + } + } + $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + if(!empty($row)) { + foreach($row as $reinf) { + $settlers += $reinf[0]; + } + } + $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; + $result = mysqli_query($this->dblink,$q); + $row = mysqli_fetch_row($result); + if(!empty($row)) { + foreach($row as $reinf) { + $chiefs += $reinf[0]; + } + } + $trainlist = $technology->getTrainingList(4); + if(!empty($trainlist)) { + foreach($trainlist as $train) { + if($train['unit'] % 10 == 0) { + $settlers += $train['amt']; + } + if($train['unit'] % 10 == 9) { + $chiefs += $train['amt']; + } + } + } + // trapped settlers/chiefs calculation required + + $settlerslots = $maxslots * 3 - $settlers - $chiefs * 3; + $chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3); + + if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) { + $chiefslots = 0; + } + $slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots); + return $slots; + } + + function addArtefact($vref, $owner, $type, $size, $name, $desc, $effect, $img) { + $q = "INSERT INTO `" . TB_PREFIX . "artefacts` (`vref`, `owner`, `type`, `size`, `conquered`, `name`, `desc`, `effect`, `img`, `active`) VALUES ('$vref', '$owner', '$type', '$size', '" . time() . "', '$name', '$desc', '$effect', '$img', '0')"; + return mysqli_query($this->dblink,$q); + } + + function getOwnArtefactInfo($vref) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getOwnArtefactInfo2($vref) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getOwnArtefactInfo3($uid) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $uid"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getOwnArtefactInfoByType($vref, $type) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = '$vref' AND type = '$type' order by size"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getOwnArtefactInfoByType2($vref, $type) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getOwnUniqueArtefactInfo($id, $type, $size) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getOwnUniqueArtefactInfo2($id, $type, $size, $mode) { + if(!$mode){ + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND active = 1 AND type = $type AND size=$size"; + }else{ + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND active = 1 AND type = $type AND size=$size"; + } + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getFoolArtefactInfo($type,$vid,$uid) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function claimArtefact($vref, $ovref, $id) { + $time = time(); + $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time, active = 1 WHERE vref = $ovref"; + return mysqli_query($this->dblink,$q); + } + + public function canClaimArtifact($from,$vref,$size,$type) { + //fix by Ronix + global $session, $form; + $size1 = $size2 = $size3 = 0; + + $artifact = $this->getOwnArtefactInfo($from); + if (!empty($artifact)) { + $form->addError("error","Treasury is full. Your hero could not claim the artefact"); + return false; + } + $uid=$session->uid; + $q="SELECT Count(size) AS totals, + SUM(IF(size = '1',1,0)) small, + SUM(IF(size = '2',1,0)) great, + SUM(IF(size = '3',1,0)) `unique` + FROM ".TB_PREFIX."artefacts WHERE owner = ".$uid; + $result = mysqli_query($this->dblink,$q); + $artifact= $this->mysqli_fetch_all($result); + + if($artifact['totals'] < 3 || $type==11) { + $DefenderFields = $this->getResourceLevel($vref); + $defcanclaim = TRUE; + for($i=19;$i<=38;$i++) { + if($DefenderFields['f'.$i.'t'] == 27) { + $defTresuaryLevel = $DefenderFields['f'.$i]; + if($defTresuaryLevel > 0) { + $defcanclaim = FALSE; + $form->addError("error","Treasury has not been destroyed. Your hero could not claim the artefact"); + return false; + } else { + $defcanclaim = TRUE; + } + } + } + $AttackerFields = $this->getResourceLevel($from,2); + for($i=19;$i<=38;$i++) { + if($AttackerFields['f'.$i.'t'] == 27) { + $attTresuaryLevel = $AttackerFields['f'.$i]; + if ($attTresuaryLevel >= 10) { + $villageartifact = TRUE; + } else { + $villageartifact = FALSE; + } + if ($attTresuaryLevel >= 20){ + $accountartifact = TRUE; + } else { + $accountartifact = FALSE; + } + } + } + if (($artifact['great']>0 || $artifact['unique']>0) && $size>1) { + $form->addError("error","Max num. of great/unique artefacts. Your hero could not claim the artefact"); + return FALSE; + } + if (($size == 1 && ($villageartifact || $accountartifact)) || (($size == 2 || $size == 3)&& $accountartifact)) { + return true; +/* + if($this->getVillageField($from,"capital")==1 && $type==11) { + $form->addError("error","Ancient Construction Plan cannot kept in capital village"); + return FALSE; + }else{ + return TRUE; + } +*/ + } else { + $form->addError("error","Your level treasury is low. Your hero could not claim the artefact"); + return FALSE; + } + } else { + $form->addError("error","Max num. of artefacts. Your hero could not claim the artefact"); + return FALSE; + } +} + + function getArtefactDetails($id) { + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . ""; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getMovementById($id){ + $q = "SELECT * FROM ".TB_PREFIX."movement WHERE moveid = ".$id.""; + $result = mysqli_query($q); + $array = $this->mysqli_fetch_all($result); + return $array; + } + + function getLinks($id){ + $q = 'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . $id . ' ORDER BY `pos` ASC'; + return mysqli_query($this->dblink,$q); + } + + function removeLinks($id,$uid){ + $q = "DELETE FROM " . TB_PREFIX . "links WHERE `id` = ".$id." and `userid` = ".$uid.""; + return mysqli_query($this->dblink,$q); + } + + function getVilFarmlist($wref){ + $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC'; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + + if($dbarray['id']!=0) { + return true; + } else { + return false; + } + + } + + function getRaidList($id) { + $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id.""; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function delFarmList($id, $owner) { + $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner"; + return mysqli_query($this->dblink,$q); + } + + function delSlotFarm($id) { + $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id"; + return mysqli_query($this->dblink,$q); + } + + function createFarmList($wref, $owner, $name) { + $q = "INSERT INTO " . TB_PREFIX . "farmlist (`wref`, `owner`, `name`) VALUES ('$wref', '$owner', '$name')"; + return mysqli_query($this->dblink,$q); + } + + function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { + $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')"; + return mysqli_query($this->dblink,$q); + } + + function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { + $q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid"; + return mysqli_query($this->dblink,$q); + } + + function getArrayMemberVillage($uid){ + $q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC'; + $result = mysqli_query($this->dblink,$q); + $array = $this->mysqli_fetch_all($result); + return $array; + } + + function addPassword($uid, $npw, $cpw){ + $q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')"; + mysqli_query($this->dblink,$q) or die(mysqli_error()); + } + + function resetPassword($uid, $cpw){ + $q = "SELECT npw FROM `" . TB_PREFIX . "password` WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; + $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); + $dbarray = mysqli_fetch_array($result); + + if(!empty($dbarray)) { + if(!$this->updateUserField($uid, 'password', md5($dbarray['npw']), 1)) return false; + $q = "UPDATE `" . TB_PREFIX . "password` SET used = 1 WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; + mysqli_query($this->dblink,$q) or die(mysqli_error()); + return true; + } + + return false; + } + + function getCropProdstarv($wref) { + global $bid4,$bid8,$bid9,$sesion,$technology; + + $basecrop = $grainmill = $bakery = 0; + $owner = $this->getVrefField($wref, 'owner'); + $bonus = $this->getUserField($owner, 'b4', 0); + + $buildarray = $this->getResourceLevel($wref); + $cropholder = array(); + for($i=1;$i<=38;$i++) { + if($buildarray['f'.$i.'t'] == 4) { + array_push($cropholder,'f'.$i); + } + if($buildarray['f'.$i.'t'] == 8) { + $grainmill = $buildarray['f'.$i]; + } + if($buildarray['f'.$i.'t'] == 9) { + $bakery = $buildarray['f'.$i]; + } + } + $q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = $wref"; + $oasis = $this->query_return($q); + foreach($oasis as $oa){ + switch($oa['type']) { + case 1: + case 2: + $wood += 1; + break; + case 3: + $wood += 1; + $cropo += 1; + break; + case 4: + case 5: + $clay += 1; + break; + case 6: + $clay += 1; + $cropo += 1; + break; + case 7: + case 8: + $iron += 1; + break; + case 9: + $iron += 1; + $cropo += 1; + break; + case 10: + case 11: + $cropo += 1; + break; + case 12: + $cropo += 2; + break; + } + } + for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$buildarray[$cropholder[$i]]]['prod']; } + $crop = $basecrop + $basecrop * 0.25 * $cropo; + if($grainmill >= 1 || $bakery >= 1) { + $crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']); + } + if($bonus > time()) { + $crop *= 1.25; + } + $crop *= SPEED; + return $crop; + } + + //general statistics + + function addGeneralAttack($casualties) { + $time = time(); + $q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)"; + return mysqli_query($this->dblink,$q) or die(mysqli_error()); + } + + function getAttackByDate($time) { + $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1"; + $result = $this->query_return($q); + $attack = 0; + foreach($result as $general){ + if(date("j. M",$time) == date("j. M",$general['time'])){ + $attack += 1; + } + } + return $attack; + } + + function getAttackCasualties($time) { + $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1"; + $result = $this->query_return($q); + $casualties = 0; + foreach($result as $general){ + if(date("j. M",$time) == date("j. M",$general['time'])){ + $casualties += $general['casualties']; + } + } + return $casualties; + } + + //end general statistics + + function addFriend($uid, $column, $friend) { + $q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid"; + return mysqli_query($this->dblink,$q); + } + + function deleteFriend($uid, $column) { + $q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid"; + return mysqli_query($this->dblink,$q); + } + + function checkFriends($uid) { + $user = $this->getUserArray($uid, 1); + for($i=0;$i<=19;$i++) { + if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){ + for($j=$i+1;$j<=19;$j++) { + $k = $j-1; + if($user['friend'.$j] != 0){ + $friend = $this->getUserField($uid, "friend".$j, 0); + $this->addFriend($uid,"friend".$k,$friend); + $this->deleteFriend($uid,"friend".$j); + } + if($user['friend'.$j.'wait'] == 0){ + $friendwait = $this->getUserField($uid, "friend".$j."wait", 0); + $this->addFriend($sessionuid,"friend".$k."wait",$friendwait); + $this->deleteFriend($uid,"friend".$j."wait"); + } + } + } + } + } + + function setVillageEvasion($vid) { + $village = $this->getVillage($vid); + if($village['evasion'] == 0){ + $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 1 WHERE wref = $vid"; + }else{ + $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid"; + } + return mysqli_query($this->dblink,$q); + } + + function addPrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { + $q = "INSERT INTO " . TB_PREFIX . "prisoners values (0,$wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11)"; + mysqli_query($this->dblink,$q); + return mysqli_insert_id($this->dblink); + } + + function updatePrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { + $q = "UPDATE " . TB_PREFIX . "prisoners set t1 = t1 + $t1, t2 = t2 + $t2, t3 = t3 + $t3, t4 = t4 + $t4, t5 = t5 + $t5, t6 = t6 + $t6, t7 = t7 + $t7, t8 = t8 + $t8, t9 = t9 + $t9, t10 = t10 + $t10, t11 = t11 + $t11 where wref = $wid and ".TB_PREFIX."prisoners.from = $from"; + return mysqli_query($this->dblink,$q) or die(mysqli_error()); + } + + function getPrisoners($wid,$mode=0) { + if(!$mode) { + $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid"; + }else { + $q = "SELECT * FROM " . TB_PREFIX . "prisoners where `from` = $wid"; + } + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getPrisoners2($wid,$from) { + $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from"; + $result = mysqli_query($this->dblink,$q); + return $this->mysqli_fetch_all($result); + } + + function getPrisonersByID($id) { + $q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id"; + $result = mysqli_query($this->dblink,$q); + return mysqli_fetch_array($result); + } + + function getPrisoners3($from) { + $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) { + $q = "DELETE from " . TB_PREFIX . "prisoners where id = '$id'"; + mysqli_query($this->dblink,$q); + } + +/***************************************** +Function to vacation mode - by advocaite +References: +*****************************************/ + + function setvacmode($uid,$days){ + $days1 =60*60*24*$days; + $time =time()+$days1; + $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '1' , vac_time=".$time." WHERE id=".$uid.""; + $result =mysqli_query($this->dblink,$q); + } + + function removevacationmode($uid){ + $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '0' , vac_time='0' WHERE id=".$uid.""; + $result =mysqli_query($this->dblink,$q); + } + + function getvacmodexy($wref){ + $q = "SELECT id,oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; + $result = mysqli_query($this->dblink,$q); + $dbarray = mysqli_fetch_array($result); + if($dbarray['occupied'] != 0 && $dbarray['oasistype'] == 0) { + $q1 = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = ".$dbarray['id'].""; + $result1 = mysqli_query($this->dblink,$q1); + $dbarray1 = mysqli_fetch_array($result1); + if($dbarray1['owner'] != 0){ + $q2 = "SELECT vac_mode,vac_time FROM " . TB_PREFIX . "users where id = ".$dbarray1['owner'].""; + $result2 = mysqli_query($this->dblink,$q2); + $dbarray2 = mysqli_fetch_array($result2); + if($dbarray2['vac_mode'] ==1){ + return true; + }else{ + return false; + } + } + } else { + return false; + } + } + + /***************************************** + Function to vacation mode - by advocaite + References: + *****************************************/ + + /*************************** + Function to get Hero Dead + Made by: Shadow and brainiacX + ***************************/ + + function getHeroDead($id) { + $q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; + $result = mysqli_query($this->dblink,$q); + $notend= mysqli_fetch_array($result); + return $notend['dead']; + } + + /*************************** + Function to get Hero In Revive + Made by: Shadow + ***************************/ + + function getHeroInRevive($id) { + $q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; + $result = mysqli_query($this->dblink,$q); + $notend= mysqli_fetch_array($result); + return $notend['inrevive']; + } + + /*************************** + Function to get Hero In Training + Made by: Shadow + ***************************/ + + function getHeroInTraining($id) { + $q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; + $result = mysqli_query($this->dblink,$q); + $notend= mysqli_fetch_array($result); + return $notend['intraining']; + } + + /*************************** + Function to check Hero Not in Village + Made by: Shadow and brainiacX + ***************************/ + + function HeroNotInVil($id) { + $heronum=0; + $outgoingarray = $this->getMovement(3, $id, 0); + if(!empty($outgoingarray)) { + foreach($outgoingarray as $out) { + $heronum += $out['t11']; + } + } + $returningarray = $this->getMovement(4, $id, 1); + if(!empty($returningarray)) { + foreach($returningarray as $ret) { + if($ret['attack_type'] != 1) { + $heronum += $ret['t11']; + } + } + } + return $heronum; + } + + /*************************** + Function to Kill hero if not found + Made by: Shadow and brainiacX + ***************************/ + + function KillMyHero($id) { + $q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id; + return mysqli_query($this->dblink,$q); + } + + /*************************** + Function to find Hero place + Made by: ronix + ***************************/ + function FindHeroInVil($wid) { + $result = $this->query("SELECT * FROM ".TB_PREFIX."units WHERE hero>0 AND vref='".$wid."'"); + if (!empty($result)) { + $dbarray = mysqli_fetch_array($result); + if(isset($dbarray['hero'])) { + $this->query("UPDATE ".TB_PREFIX."units SET hero=0 WHERE vref='".$wid."'"); + unset($dbarray); + return true; + } + } + return false; + } + function FindHeroInDef($wid) { + $delDef=true; + $result = $this->query_return("SELECT * FROM ".TB_PREFIX."enforcement WHERE hero>0 AND `from` = ".$wid); + if (!empty($result)) { + $dbarray = mysqli_fetch_array($result); + if(isset($dbarray['hero'])) { + $this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$wid); + for ($i=0;$i<50;$i++) { + if($dbarray['u'.$i]>0) { + $delDef=false; + break; + } + } + if ($delDef) $this->deleteReinf($wid); + unset($dbarray); + return true; + } + } + return false; + } + function FindHeroInOasis($uid) { + $delDef=true; + $dbarray = $this->query_return("SELECT e.*,o.conqured,o.owner FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.owner=".$uid." AND e.hero>0"); + if(!empty($dbarray)) { + foreach($dbarray as $defoasis) { + if($defoasis['hero']>0) { + $this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$defoasis['from']); + for ($i=0;$i<50;$i++) { + if($dbarray['u'.$i]>0) { + $delDef=false; + break; + } + } + if ($delDef) $this->deleteReinf($defoasis['from']); + unset($dbarray); + return true; + } + } + } + return 0; + } + + function FindHeroInMovement($wid) { + $outgoingarray = $this->getMovement(3, $wid, 0); + if(!empty($outgoingarray)) { + foreach($outgoingarray as $out) { + if ($out['t11']>0) { + $dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$out['ref']); + return true; + break; + } + } + } + $returningarray = $this->getMovement(4, $wid, 1); + if(!empty($returningarray)) { + foreach($returningarray as $ret) { + if($ret['attack_type'] != 1 && $ret['t11']>0) { + $dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$ret['ref']); + return true; + break; + } + } + } + return false; + } + + /*************************** + Function checkAttack + Made by: Shadow + ***************************/ + + function checkAttack($wref, $toWref){ + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and (" . TB_PREFIX . "attacks.attack_type = 3 or " . TB_PREFIX . "attacks.attack_type = 4) ORDER BY endtime ASC"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + } else { + return false; + } + } + + /*************************** + Function checkEnforce + Made by: Shadow + ***************************/ + + function checkEnforce($wref, $toWref) { + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 2 ORDER BY endtime ASC"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + }else{ + return false; + } + } + + /*************************** + Function checkScout + Made by: yi12345 + ***************************/ + + function checkScout($wref, $toWref) { + $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; + $result = mysqli_query($this->dblink,$q); + if(mysqli_num_rows($result)) { + return true; + }else{ + return false; + } + } + +}; +$database = new MYSQLi_DB; +$link = $database->return_link(); +$GLOBALS['db'] = $database; +$GLOBALS['link'] = $database->return_link(); ?> diff --git a/GameEngine/Database/db_MYSQLi.php b/GameEngine/Database/db_MYSQLi.php deleted file mode 100755 index 36307a2f..00000000 --- a/GameEngine/Database/db_MYSQLi.php +++ /dev/null @@ -1,3876 +0,0 @@ -dblink = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); - mysqli_select_db($this->dblink, SQL_DB); - mysqli_query($this->dblink,"SET NAMES 'UTF8'"); - } - - function return_link() { - return $this->dblink; - } - - function register($username, $password, $email, $tribe, $act) { - $time = time(); - $stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME); - if($stime > time()){ - $time = $stime; - } - $timep = $time + PROTECTION; - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)"; - if(mysqli_query($this->dblink,$q)) { - return mysqli_insert_id($this->dblink); - } else { - return false; - } - } - - function activate($username, $password, $email, $tribe, $locate, $act, $act2) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')"; - if(mysqli_query($this->dblink,$q)) { - return mysqli_insert_id($this->dblink); - } else { - return false; - } - } - - function unreg($username) { - $q = "DELETE from " . TB_PREFIX . "activate where username = '$username'"; - return mysqli_query($this->dblink,$q); - } - function deleteReinf($id) { - $q = "DELETE from " . TB_PREFIX . "enforcement where id = '$id'"; - mysqli_query($this->dblink,$q); - } - function updateResource($vid, $what, $number) { - - $q = "UPDATE " . TB_PREFIX . "vdata set " . $what . "=" . $number . " where wref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_query($this->dblink,$q); - } - - function checkExist($ref, $mode) { - - if(!$mode) { - $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1"; - } else { - $q = "SELECT email FROM " . TB_PREFIX . "users where email = '$ref' LIMIT 1"; - } - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function checkExist_activate($ref, $mode) { - - if(!$mode) { - $q = "SELECT username FROM " . TB_PREFIX . "activate where username = '$ref' LIMIT 1"; - } else { - $q = "SELECT email FROM " . TB_PREFIX . "activate where email = '$ref' LIMIT 1"; - } - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - public function hasBeginnerProtection($vid) { - $q = "SELECT u.protect FROM ".TB_PREFIX."users u,".TB_PREFIX."vdata v WHERE u.id=v.owner AND v.wref=".$vid; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - if(!empty($dbarray)) { - if(time()<$dbarray[0]) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - function updateUserField($ref, $field, $value, $switch) { - if(!$switch) { - $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where username = '$ref'"; - } else { - $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where id = '$ref'"; - } - return mysqli_query($this->dblink,$q); - } - - function getSitee($uid) { - $q = "SELECT id from " . TB_PREFIX . "users where sit1 = $uid or sit2 = $uid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getVilWref($x, $y) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where x = $x AND y = $y"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['id']; - } - - function caststruc($user) { - //loop search village user - $query = mysqli_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); - while($villaggi_array = mysqli_fetch_array($query)) - - //loop structure village - $query1 = mysqli_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); - $strutture= mysqli_fetch_array($query1); - return $strutture; - } - - function removeMeSit($uid, $uid2) { - $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2"; - mysqli_query($this->dblink,$q); - $q2 = "UPDATE " . TB_PREFIX . "users set sit2 = 0 where id = $uid and sit2 = $uid2"; - mysqli_query($q2, $this->dblink); - } - - function getUserField($ref, $field, $mode) { - if(!$mode) { - $q = "SELECT $field FROM " . TB_PREFIX . "users where id = '$ref'"; - } else { - $q = "SELECT $field FROM " . TB_PREFIX . "users where username = '$ref'"; - } - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - if($result) { - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - }elseif($field=="username"){ - return "??"; - }else return 0; - } - - function getInvitedUser($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "users where invited = $uid order by regtime desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getVrefField($ref, $field){ - $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - } - - function getVrefCapital($ref){ - $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray; - } - - 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); - } - - function getUnstarvation(){ - $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv = 0 and starvupdate = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getActivateField($ref, $field, $mode) { - if(!$mode) { - $q = "SELECT $field FROM " . TB_PREFIX . "activate where id = '$ref'"; - } else { - $q = "SELECT $field FROM " . TB_PREFIX . "activate where username = '$ref'"; - } - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - } - - function login($username, $password) { - $q = "SELECT password,sessid FROM " . TB_PREFIX . "users where username = '$username'"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - if($dbarray['password'] == md5($password)) { - return true; - } else { - return false; - } - } - - function checkActivate($act) { - $q = "SELECT * FROM " . TB_PREFIX . "activate where act = '$act'"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - - return $dbarray; - } - - function sitterLogin($username, $password) { - $q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - if($dbarray['sit1'] != 0) { - $q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED; - $result2 = mysqli_query($q2, $this->dblink); - $dbarray2 = mysqli_fetch_array($result2); - } - if($dbarray['sit2'] != 0) { - $q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED; - $result3 = mysqli_query($q3, $this->dblink); - $dbarray3 = mysqli_fetch_array($result3); - } - if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) { - if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - function setDeleting($uid, $mode) { - $time = time() + 72 * 3600; - if(!$mode) { - $q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)"; - } else { - $q = "DELETE FROM " . TB_PREFIX . "deleting where uid = $uid"; - } - mysqli_query($this->dblink,$q); - } - - function isDeleting($uid) { - $q = "SELECT timestamp from " . TB_PREFIX . "deleting where uid = $uid"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['timestamp']; - } - - function modifyGold($userid, $amt, $mode) { - if(!$mode) { - $q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid"; - } else { - $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid"; - } - return mysqli_query($this->dblink,$q); - } - - /***************************************** - Function to retrieve user array via Username or ID - Mode 0: Search by Username - Mode 1: Search by ID - References: Alliance ID - *****************************************/ - - function getUserArray($ref, $mode) { - if(!$mode) { - $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref'"; - } else { - $q = "SELECT * FROM " . TB_PREFIX . "users where id = '$ref'"; - } - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function activeModify($username, $mode) { - $time = time(); - if(!$mode) { - $q = "INSERT into " . TB_PREFIX . "active VALUES ('$username',$time)"; - } else { - $q = "DELETE FROM " . TB_PREFIX . "active where username = '$username'"; - } - return mysqli_query($this->dblink,$q); - } - - function addActiveUser($username, $time) { - $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; - if(mysqli_query($this->dblink,$q)) { - return true; - } else { - return false; - } - } - - function updateActiveUser($username, $time) { - $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)"; - $q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'"; - $exec1 = mysqli_query($this->dblink,$q); - $exec2 = mysqli_query($q2, $this->dblink); - if($exec1 && $exec2) { - return true; - } else { - return false; - } - } - - function checkactiveSession($username, $sessid) { - $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$username' and sessid = '$sessid' LIMIT 1"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result) != 0) { - return true; - } else { - return false; - } - } - - function submitProfile($uid, $gender, $location, $birthday, $des1, $des2) { - $q = "UPDATE " . TB_PREFIX . "users set gender = $gender, location = '$location', birthday = '$birthday', desc1 = '$des1', desc2 = '$des2' where id = $uid"; - return mysqli_query($this->dblink,$q); - } - - function gpack($uid, $gpack) { - $q = "UPDATE " . TB_PREFIX . "users set gpack = '$gpack' where id = $uid"; - return mysqli_query($this->dblink,$q); - } - - function GetOnline($uid) { - $q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['sit']; - } - - function UpdateOnline($mode, $name = "", $time = "", $uid = 0) { - global $session; - if($mode == "login") { - $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)"; - return mysqli_query($this->dblink,$q); - } else if($mode == "sitter") { - $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)"; - return mysqli_query($this->dblink,$q); - } else { - $q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . addslashes($session->username) . "'"; - return mysqli_query($this->dblink,$q); - } - } - - function generateBase($sector, $mode=1) { - $num_rows = 0; - $count_while = 0; - while (!$num_rows){ - if (!$mode) { - $gamesday=time()-COMMENCE; - if ($gamesday<3600*24*10 && $count_while==0) { //10 day - $wide1=1; - $wide2=20; - } elseif ($gamesday<3600*24*20 && $count_while==1) { //20 day - $wide1=20; - $wide2=40; - } elseif ($gamesday<3600*24*30 && $count_while==2) { //30 day - $wide1=40; - $wide2=80; - } else { // over 30 day - $wide1=80; - $wide2=WORLD_MAX; - } - } - else { - $wide1=1; - $wide2=WORLD_MAX; - } - switch($sector) { - case 1: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x- y+ - break; - case 2: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x+ y+ - break; - case 3: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x- y- - break; - case 4: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- - break; - } - $result = mysqli_query($this->dblink,$q); - $num_rows = mysqli_num_rows($result); - $count_while++; - } - $result = $this->mysqli_fetch_all($result); - $base = rand(0, ($num_rows-1)); - return $result[$base]['id']; - } - - function setFieldTaken($id) { - $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function addVillage($wid, $uid, $username, $capital) { - $total = count($this->getVillagesID($uid)); - if($total >= 1) { - $vname = $username . "\'s village " . ($total + 1); - } else { - $vname = $username . "\'s village"; - } - $time = time(); - $q = "INSERT into " . TB_PREFIX . "vdata (wref, owner, name, capital, pop, cp, celebration, wood, clay, iron, maxstore, crop, maxcrop, lastupdate, created) values ('$wid', '$uid', '$vname', '$capital', 2, 1, 0, 750, 750, 750, ".STORAGE_BASE.", 750, ".STORAGE_BASE.", '$time', '$time')"; - return mysqli_query($this->dblink,$q) or die(mysqli_error()); - } - - function addResourceFields($vid, $type) { - switch($type) { - case 1: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,4,4,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 2: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 3: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 4: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 5: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 6: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,3,4,4,4,4,4,4,4,4,4,4,4,2,4,4,1,15)"; - break; - case 7: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 8: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 9: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 10: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - case 11: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,1,1,3,1,4,4,3,3,2,2,3,1,4,4,2,4,4,1,15)"; - break; - case 12: - $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)"; - break; - } - return mysqli_query($this->dblink,$q); - } - function isVillageOases($wref) { - $q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - if($result){ - $dbarray = mysqli_fetch_array($result); - return $dbarray['oasistype']; - }else return 0; - } - - public function VillageOasisCount($vref) { - $q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - public function countOasisTroops($vref){ - //count oasis troops: $troops_o - $troops_o=0; - $o_unit2=mysqli_query("select * from ".TB_PREFIX."units where `vref`='".$vref."'"); - $o_unit=mysqli_fetch_array($o_unit2); - - for ($i=1;$i<51;$i++) - { - $troops_o+=$o_unit[$i]; - } - $troops_o+=$o_unit['hero']; - - $o_unit2=mysqli_query("select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'"); - while ($o_unit=@mysqli_fetch_array($o_unit2)) - { - for ($i=1;$i<51;$i++) - { - $troops_o+=$o_unit[$i]; - } - $troops_o+=$o_unit['hero']; - } - return $troops_o; - } - - public function canConquerOasis($vref,$wref) { - $AttackerFields = $this->getResourceLevel($vref); - for($i=19;$i<=38;$i++) { - if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; } - } - if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) { - $OasisInfo = $this->getOasisInfo($wref); - //fix by ronix - if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && intval($OasisInfo['loyalty']) < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))){ - $CoordsVillage = $this->getCoor($vref); - $CoordsOasis = $this->getCoor($wref); - $max = 2 * WORLD_MAX + 1; - $x1 = intval($CoordsOasis['x']); - $y1 = intval($CoordsOasis['y']); - $x2 = intval($CoordsVillage['x']); - $y2 = intval($CoordsVillage['y']); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - if ($distanceX<=3 && $distanceY<=3) { - return 1; //can - } else { - return 2; //can but not in 7x7 field - } - } else { - return 3; //loyalty >0 - } - } else { - return 0; //req level hero mansion - } - } - - public function conquerOasis($vref,$wref) { - $vinfo = $this->getVillage($vref); - $uid = $vinfo['owner']; - $q = "UPDATE `".TB_PREFIX."odata` SET conqured=$vref,loyalty=100,lastupdated=".time().",owner=$uid,name='Occupied Oasis' WHERE wref=$wref"; - return mysqli_query($this->dblink,$q); - } - - public function modifyOasisLoyalty($wref) { - if($this->isVillageOases($wref) != 0) { - $OasisInfo = $this->getOasisInfo($wref); - if($OasisInfo['conqured'] != 0) { - $LoyaltyAmendment = floor(100 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))); - $q = "UPDATE `".TB_PREFIX."odata` SET loyalty=loyalty-$LoyaltyAmendment, lastupdated=".time()." WHERE wref=$wref"; - $result=mysqli_query($this->dblink,$q); - return $OasisInfo['loyalty']-$LoyaltyAmendment; - } - } - } - - function populateOasis() { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result = mysqli_query($this->dblink,$q); - while($row = mysqli_fetch_array($result)) { - $wid = $row['id']; - - $this->addUnits($wid); - - } - } - - function populateOasisUnits($wid, $high) { - $basearray = $this->getOasisInfo($wid); - if($high == 0){ - $max = rand(15,30); - }elseif($high == 1){ - $max = rand(50,70); - }elseif($high == 2){ - $max = rand(90,120); - } - $max2 = 0; - $rand = rand(0,3); - if($rand == 1){ - $max2 = 3; - } - //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less - switch($basearray['type']) { - case 1: - case 2: - //+25% lumber per hour - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u35 <= ".$max." OR u36 <= ".$max." OR u37 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 3: - //+25% lumber and +25% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 4: - case 5: - //+25% clay per hour - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 6: - //+25% clay and +25% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 7: - case 8: - //+25% iron per hour - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 9: - //+25% iron and +25% crop - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 10: - case 11: - //+25% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - case 12: - //+50% crop per hour - $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max." OR u39 <= ".$max.")"; - $result = mysqli_query($this->dblink,$q); - break; - } - } - - function populateOasisUnits2() { - $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result2 = mysqli_query($q2, $this->dblink); - while($row = mysqli_fetch_array($result2)) { - $wid = $row['id']; - switch($row['oasistype']) { - case 1: - case 2: - //+25% lumber oasis - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,10)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <= '10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 3: - //+25% lumber and +25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,15)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <='10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 4: - case 5: - //+25% clay oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <= '10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 6: - //+25% clay and +25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <='10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 7: - case 8: - //+25% iron oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <= '10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 9: - //+25% iron and +25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <='10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 10: - case 11: - //+25% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(5,15)."', u33 = u33 + '".rand(5,10)."', u37 = u37 + '".rand(0,10)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u37 <='10' AND u39 <='10'"; - $result = mysqli_query($this->dblink,$q); - break; - case 12: - //+50% crop oasis - $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u33 = u33 + '".rand(5,10)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u38 <='10'AND u39 <='10'"; - $result = mysqli_query($this->dblink,$q); - break; - } - } - } - - function removeOases($wref) { - $q = "UPDATE ".TB_PREFIX."odata SET conqured = 0, owner = 2, name = 'Unoccupied Oasis' WHERE wref = $wref"; - return mysqli_query($this->dblink,$q); - } - - - /*************************** - Function to retrieve type of village via ID - References: Village ID - ***************************/ - function getVillageType($wref) { - $q = "SELECT id, fieldtype FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['fieldtype']; - } - - - - /***************************************** - Function to retrieve if is ocuped via ID - References: Village ID - *****************************************/ - function getVillageState($wref) { - $q = "SELECT oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - if($dbarray['occupied'] != 0 || $dbarray['oasistype'] != 0) { - return true; - } else { - return false; - } - } - - function getProfileVillages($uid) { - $q = "SELECT capital,wref,name,pop,created from " . TB_PREFIX . "vdata where owner = $uid order by pop desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getProfileMedal($uid) { - $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "medal where userid = $uid and del = 0 order by id desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - - } - - function getProfileMedalAlly($uid) { - $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "allimedal where allyid = $uid and del = 0 order by id desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - - } - - function getVillageID($uid) { - $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE owner = $uid"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['wref']; - } - - - function getVillagesID($uid) { - $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); - $newarray = array(); - for($i = 0; $i < count($array); $i++) { - array_push($newarray, $array[$i]['wref']); - } - return $newarray; - } - - function getVillagesID2($uid) { - $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); - return $array; - } - - function getVillage($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - public function getVillageBattleData($vid) { - $q = "SELECT u.id,u.tribe,v.capital,f.f40 AS wall FROM ".TB_PREFIX."users u,".TB_PREFIX."fdata f,".TB_PREFIX."vdata v WHERE u.id=v.owner AND f.vref=v.wref AND v.wref=".$vid; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - public function getPopulation($uid) { - $q = "SELECT sum(pop) AS pop FROM ".TB_PREFIX."vdata WHERE owner=".$uid; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['pop']; - } - - function getOasisV($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getMInfo($id) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "vdata ON " . TB_PREFIX . "vdata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getOMInfo($id) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "odata ON " . TB_PREFIX . "odata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getOasis($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = $vid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getOasisInfo($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $wid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function getVillageField($ref, $field) { - $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref"; - $result = mysqli_query($this->dblink,$q); - if($result){ - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - }elseif($field=="name"){ - return "??"; - }else return 0; - } - - function getOasisField($ref, $field) { - $q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - } - - function setVillageField($ref, $field, $value) { - $q = "UPDATE " . TB_PREFIX . "vdata set $field = '$value' where wref = $ref"; - return mysqli_query($this->dblink,$q); - } - - function setVillageLevel($ref, $field, $value) { - $q = "UPDATE " . TB_PREFIX . "fdata set " . $field . " = '" . $value . "' where vref = " . $ref . ""; - return mysqli_query($this->dblink,$q); - } - - function getResourceLevel($vid) { - $q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function getAdminLog() { - $q = "SELECT id,user,log,time from " . TB_PREFIX . "admin_log where id != 0 ORDER BY id ASC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - //fix market log - function getMarketLog() { - $q = "SELECT id,wid,log from " . TB_PREFIX . "market_log where id != 0 ORDER BY id ASC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - function getMarketLogVillage($village) { - $q = "SELECT wref,owner,name from " . TB_PREFIX . "vdata where wref =$village "; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - function getMarketLogUsers($id_user) { - $q = "SELECT id,username from " . TB_PREFIX . "users where id =$id_user "; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - //end fix - - function getCoor($wref) { - if ($wref !=""){ - $q = "SELECT x,y FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - } - - function CheckForum($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CountCat($id) { - $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - function LastTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' order by post_date"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function CheckLastTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CheckLastPost($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function LastPost($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function CountTopic($id) { - $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where owner = '$id'"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - - $qs = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where owner = '$id'"; - $results = mysqli_query($qs, $this->dblink); - $rows = mysqli_fetch_row($results); - return $row[0] + $rows[0]; - } - - function CountPost($id) { - $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - function ForumCat($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id' ORDER BY id"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function ForumCatEdit($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_cat where id = '$id'"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function ForumCatAlliance($id) { - $q = "SELECT alliance from " . TB_PREFIX . "forum_cat where id = $id"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['alliance']; - } - - function ForumCatName($id) { - $q = "SELECT forum_name from " . TB_PREFIX . "forum_cat where id = $id"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['forum_name']; - } - - function CheckCatTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CheckResultEdit($alli) { - $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function CheckCloseTopic($id) { - $q = "SELECT close from " . TB_PREFIX . "forum_topic where id = '$id'"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['close']; - } - - function CheckEditRes($alli) { - $q = "SELECT result from " . TB_PREFIX . "forum_edit where alliance = '$alli'"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['result']; - } - - function CreatResultEdit($alli, $result) { - $q = "INSERT into " . TB_PREFIX . "forum_edit values (0,'$alli','$result')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function UpdateResultEdit($alli, $result) { - $date = time(); - $q = "UPDATE " . TB_PREFIX . "forum_edit set result = '$result' where alliance = '$alli'"; - return mysqli_query($this->dblink,$q); - } - - function getVillageType2($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['oasistype']; - } - - function getVillageType3($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray; - } - - function getFLData($id) { - $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function checkVilExist($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function checkOasisExist($wref) { - $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function UpdateEditTopic($id, $title, $cat) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set title = '$title', cat = '$cat' where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function UpdateEditForum($id, $name, $des) { - $q = "UPDATE " . TB_PREFIX . "forum_cat set forum_name = '$name', forum_des = '$des' where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function StickTopic($id, $mode) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set stick = '$mode' where id = '$id'"; - return mysqli_query($this->dblink,$q); - } - - function ForumCatTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '' ORDER BY post_date desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function ForumCatTopicStick($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '1' ORDER BY post_date desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function ShowTopic($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_topic where id = '$id'"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function ShowPost($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function ShowPostEdit($id) { - $q = "SELECT * from " . TB_PREFIX . "forum_post where id = '$id'"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function CreatForum($owner, $alli, $name, $des, $area) { - $q = "INSERT into " . TB_PREFIX . "forum_cat values (0,'$owner','$alli','$name','$des','$area')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - /************************* - FORUM SUREY - *************************/ - - function createSurvey($topic, $title, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $ends) { - $q = "INSERT into " . TB_PREFIX . "forum_survey (topic,title,option1,option2,option3,option4,option5,option6,option7,option8,ends) values ('$topic','$title','$option1','$option2','$option3','$option4','$option5','$option6','$option7','$option8','$ends')"; - return mysqli_query($this->dblink,$q); - } - - function getSurvey($topic) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function checkSurvey($topic) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function Vote($topic, $num, $text) { - $q = "UPDATE " . TB_PREFIX . "forum_survey set vote".$num." = vote".$num." + 1, voted = '$text' where topic = ".$topic.""; - return mysqli_query($this->dblink,$q); - } - - function checkVote($topic, $uid) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($this->dblink,$q); - $array = mysqli_fetch_array($result); - $text = $array['voted']; - if(preg_match('/,'.$uid.',/',$text)) { - return true; - } else { - return false; - } - } - - function getVoteSum($topic) { - $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic"; - $result = mysqli_query($this->dblink,$q); - $array = mysqli_fetch_array($result); - $sum = 0; - for($i=1;$i<=8;$i++){ - $sum += $array['vote'.$i]; - } - return $sum; - } - - - /************************* - FORUM SUREY - *************************/ - - function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function UpdatePostDate($id) { - $date = time(); - $q = "UPDATE " . TB_PREFIX . "forum_topic set post_date = '$date' where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) { - $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function LockTopic($id, $mode) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'"; - return mysqli_query($this->dblink,$q); - } - - function DeleteCat($id) { - $qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'"; - $q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'"; - $q2="SELECT id from ".TB_PREFIX."forum_topic where cat ='$id'"; - $result = mysqli_query($q2, $this->dblink); - if (!empty($result)) { - $array=$this->mysqli_fetch_all($result); - foreach($array as $ss) { - $this->DeleteSurvey($ss['id']); - } - } - mysqli_query($qs, $this->dblink); - return mysqli_query($this->dblink,$q); - } - - function DeleteSurvey($id) { - $qs = "DELETE from " . TB_PREFIX . "forum_survey where topic = '$id'"; - return mysqli_query($qs, $this->dblink); - } - - function DeleteTopic($id) { - $qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'"; - // $q = "DELETE from ".TB_PREFIX."forum_post where topic = '$id'";// - return mysqli_query($qs, $this->dblink); // - // mysqli_query($this->dblink,$q); - } - - function DeletePost($id) { - $q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'"; - return mysqli_query($this->dblink,$q); - } - - function getAllianceName($id) { - $q = "SELECT tag from " . TB_PREFIX . "alidata where id = $id"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['tag']; - } - - function getAlliancePermission($ref, $field, $mode) { - if(!$mode) { - $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where uid = '$ref'"; - } else { - $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where username = '$ref'"; - } - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - } - - function getAlliance($id) { - $q = "SELECT * from " . TB_PREFIX . "alidata where id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function setAlliName($aid, $name, $tag) { - $q = "UPDATE " . TB_PREFIX . "alidata set name = '$name', tag = '$tag' where id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function isAllianceOwner($id) { - $q = "SELECT * from " . TB_PREFIX . "alidata where leader = '$id'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function aExist($ref, $type) { - $q = "SELECT $type FROM " . TB_PREFIX . "alidata where $type = '$ref'"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - function modifyPoints($aid, $points, $amt) { - $q = "UPDATE " . TB_PREFIX . "users set $points = $points + $amt where id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function modifyPointsAlly($aid, $points, $amt) { - $q = "UPDATE " . TB_PREFIX . "alidata set $points = $points + $amt where id = $aid"; - return mysqli_query($this->dblink,$q); - } - - /***************************************** - Function to create an alliance - References: - *****************************************/ - function createAlliance($tag, $name, $uid, $max) { - $q = "INSERT into " . TB_PREFIX . "alidata values (0,'$name','$tag',$uid,0,0,0,'','',$max,'','','','','','','','','')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function procAllyPop($aid) { - $ally = $this->getAlliance($aid); - $memberlist = $this->getAllMember($ally['id']); - $oldrank = 0; - foreach($memberlist as $member) { - $oldrank += $this->getVSumField($member['id'],"pop"); - } - if($ally['oldrank'] != $oldrank){ - if($ally['oldrank'] < $oldrank) { - $totalpoints = $oldrank - $ally['oldrank']; - $this->addclimberrankpopAlly($ally['id'], $totalpoints); - $this->updateoldrankAlly($ally['id'], $oldrank); - } else - if($ally['oldrank'] > $oldrank) { - $totalpoints = $ally['oldrank'] - $oldrank; - $this->removeclimberrankpopAlly($ally['id'], $totalpoints); - $this->updateoldrankAlly($ally['id'], $oldrank); - } - } - } - - /***************************************** - Function to insert an alliance new - References: - *****************************************/ - function insertAlliNotice($aid, $notice) { - $time = time(); - $q = "INSERT into " . TB_PREFIX . "ali_log values (0,'$aid','$notice',$time)"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - /***************************************** - Function to delete alliance if empty - References: - *****************************************/ - function deleteAlliance($aid) { - $result = mysqli_query("SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"); - $num_rows = mysqli_num_rows($result); - if($num_rows == 0) { - $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid"; - } - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - /***************************************** - Function to read all alliance news - References: - *****************************************/ - function readAlliNotice($aid) { - $q = "SELECT * from " . TB_PREFIX . "ali_log where aid = $aid ORDER BY date DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - /***************************************** - Function to create alliance permissions - References: ID, notice, description - *****************************************/ - function createAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) { - - $q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - /***************************************** - Function to update alliance permissions - References: - *****************************************/ - function deleteAlliPermissions($uid) { - $q = "DELETE from " . TB_PREFIX . "ali_permission where uid = '$uid'"; - return mysqli_query($this->dblink,$q); - } - /***************************************** - Function to update alliance permissions - References: - *****************************************/ - function updateAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7) { - - $q = "UPDATE " . TB_PREFIX . "ali_permission SET rank = '$rank', opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' where uid = $uid && alliance =$aid"; - return mysqli_query($this->dblink,$q); - } - - /***************************************** - Function to read alliance permissions - References: ID, notice, description - *****************************************/ - function getAlliPermissions($uid, $aid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_permission where uid = $uid && alliance = $aid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - /***************************************** - Function to update an alliance description and notice - References: ID, notice, description - *****************************************/ - function submitAlliProfile($aid, $notice, $desc) { - - $q = "UPDATE " . TB_PREFIX . "alidata SET `notice` = '$notice', `desc` = '$desc' where id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function diplomacyInviteAdd($alli1, $alli2, $type) { - $q = "INSERT INTO " . TB_PREFIX . "diplomacy (alli1,alli2,type,accepted) VALUES ($alli1,$alli2," . (int)intval($type) . ",0)"; - return mysqli_query($this->dblink,$q); - } - - function diplomacyOwnOffers($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getAllianceID($name) { - $q = "SELECT id FROM " . TB_PREFIX . "alidata WHERE tag ='" . $this->RemoveXSS($name) . "'"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray['id']; - } - - function getDiplomacy($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE id = $aid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function diplomacyCancelOffer($id) { - $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id"; - return mysqli_query($this->dblink,$q); - } - - function diplomacyInviteAccept($id, $session_alliance) { - $q = "UPDATE " . TB_PREFIX . "diplomacy SET accepted = 1 WHERE id = $id AND alli2 = $session_alliance"; - return mysqli_query($this->dblink,$q); - } - - function diplomacyInviteDenied($id, $session_alliance) { - $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance"; - return mysqli_query($this->dblink,$q); - } - - function diplomacyInviteCheck($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function diplomacyInviteCheck2($ally1, $ally2) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getAllianceDipProfile($aid, $type){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'"; - $array = $this->query_return($q); - foreach($array as $row){ - if($row['alli1'] == $aid){ - $alliance = $this->getAlliance($row['alli2']); - }elseif($row['alli2'] == $aid){ - $alliance = $this->getAlliance($row['alli1']); - } - $text .= ""; - $text .= "".$alliance['tag']."
"; - } - if(strlen($text) == 0){ - $text = "-
"; - } - return $text; - } - - function getAllianceWar($aid){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; - $array = $this->query_return($q); - foreach($array as $row){ - if($row['alli1'] == $aid){ - $alliance = $this->getAlliance($row['alli2']); - }elseif($row['alli2'] == $aid){ - $alliance = $this->getAlliance($row['alli1']); - } - $text .= ""; - $text .= "".$alliance['tag']."
"; - } - if(strlen($text) == 0){ - $text = "-
"; - } - return $text; - } - - function getAllianceAlly($aid, $type){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE (alli1 = '$aid' or alli2 = '$aid') AND (type = '$type' AND accepted = '1')"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getAllianceWar2($aid){ - $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function diplomacyExistingRelationships($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function diplomacyExistingRelationships2($session_alliance) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 1"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function diplomacyCancelExistingRelationship($id, $session_alliance) { - $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance"; - return mysqli_query($this->dblink,$q); - } - - function checkDiplomacyInviteAccept($aid, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1"; - $result = mysqli_query($this->dblink,$q); - if($type == 3){ - return true; - }else{ - if(mysqli_num_rows($result) < 4) { - return true; - } else { - return false; - } - } - } - - function setAlliForumdblink($aid, $dblink) { - $q = "UPDATE " . TB_PREFIX . "alidata SET `forumdblink` = '$dblink' WHERE id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function getUserAlliance($id) { - $q = "SELECT " . TB_PREFIX . "alidata.tag from " . TB_PREFIX . "users join " . TB_PREFIX . "alidata where " . TB_PREFIX . "users.alliance = " . TB_PREFIX . "alidata.id and " . TB_PREFIX . "users.id = $id"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - if($dbarray['tag'] == "") { - return "-"; - } else { - return $dbarray['tag']; - } - } - - /////////////ADDED BY BRAINIAC - THANK YOU - - function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) { - $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "vdata where wref = ".$vid.""; - $result = mysqli_query($this->dblink,$q); - $checkres= $this->mysqli_fetch_all($result); - if(!$mode){ - $nwood=$checkres[0]['wood']-$wood; - $nclay=$checkres[0]['clay']-$clay; - $niron=$checkres[0]['iron']-$iron; - $ncrop=$checkres[0]['crop']-$crop; - if($nwood<0 or $nclay<0 or $niron<0 or $ncrop<0){$shit=true;} - $dwood=($nwood<0)?0:$nwood; - $dclay=($nclay<0)?0:$nclay; - $diron=($niron<0)?0:$niron; - $dcrop=($ncrop<0)?0:$ncrop; - }else{ - $nwood=$checkres[0]['wood']+$wood; - $nclay=$checkres[0]['clay']+$clay; - $niron=$checkres[0]['iron']+$iron; - $ncrop=$checkres[0]['crop']+$crop; - $dwood=($nwood>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nwood; - $dclay=($nclay>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nclay; - $diron=($niron>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$niron; - $dcrop=($ncrop>$checkres[0]['maxcrop'])?$checkres[0]['maxcrop']:$ncrop; - } - if(!$shit){ - $q = "UPDATE " . TB_PREFIX . "vdata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; - return mysqli_query($this->dblink,$q); }else{return false;} - } - - function modifyOasisResource($vid, $wood, $clay, $iron, $crop, $mode) { - $q="SELECT wood,clay,iron,crop,maxstore,maxcrop from " . TB_PREFIX . "odata where wref = ".$vid.""; - $result = mysqli_query($this->dblink,$q); - $checkres= $this->mysqli_fetch_all($result); - if(!$mode){ - $nwood=$checkres[0]['wood']-$wood; - $nclay=$checkres[0]['clay']-$clay; - $niron=$checkres[0]['iron']-$iron; - $ncrop=$checkres[0]['crop']-$crop; - if($nwood<0 or $nclay<0 or $niron<0 or $ncrop<0){$shit=true;} - $dwood=($nwood<0)?0:$nwood; - $dclay=($nclay<0)?0:$nclay; - $diron=($niron<0)?0:$niron; - $dcrop=($ncrop<0)?0:$ncrop; - }else{ - $nwood=$checkres[0]['wood']+$wood; - $nclay=$checkres[0]['clay']+$clay; - $niron=$checkres[0]['iron']+$iron; - $ncrop=$checkres[0]['crop']+$crop; - $dwood=($nwood>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nwood; - $dclay=($nclay>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$nclay; - $diron=($niron>$checkres[0]['maxstore'])?$checkres[0]['maxstore']:$niron; - $dcrop=($ncrop>$checkres[0]['maxcrop'])?$checkres[0]['maxcrop']:$ncrop; - } - if(!$shit){ - $q = "UPDATE " . TB_PREFIX . "odata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = ".$vid; - return mysqli_query($this->dblink,$q); }else{return false;} - } - - function getFieldLevel($vid, $field) { - $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid LIMIT 1"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_array($result); - return $row["f" . $field]; - } - - function getFieldType($vid, $field) { - $q = "SELECT f" . $field . "t from " . TB_PREFIX . "fdata where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_result($result, 0); - } - - function getFieldDistance($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner > 4 and wref != $wid"; - $array = $this->query_return($q); - $coor = $this->getCoor($wid); - $x1 = intval($coor['x']); - $y1 = intval($coor['y']); - $prevdist = 0; - $q2 = "SELECT * FROM " . TB_PREFIX . "vdata where owner = 4"; - $array2 = mysqli_fetch_array(mysqli_query($q2)); - $vill = $array2['wref']; - if(mysqli_num_rows(mysqli_query($q)) > 0){ - foreach($array as $village){ - $coor2 = $this->getCoor($village['wref']); - $max = 2 * WORLD_MAX + 1; - $x2 = intval($coor2['x']); - $y2 = intval($coor2['y']); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - if($dist < $prevdist or $prevdist == 0){ - $prevdist = $dist; - $vill = $village['wref']; - } - } - } - return $vill; - } - - function getVSumField($uid, $field) { - if($field != "cp"){ - $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid"; - }else{ - $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid and natar = 0"; - } - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - function updateVillage($vid) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid"; - return mysqli_query($this->dblink,$q); - } - - - function updateOasis($vid) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid"; - return mysqli_query($this->dblink,$q); - } - - function updateOasis2($vid, $time) { - $time = time(); - $time2 = NATURE_REGTIME; - $q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time + $time2 where wref = $vid"; - return mysqli_query($this->dblink,$q); - } - - function setVillageName($vid, $name) { - if(!empty($name)) - { - $q = "UPDATE " . TB_PREFIX . "vdata set name = '$name' where wref = $vid"; - return mysqli_query($this->dblink,$q); - } - } - - function modifyPop($vid, $pop, $mode) { - if(!$mode) { - $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop + $pop where wref = $vid"; - } else { - $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop - $pop where wref = $vid"; - } - return mysqli_query($this->dblink,$q); - } - - function addCP($ref, $cp) { - $q = "UPDATE " . TB_PREFIX . "vdata set cp = cp + $cp where wref = $ref"; - return mysqli_query($this->dblink,$q); - } - - function addCel($ref, $cel, $type) { - $q = "UPDATE " . TB_PREFIX . "vdata set celebration = $cel, type= $type where wref = $ref"; - return mysqli_query($this->dblink,$q); - } - 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); - } - - function clearCel($ref) { - $q = "UPDATE " . TB_PREFIX . "vdata set celebration = 0, type = 0 where wref = $ref"; - return mysqli_query($this->dblink,$q); - } - function setCelCp($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp where id = $user"; - return mysqli_query($this->dblink,$q); - } - - function clearExpansionSlot($id) { - for($i = 1; $i <= 3; $i++) { - $q = "UPDATE " . TB_PREFIX . "vdata SET exp" . $i . "=0 WHERE exp" . $i . "=" . $id; - mysqli_query($this->dblink,$q); - } - } - - function getInvitation($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getInvitation2($uid, $aid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid and alliance = $aid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getAliInvitations($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where alliance = $aid && accept = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function sendInvitation($uid, $alli, $sender) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "ali_invite values (0,$uid,$alli,$sender,$time,0)"; - return mysqli_query($this->dblink,$q) or die(mysqli_error()); - } - - function removeInvitation($id) { - $q = "DELETE FROM " . TB_PREFIX . "ali_invite where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function sendMessage($client, $owner, $topic, $message, $send, $alliance, $player, $coor, $report) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "mdata values (0,$client,$owner,'$topic',\"$message\",0,0,$send,$time,0,0,$alliance,$player,$coor,$report)"; - return mysqli_query($this->dblink,$q); - } - - function setArchived($id) { - $q = "UPDATE " . TB_PREFIX . "mdata set archived = 1 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function setNorm($id) { - $q = "UPDATE " . TB_PREFIX . "mdata set archived = 0 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - /*************************** - Function to get messages - Mode 1: Get inbox - Mode 2: Get sent - Mode 3: Get message - Mode 4: Set viewed - Mode 5: Remove message - Mode 6: Retrieve archive - References: User ID/Message ID, Mode - ***************************/ - function getMessage($id, $mode) { - global $session; - switch($mode) { - case 1: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 ORDER BY time DESC"; - break; - case 2: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id ORDER BY time DESC"; - break; - case 3: - $q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id"; - break; - case 4: - $q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target = $session->uid"; - break; - case 5: - $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id = $id"; - break; - case 6: - $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1"; - break; - case 7: - $q = "UPDATE " . TB_PREFIX . "mdata set delowner = 1 where id = $id"; - break; - case 8: - $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where id = $id"; - break; - case 9: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC"; - break; - case 10: - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id and delowner = 0 ORDER BY time DESC"; - break; - case 11: - $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1 and deltarget = 0"; - break; - } - if($mode <= 3 || $mode == 6 || $mode > 8) { - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } else { - return mysqli_query($this->dblink,$q); - } - } - - function getDelSent($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $uid and delowner = 1 ORDER BY time DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getDelInbox($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and deltarget = 1 ORDER BY time DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getDelArchive($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and archived = 1 and deltarget = 1 OR owner = $uid and archived = 1 and delowner = 1 ORDER BY time DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function unarchiveNotice($id) { - $q = "UPDATE " . TB_PREFIX . "ndata set ntype = archive, archive = 0 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function archiveNotice($id) { - $q = "update " . TB_PREFIX . "ndata set archive = ntype, ntype = 9 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function removeNotice($id) { - $q = "UPDATE " . TB_PREFIX . "ndata set del = 1,viewed = 1 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function noticeViewed($id) { - $q = "UPDATE " . TB_PREFIX . "ndata set viewed = 1 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function addNotice($uid, $toWref, $ally, $type, $topic, $data, $time = 0) { - if($time == 0) { - $time = time(); - } - $q = "INSERT INTO " . TB_PREFIX . "ndata (id, uid, toWref, ally, topic, ntype, data, time, viewed) values (0,'$uid','$toWref','$ally','$topic',$type,'$data',$time,0)"; - return mysqli_query($this->dblink,$q) or die(mysqli_error()); - } - - function getNotice($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getNotice2($id, $field) { - $q = "SELECT ".$field." FROM " . TB_PREFIX . "ndata where `id` = '$id'"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - } - - function getNotice3($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getNotice4($id) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where id = $id ORDER BY time DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - function getUnViewNotice($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid AND viewed=0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) { - $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid.""; - mysqli_query($x, $this->dblink); - $timeleft = time()+604800; - $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)"; - return mysqli_query($this->dblink,$q); - } - - function getTradeRoute($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getTradeRoute2($id) { - $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray; - } - - function getTradeRouteUid($id) { - $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['uid']; - } - - function editTradeRoute($id,$column,$value,$mode) { - if(!$mode){ - $q = "UPDATE " . TB_PREFIX . "route set $column = $value where id = $id"; - }else{ - $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id"; - } - return mysqli_query($this->dblink,$q); - } - - function deleteTradeRoute($id) { - $q = "DELETE FROM " . TB_PREFIX . "route where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function addBuilding($wid, $field, $type, $loop, $time, $master, $level) { - $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid; - mysqli_query($this->dblink,$x) or die(mysqli_error()); - $q = "INSERT into " . TB_PREFIX . "bdata values (0,$wid,$field,$type,$loop,$time,$master,$level)"; - return mysqli_query($this->dblink,$q); - } - - function removeBuilding($d) { - global $building, $village; - $jobLoopconID = -1; - $SameBuildCount = 0; - $jobs = $building->buildArray; - for($i = 0; $i < sizeof($jobs); $i++) { - if($jobs[$i]['id'] == $d) { - $jobDeleted = $i; - } - if($jobs[$i]['loopcon'] == 1) { - $jobLoopconID = $i; - } - if($jobs[$i]['master'] == 1) { - $jobMaster = $i; - } - } - if(count($jobs) > 1 && ($jobs[0]['field'] == $jobs[1]['field'])) { - $SameBuildCount = 1; - } - if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[2]['field'])) { - $SameBuildCount = 2; - } - if(count($jobs) > 2 && ($jobs[1]['field'] == $jobs[2]['field'])) { - $SameBuildCount = 3; - } - if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 8; - } - if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 9; - } - if(count($jobs) > 3 && ($jobs[2]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 10; - } - if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[2]['field'])) { - $SameBuildCount = 4; - } - if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 5; - } - if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 6; - } - if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) { - $SameBuildCount = 7; - } - if($SameBuildCount > 0) { - if($SameBuildCount > 3){ - if($SameBuildCount == 4 or $SameBuildCount == 5){ - if($jobDeleted == 0){ - $uprequire = $building->resourceRequired($jobs[1]['field'],$jobs[1]['type'],1); - $time = $uprequire['time']; - $timestamp = $time+time(); - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[1]['id'].""; - mysqli_query($this->dblink,$q); - } - }else if($SameBuildCount == 6){ - if($jobDeleted == 0){ - $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1); - $time = $uprequire['time']; - $timestamp = $time+time(); - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; - mysqli_query($this->dblink,$q); - } - }else if($SameBuildCount == 7){ - if($jobDeleted == 1){ - $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1); - $time = $uprequire['time']; - $timestamp = $time+time(); - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id'].""; - mysqli_query($this->dblink,$q); - } - } - if($SameBuildCount < 8){ - $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],2); - $time1 = $uprequire1['time']; - $timestamp1 = $time1; - $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; - mysqli_query($q1, $this->dblink); - }else{ - $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],1); - $time1 = $uprequire1['time']; - $timestamp1 = $time1; - $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id'].""; - mysqli_query($q1, $this->dblink); - } - }else if($d == $jobs[floor($SameBuildCount / 3)]['id'] || $d == $jobs[floor($SameBuildCount / 2) + 1]['id']) { - $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=" . $jobs[floor($SameBuildCount / 3)]['timestamp'] . " WHERE master = 0 AND id > ".$d." and (ID=" . $jobs[floor($SameBuildCount / 3)]['id'] . " OR ID=" . $jobs[floor($SameBuildCount / 2) + 1]['id'] . ")"; - mysqli_query($this->dblink,$q); - } - } else { - if($jobs[$jobDeleted]['field'] >= 19) { - $x = "SELECT f" . $jobs[$jobDeleted]['field'] . " FROM " . TB_PREFIX . "fdata WHERE vref=" . $jobs[$jobDeleted]['wid']; - $result = mysqli_query($x, $this->dblink) or die(mysqli_error()); - $fieldlevel = mysqli_fetch_row($result); - if($fieldlevel[0] == 0) { - if ($village->natar==1 && $jobs[$jobDeleted]['field']==99) { //fix by ronix - }else{ - $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $jobs[$jobDeleted]['field'] . "t=0 WHERE vref=" . $jobs[$jobDeleted]['wid']; - mysqli_query($x, $this->dblink) or die(mysqli_error()); - } - } - } - if(($jobLoopconID >= 0) && ($jobs[$jobDeleted]['loopcon'] != 1)) { - if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) { - $uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']); - $x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0"; - mysqli_query($x, $this->dblink) or die(mysqli_error()); - } - } - } - $q = "DELETE FROM " . TB_PREFIX . "bdata where id = $d"; - return mysqli_query($this->dblink,$q); - } - - function addDemolition($wid, $field) { - global $building, $village; - $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid"; - mysqli_query($this->dblink,$q); - $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0); - $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($this->getFieldLevel($wid,$field)-1).",".(time()+floor($uprequire['time']/2)).")"; - return mysqli_query($this->dblink,$q); - } - - - function getDemolition($wid = 0) { - if($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; - } else { - $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE timetofinish<=" . time(); - } - $result = mysqli_query($this->dblink,$q); - if(!empty($result)) { - return $this->mysqli_fetch_all($result); - } else { - return NULL; - } - } - - function finishDemolition($wid) { - $q = "UPDATE " . TB_PREFIX . "demolition SET timetofinish=" . time() . " WHERE vref=" . $wid; - $result= mysqli_query($this->dblink,$q); - return mysqli_affected_rows(); - } - - function delDemolition($wid) { - $q = "DELETE FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid; - return mysqli_query($this->dblink,$q); - } - - function getJobs($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function FinishWoodcutter($wid) { - $time = time()-1; - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by master,timestamp ASC"; - $result = mysqli_query($q); - $dbarray = mysqli_fetch_array($result); - $q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'"; - $this->query($q); - $tribe = $this->getUserField($this->getVillageField($wid, "owner"), "tribe", 0); - if($tribe == 1){ - $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 and field >= 19 order by master,timestamp ASC"; - }else{ - $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 order by master,timestamp ASC"; - } - $result2 = mysqli_query($q2); - if(mysqli_num_rows($result2) > 0){ - $dbarray2 = mysqli_fetch_array($result2); - $wc_time = $dbarray['timestamp']; - $q2 = "UPDATE ".TB_PREFIX."bdata SET timestamp = timestamp - $wc_time WHERE id = '".$dbarray2['id']."'"; - $this->query($q2); - } - } - - function getMasterJobs($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getMasterJobsByField($wid,$field) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 1 order by master,timestamp ASC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getBuildingByField($wid,$field) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getBuildingByField2($wid,$field) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0"; - $result = mysqli_query($this->dblink,$q); - return mysqli_num_rows($result); - } - - function getBuildingByType($wid,$type) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getBuildingByType2($wid,$type) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0"; - $result = mysqli_query($this->dblink,$q); - return mysqli_num_rows($result); - } - - function getDorf1Building($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field < 19 and master = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getDorf2Building($wid) { - $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field > 18 and master = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function updateBuildingWithMaster($id, $time,$loop) { - $q = "UPDATE " . TB_PREFIX . "bdata SET master = 0, timestamp = ".$time.",loopcon = ".$loop." WHERE id = ".$id.""; - return mysqli_query($this->dblink,$q); - } - - function getVillageByName($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 to set accept flag on market - References: id - ***************************/ - function setMarketAcc($id) { - $q = "UPDATE " . TB_PREFIX . "market set accept = 1 where id = $id"; - return mysqli_query($this->dblink,$q); - } - - /*************************** - Function to send resource to other village - Mode 0: Send - Mode 1: Cancel - References: Wood/ID, Clay, Iron, Crop, Mode - ***************************/ - function sendResource($ref, $clay, $iron, $crop, $merchant, $mode) { - if(!$mode) { - $q = "INSERT INTO " . TB_PREFIX . "send values (0,$ref,$clay,$iron,$crop,$merchant)"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } else { - $q = "DELETE FROM " . TB_PREFIX . "send where id = $ref"; - return mysqli_query($this->dblink,$q); - } - } - - /*************************** - Function to get resources back if you delete offer - References: VillageRef (vref) - Made by: Dzoki - ***************************/ - - function getResourcesBack($vref, $gtype, $gamt) { - //Xtype (1) = wood, (2) = clay, (3) = iron, (4) = crop - if($gtype == 1) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + '$gamt' WHERE wref = $vref"; - return mysqli_query($this->dblink,$q); - } else - if($gtype == 2) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` + '$gamt' WHERE wref = $vref"; - return mysqli_query($this->dblink,$q); - } else - if($gtype == 3) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` + '$gamt' WHERE wref = $vref"; - return mysqli_query($this->dblink,$q); - } else - if($gtype == 4) { - $q = "UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` + '$gamt' WHERE wref = $vref"; - return mysqli_query($this->dblink,$q); - } - } - - /*************************** - Function to get info about offered resources - References: VillageRef (vref) - Made by: Dzoki - ***************************/ - - function getMarketField($vref, $field) { - $q = "SELECT $field FROM " . TB_PREFIX . "market where vref = '$vref'"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$field]; - } - - function removeAcceptedOffer($id) { - $q = "DELETE FROM " . TB_PREFIX . "market where id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - /*************************** - Function to add market offer - Mode 0: Add - Mode 1: Cancel - References: Village, Give, Amt, Want, Amt, Time, Alliance, Mode - ***************************/ - function addMarket($vid, $gtype, $gamt, $wtype, $wamt, $time, $alliance, $merchant, $mode) { - if(!$mode) { - $q = "INSERT INTO " . TB_PREFIX . "market values (0,$vid,$gtype,$gamt,$wtype,$wamt,0,$time,$alliance,$merchant)"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } else { - $q = "DELETE FROM " . TB_PREFIX . "market where id = $gtype and vref = $vid"; - return mysqli_query($this->dblink,$q); - } - } - - /*************************** - Function to get market offer - References: Village, Mode - ***************************/ - function getMarket($vid, $mode) { - $alliance = $this->getUserField($this->getVillageField($vid, "owner"), "alliance", 0); - if(!$mode) { - $q = "SELECT * FROM " . TB_PREFIX . "market where vref = $vid and accept = 0"; - } else { - $q = "SELECT * FROM " . TB_PREFIX . "market where vref != $vid and alliance = $alliance or vref != $vid and alliance = 0 and accept = 0"; - } - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - /*************************** - Function to get market offer - References: ID - ***************************/ - function getMarketInfo($id) { - $q = "SELECT * FROM " . TB_PREFIX . "market where id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function setMovementProc($moveid) { - $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where moveid = $moveid"; - return mysqli_query($this->dblink,$q); - } - - /*************************** - Function to retrieve used merchant - References: Village - ***************************/ - function totalMerchantUsed($vid) { - $time = time(); - $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = '$vid' and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = '$vid' and proc = 0"; - $result2 = mysqli_query($this->dblink,$q2); - $row2 = mysqli_fetch_row($result2); - $q3 = "SELECT sum(merchant) from " . TB_PREFIX . "market where vref = $vid and accept = 0"; - $result3 = mysqli_query($this->dblink,$q3); - $row3 = mysqli_fetch_row($result3); - return $row[0] + $row2[0] + $row3[0]; - } - - function getMovement($type, $village, $mode) { - $time = time(); - if(!$mode) { - $where = "from"; - } else { - $where = "to"; - } - switch($type) { - case 0: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC"; - break; - case 1: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC"; - break; - case 2: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC"; - break; - case 3: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; - break; - case 4: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; - break; - case 5: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 5 and proc = 0 ORDER BY endtime ASC"; - break; - case 6: - $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = '$village' and " . TB_PREFIX . "movement.to = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; - //$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; - break; - case 7: - $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC"; - break; - case 8: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; - break; - case 34: - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC"; - break; - default: - return null; - } - $result = mysqli_query($this->dblink,$q); - $array = $this->mysqli_fetch_all($result); - return $array; - } - - function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) { - $q = "INSERT INTO " . TB_PREFIX . "a2b (ckey,time_check,to_vid,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,type) VALUES ('$ckey', '$timestamp', '$to', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10', '$t11', '$type')"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function getA2b($ckey, $check) { - $q = "SELECT * from " . TB_PREFIX . "a2b where ckey = '" . $ckey . "' AND time_check = '" . $check . "'"; - $result = mysqli_query($this->dblink,$q); - if($result) { - return mysqli_fetch_assoc($result); - } else { - return false; - } - } - - function addMovement($type, $from, $to, $ref, $time, $endtime, $send = 1, $wood = 0, $clay = 0, $iron = 0, $crop = 0, $ref2 = 0) { - $q = "INSERT INTO " . TB_PREFIX . "movement values (0,$type,$from,$to,$ref,$ref2,$time,$endtime,0,$send,$wood,$clay,$iron,$crop)"; - return mysqli_query($this->dblink,$q); - } - - function addAttack($vid, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type, $ctar1, $ctar2, $spy,$b1=0,$b2=0,$b3=0,$b4=0,$b5=0,$b6=0,$b7=0,$b8=0) { - $q = "INSERT INTO " . TB_PREFIX . "attacks values (0,$vid,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$type,$ctar1,$ctar2,$spy,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8)"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function modifyAttack($aid, $unit, $amt) { - $unit = 't' . $unit; - $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit - $amt where id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function modifyAttack2($aid, $unit, $amt) { - $unit = 't' . $unit; - $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit + $amt where id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function modifyAttack3($aid, $units) { - $q = "UPDATE ".TB_PREFIX."attacks set $units WHERE id = $aid"; - return mysqli_query($this->dblink,$q); - } - - function getRanking() { - $q = "SELECT id,username,alliance,ap,apall,dp,dpall,access FROM " . TB_PREFIX . "users WHERE tribe<=3 AND access<" . (INCLUDE_ADMIN ? "10" : "8"); - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getVRanking() { - $q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe<=3 AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8"); - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getARanking() { - $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getUserByTribe($tribe){ - $q = "SELECT * FROM " . TB_PREFIX . "users where tribe = $tribe"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getUserByAlliance($aid){ - $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getHeroRanking() { - $q = "SELECT * FROM " . TB_PREFIX . "hero WHERE dead = 0"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getAllMember($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getAllMember2($aid) { - $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function addUnits($vid) { - $q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)"; - return mysqli_query($this->dblink,$q); - } - - function getUnit($vid) { - $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - if (!empty($result)) { - return mysqli_fetch_assoc($result); - } else { - return NULL; - } - } - - function getUnitsNumber($vid) { - $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_assoc($result); - $totalunits = 0; - $movingunits = $this->getVillageMovement($vid); - for($i=1;$i<=50;$i++){ - $totalunits += $dbarray['u'.$i]; - } - $totalunits += $dbarray['hero']; - $movingunits = $this->getVillageMovement($vid); - $reinforcingunits = $this->getEnforceArray($vid,1); - $owner = $this->getVillageField($vid,"owner"); - $ownertribe = $this->getUserField($owner,"tribe",0); - $start = ($ownertribe-1)*10+1; - $end = ($ownertribe*10); - for($i=$start;$i<=$end;$i++){ - $totalunits += $movingunits['u'.$i]; - $totalunits += $reinforcingunits['u'.$i]; - } - $totalunits += $movingunits['hero']; - $totalunits += $reinforcingunits['hero']; - return $totalunits; - } - - function getHero($uid=0,$all=0) { - if ($all) { - $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid=$uid"; - } elseif (!$uid) { - $q = "SELECT * FROM ".TB_PREFIX."hero"; - } else { - $q = "SELECT * FROM ".TB_PREFIX."hero WHERE dead=0 AND uid=$uid LIMIT 1"; - } - $result = mysqli_query($this->dblink,$q); - if (!empty($result)) { - return $this->mysqli_fetch_all($result); - } else { - return NULL; - } - } - - function getHeroField($uid,$field){ - $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function modifyHero($column,$value,$heroid,$mode=0) { - if(!$mode) { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE heroid = $heroid"; - } elseif($mode=1) { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE heroid = $heroid"; - } else { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE heroid = $heroid"; - } - return mysqli_query($this->dblink,$q); - } - - function modifyHeroByOwner($column,$value,$uid,$mode=0) { - if(!$mode) { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE uid = $uid"; - } elseif($mode=1) { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE uid = $uid"; - } else { - $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE uid = $uid"; - } - return mysqli_query($this->dblink,$q); - } - - function modifyHeroXp($column,$value,$heroid) { - $q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid"; - return mysqli_query($this->dblink,$q); - } - - function addTech($vid) { - $q = "INSERT into " . TB_PREFIX . "tdata (vref) values ($vid)"; - return mysqli_query($this->dblink,$q); - } - - function addABTech($vid) { - $q = "INSERT into " . TB_PREFIX . "abdata (vref) values ($vid)"; - return mysqli_query($this->dblink,$q); - } - - function getABTech($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "abdata where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function addResearch($vid, $tech, $time) { - $q = "INSERT into " . TB_PREFIX . "research values (0,$vid,'$tech',$time)"; - return mysqli_query($this->dblink,$q); - } - - function getResearching($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "research where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function checkIfResearched($vref, $unit) { - $q = "SELECT $unit FROM " . TB_PREFIX . "tdata WHERE vref = $vref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray[$unit]; - } - - function getTech($vid) { - $q = "SELECT * from " . TB_PREFIX . "tdata where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function getTraining($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "training where vref = $vid ORDER BY id"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function countTraining($vid) { - $q = "SELECT * FROM " . TB_PREFIX . "training WHERE vref = $vid"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - function trainUnit($vid, $unit, $amt, $pop, $each, $time, $mode) { - global $village, $building, $session, $technology; - - if(!$mode) { - $barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44); - // fix by brainiac - THANK YOU - $greatbarracks = array(61,62,63,71,72,73,74,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104); - $stables = array(4,5,6,15,16,23,24,25,26,45,46); - $greatstables = array(64,65,66,75,76,83,84,85,86,105,106); - $workshop = array(7,8,17,18,27,28,47,48); - $greatworkshop = array(67,68,77,78,87,88,107,108); - $residence = array(9,10,19,20,29,30,49,50); - $trapper = array(99); - - if(in_array($unit, $barracks)) { - $queued = $technology->getTrainingList(1); - } elseif(in_array($unit, $stables)) { - $queued = $technology->getTrainingList(2); - } elseif(in_array($unit, $workshop)) { - $queued = $technology->getTrainingList(3); - } elseif(in_array($unit, $residence)) { - $queued = $technology->getTrainingList(4); - } elseif(in_array($unit, $greatstables)) { - $queued = $technology->getTrainingList(6); - } elseif(in_array($unit, $greatbarracks)) { - $queued = $technology->getTrainingList(5); - } elseif(in_array($unit, $greatworkshop)) { - $queued = $technology->getTrainingList(7); - } elseif(in_array($unit, $trapper)) { - $queued = $technology->getTrainingList(8); - } - $now = time(); - - $uid = $this->getVillageField($vid, "owner"); - $artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0)); - $artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1)); - $artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0)); - if($artefact > 0){ - $time = $now+round(($time-$now)/2); - $each /= 2; - $each = round($each); - }else if($artefact1 > 0){ - $time = $now+round(($time-$now)/2); - $each /= 2; - $each = round($each); - }else if($artefact2 > 0){ - $time = $now+round(($time-$now)/4*3); - $each /= 4; - $each = round($each); - $each *= 3; - $each = round($each); - } - $foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid); - if(count($foolartefact) > 0){ - foreach($foolartefact as $arte){ - if($arte['bad_effect'] == 1){ - $each *= $arte['effect2']; - }else{ - $each /= $arte['effect2']; - $each = round($each); - } - } - } - if($each == 0){ $each = 1; } - $time2 = $now+$each; - if(count($queued) > 0) { - $time += $queued[count($queued) - 1]['timestamp'] - $now; - $time2 += $queued[count($queued) - 1]['timestamp'] - $now; - } - // TROOPS MAKE SUM IN BARAKS , ETC - //if($queued[count($queued) - 1]['unit'] == $unit){ - //$time = $amt*$queued[count($queued) - 1]['eachtime']; - //$q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id'].""; - //}else{ - $q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)"; - //} - } else { - $q = "DELETE FROM " . TB_PREFIX . "training where id = $vid"; - } - return mysqli_query($this->dblink,$q); - } - - function updateTraining($id, $trained, $each) { - $q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function modifyUnit($vref, $array_unit, $array_amt, $array_mode){ - $i = -1; - $units=''; - $number = count($array_unit); - foreach($array_unit as $unit){ - if($unit == 230){$unit = 30;} - if($unit == 231){$unit = 31;} - if($unit == 120){$unit = 20;} - if($unit == 121){$unit = 21;} - if($unit =="hero"){$unit = 'hero';} - else{$unit = 'u' . $unit;} - ++$i; - //Fixed part of negativ troops (double troops) - by InCube - $array_amt[$i] = $array_amt[$i] < 0 ? 0 : $array_amt[$i]; - //Fixed part of negativ troops (double troops) - by InCube - $units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.$array_amt[$i].(($number > $i+1) ? ', ' : ''); - } - $q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref"; - return mysqli_query($this->dblink,$q); - } - - function getEnforce($vid, $from) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function getOasisEnforce($ref, $mode=0) { - 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"; - }else{ - $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); - return $this->mysqli_fetch_all($result); - } - - function getOasisEnforceArray($id, $mode=0) { - 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"; - }else{ - $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); - return mysqli_fetch_assoc($result); - } - - function getEnforceControllTroops($vid) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $vid"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function addEnforce($data) { - $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; - mysqli_query($this->dblink,$q); - $id = mysqli_insert_id($this->dblink); - $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); - $start = ($owntribe - 1) * 10 + 1; - $end = ($owntribe * 10); - //add unit - $j = '1'; - for($i = $start; $i <= $end; $i++) { - $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1); - $j++; - } - $this->modifyEnforce($id,'hero',$data['t11'],1); - return mysqli_insert_id($this->dblink); - } - - function addEnforce2($data,$tribe,$dead1,$dead2,$dead3,$dead4,$dead5,$dead6,$dead7,$dead8,$dead9,$dead10,$dead11) { - $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")"; - mysqli_query($this->dblink,$q); - $id = mysqli_insert_id($this->dblink); - $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0); - $start = ($owntribe - 1) * 10 + 1; - $end = ($owntribe * 10); - $start2 = ($tribe - 1) * 10 + 1; - $start3 = ($tribe - 1) * 10; - if($start3 == 0){ - $start3 = ""; - } - $end2 = ($tribe * 10); - //add unit - $j = '1'; - for($i = $start; $i <= $end; $i++) { - $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1); - $this->modifyEnforce($id, $i, ${dead.$j}, 0); - $j++; - } - $this->modifyEnforce($id,'hero',$data['t11'],1); - $this->modifyEnforce($id,'hero',$dead11,0); - return mysqli_insert_id($this->dblink); - } - - function modifyEnforce($id, $unit, $amt, $mode) { - if($unit != 'hero') { $unit = 'u' . $unit; } - if(!$mode) { - $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit - $amt where id = $id"; - } else { - $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit + $amt where id = $id"; - } - mysqli_query($this->dblink,$q); - } - - function getEnforceArray($id, $mode) { - if(!$mode) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id"; - } else { - $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; - } - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_assoc($result); - } - - function getEnforceVillage($id, $mode) { - if(!$mode) { - $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id"; - } else { - $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id"; - } - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getVillageMovement($id) { - $vinfo = $this->getVillage($id); - $vtribe = $this->getUserField($vinfo['owner'], "tribe", 0); - $movingunits = array(); - $outgoingarray = $this->getMovement(3, $id, 0); - if(!empty($outgoingarray)) { - foreach($outgoingarray as $out) { - for($i = 1; $i <= 10; $i++) { - $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $out['t' . $i]; - } - $movingunits['hero'] += $out['t11']; - } - } - $returningarray = $this->getMovement(4, $id, 1); - if(!empty($returningarray)) { - foreach($returningarray as $ret) { - if($ret['attack_type'] != 1) { - for($i = 1; $i <= 10; $i++) { - $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $ret['t' . $i]; - } - $movingunits['hero'] += $ret['t11']; - } - } - } - $settlerarray = $this->getMovement(5, $id, 0); - if(!empty($settlerarray)) { - $movingunits['u' . ($vtribe * 10)] += 3 * count($settlerarray); - } - return $movingunits; - } - - ################# -START- ################## - ## WORLD WONDER STATISTICS FUNCTIONS! ## - ############################################ - - /*************************** - Function to get all World Wonders - Made by: Dzoki - ***************************/ - - function getWW() { - $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - /*************************** - Function to get world wonder level! - Made by: Dzoki - ***************************/ - - function getWWLevel($vref) { - $q = "SELECT f99 FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['f99']; - } - - /*************************** - Function to get world wonder owner ID! - Made by: Dzoki - ***************************/ - - function getWWOwnerID($vref) { - $q = "SELECT owner FROM " . TB_PREFIX . "vdata WHERE wref = $vref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['owner']; - } - - /*************************** - Function to get user alliance name! - Made by: Dzoki - ***************************/ - - function getUserAllianceID($id) { - $q = "SELECT alliance FROM " . TB_PREFIX . "users where id = $id"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['alliance']; - } - - /*************************** - Function to get WW name - Made by: Dzoki - ***************************/ - - function getWWName($vref) { - $q = "SELECT wwname FROM " . TB_PREFIX . "fdata WHERE vref = $vref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['wwname']; - } - - /*************************** - Function to change WW name - Made by: Dzoki - ***************************/ - - function submitWWname($vref, $name) { - $q = "UPDATE " . TB_PREFIX . "fdata SET `wwname` = '$name' WHERE " . TB_PREFIX . "fdata.`vref` = $vref"; - return mysqli_query($this->dblink,$q); - } - - //medal functions - function addclimberpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc + '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function addclimberrankpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set clp = clp + '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function removeclimberrankpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set clp = clp - '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function setclimberrankpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set clp = '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function updateoldrank($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set oldrank = '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function removeclimberpop($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc - '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - // ALLIANCE MEDAL FUNCTIONS - function addclimberpopAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc + '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function addclimberrankpopAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp + '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function removeclimberrankpopAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp - '$cp'' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function updateoldrankAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set oldrank = '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - function removeclimberpopAlly($user, $cp) { - $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc - '$cp' where id = $user"; - return mysqli_query($this->dblink,$q); - } - - function getTrainingList() { - $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getNeedDelete() { - $time = time(); - $q = "SELECT uid FROM " . TB_PREFIX . "deleting where timestamp < $time"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function countUser() { - $q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - function countAlli() { - $q = "SELECT count(id) FROM " . TB_PREFIX . "alidata where id != 0"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - return $row[0]; - } - - /*************************** - Function to process MYSQLi->fetch_all (Only exist in MYSQL) - References: Result - ***************************/ - function mysqli_fetch_all($result) { - $all = array(); - if($result) { - while($row = mysqli_fetch_assoc($result)) { - $all[] = $row; - } - return $all; - } - } - - function query_return($q) { - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - /*************************** - Function to do free query - References: Query - ***************************/ - function query($query) { - return mysqli_query($this->dblink,$query); - } - - function RemoveXSS($val) { - return htmlspecialchars($val, ENT_QUOTES); - } - - //MARKET FIXES - function getWoodAvailable($wref) { - $q = "SELECT wood FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['wood']; - } - - function getClayAvailable($wref) { - $q = "SELECT clay FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['clay']; - } - - function getIronAvailable($wref) { - $q = "SELECT iron FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['iron']; - } - - function getCropAvailable($wref) { - $q = "SELECT crop FROM " . TB_PREFIX . "vdata WHERE wref = $wref"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - return $dbarray['crop']; - } - - function Getowner($vid) { - $s = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = $vid"; - $result1 = mysqli_query($s, $this->dblink); - $row1 = mysqli_fetch_row($result1); - return $row1[0]; - } - - public function debug($time, $uid, $debug_info) { - $q = "INSERT INTO " . TB_PREFIX . "debug_info (time,uid,debug_info) VALUES ($time,$uid,$debug_info)"; - if(mysqli_query($this->dblink,$q)) { - return mysqli_insert_id($this->dblink); - } else { - return false; - } - } - - function populateOasisdata() { - $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; - $result2 = mysqli_query($q2, $this->dblink); - while($row = mysqli_fetch_array($result2)) { - $wid = $row['id']; - $basearray = $this->getOMInfo($wid); - if($basearray['oasistype'] < 4) { - $high = 1; - } else if ($basearray['oasistype'] < 10){ - $high = 2; - }else { - $high = 0; - } - //We switch type of oasis and instert record with apropriate infomation. - $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . "," . time() . ",100,2,'Unoccupied Oasis',".$high.")"; - $result = mysqli_query($this->dblink,$q); - } - } - - 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 = $village->wid"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - $maxslots = $row[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 = $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 = $village->wid"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - $chiefs = $row[0]; - - $settlers += 3 * count($this->getMovement(5, $village->wid, 0)); - $current_movement = $this->getMovement(3, $village->wid, 0); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $current_movement = $this->getMovement(3, $village->wid, 1); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $current_movement = $this->getMovement(4, $village->wid, 0); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $current_movement = $this->getMovement(4, $village->wid, 1); - if(!empty($current_movement)) { - foreach($current_movement as $build) { - $settlers += $build['t10']; - $chiefs += $build['t9']; - } - } - $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - if(!empty($row)) { - foreach($row as $reinf) { - $settlers += $reinf[0]; - } - } - $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid"; - $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - if(!empty($row)) { - foreach($row as $reinf) { - $chiefs += $reinf[0]; - } - } - $trainlist = $technology->getTrainingList(4); - if(!empty($trainlist)) { - foreach($trainlist as $train) { - if($train['unit'] % 10 == 0) { - $settlers += $train['amt']; - } - if($train['unit'] % 10 == 9) { - $chiefs += $train['amt']; - } - } - } - // trapped settlers/chiefs calculation required - - $settlerslots = $maxslots * 3 - $settlers - $chiefs * 3; - $chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3); - - if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) { - $chiefslots = 0; - } - $slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots); - return $slots; - } - - function addArtefact($vref, $owner, $type, $size, $name, $desc, $effect, $img) { - $q = "INSERT INTO `" . TB_PREFIX . "artefacts` (`vref`, `owner`, `type`, `size`, `conquered`, `name`, `desc`, `effect`, `img`, `active`) VALUES ('$vref', '$owner', '$type', '$size', '" . time() . "', '$name', '$desc', '$effect', '$img', '0')"; - return mysqli_query($this->dblink,$q); - } - - function getOwnArtefactInfo($vref) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getOwnArtefactInfo2($vref) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getOwnArtefactInfo3($uid) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $uid"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getOwnArtefactInfoByType($vref, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = '$vref' AND type = '$type' order by size"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getOwnArtefactInfoByType2($vref, $type) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getOwnUniqueArtefactInfo($id, $type, $size) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getOwnUniqueArtefactInfo2($id, $type, $size, $mode) { - if(!$mode){ - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND active = 1 AND type = $type AND size=$size"; - }else{ - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND active = 1 AND type = $type AND size=$size"; - } - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getFoolArtefactInfo($type,$vid,$uid) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function claimArtefact($vref, $ovref, $id) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time, active = 1 WHERE vref = $ovref"; - return mysqli_query($this->dblink,$q); - } - - public function canClaimArtifact($from,$vref,$size,$type) { - //fix by Ronix - global $session, $form; - $size1 = $size2 = $size3 = 0; - - $artifact = $this->getOwnArtefactInfo($from); - if (!empty($artifact)) { - $form->addError("error","Treasury is full. Your hero could not claim the artefact"); - return false; - } - $uid=$session->uid; - $q="SELECT Count(size) AS totals, - SUM(IF(size = '1',1,0)) small, - SUM(IF(size = '2',1,0)) great, - SUM(IF(size = '3',1,0)) `unique` - FROM ".TB_PREFIX."artefacts WHERE owner = ".$uid; - $result = mysqli_query($this->dblink,$q); - $artifact= $this->mysqli_fetch_all($result); - - if($artifact['totals'] < 3 || $type==11) { - $DefenderFields = $this->getResourceLevel($vref); - $defcanclaim = TRUE; - for($i=19;$i<=38;$i++) { - if($DefenderFields['f'.$i.'t'] == 27) { - $defTresuaryLevel = $DefenderFields['f'.$i]; - if($defTresuaryLevel > 0) { - $defcanclaim = FALSE; - $form->addError("error","Treasury has not been destroyed. Your hero could not claim the artefact"); - return false; - } else { - $defcanclaim = TRUE; - } - } - } - $AttackerFields = $this->getResourceLevel($from,2); - for($i=19;$i<=38;$i++) { - if($AttackerFields['f'.$i.'t'] == 27) { - $attTresuaryLevel = $AttackerFields['f'.$i]; - if ($attTresuaryLevel >= 10) { - $villageartifact = TRUE; - } else { - $villageartifact = FALSE; - } - if ($attTresuaryLevel >= 20){ - $accountartifact = TRUE; - } else { - $accountartifact = FALSE; - } - } - } - if (($artifact['great']>0 || $artifact['unique']>0) && $size>1) { - $form->addError("error","Max num. of great/unique artefacts. Your hero could not claim the artefact"); - return FALSE; - } - if (($size == 1 && ($villageartifact || $accountartifact)) || (($size == 2 || $size == 3)&& $accountartifact)) { - return true; -/* - if($this->getVillageField($from,"capital")==1 && $type==11) { - $form->addError("error","Ancient Construction Plan cannot kept in capital village"); - return FALSE; - }else{ - return TRUE; - } -*/ - } else { - $form->addError("error","Your level treasury is low. Your hero could not claim the artefact"); - return FALSE; - } - } else { - $form->addError("error","Max num. of artefacts. Your hero could not claim the artefact"); - return FALSE; - } -} - - function getArtefactDetails($id) { - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . ""; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getMovementById($id){ - $q = "SELECT * FROM ".TB_PREFIX."movement WHERE moveid = ".$id.""; - $result = mysqli_query($q); - $array = $this->mysqli_fetch_all($result); - return $array; - } - - function getLinks($id){ - $q = 'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . $id . ' ORDER BY `pos` ASC'; - return mysqli_query($this->dblink,$q); - } - - function removeLinks($id,$uid){ - $q = "DELETE FROM " . TB_PREFIX . "links WHERE `id` = ".$id." and `userid` = ".$uid.""; - return mysqli_query($this->dblink,$q); - } - - function getVilFarmlist($wref){ - $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC'; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - - if($dbarray['id']!=0) { - return true; - } else { - return false; - } - - } - - function getRaidList($id) { - $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id.""; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function delFarmList($id, $owner) { - $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner"; - return mysqli_query($this->dblink,$q); - } - - function delSlotFarm($id) { - $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id"; - return mysqli_query($this->dblink,$q); - } - - function createFarmList($wref, $owner, $name) { - $q = "INSERT INTO " . TB_PREFIX . "farmlist (`wref`, `owner`, `name`) VALUES ('$wref', '$owner', '$name')"; - return mysqli_query($this->dblink,$q); - } - - function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { - $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')"; - return mysqli_query($this->dblink,$q); - } - - function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { - $q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid"; - return mysqli_query($this->dblink,$q); - } - - function getArrayMemberVillage($uid){ - $q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC'; - $result = mysqli_query($this->dblink,$q); - $array = $this->mysqli_fetch_all($result); - return $array; - } - - function addPassword($uid, $npw, $cpw){ - $q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')"; - mysqli_query($this->dblink,$q) or die(mysqli_error()); - } - - function resetPassword($uid, $cpw){ - $q = "SELECT npw FROM `" . TB_PREFIX . "password` WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; - $result = mysqli_query($this->dblink,$q) or die(mysqli_error()); - $dbarray = mysqli_fetch_array($result); - - if(!empty($dbarray)) { - if(!$this->updateUserField($uid, 'password', md5($dbarray['npw']), 1)) return false; - $q = "UPDATE `" . TB_PREFIX . "password` SET used = 1 WHERE uid = $uid AND cpw = '$cpw' AND used = 0"; - mysqli_query($this->dblink,$q) or die(mysqli_error()); - return true; - } - - return false; - } - - function getCropProdstarv($wref) { - global $bid4,$bid8,$bid9,$sesion,$technology; - - $basecrop = $grainmill = $bakery = 0; - $owner = $this->getVrefField($wref, 'owner'); - $bonus = $this->getUserField($owner, 'b4', 0); - - $buildarray = $this->getResourceLevel($wref); - $cropholder = array(); - for($i=1;$i<=38;$i++) { - if($buildarray['f'.$i.'t'] == 4) { - array_push($cropholder,'f'.$i); - } - if($buildarray['f'.$i.'t'] == 8) { - $grainmill = $buildarray['f'.$i]; - } - if($buildarray['f'.$i.'t'] == 9) { - $bakery = $buildarray['f'.$i]; - } - } - $q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = $wref"; - $oasis = $this->query_return($q); - foreach($oasis as $oa){ - switch($oa['type']) { - case 1: - case 2: - $wood += 1; - break; - case 3: - $wood += 1; - $cropo += 1; - break; - case 4: - case 5: - $clay += 1; - break; - case 6: - $clay += 1; - $cropo += 1; - break; - case 7: - case 8: - $iron += 1; - break; - case 9: - $iron += 1; - $cropo += 1; - break; - case 10: - case 11: - $cropo += 1; - break; - case 12: - $cropo += 2; - break; - } - } - for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$buildarray[$cropholder[$i]]]['prod']; } - $crop = $basecrop + $basecrop * 0.25 * $cropo; - if($grainmill >= 1 || $bakery >= 1) { - $crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']); - } - if($bonus > time()) { - $crop *= 1.25; - } - $crop *= SPEED; - return $crop; - } - - //general statistics - - function addGeneralAttack($casualties) { - $time = time(); - $q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)"; - return mysqli_query($this->dblink,$q) or die(mysqli_error()); - } - - function getAttackByDate($time) { - $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1"; - $result = $this->query_return($q); - $attack = 0; - foreach($result as $general){ - if(date("j. M",$time) == date("j. M",$general['time'])){ - $attack += 1; - } - } - return $attack; - } - - function getAttackCasualties($time) { - $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1"; - $result = $this->query_return($q); - $casualties = 0; - foreach($result as $general){ - if(date("j. M",$time) == date("j. M",$general['time'])){ - $casualties += $general['casualties']; - } - } - return $casualties; - } - - //end general statistics - - function addFriend($uid, $column, $friend) { - $q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid"; - return mysqli_query($this->dblink,$q); - } - - function deleteFriend($uid, $column) { - $q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid"; - return mysqli_query($this->dblink,$q); - } - - function checkFriends($uid) { - $user = $this->getUserArray($uid, 1); - for($i=0;$i<=19;$i++) { - if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){ - for($j=$i+1;$j<=19;$j++) { - $k = $j-1; - if($user['friend'.$j] != 0){ - $friend = $this->getUserField($uid, "friend".$j, 0); - $this->addFriend($uid,"friend".$k,$friend); - $this->deleteFriend($uid,"friend".$j); - } - if($user['friend'.$j.'wait'] == 0){ - $friendwait = $this->getUserField($uid, "friend".$j."wait", 0); - $this->addFriend($sessionuid,"friend".$k."wait",$friendwait); - $this->deleteFriend($uid,"friend".$j."wait"); - } - } - } - } - } - - function setVillageEvasion($vid) { - $village = $this->getVillage($vid); - if($village['evasion'] == 0){ - $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 1 WHERE wref = $vid"; - }else{ - $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid"; - } - return mysqli_query($this->dblink,$q); - } - - function addPrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { - $q = "INSERT INTO " . TB_PREFIX . "prisoners values (0,$wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11)"; - mysqli_query($this->dblink,$q); - return mysqli_insert_id($this->dblink); - } - - function updatePrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) { - $q = "UPDATE " . TB_PREFIX . "prisoners set t1 = t1 + $t1, t2 = t2 + $t2, t3 = t3 + $t3, t4 = t4 + $t4, t5 = t5 + $t5, t6 = t6 + $t6, t7 = t7 + $t7, t8 = t8 + $t8, t9 = t9 + $t9, t10 = t10 + $t10, t11 = t11 + $t11 where wref = $wid and ".TB_PREFIX."prisoners.from = $from"; - return mysqli_query($this->dblink,$q) or die(mysqli_error()); - } - - function getPrisoners($wid,$mode=0) { - if(!$mode) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid"; - }else { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where `from` = $wid"; - } - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getPrisoners2($wid,$from) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from"; - $result = mysqli_query($this->dblink,$q); - return $this->mysqli_fetch_all($result); - } - - function getPrisonersByID($id) { - $q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - - function getPrisoners3($from) { - $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) { - $q = "DELETE from " . TB_PREFIX . "prisoners where id = '$id'"; - mysqli_query($this->dblink,$q); - } - -/***************************************** -Function to vacation mode - by advocaite -References: -*****************************************/ - - function setvacmode($uid,$days){ - $days1 =60*60*24*$days; - $time =time()+$days1; - $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '1' , vac_time=".$time." WHERE id=".$uid.""; - $result =mysqli_query($this->dblink,$q); - } - - function removevacationmode($uid){ - $q ="UPDATE ".TB_PREFIX."users SET vac_mode = '0' , vac_time='0' WHERE id=".$uid.""; - $result =mysqli_query($this->dblink,$q); - } - - function getvacmodexy($wref){ - $q = "SELECT id,oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref"; - $result = mysqli_query($this->dblink,$q); - $dbarray = mysqli_fetch_array($result); - if($dbarray['occupied'] != 0 && $dbarray['oasistype'] == 0) { - $q1 = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = ".$dbarray['id'].""; - $result1 = mysqli_query($q1, $this->dblink); - $dbarray1 = mysqli_fetch_array($result1); - if($dbarray1['owner'] != 0){ - $q2 = "SELECT vac_mode,vac_time FROM " . TB_PREFIX . "users where id = ".$dbarray1['owner'].""; - $result2 = mysqli_query($q2, $this->dblink); - $dbarray2 = mysqli_fetch_array($result2); - if($dbarray2['vac_mode'] ==1){ - return true; - }else{ - return false; - } - } - } else { - return false; - } - } - - /***************************************** - Function to vacation mode - by advocaite - References: - *****************************************/ - - /*************************** - Function to get Hero Dead - Made by: Shadow and brainiacX - ***************************/ - - function getHeroDead($id) { - $q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysqli_query($this->dblink,$q); - $notend= mysqli_fetch_array($result); - return $notend['dead']; - } - - /*************************** - Function to get Hero In Revive - Made by: Shadow - ***************************/ - - function getHeroInRevive($id) { - $q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysqli_query($this->dblink,$q); - $notend= mysqli_fetch_array($result); - return $notend['inrevive']; - } - - /*************************** - Function to get Hero In Training - Made by: Shadow - ***************************/ - - function getHeroInTraining($id) { - $q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id"; - $result = mysqli_query($this->dblink,$q); - $notend= mysqli_fetch_array($result); - return $notend['intraining']; - } - - /*************************** - Function to check Hero Not in Village - Made by: Shadow and brainiacX - ***************************/ - - function HeroNotInVil($id) { - $heronum=0; - $outgoingarray = $this->getMovement(3, $id, 0); - if(!empty($outgoingarray)) { - foreach($outgoingarray as $out) { - $heronum += $out['t11']; - } - } - $returningarray = $this->getMovement(4, $id, 1); - if(!empty($returningarray)) { - foreach($returningarray as $ret) { - if($ret['attack_type'] != 1) { - $heronum += $ret['t11']; - } - } - } - return $heronum; - } - - /*************************** - Function to Kill hero if not found - Made by: Shadow and brainiacX - ***************************/ - - function KillMyHero($id) { - $q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id; - return mysqli_query($this->dblink,$q); - } - - /*************************** - Function to find Hero place - Made by: ronix - ***************************/ - function FindHeroInVil($wid) { - $result = $this->query("SELECT * FROM ".TB_PREFIX."units WHERE hero>0 AND vref='".$wid."'"); - if (!empty($result)) { - $dbarray = mysqli_fetch_array($result); - if(isset($dbarray['hero'])) { - $this->query("UPDATE ".TB_PREFIX."units SET hero=0 WHERE vref='".$wid."'"); - unset($dbarray); - return true; - } - } - return false; - } - function FindHeroInDef($wid) { - $delDef=true; - $result = $this->query_return("SELECT * FROM ".TB_PREFIX."enforcement WHERE hero>0 AND `from` = ".$wid); - if (!empty($result)) { - $dbarray = mysqli_fetch_array($result); - if(isset($dbarray['hero'])) { - $this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$wid); - for ($i=0;$i<50;$i++) { - if($dbarray['u'.$i]>0) { - $delDef=false; - break; - } - } - if ($delDef) $this->deleteReinf($wid); - unset($dbarray); - return true; - } - } - return false; - } - function FindHeroInOasis($uid) { - $delDef=true; - $dbarray = $this->query_return("SELECT e.*,o.conqured,o.owner FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.owner=".$uid." AND e.hero>0"); - if(!empty($dbarray)) { - foreach($dbarray as $defoasis) { - if($defoasis['hero']>0) { - $this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$defoasis['from']); - for ($i=0;$i<50;$i++) { - if($dbarray['u'.$i]>0) { - $delDef=false; - break; - } - } - if ($delDef) $this->deleteReinf($defoasis['from']); - unset($dbarray); - return true; - } - } - } - return 0; - } - - function FindHeroInMovement($wid) { - $outgoingarray = $this->getMovement(3, $wid, 0); - if(!empty($outgoingarray)) { - foreach($outgoingarray as $out) { - if ($out['t11']>0) { - $dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$out['ref']); - return true; - break; - } - } - } - $returningarray = $this->getMovement(4, $wid, 1); - if(!empty($returningarray)) { - foreach($returningarray as $ret) { - if($ret['attack_type'] != 1 && $ret['t11']>0) { - $dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$ret['ref']); - return true; - break; - } - } - } - return false; - } - - /*************************** - Function checkAttack - Made by: Shadow - ***************************/ - - function checkAttack($wref, $toWref){ - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and (" . TB_PREFIX . "attacks.attack_type = 3 or " . TB_PREFIX . "attacks.attack_type = 4) ORDER BY endtime ASC"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - } else { - return false; - } - } - - /*************************** - Function checkEnforce - Made by: Shadow - ***************************/ - - function checkEnforce($wref, $toWref) { - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 2 ORDER BY endtime ASC"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - }else{ - return false; - } - } - - /*************************** - Function checkScout - Made by: yi12345 - ***************************/ - - function checkScout($wref, $toWref) { - $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC"; - $result = mysqli_query($this->dblink,$q); - if(mysqli_num_rows($result)) { - return true; - }else{ - return false; - } - } - -}; -$database = new MYSQLi_DB; -$link = $database->return_link(); -$GLOBALS['db'] = $database; -$GLOBALS['link'] = $database->return_link(); -?> diff --git a/GameEngine/Database/index.php b/GameEngine/Database/index.php deleted file mode 100755 index 2bb0d912..00000000 --- a/GameEngine/Database/index.php +++ /dev/null @@ -1,19 +0,0 @@ - -
-
-

404 - File not found

- Not Found
-

We looked 404 times already but can't find anything, Not even an X marking the spot.

-

This system is not complete yet. So the page probably does not exist.


-
-
\ No newline at end of file diff --git a/GameEngine/Message.php b/GameEngine/Message.php index 6afc5bd3..edb98f5b 100755 --- a/GameEngine/Message.php +++ b/GameEngine/Message.php @@ -210,8 +210,8 @@ class Message { global $database,$session; for($i = 1; $i <= 10; $i++) { if(isset($post['n' . $i])) { - $message1 = mysql_query("SELECT * FROM " . TB_PREFIX . "mdata where id = ".$post['n' . $i].""); - $message = mysql_fetch_array($message1); + $message1 = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "mdata where id = ".$post['n' . $i].""); + $message = mysqli_fetch_array($message1); if($message['target'] == $session->uid && $message['owner'] == $session->uid){ $database->getMessage($post['n' . $i], 8); }else if($message['target'] == $session->uid){ @@ -321,16 +321,16 @@ class Message { // Vulnerability closed by Shadow $q = "SELECT * FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".time()." - 60"; - $res = mysql_query($q) or die(mysql_error(). " query ".$q); - $flood = mysql_num_rows($res); + $res = mysqli_query($GLOBALS['link'],$q) or die(mysqli_error(). " query ".$q); + $flood = mysqli_num_rows($res); if($flood > 5) return; //flood // Vulnerability closed by Shadow - $allmembersQ = mysql_query("SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'"); + $allmembersQ = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'"); $userally = $database->getUserField($session->uid,"alliance",0); - $permission=mysql_fetch_array(mysql_query("SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'")); + $permission=mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'")); if(WORD_CENSOR) { $topic = $this->wordCensor($topic); $text = $this->wordCensor($text); @@ -395,7 +395,7 @@ class Message { } if($permission[opt7]==1){ if ($userally != 0) { - while ($allmembers = mysql_fetch_array($allmembersQ)) { + while ($allmembers = mysqli_fetch_array($allmembersQ)) { $database->sendMessage($allmembers[id],$session->uid,htmlspecialchars(addslashes($topic)),htmlspecialchars(addslashes($text)),0,$alliance,$player,$coor,$report); } } @@ -410,8 +410,8 @@ class Message { // Vulnerability closed by Shadow $q = "SELECT * FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".time()." - 60"; - $res = mysql_query($q) or die(mysql_error(). " query ".$q); - $flood = mysql_num_rows($res); + $res = mysqli_query($GLOBALS['link'],$q) or die(mysqli_error(). " query ".$q); + $flood = mysqli_num_rows($res); if($flood > 5) return; //flood diff --git a/GameEngine/Profile.php b/GameEngine/Profile.php index 24f55f20..b77d54d5 100755 --- a/GameEngine/Profile.php +++ b/GameEngine/Profile.php @@ -120,7 +120,7 @@ class Profile { if($set){ unset($_SESSION['wid']); $database->activeModify(addslashes($session->username),1); - $database->UpdateOnline("logout") or die(mysql_error()); + $database->UpdateOnline("logout") or die(mysqli_error()); $session->Logout(); header("Location: login.php"); }else{ diff --git a/GameEngine/Session.php b/GameEngine/Session.php index 2f53f787..e398fcb0 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -88,23 +88,23 @@ class Session { $_SESSION['checker'] = $generator->generateRandStr(3); $_SESSION['mchecker'] = $generator->generateRandStr(5); $_SESSION['qst'] = $database->getUserField($_SESSION['username'], "quest", 1); - $result = mysqli_query($link,"SELECT village_select FROM `". TB_PREFIX."users` WHERE `username`='".$_SESSION['username']."'"); + $result = mysqli_query($GLOBALS['link'],"SELECT village_select FROM `". TB_PREFIX."users` WHERE `username`='".$_SESSION['username']."'"); $dbarray = mysqli_fetch_assoc($result); $selected_village=$dbarray['village_select']; if(!isset($_SESSION['wid'])) { if($selected_village!='') { - $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); }else{ - $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); } $data = mysqli_fetch_assoc($query); $_SESSION['wid'] = $data['wref']; } else if($_SESSION['wid'] == '') { if($selected_village!='') { - $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); }else{ - $query = mysqli_query($link,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1'); } $data = mysqli_fetch_assoc($query); $_SESSION['wid'] = $data['wref']; @@ -161,18 +161,18 @@ class Session { $hero=0; foreach($this->villages as $myvill){ $q1 = "SELECT SUM(hero) from " . TB_PREFIX . "enforcement where `from` = ".$myvill; // check if hero is send as reinforcement - $result1 = mysqli_query($link,$q1); + $result1 = mysqli_query($GLOBALS['link'],$q1); if(mysqli_num_rows($result1) != 0) { $he1=mysqli_fetch_array($result1); $hero+=$he1[0]; } $q2 = "SELECT SUM(hero) from " . TB_PREFIX . "units where `vref` = ".$myvill; // check if hero is on my account (all villages) - $result2 = mysqli_query($link,$q2); + $result2 = mysqli_query($GLOBALS['link'],$q2); $he2=mysqli_fetch_array($result2); $hero+=$he2[0]; $q3 = "SELECT SUM(t11) from " . TB_PREFIX . "prisoners where `from` = ".$myvill; // check if hero is prisoner - $result3 = mysqli_query($link,$q3); + $result3 = mysqli_query($GLOBALS['link'],$q3); $he3=mysqli_fetch_array($result3); $hero+=$he3[0]; $hero+=$database->HeroNotInVil($myvill); // check if hero is not in village (come back from attack , raid , etc.) diff --git a/GameEngine/Units.php b/GameEngine/Units.php index dbde4da1..413a1b78 100755 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -287,8 +287,8 @@ class Units { } if( intval($enforce['hero']) > 0){ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $result = mysql_query($q); - $hero_f=mysql_fetch_array($result); + $result = mysqli_query($GLOBALS['link'],$q); + $hero_f=mysqli_fetch_array($result); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; }else{ @@ -378,14 +378,14 @@ if($session->access != BANNED){ array(0,0,0,0,0,0,0,0,0,0,0) ); - $query1 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysql_escape_string($data['to_vid'])); - $data1 = mysql_fetch_assoc($query1); - $query2 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data1['owner']); - $data2 = mysql_fetch_assoc($query2); - $query11 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysql_escape_string($village->wid)); - $data11 = mysql_fetch_assoc($query11); - $query21 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data11['owner']); - $data21 = mysql_fetch_assoc($query21); + $query1 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysqli_escape_string($GLOBALS['link'],$data['to_vid'])); + $data1 = mysqli_fetch_assoc($query1); + $query2 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data1['owner']); + $data2 = mysqli_fetch_assoc($query2); + $query11 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysqli_escape_string($GLOBALS['link'],$village->wid)); + $data11 = mysqli_fetch_assoc($query11); + $query21 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data11['owner']); + $data21 = mysqli_fetch_assoc($query21); @@ -445,8 +445,8 @@ if($session->access != BANNED){ // If is a WW village you can target on WW , if is not a WW village catapults will target randomly. // Like it says : Exceptions are the WW which can always be targeted and the treasure chamber which can always be targeted, except with the unique artifact. // Fixed by Advocaite and Shadow - $q = mysql_query("SELECT vref FROM ".TB_PREFIX."fdata WHERE f99t = '40' AND vref = ".$data['to_vid'].""); - $isThere = mysql_num_rows($q); + $q = mysqli_query($GLOBALS['link'],"SELECT vref FROM ".TB_PREFIX."fdata WHERE f99t = '40' AND vref = ".$data['to_vid'].""); + $isThere = mysqli_num_rows($q); if($isThere > 0) { $iswwvilla = 1; @@ -515,7 +515,7 @@ if($session->access != BANNED){ if($checkexist or $checkoexist){ $database->addMovement(3,$village->wid,$data['to_vid'],$reference,time(),($time+time())); if(($database->hasBeginnerProtection($village->wid)==1)&&($checkexist)){ - mysql_query("UPDATE ".TB_PREFIX."users SET protect = 0 WHERE id = $session->uid"); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users SET protect = 0 WHERE id = $session->uid"); } } @@ -615,8 +615,8 @@ if($session->access != BANNED){ if (isset($post['t11'])){ if( $post['t11'] != '' && $post['t11'] > 0){ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $resulth = mysql_query($qh); - $hero_f=mysql_fetch_array($resulth); + $resulth = mysqli_query($GLOBALS['link'],$qh); + $hero_f=mysqli_fetch_array($resulth); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } else { diff --git a/Templates/Ajax/mapscroll.tpl b/Templates/Ajax/mapscroll.tpl index e1f709eb..29bc63ec 100644 --- a/Templates/Ajax/mapscroll.tpl +++ b/Templates/Ajax/mapscroll.tpl @@ -2,10 +2,8 @@ session_start(); include('GameEngine/config.php'); include_once ("GameEngine/Lang/" . LANG . ".php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); -mysql_select_db(SQL_DB) or die(mysql_error()); include("GameEngine/Generator.php"); -include("GameEngine/Database/db_MYSQL.php"); +include("GameEngine/Database.php"); //include("GameEngine/Session.php"); @@ -88,14 +86,14 @@ $query2 = "SELECT where ".TB_PREFIX."wdata.id IN ($maparray) ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')"; -$result2 = mysql_query($query2) or die(mysql_error()); +$result2 = mysqli_query($GLOBALS['link'],$query2) or die(mysqli_error()); $i=0; //Load coor array $yrow = 0; $map_js =''; -while ($donnees = mysql_fetch_assoc($result2)){ +while ($donnees = mysqli_fetch_assoc($result2)){ $targetalliance=$donnees["aliance_id"]; $friendarray=$database->getAllianceAlly($donnees["aliance_id"],1); diff --git a/Templates/Ajax/mapscroll2.tpl b/Templates/Ajax/mapscroll2.tpl index 82347e85..636290c4 100644 --- a/Templates/Ajax/mapscroll2.tpl +++ b/Templates/Ajax/mapscroll2.tpl @@ -2,10 +2,8 @@ session_start(); include('GameEngine/config.php'); include_once ("GameEngine/Lang/" . LANG . ".php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); -mysql_select_db(SQL_DB) or die(mysql_error()); include("GameEngine/Generator.php"); -include("GameEngine/Database/db_MYSQL.php"); +include("GameEngine/Database.php"); header("Content-Type: application/json;"); //include("GameEngine/Session.php"); @@ -103,7 +101,7 @@ $query2 = "SELECT ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')"; //echo $query2; -$result2 = mysql_query($query2) or die(mysql_error()); +$result2 = mysqli_query($GLOBALS['link'],$query2) or die(mysqli_error()); $i=0; $i2=0; @@ -112,7 +110,7 @@ $row = 0; $coorindex = 0; $map_js =''; -while ($donnees = mysql_fetch_assoc($result2)){ +while ($donnees = mysqli_fetch_assoc($result2)){ $targetalliance=$donnees["aliance_id"]; $friendarray=$database->getAllianceAlly($donnees["aliance_id"],1); diff --git a/Templates/Ajax/quest_core.tpl b/Templates/Ajax/quest_core.tpl index a8f13091..99cc3fe4 100644 --- a/Templates/Ajax/quest_core.tpl +++ b/Templates/Ajax/quest_core.tpl @@ -71,7 +71,7 @@ if (isset($qact)){ $_SESSION['qst']= 3; //Give Reward if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus','username'); $plus+=86400; @@ -151,7 +151,7 @@ if (isset($qact)){ $_SESSION['qst']= 11; //Give Reward if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus','username'); $plus+=172800; @@ -338,7 +338,7 @@ if (isset($qact)){ $_SESSION['qst_time'] = time()+$skipp_time; //Give Reward if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus','username'); $plus+=86400; @@ -401,7 +401,7 @@ if (isset($qact)){ $_SESSION['qst']= 97; //Give Reward 20 gold + 2 days plus if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus','username'); $plus+=172800; diff --git a/Templates/Ajax/quest_core25.tpl b/Templates/Ajax/quest_core25.tpl index c17de09b..1ac6e289 100644 --- a/Templates/Ajax/quest_core25.tpl +++ b/Templates/Ajax/quest_core25.tpl @@ -70,7 +70,7 @@ if (isset($qact)){ $_SESSION['qst']= 3; //Give Reward if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus','username'); $plus+=86400; @@ -155,7 +155,7 @@ if (isset($qact)){ $_SESSION['qst']= 11; //Give Reward if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus','username'); $plus+=172800; @@ -323,7 +323,7 @@ if (isset($qact)){ $_SESSION['qst_time'] = time()+$skipp_time; //Give Reward if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus',1); $plus+=86400; @@ -386,7 +386,7 @@ if (isset($qact)){ $_SESSION['qst']= 97; //Give Reward 20 gold + 2 days plus if(!$session->plus){ - mysql_query("UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$_SESSION['username']."'") or die(mysqli_error()); } else { $plus=$database->getUserField($_SESSION['username'],'plus',1); $plus+=172800; diff --git a/Templates/Alliance/Forum/forum_2.tpl b/Templates/Alliance/Forum/forum_2.tpl index 063cba66..14e1de0a 100644 --- a/Templates/Alliance/Forum/forum_2.tpl +++ b/Templates/Alliance/Forum/forum_2.tpl @@ -9,14 +9,14 @@ if($session->access!=BANNED){ $displayarray = $database->getUserArray($session->uid,1); $forumcat = $database->ForumCat(htmlspecialchars($displayarray['alliance'])); $ally = $session->alliance; -$public = mysql_query("SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 1"); -$public1 = mysql_num_rows($public); -$cofederation = mysql_query("SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 2"); -$cofederation1 = mysql_num_rows($cofederation); -$alliance = mysql_query("SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 0"); -$alliance1 = mysql_num_rows($alliance); -$closed = mysql_query("SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 3"); -$closed1 = mysql_num_rows($closed); +$public = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 1"); +$public1 = mysqli_num_rows($public); +$cofederation = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 2"); +$cofederation1 = mysqli_num_rows($cofederation); +$alliance = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 0"); +$alliance1 = mysqli_num_rows($alliance); +$closed = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 3"); +$closed1 = mysqli_num_rows($closed); if($public1 != 0){ ?> diff --git a/Templates/Alliance/attack-attacker.tpl b/Templates/Alliance/attack-attacker.tpl index 579b08a0..f59f7211 100644 --- a/Templates/Alliance/attack-attacker.tpl +++ b/Templates/Alliance/attack-attacker.tpl @@ -1,14 +1,14 @@ alliance AND $limit ORDER BY time DESC LIMIT 20"); -$query = mysql_num_rows($sql); +$sql = mysqli_query($GLOBALS['link'],"SELECT * FROM $prefix WHERE ally = $session->alliance AND $limit ORDER BY time DESC LIMIT 20"); +$query = mysqli_num_rows($sql); $outputList = ''; $name = 1; if($query == 0) { $outputList .= ""; }else{ -while($row = mysql_fetch_array($sql)){ +while($row = mysqli_fetch_array($sql)){ $dataarray = explode(",",$row['data']); $id = $row["id"]; $uid = $row["uid"]; diff --git a/Templates/Alliance/attack-defender.tpl b/Templates/Alliance/attack-defender.tpl index ce537d9f..ca073c62 100644 --- a/Templates/Alliance/attack-defender.tpl +++ b/Templates/Alliance/attack-defender.tpl @@ -1,14 +1,14 @@ alliance AND $limit ORDER BY time DESC LIMIT 20"); -$query = mysql_num_rows($sql); +$sql = mysqli_query($GLOBALS['link'],"SELECT * FROM $prefix WHERE ally = $session->alliance AND $limit ORDER BY time DESC LIMIT 20"); +$query = mysqli_num_rows($sql); $outputList = ''; $name = 1; if($query == 0) { $outputList .= ""; }else{ -while($row = mysql_fetch_array($sql)){ +while($row = mysqli_fetch_array($sql)){ $dataarray = explode(",",$row['data']); $id = $row["id"]; $uid = $row["uid"]; diff --git a/Templates/Alliance/attacks.tpl b/Templates/Alliance/attacks.tpl index b5991047..8efc46d9 100644 --- a/Templates/Alliance/attacks.tpl +++ b/Templates/Alliance/attacks.tpl @@ -28,14 +28,14 @@ include("alli_menu.tpl"); }else{ $prefix = "".TB_PREFIX."ndata"; $limit = "ntype!=8 AND ntype!=9 AND ntype!=10 AND ntype!=11 AND ntype!=12 AND ntype!=13 AND ntype!=14 AND ntype!=15 AND ntype!=16 AND ntype!=17"; -$sql = mysql_query("SELECT * FROM $prefix WHERE ally = $session->alliance AND $limit ORDER BY time DESC LIMIT 20"); -$query = mysql_num_rows($sql); +$sql = mysqli_query($GLOBALS['link'],"SELECT * FROM $prefix WHERE ally = $session->alliance AND $limit ORDER BY time DESC LIMIT 20"); +$query = mysqli_num_rows($sql); $outputList = ''; $name = 1; if($query == 0) { $outputList .= ""; }else{ -while($row = mysql_fetch_array($sql)){ +while($row = mysqli_fetch_array($sql)){ $dataarray = explode(",",$row['data']); $id = $row["id"]; $uid = $row["uid"]; diff --git a/Templates/Build/16_incomming.tpl b/Templates/Build/16_incomming.tpl index f7cb432a..788b190e 100644 --- a/Templates/Build/16_incomming.tpl +++ b/Templates/Build/16_incomming.tpl @@ -8,8 +8,8 @@ $total_for2 = count($send); for($y=0;$y < $total_for;$y++){ for($i=0;$i < $total_for2;$i++){ if($units[$y]['ref'] == $send[$i]['ref2']){ -$res1 = mysql_query("SELECT * FROM " . TB_PREFIX . "send where id = ".$send[$i]['ref'].""); -$res = mysql_fetch_array($res1); +$res1 = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "send where id = ".$send[$i]['ref'].""); +$res = mysqli_fetch_array($res1); } } $timer = $y+1; diff --git a/Templates/Build/26.tpl b/Templates/Build/26.tpl index 84269cd5..82a11b8e 100644 --- a/Templates/Build/26.tpl +++ b/Templates/Build/26.tpl @@ -6,33 +6,33 @@ if(time() - $_SESSION['time_p'] > 5) { } if($_POST AND $_GET['action'] == 'change_capital') { - $pass = mysql_escape_string($_POST['pass']); - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $session->uid); - $data = mysql_fetch_assoc($query); + $pass = mysqli_escape_string($GLOBALS['link'],$_POST['pass']); + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $session->uid); + $data = mysqli_fetch_assoc($query); if($data['password'] == md5($pass)) { - $query1 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $session->uid . ' AND `capital` = 1'); - $data1 = mysql_fetch_assoc($query1); - $query2 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'fdata` WHERE `vref` = ' . $data1['wref']); - $data2 = mysql_fetch_assoc($query2); + $query1 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $session->uid . ' AND `capital` = 1'); + $data1 = mysqli_fetch_assoc($query1); + $query2 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'fdata` WHERE `vref` = ' . $data1['wref']); + $data2 = mysqli_fetch_assoc($query2); if($data2['vref'] != $village->wid) { for($i = 1; $i<=18; ++$i) { if($data2['f' . $i] > 10) { - $query2 = mysql_query('UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . '` = 10 WHERE `vref` = ' . $data2['vref']) or die(mysql_error()); + $query2 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . '` = 10 WHERE `vref` = ' . $data2['vref']) or die(mysqli_error()); } } for($i=19; $i<=40; ++$i) { if($data2['f' . $i . 't'] == 34) { - $query3 = mysql_query('UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . $data2['vref']) or die(mysql_error()); + $query3 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . $data2['vref']) or die(mysqli_error()); } } for($i=19; $i<=40; ++$i) { if($data2['f' . $i . 't'] == 29 or $data2['f' . $i . 't'] == 30 or $data2['f' . $i . 't'] == 38 or $data2['f' . $i . 't'] == 39 or $data2['f' . $i . 't'] == 42) { - $query3 = mysql_query('UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . $village->wid) or die(mysql_error()); + $query3 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . $village->wid) or die(mysqli_error()); } } -$query3 = mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 0 WHERE `wref` = ' . $data1['wref']); -$query4 = mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 1 WHERE `wref` = ' . $village->wid); +$query3 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 0 WHERE `wref` = ' . $data1['wref']); +$query4 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 1 WHERE `wref` = ' . $village->wid); } } else { $error = '
'.LOGIN_PW_ERROR.'
'; @@ -68,8 +68,8 @@ else{ ?> uid . ' AND `capital` = 1'); -$data = mysql_fetch_assoc($query); +$query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $session->uid . ' AND `capital` = 1'); +$data = mysqli_fetch_assoc($query); if($data['wref'] == $village->wid) { ?>

diff --git a/Templates/Build/27_1.tpl b/Templates/Build/27_1.tpl index 56436b62..9f3ea35f 100644 --- a/Templates/Build/27_1.tpl +++ b/Templates/Build/27_1.tpl @@ -84,7 +84,7 @@ Treasury ' . $reqlvl . ', Effect ' . $effect . ''.NO_ARTIFACTS_AREA.''; } else { @@ -102,11 +102,11 @@ if(mysql_num_rows(mysql_query("SELECT * FROM " . TB_PREFIX . "artefacts")) == 0) unset($reqlvl); unset($effect); - $arts = mysql_query("SELECT * FROM " . TB_PREFIX . "artefacts"); + $arts = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "artefacts"); $rows = array(); - while($row = mysql_fetch_array($arts)) { - $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . $row['vref']); - $coor2 = mysql_fetch_assoc($query); + while($row = mysqli_fetch_array($arts)) { + $query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . $row['vref']); + $coor2 = mysqli_fetch_assoc($query); $dist = round(getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']),1); diff --git a/Templates/Build/27_2.tpl b/Templates/Build/27_2.tpl index 9f957218..1eac2cda 100644 --- a/Templates/Build/27_2.tpl +++ b/Templates/Build/27_2.tpl @@ -31,13 +31,13 @@ '.NO_ARTIFACTS.''; } else { - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 1"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 1"); + while($row = mysqli_fetch_array($artefact)) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''.NO_ARTIFACTS.''; } else { - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 1"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 1"); + while($row = mysqli_fetch_array($artefact)) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
There are no reports available.There are no reports available.There are no reports available.
'; @@ -56,8 +56,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 2"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 2"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -76,8 +76,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 3"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 3"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -96,8 +96,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 4"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 4"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -115,8 +115,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 5"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 5"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -134,8 +134,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 6"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 6"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -153,8 +153,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 7"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 7"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -172,8 +172,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 8"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 8"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -186,8 +186,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 8"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 8"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; diff --git a/Templates/Build/27_3.tpl b/Templates/Build/27_3.tpl index 920e994e..58ff4ebe 100644 --- a/Templates/Build/27_3.tpl +++ b/Templates/Build/27_3.tpl @@ -31,12 +31,12 @@
'; @@ -49,8 +49,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 1"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 1"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -69,8 +69,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 2"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 2"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -83,8 +83,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 2"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 2"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -103,8 +103,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 3"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 3"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -117,8 +117,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 3"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 3"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -137,8 +137,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 4"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 4"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -151,8 +151,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 4"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 4"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -170,8 +170,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 5"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 5"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -184,8 +184,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 5"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 5"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -203,8 +203,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 6"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 6"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -217,8 +217,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 6"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 6"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -236,8 +236,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 7"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 7"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -250,8 +250,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 7"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 7"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; @@ -269,8 +269,8 @@ unset($artefact); unset($row); - $artefact = mysql_query("SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 8"); - while($row = mysql_fetch_array($artefact)) { + $artefact = mysqli_query($GLOBALS['link'],"SELECT * FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 8"); + while($row = mysqli_fetch_array($artefact)) { echo '
'; diff --git a/Templates/Build/37.tpl b/Templates/Build/37.tpl index 26563fc4..e709187a 100644 --- a/Templates/Build/37.tpl +++ b/Templates/Build/37.tpl @@ -8,8 +8,8 @@ | Copyright: TravianX Project All rights reserved | \*-------------------------------------------------------*/ - $hero = mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . ""); - $hero_info = mysql_fetch_array($hero); + $hero = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . ""); + $hero_info = mysqli_fetch_array($hero); $define['reset_level'] = 3; // Until which level you are able to reset your points @@ -61,7 +61,7 @@ if(isset($_GET['land'])) { include("37_land.tpl"); } else { - if(mysql_num_rows($hero) == 0){ + if(mysqli_num_rows($hero) == 0){ include("37_train.tpl"); }elseif($hero_info['intraining'] == 1){ $timeleft = $generator->getTimeFormat($hero_info['trainingtime'] - time()); @@ -87,10 +87,10 @@
uid."'") or die("ERROR:".mysql_error()); - $hero = mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . ""); - $hero_info = mysql_fetch_array($hero); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `name`='".($_POST['name'])."' where `uid`='".$session->uid."'") or die("ERROR:".mysqli_error()); + $hero = mysqli_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . ""); + $hero_info = mysqli_fetch_array($hero); echo "".NAME_CHANGED.""; } @@ -169,48 +169,48 @@ if (isset($_POST['name'])) { if($_GET['add'] == "reset") { if($hero_info['level'] <= 3){ if($hero_info['attack'] != 0 OR $hero_info['defence'] != 0 OR $hero_info['attackbonus'] != 0 OR $hero_info['defencebonus'] != 0 OR $hero_info['regeneration'] != 0){ - mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `uid` = '" . $session->uid . "'"); header("Location: build.php?id=".$id.""); } } } if($_GET['add'] == "off" && $hero_info['attack'] < 100) { if($hero_info['points'] > 0) { - mysql_query("UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); header("Location: build.php?id=".$id.""); } } if($_GET['add'] == "deff" && $hero_info['defence'] < 100) { if($hero_info['points'] > 0) { - mysql_query("UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); header("Location: build.php?id=".$id.""); } } if($_GET['add'] == "obonus" && $hero_info['attackbonus'] < 100) { if($hero_info['points'] > 0) { - mysql_query("UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); header("Location: build.php?id=".$id.""); } } if($_GET['add'] == "dbonus" && $hero_info['defencebonus'] < 100) { if($hero_info['points'] > 0) { - mysql_query("UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); header("Location: build.php?id=".$id.""); } } if($_GET['add'] == "reg" && $hero_info['regeneration'] < 100) { if($hero_info['points'] > 0) { - mysql_query("UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `uid` = '" . $session->uid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $session->uid . "'"); header("Location: build.php?id=".$id.""); } } diff --git a/Templates/Build/37_revive.tpl b/Templates/Build/37_revive.tpl index ec9dd953..39ae80be 100644 --- a/Templates/Build/37_revive.tpl +++ b/Templates/Build/37_revive.tpl @@ -171,11 +171,11 @@ if($_GET['revive'] == 1 && $hero_info['inrevive'] == 0 && $hero_info['intraining'] == 0 && $hero_info['dead'] == 1){ if($session->access != BANNED){ - mysql_query("UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".$training_time2."', `wref` = '".$village->wid."' WHERE `uid` = '".$session->uid."'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$wood." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$clay." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$iron." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$crop." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".$training_time2."', `wref` = '".$village->wid."' WHERE `uid` = '".$session->uid."'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$wood." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$clay." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$iron." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$crop." WHERE `wref` = '" . $village->wid . "'"); header("Location: build.php?id=".$id.""); }else{ header("Location: banned.php"); diff --git a/Templates/Build/37_train.tpl b/Templates/Build/37_train.tpl index b600e3bb..fe3423e7 100644 --- a/Templates/Build/37_train.tpl +++ b/Templates/Build/37_train.tpl @@ -34,8 +34,8 @@ //check if there is unit needed in the village -$result = mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".$village->wid.""); -$units = mysql_fetch_array($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".$village->wid.""); +$units = mysqli_fetch_array($result); $output=" @@ -529,18 +529,18 @@ $output.=" //HERO TRAINING - $count_hero = mysql_num_rows(mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . "")); + $count_hero = mysqli_num_rows(mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $session->uid . "")); if($session->tribe == 1){ if($_GET['train'] == 1){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '1', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u1` = `u1` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u1['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u1['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u1['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u1['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '1', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u1['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u1['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u1['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u1['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -549,14 +549,14 @@ $output.=" } if($_GET['train'] == 2){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '2', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u2` = `u2` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u2['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u2['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u2['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u2['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '2', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u2['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u2['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u2['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u2['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -565,13 +565,13 @@ $output.=" } if($_GET['train'] == 3){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '3', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u3['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u3` = `u3` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u3['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u3['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u3['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u3['crop']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '3', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u3['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u3['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u3['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u3['crop']." WHERE `wref` = '" . $village->wid . "'"); header("Location: build.php?id=".$id.""); }else{ header("Location: banned.php"); @@ -579,14 +579,14 @@ $output.=" } if($_GET['train'] == 5){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '5', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u5['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u5` = `u5` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u5['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u5['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u5['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u5['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '5', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u5['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u5['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u5['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u5['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -595,14 +595,14 @@ $output.=" } if($_GET['train'] == 6){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '6', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u6['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u6` = `u6` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u6['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u6['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u6['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u6['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '6', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u6['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u6['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u6['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u6['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -613,14 +613,14 @@ $output.=" if($session->tribe == 2){ if($_GET['train'] == 11){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '11', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u11['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u11` = `u11` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u11['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u11['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u11['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u11['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '11', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u11['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u11['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u11['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u11['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -629,14 +629,14 @@ $output.=" } if($_GET['train'] == 12){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '12', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u12['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u12` = `u12` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u12['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u12['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u12['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u12['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '12', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u12['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u12['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u12['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u12['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -645,14 +645,14 @@ $output.=" } if($_GET['train'] == 13){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '13', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u13['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u13` = `u13` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u13['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u13['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u13['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u13['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '13', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u13['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u13['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u13['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u13['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -661,14 +661,14 @@ $output.=" } if($_GET['train'] == 15){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '15', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u15['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u15` = `u15` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u15['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u15['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u15['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u15['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '15', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u15['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u15['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u15['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u15['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -677,14 +677,14 @@ $output.=" } if($_GET['train'] == 16){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '16', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u16['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u16` = `u16` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u16['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u16['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u16['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u16['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '16', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u16['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u16['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u16['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u16['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -695,14 +695,14 @@ $output.=" if($session->tribe == 3){ if($_GET['train'] == 21){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '21', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u21['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u21` = `u21` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u21['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u21['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u21['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u21['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '21', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u21['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u21['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u21['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u21['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -711,14 +711,14 @@ $output.=" } if($_GET['train'] == 22){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '22', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u22['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u22` = `u22` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u22['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u22['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u22['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u22['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '22', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u22['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u22['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u22['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u22['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -727,14 +727,14 @@ $output.=" } if($_GET['train'] == 24){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '24', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u24['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u24` = `u24` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u24['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u24['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u24['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u24['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '24', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u24['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u24['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u24['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u24['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -743,14 +743,14 @@ $output.=" } if($_GET['train'] == 25){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '25', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u25['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u25` = `u25` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u25['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u25['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u25['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u25['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '25', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u25['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u25['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u25['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u25['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ @@ -759,14 +759,14 @@ $output.=" } if($_GET['train'] == 26){ if($session->access != BANNED){ - mysql_query("DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); + mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $session->uid . "'"); if($count_hero == 0){ - mysql_query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$session->uid."', '" . $village->wid . "', '0', '26', '".addslashes($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u26['time'] / SPEED)*3))."', '50', '1')"); - mysql_query("UPDATE " . TB_PREFIX . "units SET `u26` = `u26` - 1 WHERE `vref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u26['wood']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u26['clay']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u26['iron']." WHERE `wref` = '" . $village->wid . "'"); - mysql_query("UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u26['crop']." WHERE `wref` = '" . $village->wid . "'"); + 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 ('".$session->uid."', '" . $village->wid . "', '0', '26', '".addslashes($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` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".$u26['wood']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".$u26['clay']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".$u26['iron']." WHERE `wref` = '" . $village->wid . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".$u26['crop']." WHERE `wref` = '" . $village->wid . "'"); } header("Location: build.php?id=".$id.""); }else{ diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index 28873714..5e7b6e6f 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -162,17 +162,14 @@ if($palace == 0 && $palace1 == 0 && $village->natar == 0 && $embassy >= 1 && $ma //id user $user = $session->uid; -//connect to DB -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); //loop search village user -$query = mysql_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); -while($villaggi_array = mysql_fetch_array($query)){ +$query = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); +while($villaggi_array = mysqli_fetch_array($query)){ //loop structure village - $query1 = mysql_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); - $strutture= mysql_fetch_array($query1); + $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); + $strutture= mysqli_fetch_array($query1); //search Castle in array structure village $test = in_array(26,$strutture); @@ -285,16 +282,16 @@ if($embassy == 0 || $mainbuilding >= 2 && $mainbuilding <= 4 && $village->natar $user = $session->uid; //connect to DB -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +//mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); +//mysql_select_db(SQL_DB); //loop search village user -$query = mysql_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); -while($villaggi_array = mysql_fetch_array($query)){ +$query = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); +while($villaggi_array = mysqli_fetch_array($query)){ //loop structure village - $query1 = mysql_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); - $strutture= mysql_fetch_array($query1); + $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); + $strutture= mysqli_fetch_array($query1); //search Castle in array structure village $test = in_array(26,$strutture); diff --git a/Templates/Map/mapviewlarge.tpl b/Templates/Map/mapviewlarge.tpl index 0268a10a..2b734a35 100644 --- a/Templates/Map/mapviewlarge.tpl +++ b/Templates/Map/mapviewlarge.tpl @@ -121,7 +121,7 @@ $query2 = "SELECT ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')"; //echo $query2; -$result2 = mysql_query($query2) or die(mysql_error()); +$result2 = mysqli_query($GLOBALS['link'],$query2) or die(mysqli_error()); $targetalliance = array(); $neutralarray = array(); @@ -307,7 +307,7 @@ $coorarray = array( ,"924, 253, 961, 273, 924, 293, 887, 273" ); -while ($donnees = mysql_fetch_assoc($result2)){ +while ($donnees = mysqli_fetch_assoc($result2)){ $targetalliance=$donnees["aliance_id"]; $friendarray=$database->getAllianceAlly($donnees["aliance_id"],1); diff --git a/Templates/Message/inbox.tpl b/Templates/Message/inbox.tpl index 9d2380e6..fb2749cc 100644 --- a/Templates/Message/inbox.tpl +++ b/Templates/Message/inbox.tpl @@ -11,8 +11,8 @@ include("menu.tpl");
Sent
uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); $date2=strtotime("NOW"); if ($golds['plus'] <= $date2) { ?> diff --git a/Templates/Message/sent.tpl b/Templates/Message/sent.tpl index 708e6a0a..370ee3cb 100644 --- a/Templates/Message/sent.tpl +++ b/Templates/Message/sent.tpl @@ -22,8 +22,8 @@ Recipient Sent
uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); $date2=strtotime("NOW"); if ($golds['plus'] <= $date2) { ?> diff --git a/Templates/News/newsbox1.tpl b/Templates/News/newsbox1.tpl index 269941e0..c6777efd 100644 --- a/Templates/News/newsbox1.tpl +++ b/Templates/News/newsbox1.tpl @@ -1,8 +1,8 @@
newsbox 1
5 AND tribe<=3 AND tribe > 0 ORDER BY oldrank ASC Limit 1")); +$online = mysqli_num_rows(mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "users WHERE " . time() . "-timestamp < (60*10) AND tribe!=0 AND tribe!=4 AND tribe!=5")); +$top_rank = mysqli_fetch_assoc(mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE access< 8 AND id > 5 AND tribe<=3 AND tribe > 0 ORDER BY oldrank ASC Limit 1")); ?> diff --git a/Templates/News/newsbox2.tpl b/Templates/News/newsbox2.tpl index fbccac4f..aeda3cda 100644 --- a/Templates/News/newsbox2.tpl +++ b/Templates/News/newsbox2.tpl @@ -1,7 +1,7 @@
newsbox 2
diff --git a/Templates/Notice/all.tpl b/Templates/Notice/all.tpl index c1169bca..dba36a62 100644 --- a/Templates/Notice/all.tpl +++ b/Templates/Notice/all.tpl @@ -12,8 +12,8 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att
uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); $date2=strtotime("NOW"); if ($golds['plus'] <= $date2) { ?> diff --git a/Templates/Plus/10.tpl b/Templates/Plus/10.tpl index 44ff814e..ebcb6e3a 100644 --- a/Templates/Plus/10.tpl +++ b/Templates/Plus/10.tpl @@ -1,40 +1,40 @@ access != BANNED){ - $MyGold = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); - $MyId = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysql_error()); - $uuid = mysql_fetch_array($MyId); + $MyId = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $uuid = mysqli_fetch_array($MyId); - $MyVilId = mysql_query("SELECT * FROM ".TB_PREFIX."bdata WHERE `wid`='".$village->wid."'") or die(mysql_error()); - $uuVilid = mysql_fetch_array($MyVilId); + $MyVilId = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."bdata WHERE `wid`='".$village->wid."'") or die(mysqli_error()); + $uuVilid = mysqli_fetch_array($MyVilId); - $goldlog = mysql_query("SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysql_error()); + $goldlog = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysqli_error()); $today = date("mdHi"); if($session->sit == 0) { -if (mysql_num_rows($MyGold)) { +if (mysqli_num_rows($MyGold)) { if($golds['6'] > 2) { -if (mysql_num_rows($MyGold)) { +if (mysqli_num_rows($MyGold)) { if($golds['b2'] < time()) { -mysql_query("UPDATE ".TB_PREFIX."users set b2 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysql_error()); +mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b2 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error()); } else { -mysql_query("UPDATE ".TB_PREFIX."users set b2 = '".($golds['b2']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysql_error()); +mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b2 = '".($golds['b2']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error()); } $done1 = "+25% Production: Clay"; - mysql_query("UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysql_error()); - mysql_query("INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysql_num_rows($goldlog)+1)."', '".$village->wid."', '+25% Production: Clay')") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error()); + mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', '+25% Production: Clay')") or die(mysqli_error()); } else { $done1 = "nothing has been done"; - mysql_query("INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysql_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed +25% Production: Clay')") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed +25% Production: Clay')") or die(mysqli_error()); } } else { diff --git a/Templates/Plus/11.tpl b/Templates/Plus/11.tpl index 3914f63a..c4aa5a96 100644 --- a/Templates/Plus/11.tpl +++ b/Templates/Plus/11.tpl @@ -1,40 +1,40 @@ access != BANNED){ - $MyGold = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); - $MyId = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysql_error()); - $uuid = mysql_fetch_array($MyId); + $MyId = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $uuid = mysqli_fetch_array($MyId); - $MyVilId = mysql_query("SELECT * FROM ".TB_PREFIX."bdata WHERE `wid`='".$village->wid."'") or die(mysql_error()); - $uuVilid = mysql_fetch_array($MyVilId); + $MyVilId = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."bdata WHERE `wid`='".$village->wid."'") or die(mysqli_error()); + $uuVilid = mysqli_fetch_array($MyVilId); - $goldlog = mysql_query("SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysql_error()); + $goldlog = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysqli_error()); $today = date("mdHi"); if($session->sit == 0) { -if (mysql_num_rows($MyGold)) { +if (mysqli_num_rows($MyGold)) { if($golds['6'] > 2) { -if (mysql_num_rows($MyGold)) { +if (mysqli_num_rows($MyGold)) { if($golds['b3'] < time()) { -mysql_query("UPDATE ".TB_PREFIX."users set b3 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysql_error()); +mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b3 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error()); } else { -mysql_query("UPDATE ".TB_PREFIX."users set b3 = '".($golds['b3']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysql_error()); +mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b3 = '".($golds['b3']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error()); } $done1 = "+25% Production: Iron"; - mysql_query("UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysql_error()); - mysql_query("INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysql_num_rows($goldlog)+1)."', '".$village->wid."', '+25% Production: Iron')") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error()); + mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', '+25% Production: Iron')") or die(mysqli_error()); } else { $done1 = "nothing has been done"; - mysql_query("INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysql_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed +25% Production: Iron')") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed +25% Production: Iron')") or die(mysqli_error()); } } else { diff --git a/Templates/Plus/12.tpl b/Templates/Plus/12.tpl index 3142525d..9c89836a 100644 --- a/Templates/Plus/12.tpl +++ b/Templates/Plus/12.tpl @@ -1,40 +1,40 @@ access != BANNED){ - $MyGold = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); - $MyId = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysql_error()); - $uuid = mysql_fetch_array($MyId); + $MyId = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $uuid = mysqli_fetch_array($MyId); - $MyVilId = mysql_query("SELECT * FROM ".TB_PREFIX."bdata WHERE `wid`='".$village->wid."'") or die(mysql_error()); - $uuVilid = mysql_fetch_array($MyVilId); + $MyVilId = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."bdata WHERE `wid`='".$village->wid."'") or die(mysqli_error()); + $uuVilid = mysqli_fetch_array($MyVilId); - $goldlog = mysql_query("SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysql_error()); + $goldlog = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysqli_error()); $today = date("mdHi"); if($session->sit == 0) { -if (mysql_num_rows($MyGold)) { +if (mysqli_num_rows($MyGold)) { if($golds['6'] > 2) { -if (mysql_num_rows($MyGold)) { +if (mysqli_num_rows($MyGold)) { if($golds['b4'] < time()) { -mysql_query("UPDATE ".TB_PREFIX."users set b4 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysql_error()); +mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b4 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error()); } else { -mysql_query("UPDATE ".TB_PREFIX."users set b4 = '".($golds['b4']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysql_error()); +mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b4 = '".($golds['b4']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error()); } $done1 = "+25% Production: Crop"; - mysql_query("UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysql_error()); - mysql_query("INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysql_num_rows($goldlog)+1)."', '".$village->wid."', '+25% Production: Crop')") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error()); + mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', '+25% Production: Crop')") or die(mysqli_error()); } else { $done1 = "nothing has been done"; - mysql_query("INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysql_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed +25% Production: Crop')") or die(mysql_error()); + mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed +25% Production: Crop')") or die(mysqli_error()); } } else { diff --git a/Templates/Plus/13.tpl b/Templates/Plus/13.tpl index 2c2e977a..015b14d3 100644 --- a/Templates/Plus/13.tpl +++ b/Templates/Plus/13.tpl @@ -1,7 +1,7 @@ -
+
Support: -
+
Travian PLUS: -

-Youth protection officer:
-Rechtsanwalt Dr. Andreas Lober
-Schulte Riesenkampff Rechtsanwaltsgesellschaft mbH
+

+Youth protection officer:
+Rechtsanwalt Dr. Andreas Lober
+Schulte Riesenkampff Rechtsanwaltsgesellschaft mbH
-
-
-Data protection officer:
-Robin Houben
+
+
+Data protection officer:
+Robin Houben
-

+

Please don't forget Username + Game-Server when you write to support -

+

All rights to texts, graphics and source codes are held by Travian Games GmbH. Travian is a registered trade mark of Travian Games GmbH.

- - diff --git a/install/data/.htaccess b/install/data/.htaccess deleted file mode 100755 index 85b65c30..00000000 --- a/install/data/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - -Order allow,deny -Deny from all - \ No newline at end of file diff --git a/install/data/constant_format.tpl b/install/data/constant_format.tpl deleted file mode 100755 index e3da2048..00000000 --- a/install/data/constant_format.tpl +++ /dev/null @@ -1,288 +0,0 @@ - diff --git a/install/data/sql.sql b/install/data/sql.sql deleted file mode 100755 index fe43c664..00000000 --- a/install/data/sql.sql +++ /dev/null @@ -1,1618 +0,0 @@ --- phpMyAdmin SQL Dump --- version 3.3.9 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Jul 21, 2011 at 02:49 AM --- Server version: 5.5.8 --- PHP Version: 5.3.5 - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%a2b` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%a2b` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ckey` varchar(255) NULL, - `time_check` int(11) NULL DEFAULT '0', - `to_vid` int(11) NULL, - `u1` int(11) NULL, - `u2` int(11) NULL, - `u3` int(11) NULL, - `u4` int(11) NULL, - `u5` int(11) NULL, - `u6` int(11) NULL, - `u7` int(11) NULL, - `u8` int(11) NULL, - `u9` int(11) NULL, - `u10` int(11) NULL, - `u11` int(11) NULL, - `type` smallint(1) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%a2b` --- - --- --- Table structure for table `%PREFIX%links` --- - -CREATE TABLE `%PREFIX%links` ( - `id` INT( 25 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , - `userid` INT( 25 ) NULL , - `name` VARCHAR( 50 ) NULL , - `url` VARCHAR( 150 ) NULL , - `pos` INT( 10 ) NULL -) ENGINE = InnoDB; - --- --- Dumping data for table `%PREFIX%links` --- - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%abdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%abdata` ( - `vref` int(11) NOT NULL, - `a1` tinyint(2) NULL DEFAULT '0', - `a2` tinyint(2) NULL DEFAULT '0', - `a3` tinyint(2) NULL DEFAULT '0', - `a4` tinyint(2) NULL DEFAULT '0', - `a5` tinyint(2) NULL DEFAULT '0', - `a6` tinyint(2) NULL DEFAULT '0', - `a7` tinyint(2) NULL DEFAULT '0', - `a8` tinyint(2) NULL DEFAULT '0', - `b1` tinyint(2) NULL DEFAULT '0', - `b2` tinyint(2) NULL DEFAULT '0', - `b3` tinyint(2) NULL DEFAULT '0', - `b4` tinyint(2) NULL DEFAULT '0', - `b5` tinyint(2) NULL DEFAULT '0', - `b6` tinyint(2) NULL DEFAULT '0', - `b7` tinyint(2) NULL DEFAULT '0', - `b8` tinyint(2) NULL DEFAULT '0', - PRIMARY KEY (`vref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%abdata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%activate` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%activate` ( - `id` int(255) NOT NULL AUTO_INCREMENT, - `username` varchar(100) NULL, - `password` varchar(100) NULL, - `email` text NULL, - `tribe` tinyint(1) NULL, - `access` tinyint(1) NULL DEFAULT '1', - `act` varchar(10) NULL, - `timestamp` int(11) NULL DEFAULT '0', - `location` text NULL, - `act2` varchar(10) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%activate` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%active` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%active` ( - `username` varchar(100) NOT NULL, - `timestamp` int(11) NULL, - PRIMARY KEY (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%PREFIX%active` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%admin_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%admin_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user` text NULL, - `log` text NULL, - `time` int(25) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=80 ; - --- --- Dumping data for table `%PREFIX%admin_log` --- - - --- -------------------------------------------------------- --- --- Table structure for table `%PREFIX%allimedal` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%allimedal` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `allyid` int(11) NULL, - `categorie` int(11) NULL, - `plaats` int(11) NULL, - `week` int(11) NULL, - `points` bigint(255) NULL, - `img` varchar(255) NULL, - `del` tinyint(1) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%artefacts` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%artefacts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `vref` int(11) NULL, - `owner` int(11) NULL, - `type` tinyint(2) NULL, - `size` tinyint(1) NULL, - `conquered` int(11) NULL, - `name` varchar(100) NULL, - `desc` text NULL, - `effect` varchar(100) NULL, - `img` varchar(20) NULL, - `active` tinyint(1) NULL, - `kind` tinyint(1) NULL DEFAULT '0', - `bad_effect` tinyint(1) NULL DEFAULT '0', - `effect2` tinyint(2) NULL DEFAULT '0', - `lastupdate` int(11) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Table structure for table `s1_artefacts` --- --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%alidata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%alidata` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) NULL, - `tag` varchar(100) NULL, - `leader` int(11) NULL, - `coor` int(11) NULL, - `advisor` int(11) NULL, - `recruiter` int(11) NULL, - `notice` text NULL, - `desc` text NULL, - `max` tinyint(2) NULL, - `ap` bigint(255) NULL DEFAULT '0', - `dp` bigint(255) NULL DEFAULT '0', - `Rc` bigint(255) NULL DEFAULT '0', - `RR` bigint(255) NULL DEFAULT '0', - `Aap` bigint(255) NULL DEFAULT '0', - `Adp` bigint(255) NULL DEFAULT '0', - `clp` bigint(255) NULL DEFAULT '0', - `oldrank` bigint(255) NULL DEFAULT '0', - `forumlink` varchar(150) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%alidata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%ali_invite` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%ali_invite` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `alliance` int(11) NULL, - `sender` int(11) NULL, - `timestamp` int(11) NULL, - `accept` int(1) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%ali_invite` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%ali_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%ali_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `aid` int(11) NULL, - `comment` text NULL, - `date` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%ali_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%ali_permission` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%ali_permission` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `alliance` int(11) NULL, - `rank` varchar(100) NULL, - `opt1` int(1) NULL DEFAULT '0', - `opt2` int(1) NULL DEFAULT '0', - `opt3` int(1) NULL DEFAULT '0', - `opt4` int(1) NULL DEFAULT '0', - `opt5` int(1) NULL DEFAULT '0', - `opt6` int(1) NULL DEFAULT '0', - `opt7` int(1) NULL DEFAULT '0', - `opt8` int(1) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%ali_permission` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%attacks` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%attacks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `vref` int(11) NULL, - `t1` int(11) NULL, - `t2` int(11) NULL, - `t3` int(11) NULL, - `t4` int(11) NULL, - `t5` int(11) NULL, - `t6` int(11) NULL, - `t7` int(11) NULL, - `t8` int(11) NULL, - `t9` int(11) NULL, - `t10` int(11) NULL, - `t11` int(11) NULL, - `attack_type` tinyint(1) NULL, - `ctar1` int(11) NULL, - `ctar2` int(11) NULL, - `spy` int(11) NULL, - `b1` tinyint(1) NULL, - `b2` tinyint(1) NULL, - `b3` tinyint(1) NULL, - `b4` tinyint(1) NULL, - `b5` tinyint(1) NULL, - `b6` tinyint(1) NULL, - `b7` tinyint(1) NULL, - `b8` tinyint(1) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%attacks` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%banlist` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%banlist` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `name` varchar(100) NULL, - `reason` varchar(30) NULL, - `time` int(11) NULL, - `end` varchar(10) NULL, - `admin` int(11) NULL, - `active` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%banlist` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%bdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%bdata` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wid` int(11) NULL, - `field` tinyint(2) NULL, - `type` tinyint(2) NULL, - `loopcon` tinyint(1) NULL, - `timestamp` int(11) NULL, - `master` tinyint(1) NULL, - `level` tinyint(3) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%bdata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%build_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%build_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wid` int(11) NULL, - `log` text NULL, - `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%build_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%chat` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%chat` ( - `id` int(20) NOT NULL AUTO_INCREMENT, - `id_user` int(11) NULL, - `name` varchar(255) NULL, - `alli` varchar(255) NULL, - `date` varchar(255) NULL, - `msg` varchar(255) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%chat` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%config` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%config` ( - `lastgavemedal` int(11) NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -INSERT INTO `%PREFIX%config` VALUES (0); - --- --- Dumping data for table `%prefix%config` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%deleting` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%deleting` ( - `uid` int(11) NOT NULL, - `timestamp` int(11) NULL, - PRIMARY KEY (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%prefix%deleting` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%demolition` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%demolition` ( - `vref` int(11) NOT NULL, - `buildnumber` int(11) NULL DEFAULT '0', - `lvl` int(11) NULL DEFAULT '0', - `timetofinish` int(11) NULL, - PRIMARY KEY (`vref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%demolition` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%diplomacy` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%diplomacy` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `alli1` int(11) NULL, - `alli2` int(11) NULL, - `type` tinyint(1) NULL, - `accepted` tinyint(1) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; --- --- Dumping data for table `%prefix%diplomacy` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%enforcement` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%enforcement` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `u1` int(11) NULL DEFAULT '0', - `u2` int(11) NULL DEFAULT '0', - `u3` int(11) NULL DEFAULT '0', - `u4` int(11) NULL DEFAULT '0', - `u5` int(11) NULL DEFAULT '0', - `u6` int(11) NULL DEFAULT '0', - `u7` int(11) NULL DEFAULT '0', - `u8` int(11) NULL DEFAULT '0', - `u9` int(11) NULL DEFAULT '0', - `u10` int(11) NULL DEFAULT '0', - `u11` int(11) NULL DEFAULT '0', - `u12` int(11) NULL DEFAULT '0', - `u13` int(11) NULL DEFAULT '0', - `u14` int(11) NULL DEFAULT '0', - `u15` int(11) NULL DEFAULT '0', - `u16` int(11) NULL DEFAULT '0', - `u17` int(11) NULL DEFAULT '0', - `u18` int(11) NULL DEFAULT '0', - `u19` int(11) NULL DEFAULT '0', - `u20` int(11) NULL DEFAULT '0', - `u21` int(11) NULL DEFAULT '0', - `u22` int(11) NULL DEFAULT '0', - `u23` int(11) NULL DEFAULT '0', - `u24` int(11) NULL DEFAULT '0', - `u25` int(11) NULL DEFAULT '0', - `u26` int(11) NULL DEFAULT '0', - `u27` int(11) NULL DEFAULT '0', - `u28` int(11) NULL DEFAULT '0', - `u29` int(11) NULL DEFAULT '0', - `u30` int(11) NULL DEFAULT '0', - `u31` int(11) NULL DEFAULT '0', - `u32` int(11) NULL DEFAULT '0', - `u33` int(11) NULL DEFAULT '0', - `u34` int(11) NULL DEFAULT '0', - `u35` int(11) NULL DEFAULT '0', - `u36` int(11) NULL DEFAULT '0', - `u37` int(11) NULL DEFAULT '0', - `u38` int(11) NULL DEFAULT '0', - `u39` int(11) NULL DEFAULT '0', - `u40` int(11) NULL DEFAULT '0', - `u41` int(11) NULL DEFAULT '0', - `u42` int(11) NULL DEFAULT '0', - `u43` int(11) NULL DEFAULT '0', - `u44` int(11) NULL DEFAULT '0', - `u45` int(11) NULL DEFAULT '0', - `u46` int(11) NULL DEFAULT '0', - `u47` int(11) NULL DEFAULT '0', - `u48` int(11) NULL DEFAULT '0', - `u49` int(11) NULL DEFAULT '0', - `u50` int(11) NULL DEFAULT '0', - `hero` tinyint(1) NULL DEFAULT '0', - `from` int(11) NULL DEFAULT '0', - `vref` int(11) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%enforcement` --- - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%farmlist` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%farmlist` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wref` int(11) NULL, - `owner` int(11) NULL, - `name` varchar(100) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%farmlist` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%fdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%fdata` ( - `vref` int(11) NOT NULL, - `f1` tinyint(2) NULL DEFAULT '0', - `f1t` tinyint(2) NULL DEFAULT '0', - `f2` tinyint(2) NULL DEFAULT '0', - `f2t` tinyint(2) NULL DEFAULT '0', - `f3` tinyint(2) NULL DEFAULT '0', - `f3t` tinyint(2) NULL DEFAULT '0', - `f4` tinyint(2) NULL DEFAULT '0', - `f4t` tinyint(2) NULL DEFAULT '0', - `f5` tinyint(2) NULL DEFAULT '0', - `f5t` tinyint(2) NULL DEFAULT '0', - `f6` tinyint(2) NULL DEFAULT '0', - `f6t` tinyint(2) NULL DEFAULT '0', - `f7` tinyint(2) NULL DEFAULT '0', - `f7t` tinyint(2) NULL DEFAULT '0', - `f8` tinyint(2) NULL DEFAULT '0', - `f8t` tinyint(2) NULL DEFAULT '0', - `f9` tinyint(2) NULL DEFAULT '0', - `f9t` tinyint(2) NULL DEFAULT '0', - `f10` tinyint(2) NULL DEFAULT '0', - `f10t` tinyint(2) NULL DEFAULT '0', - `f11` tinyint(2) NULL DEFAULT '0', - `f11t` tinyint(2) NULL DEFAULT '0', - `f12` tinyint(2) NULL DEFAULT '0', - `f12t` tinyint(2) NULL DEFAULT '0', - `f13` tinyint(2) NULL DEFAULT '0', - `f13t` tinyint(2) NULL DEFAULT '0', - `f14` tinyint(2) NULL DEFAULT '0', - `f14t` tinyint(2) NULL DEFAULT '0', - `f15` tinyint(2) NULL DEFAULT '0', - `f15t` tinyint(2) NULL DEFAULT '0', - `f16` tinyint(2) NULL DEFAULT '0', - `f16t` tinyint(2) NULL DEFAULT '0', - `f17` tinyint(2) NULL DEFAULT '0', - `f17t` tinyint(2) NULL DEFAULT '0', - `f18` tinyint(2) NULL DEFAULT '0', - `f18t` tinyint(2) NULL DEFAULT '0', - `f19` tinyint(2) NULL DEFAULT '0', - `f19t` tinyint(2) NULL DEFAULT '0', - `f20` tinyint(2) NULL DEFAULT '0', - `f20t` tinyint(2) NULL DEFAULT '0', - `f21` tinyint(2) NULL DEFAULT '0', - `f21t` tinyint(2) NULL DEFAULT '0', - `f22` tinyint(2) NULL DEFAULT '0', - `f22t` tinyint(2) NULL DEFAULT '0', - `f23` tinyint(2) NULL DEFAULT '0', - `f23t` tinyint(2) NULL DEFAULT '0', - `f24` tinyint(2) NULL DEFAULT '0', - `f24t` tinyint(2) NULL DEFAULT '0', - `f25` tinyint(2) NULL DEFAULT '0', - `f25t` tinyint(2) NULL DEFAULT '0', - `f26` tinyint(2) NULL DEFAULT '0', - `f26t` tinyint(2) NULL DEFAULT '0', - `f27` tinyint(2) NULL DEFAULT '0', - `f27t` tinyint(2) NULL DEFAULT '0', - `f28` tinyint(2) NULL DEFAULT '0', - `f28t` tinyint(2) NULL DEFAULT '0', - `f29` tinyint(2) NULL DEFAULT '0', - `f29t` tinyint(2) NULL DEFAULT '0', - `f30` tinyint(2) NULL DEFAULT '0', - `f30t` tinyint(2) NULL DEFAULT '0', - `f31` tinyint(2) NULL DEFAULT '0', - `f31t` tinyint(2) NULL DEFAULT '0', - `f32` tinyint(2) NULL DEFAULT '0', - `f32t` tinyint(2) NULL DEFAULT '0', - `f33` tinyint(2) NULL DEFAULT '0', - `f33t` tinyint(2) NULL DEFAULT '0', - `f34` tinyint(2) NULL DEFAULT '0', - `f34t` tinyint(2) NULL DEFAULT '0', - `f35` tinyint(2) NULL DEFAULT '0', - `f35t` tinyint(2) NULL DEFAULT '0', - `f36` tinyint(2) NULL DEFAULT '0', - `f36t` tinyint(2) NULL DEFAULT '0', - `f37` tinyint(2) NULL DEFAULT '0', - `f37t` tinyint(2) NULL DEFAULT '0', - `f38` tinyint(2) NULL DEFAULT '0', - `f38t` tinyint(2) NULL DEFAULT '0', - `f39` tinyint(2) NULL DEFAULT '0', - `f39t` tinyint(2) NULL DEFAULT '0', - `f40` tinyint(2) NULL DEFAULT '0', - `f40t` tinyint(2) NULL DEFAULT '0', - `f99` tinyint(2) NULL DEFAULT '0', - `f99t` tinyint(2) NULL DEFAULT '0', - `wwname` varchar(100) NULL DEFAULT 'World Wonder', - PRIMARY KEY (`vref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%prefix%fdata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%forum_cat` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%forum_cat` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `owner` varchar(255) NULL, - `alliance` varchar(255) NULL, - `forum_name` varchar(255) NULL, - `forum_des` text NULL, - `forum_area` varchar(255) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%forum_cat` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%forum_edit` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%forum_edit` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `alliance` varchar(255) NULL, - `result` varchar(255) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%forum_edit` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%forum_post` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%forum_post` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `post` longtext NULL, - `topic` varchar(255) NULL, - `owner` varchar(255) NULL, - `date` varchar(255) NULL, - `alliance0` int(11) NULL, - `player0` int(11) NULL, - `coor0` int(11) NULL, - `report0` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%forum_post` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%forum_survey` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%forum_survey` ( - `topic` int(11) NULL, - `title` varchar(255) NULL, - `option1` varchar(255) NULL, - `option2` varchar(255) NULL, - `option3` varchar(255) NULL, - `option4` varchar(255) NULL, - `option5` varchar(255) NULL, - `option6` varchar(255) NULL, - `option7` varchar(255) NULL, - `option8` varchar(255) NULL, - `vote1` int(11) NULL DEFAULT '0', - `vote2` int(11) NULL DEFAULT '0', - `vote3` int(11) NULL DEFAULT '0', - `vote4` int(11) NULL DEFAULT '0', - `vote5` int(11) NULL DEFAULT '0', - `vote6` int(11) NULL DEFAULT '0', - `vote7` int(11) NULL DEFAULT '0', - `vote8` int(11) NULL DEFAULT '0', - `voted` text NULL, - `ends` int(11) NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%forum_survey` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%forum_topic` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%forum_topic` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(255) NULL, - `post` longtext NULL, - `date` varchar(255) NULL, - `post_date` varchar(255) NULL, - `cat` varchar(255) NULL, - `owner` varchar(255) NULL, - `alliance` varchar(255) NULL, - `ends` varchar(255) NULL, - `close` varchar(255) NULL, - `stick` varchar(255) NULL, - `alliance0` int(11) NULL, - `player0` int(11) NULL, - `coor0` int(11) NULL, - `report0` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%forum_topic` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%general` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%general` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `casualties` int(11) NULL, - `time` int(11) NULL, - `shown` tinyint(1) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%general` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%gold_fin_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%gold_fin_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wid` int(11) NULL, - `log` text NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%gold_fin_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%hero` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%hero` ( - `heroid` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `unit` smallint(2) NULL, - `name` tinytext NULL, - `wref` int(11) NULL, - `level` tinyint(3) NULL, - `points` int(3) NULL, - `experience` int(11) NULL, - `dead` tinyint(1) NULL, - `health` float(12,9) NULL, - `attack` tinyint(3) NULL, - `defence` tinyint(3) NULL, - `attackbonus` tinyint(3) NULL, - `defencebonus` tinyint(3) NULL, - `regeneration` tinyint(3) NULL, - `autoregen` int(2) NULL, - `lastupdate` int(11) NULL, - `trainingtime` int(11) NULL, - `inrevive` tinyint(1) NULL, - `intraining` tinyint(1) NULL, - PRIMARY KEY (`heroid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; - --- --- Dumping data for table `%prefix%hero` --- - - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%illegal_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%illegal_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user` int(11) NULL, - `log` text NULL, - `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%illegal_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%login_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%login_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `ip` varchar(15) NULL, - `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%login_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%market` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%market` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `vref` int(11) NULL, - `gtype` tinyint(1) NULL, - `gamt` int(11) NULL, - `wtype` tinyint(1) NULL, - `wamt` int(11) NULL, - `accept` tinyint(1) NULL, - `maxtime` int(11) NULL, - `alliance` int(11) NULL, - `merchant` tinyint(2) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%market` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%market_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%market_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wid` int(11) NULL, - `log` text NULL, - `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%market_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%mdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%mdata` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `target` int(11) NULL, - `owner` int(11) NULL, - `topic` varchar(100) NULL, - `message` text NULL, - `viewed` tinyint(1) NULL, - `archived` tinyint(1) NULL, - `send` tinyint(1) NULL, - `time` int(11) NULL DEFAULT '0', - `deltarget` int(11) NULL, - `delowner` int(11) NULL, - `alliance` int(11) NULL, - `player` int(11) NULL, - `coor` int(11) NULL, - `report` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%mdata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%medal` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%medal` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `userid` int(11) NULL, - `categorie` int(11) NULL, - `plaats` int(11) NULL, - `week` int(11) NULL, - `points` varchar(15) NULL, - `img` varchar(10) NULL, - `del` tinyint(1) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%medal` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%movement` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%movement` ( - `moveid` int(11) NOT NULL AUTO_INCREMENT, - `sort_type` tinyint(4) NULL DEFAULT '0', - `from` int(11) NULL DEFAULT '0', - `to` int(11) NULL DEFAULT '0', - `ref` int(11) NULL DEFAULT '0', - `ref2` int(11) NULL DEFAULT '0', - `starttime` int(11) NULL DEFAULT '0', - `endtime` int(11) NULL DEFAULT '0', - `proc` tinyint(1) NULL DEFAULT '0', - `send` tinyint(1) NULL, - `wood` int(11) NULL, - `clay` int(11) NULL, - `iron` int(11) NULL, - `crop` int(11) NULL, - PRIMARY KEY (`moveid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%movement` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%ndata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%ndata` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `toWref` int(11) NULL, - `ally` int(11) NULL, - `topic` text NULL, - `ntype` tinyint(1) NULL, - `data` text NULL, - `time` int(11) NULL, - `viewed` tinyint(1) NULL, - `archive` tinyint(1) NULL DEFAULT '0', - `del` tinyint(1) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%ndata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%odata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%odata` ( - `wref` int(11) NOT NULL, - `type` tinyint(2) NULL, - `conqured` int(11) NULL, - `wood` int(11) NULL, - `iron` int(11) NULL, - `clay` int(11) NULL, - `maxstore` int(11) NULL, - `crop` int(11) NULL, - `maxcrop` int(11) NULL, - `lastupdated` int(11) NULL, - `lastupdated2` int(11) NULL, - `loyalty` float(9,6) NULL DEFAULT '100', - `owner` int(11) NULL DEFAULT '2', - `name` varchar(32) NULL DEFAULT 'Unoccupied Oasis', - `high` tinyint(1) NULL, - PRIMARY KEY (`wref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%prefix%odata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%online` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%online` ( - `name` varchar(32) NULL, - `uid` int(11) NULL, - `time` varchar(32) NULL, - `sit` tinyint(1) NULL, - UNIQUE KEY `name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%prefix%online` --- - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%prisoners` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%prisoners` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wref` int(11) NULL, - `from` int(11) NULL, - `t1` int(11) NULL, - `t2` int(11) NULL, - `t3` int(11) NULL, - `t4` int(11) NULL, - `t5` int(11) NULL, - `t6` int(11) NULL, - `t7` int(11) NULL, - `t8` int(11) NULL, - `t9` int(11) NULL, - `t10` int(11) NULL, - `t11` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%PREFIX%prisoners` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%raidlist` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%raidlist` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `lid` int(11) NULL, - `towref` int(11) NULL, - `x` int(11) NULL, - `y` int(11) NULL, - `distance` varchar(5) NULL DEFAULT '0', - `t1` int(11) NULL, - `t2` int(11) NULL, - `t3` int(11) NULL, - `t4` int(11) NULL, - `t5` int(11) NULL, - `t6` int(11) NULL, - `t7` int(11) NULL, - `t8` int(11) NULL, - `t9` int(11) NULL, - `t10` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%raidlist` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%research` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%research` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `vref` int(11) NULL, - `tech` varchar(3) NULL, - `timestamp` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%research` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%route` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%route` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `wid` int(11) NULL, - `from` int(11) NULL, - `wood` int(5) NULL, - `clay` int(5) NULL, - `iron` int(5) NULL, - `crop` int(5) NULL, - `start` tinyint(2) NULL, - `deliveries` tinyint(1) NULL, - `merchant` int(11) NULL, - `timestamp` int(11) NULL, - `timeleft` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%route` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%send` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%send` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wood` int(11) NULL, - `clay` int(11) NULL, - `iron` int(11) NULL, - `crop` int(11) NULL, - `merchant` tinyint(2) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%send` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%tdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%tdata` ( - `vref` int(11) NOT NULL, - `t2` tinyint(1) NULL DEFAULT '0', - `t3` tinyint(1) NULL DEFAULT '0', - `t4` tinyint(1) NULL DEFAULT '0', - `t5` tinyint(1) NULL DEFAULT '0', - `t6` tinyint(1) NULL DEFAULT '0', - `t7` tinyint(1) NULL DEFAULT '0', - `t8` tinyint(1) NULL DEFAULT '0', - `t9` tinyint(1) NULL DEFAULT '0', - `t12` tinyint(1) NULL DEFAULT '0', - `t13` tinyint(1) NULL DEFAULT '0', - `t14` tinyint(1) NULL DEFAULT '0', - `t15` tinyint(1) NULL DEFAULT '0', - `t16` tinyint(1) NULL DEFAULT '0', - `t17` tinyint(1) NULL DEFAULT '0', - `t18` tinyint(1) NULL DEFAULT '0', - `t19` tinyint(1) NULL DEFAULT '0', - `t22` tinyint(1) NULL DEFAULT '0', - `t23` tinyint(1) NULL DEFAULT '0', - `t24` tinyint(1) NULL DEFAULT '0', - `t25` tinyint(1) NULL DEFAULT '0', - `t26` tinyint(1) NULL DEFAULT '0', - `t27` tinyint(1) NULL DEFAULT '0', - `t28` tinyint(1) NULL DEFAULT '0', - `t29` tinyint(1) NULL DEFAULT '0', - `t32` tinyint(1) NULL DEFAULT '0', - `t33` tinyint(1) NULL DEFAULT '0', - `t34` tinyint(1) NULL DEFAULT '0', - `t35` tinyint(1) NULL DEFAULT '0', - `t36` tinyint(1) NULL DEFAULT '0', - `t37` tinyint(1) NULL DEFAULT '0', - `t38` tinyint(1) NULL DEFAULT '0', - `t39` tinyint(1) NULL DEFAULT '0', - `t42` tinyint(1) NULL DEFAULT '0', - `t43` tinyint(1) NULL DEFAULT '0', - `t44` tinyint(1) NULL DEFAULT '0', - `t45` tinyint(1) NULL DEFAULT '0', - `t46` tinyint(1) NULL DEFAULT '0', - `t47` tinyint(1) NULL DEFAULT '0', - `t48` tinyint(1) NULL DEFAULT '0', - `t49` tinyint(1) NULL DEFAULT '0', - PRIMARY KEY (`vref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%prefix%tdata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%tech_log` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%tech_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `wid` int(11) NULL, - `log` text NULL, - `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%tech_log` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%training` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%training` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `vref` int(11) NULL, - `unit` tinyint(2) NULL, - `amt` int(11) NULL, - `pop` int(11) NULL, - `timestamp` int(11) NULL, - `eachtime` int(11) NULL, - `timestamp2` int(11) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%training` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%units` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%units` ( - `vref` int(11) NOT NULL, - `u1` int(11) NULL DEFAULT '0', - `u2` int(11) NULL DEFAULT '0', - `u3` int(11) NULL DEFAULT '0', - `u4` int(11) NULL DEFAULT '0', - `u5` int(11) NULL DEFAULT '0', - `u6` int(11) NULL DEFAULT '0', - `u7` int(11) NULL DEFAULT '0', - `u8` int(11) NULL DEFAULT '0', - `u9` int(11) NULL DEFAULT '0', - `u10` int(11) NULL DEFAULT '0', - `u11` int(11) NULL DEFAULT '0', - `u12` int(11) NULL DEFAULT '0', - `u13` int(11) NULL DEFAULT '0', - `u14` int(11) NULL DEFAULT '0', - `u15` int(11) NULL DEFAULT '0', - `u16` int(11) NULL DEFAULT '0', - `u17` int(11) NULL DEFAULT '0', - `u18` int(11) NULL DEFAULT '0', - `u19` int(11) NULL DEFAULT '0', - `u20` int(11) NULL DEFAULT '0', - `u21` int(11) NULL DEFAULT '0', - `u22` int(11) NULL DEFAULT '0', - `u23` int(11) NULL DEFAULT '0', - `u24` int(11) NULL DEFAULT '0', - `u25` int(11) NULL DEFAULT '0', - `u26` int(11) NULL DEFAULT '0', - `u27` int(11) NULL DEFAULT '0', - `u28` int(11) NULL DEFAULT '0', - `u29` int(11) NULL DEFAULT '0', - `u30` int(11) NULL DEFAULT '0', - `u31` int(11) NULL DEFAULT '0', - `u32` int(11) NULL DEFAULT '0', - `u33` int(11) NULL DEFAULT '0', - `u34` int(11) NULL DEFAULT '0', - `u35` int(11) NULL DEFAULT '0', - `u36` int(11) NULL DEFAULT '0', - `u37` int(11) NULL DEFAULT '0', - `u38` int(11) NULL DEFAULT '0', - `u39` int(11) NULL DEFAULT '0', - `u40` int(11) NULL DEFAULT '0', - `u41` int(11) NULL DEFAULT '0', - `u42` int(11) NULL DEFAULT '0', - `u43` int(11) NULL DEFAULT '0', - `u44` int(11) NULL DEFAULT '0', - `u45` int(11) NULL DEFAULT '0', - `u46` int(11) NULL DEFAULT '0', - `u47` int(11) NULL DEFAULT '0', - `u48` int(11) NULL DEFAULT '0', - `u49` int(11) NULL DEFAULT '0', - `u50` int(11) NULL DEFAULT '0', - `u99` int(11) NULL DEFAULT '0', - `u99o` int(11) NULL DEFAULT '0', - `hero` int(11) NULL DEFAULT '0', - PRIMARY KEY (`vref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `%prefix%units` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%PREFIX%users` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `username` varchar(100) NULL, - `password` varchar(100) NULL, - `email` text NULL, - `tribe` tinyint(1) NULL, - `access` tinyint(1) NULL DEFAULT '1', - `gold` int(9) NULL DEFAULT '0', - `gender` tinyint(1) NULL DEFAULT '0', - `birthday` date NULL DEFAULT '1970-01-01', - `location` text NULL, - `desc1` text NULL, - `desc2` text NULL, - `plus` int(11) NULL DEFAULT '0', - `goldclub` int(11) NULL DEFAULT '0', - `b1` int(11) NULL DEFAULT '0', - `b2` int(11) NULL DEFAULT '0', - `b3` int(11) NULL DEFAULT '0', - `b4` int(11) NULL DEFAULT '0', - `sit1` int(11) NULL DEFAULT '0', - `sit2` int(11) NULL DEFAULT '0', - `alliance` int(11) NULL DEFAULT '0', - `sessid` varchar(100) NULL, - `act` varchar(10) NULL, - `timestamp` int(11) NULL DEFAULT '0', - `ap` int(11) NULL DEFAULT '0', - `apall` int(11) NULL DEFAULT '0', - `dp` int(11) NULL DEFAULT '0', - `dpall` int(11) NULL DEFAULT '0', - `protect` int(11) NULL, - `quest` tinyint(2) NULL, - `quest_time` int(11) NULL, - `gpack` varchar(255) NULL DEFAULT 'gpack/travian_default/', - `cp` float(14,5) NULL DEFAULT '1', - `lastupdate` int(11) NULL, - `RR` int(255) NULL DEFAULT '0', - `Rc` int(255) NULL DEFAULT '0', - `ok` tinyint(1) NULL DEFAULT '0', - `clp` bigint(255) NULL DEFAULT '0', - `oldrank` bigint(255) NULL DEFAULT '0', - `regtime` int(11) NULL DEFAULT '0', - `invited` int(11) NULL DEFAULT '0', - `friend0` int(11) NULL DEFAULT '0', - `friend1` int(11) NULL DEFAULT '0', - `friend2` int(11) NULL DEFAULT '0', - `friend3` int(11) NULL DEFAULT '0', - `friend4` int(11) NULL DEFAULT '0', - `friend5` int(11) NULL DEFAULT '0', - `friend6` int(11) NULL DEFAULT '0', - `friend7` int(11) NULL DEFAULT '0', - `friend8` int(11) NULL DEFAULT '0', - `friend9` int(11) NULL DEFAULT '0', - `friend10` int(11) NULL DEFAULT '0', - `friend11` int(11) NULL DEFAULT '0', - `friend12` int(11) NULL DEFAULT '0', - `friend13` int(11) NULL DEFAULT '0', - `friend14` int(11) NULL DEFAULT '0', - `friend15` int(11) NULL DEFAULT '0', - `friend16` int(11) NULL DEFAULT '0', - `friend17` int(11) NULL DEFAULT '0', - `friend18` int(11) NULL DEFAULT '0', - `friend19` int(11) NULL DEFAULT '0', - `friend0wait` int(11) NULL DEFAULT '0', - `friend1wait` int(11) NULL DEFAULT '0', - `friend2wait` int(11) NULL DEFAULT '0', - `friend3wait` int(11) NULL DEFAULT '0', - `friend4wait` int(11) NULL DEFAULT '0', - `friend5wait` int(11) NULL DEFAULT '0', - `friend6wait` int(11) NULL DEFAULT '0', - `friend7wait` int(11) NULL DEFAULT '0', - `friend8wait` int(11) NULL DEFAULT '0', - `friend9wait` int(11) NULL DEFAULT '0', - `friend10wait` int(11) NULL DEFAULT '0', - `friend11wait` int(11) NULL DEFAULT '0', - `friend12wait` int(11) NULL DEFAULT '0', - `friend13wait` int(11) NULL DEFAULT '0', - `friend14wait` int(11) NULL DEFAULT '0', - `friend15wait` int(11) NULL DEFAULT '0', - `friend16wait` int(11) NULL DEFAULT '0', - `friend17wait` int(11) NULL DEFAULT '0', - `friend18wait` int(11) NULL DEFAULT '0', - `friend19wait` int(11) NULL DEFAULT '0', - `maxevasion` mediumint(3) NULL DEFAULT '0', - `village_select` bigint(20) DEFAULT NULL, - `vac_time` varchar(255) NULL DEFAULT '0', - `vac_mode` int(2) NULL DEFAULT '0', - `vactwoweeks` varchar(255) NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; - --- --- Dumping data for table `%prefix%users` --- - -INSERT INTO `%PREFIX%users` (`id`, `username`, `password`, `email`, `tribe`, `access`, `gold`, `gender`, `birthday`, `location`, `desc1`, `desc2`, `plus`, `b1`, `b2`, `b3`, `b4`, `sit1`, `sit2`, `alliance`, `sessid`, `act`, `timestamp`, `ap`, `apall`, `dp`, `dpall`, `protect`, `quest`, `gpack`, `cp`, `lastupdate`, `RR`, `Rc`, `ok`) VALUES -(5, 'Multihunter', '', 'multihunter@travianx.mail', 0, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(1, 'Support', '', 'support@travianx.mail', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(2, 'Nature', '4262cc190152adfc1a3fcf32af6aa430', 'support@travianx.mail', 4, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(4, 'Taskmaster', '', 'support@travianx.mail', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0); - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%vdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%vdata` ( -`wref` int(11) NOT NULL, -`owner` int(11) NULL, -`name` varchar(100) NULL, -`capital` tinyint(1) NULL, -`pop` int(11) NULL, -`cp` int(11) NULL, -`celebration` int(11) NULL DEFAULT '0', -`type` int(11) NULL DEFAULT '0', -`wood` float(12,2) NULL, -`clay` float(12,2) NULL, -`iron` float(12,2) NULL, -`maxstore` int(11) NULL, -`crop` float(12,2) NULL, -`maxcrop` int(11) NULL, -`lastupdate` int(11) NULL, -`lastupdate2` int(11) NULL DEFAULT '0', -`loyalty` float(9,6) NULL DEFAULT '100', -`exp1` int(11) NULL DEFAULT '0', -`exp2` int(11) NULL DEFAULT '0', -`exp3` int(11) NULL DEFAULT '0', -`created` int(11) NULL, -`natar` tinyint(1) NULL DEFAULT '0', -`starv` int(11) NULL DEFAULT '0', -`starvupdate` int(11) NULL DEFAULT '0', -`evasion` tinyint(1) NULL DEFAULT '0', -PRIMARY KEY (`wref`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%vdata` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `%prefix%wdata` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%wdata` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `fieldtype` tinyint(2) NULL, - `oasistype` tinyint(2) NULL, - `x` int(11) NULL, - `y` int(11) NULL, - `occupied` tinyint(1) NULL, - `image` varchar(3) NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Dumping data for table `%prefix%wdata` --- - --- -------------------------------------------------------- --- --- Table structure for table `%prefix%password` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%password` ( - `uid` int(11) NOT NULL, - `npw` varchar(100) NULL, - `cpw` varchar(100) NULL, - `used` tinyint(1) NULL DEFAULT '0', - `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; - --- --- Dumping data for table `%prefix%password` --- - --- -------------------------------------------------------- --- --- Table structure for table `%prefix%ww_attacks` --- - -CREATE TABLE IF NOT EXISTS `%PREFIX%ww_attacks` ( - `vid` int(25) NULL, - `attack_time` int(25) NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; - --- --- Dumping data for table `%prefix%password` --- - --- -------------------------------------------------------- diff --git a/install/include/database.php b/install/include/database.php deleted file mode 100755 index 55670d9a..00000000 --- a/install/include/database.php +++ /dev/null @@ -1,21 +0,0 @@ -connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die(mysqli_error()); - } - function query($query) { - return mysqli_query($this->connection, $query); - } -}; -$database = new MYSQLi_DB; -?> diff --git a/install/include/multihunter.php b/install/include/multihunter.php deleted file mode 100755 index 5800f33e..00000000 --- a/install/include/multihunter.php +++ /dev/null @@ -1,31 +0,0 @@ -getWref(0, 0); - $uid = 5; - $status = $database->getVillageState($wid); - if($status == 0) { - $database->setFieldTaken($wid); - $database->addVillage($wid, $uid, 'Multihunter', '0'); - $database->addResourceFields($wid, $database->getVillageType($wid)); - $database->addUnits($wid); - $database->addTech($wid); - $database->addABTech($wid); - } - } - -$gameinstall = 0; - header("Location: ../index.php?s=5"); - -?> \ No newline at end of file diff --git a/install/include/oasis.php b/install/include/oasis.php deleted file mode 100755 index ab0a41f8..00000000 --- a/install/include/oasis.php +++ /dev/null @@ -1,15 +0,0 @@ -populateOasisdata(); - $database->populateOasis(); - $database->populateOasisUnits2(); - - header("Location: ../index.php?s=6"); - -?> \ No newline at end of file diff --git a/install/include/wdata.php b/install/include/wdata.php deleted file mode 100755 index f70b1b44..00000000 --- a/install/include/wdata.php +++ /dev/null @@ -1,116 +0,0 @@ -= $rand){ - $typ='1'; - $otype='0'; - } else if("90" >= $rand){ - $typ='2'; - $otype='0'; - } else if("400" >= $rand){ - $typ='3'; - $otype='0'; - } else if("480" >= $rand){ - $typ='4'; - $otype='0'; - } else if("560" >= $rand){ - $typ='5'; - $otype='0'; - } else if("570" >= $rand){ - $typ='6'; - $otype='0'; - } else if("600" >= $rand){ - $typ='7'; - $otype='0'; - } else if("630" >= $rand){ - $typ='8'; - $otype='0'; - } else if("660" >= $rand){ - $typ='9'; - $otype='0'; - } else if("740" >= $rand){ - $typ='10'; - $otype='0'; - } else if("820" >= $rand){ - $typ='11'; - $otype='0'; - } else if("900" >= $rand){ - $typ='12'; - $otype='0'; - } else if("908" >= $rand){ - $typ='0'; - $otype='1'; - } else if("916" >= $rand){ - $typ='0'; - $otype='2'; - } else if("924" >= $rand){ - $typ='0'; - $otype='3'; - } else if("932" >= $rand){ - $typ='0'; - $otype='4'; - } else if("940" >= $rand){ - $typ='0'; - $otype='5'; - } else if("948" >= $rand){ - $typ='0'; - $otype='6'; - } else if("956" >= $rand){ - $typ='0'; - $otype='7'; - } else if("964" >= $rand){ - $typ='0'; - $otype='8'; - } else if("972" >= $rand){ - $typ='0'; - $otype='9'; - } else if("980" >= $rand){ - $typ='0'; - $otype='10'; - } else if("988" >= $rand){ - $typ='0'; - $otype='11'; - } else { - $typ='0'; - $otype='12'; - } - } - //image pick - if($otype=='0'){ - $image="t".rand(0,9).""; - } else { - $image="o".$otype.""; - } - - //into database - $q = "INSERT into ".TB_PREFIX."wdata values (0,'".$typ."','".$otype."','".$x."','".$y."',0,'".$image."')"; - $database->query($q); - } -} - - header("Location: ../index.php?s=4"); - -?> diff --git a/install/index.php b/install/index.php deleted file mode 100755 index ecfcf437..00000000 --- a/install/index.php +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - TravianZ Installation - - - - - - - - - - - - - - - - -
- - -
- - - -
-
- -
- - - - - -
- - -
- -
- - diff --git a/install/process.php b/install/process.php deleted file mode 100755 index 88fadc35..00000000 --- a/install/process.php +++ /dev/null @@ -1,144 +0,0 @@ -constForm(); - } else - if(isset($_POST['substruc'])) { - $this->createStruc(); - } else - if(isset($_POST['subwdata'])) { - $this->createWdata(); - } else - if(isset($_POST['subacc'])) { - $this->createAcc(); - } else { - header("Location: index.php"); - } - } - - function constForm() { - $myFile = "include/constant.php"; - $fh = fopen($myFile, 'w') or die("


Can't open file: install\include\constant.php"); - $text = file_get_contents("data/constant_format.tpl"); - $text = preg_replace("'%SERVERNAME%'", $_POST['servername'], $text); - $text = preg_replace("'%SSTARTDATE%'", $_POST['start_date'], $text); - $text = preg_replace("'%SSTARTTIME%'", $_POST['start_time'], $text); - $tz = explode(",",$_POST['tzone']); - $text = preg_replace("'%STIMEZONE%'", $tz[1], $text); - $text = preg_replace("'%LANG%'", $_POST['lang'], $text); - $text = preg_replace("'%SPEED%'", $_POST['speed'], $text); - $text = preg_replace("'%INCSPEED%'", $_POST['incspeed'], $text); - $text = preg_replace("'%EVASIONSPEED%'", $_POST['evasionspeed'], $text); - $text = preg_replace("'%TRADERCAP%'", $_POST['tradercap'], $text); - $text = preg_replace("'%CRANNYCAP%'", $_POST['crannycap'], $text); - $text = preg_replace("'%TRAPPERCAP%'", $_POST['trappercap'], $text); - $text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text); - $text = preg_replace("'%UTRACK%'", $_POST['trackusers'], $text); - $text = preg_replace("'%UTOUT%'", $_POST['timeout'], $text); - $text = preg_replace("'%AUTOD%'", $_POST['autodel'], $text); - $text = preg_replace("'%AUTODT%'", $_POST['autodeltime'], $text); - $text = preg_replace("'%MAX%'", $_POST['wmax'], $text); - $text = preg_replace("'%GP%'", $_POST['gpack'], $text); - $text = preg_replace("'%SSERVER%'", $_POST['sserver'], $text); - $text = preg_replace("'%SUSER%'", $_POST['suser'], $text); - $text = preg_replace("'%SPASS%'", $_POST['spass'], $text); - $text = preg_replace("'%SDB%'", $_POST['sdb'], $text); - $text = preg_replace("'%PREFIX%'", $_POST['prefix'], $text); - $text = preg_replace("'%AEMAIL%'", $_POST['aemail'], $text); - $text = preg_replace("'%ANAME%'", $_POST['aname'], $text); - $text = preg_replace("'%SUBDOM%'", $_POST['subdom'], $text); - $text = preg_replace("'%LOGBUILD%'", $_POST['log_build'], $text); - $text = preg_replace("'%LOGTECH%'", $_POST['log_tech'], $text); - $text = preg_replace("'%LOGLOGIN%'", $_POST['log_login'], $text); - $text = preg_replace("'%LOGGOLDFIN%'", $_POST['log_gold_fin'], $text); - $text = preg_replace("'%LOGADMIN%'", $_POST['log_admin'], $text); - $text = preg_replace("'%LOGWAR%'", $_POST['log_war'], $text); - $text = preg_replace("'%LOGMARKET%'", $_POST['log_market'], $text); - $text = preg_replace("'%LOGILLEGAL%'", $_POST['log_illegal'], $text); - $text = preg_replace("'%MINUSERLENGTH%'", $_POST['userlength'], $text); - $text = preg_replace("'%MINPASSLENGTH%'", $_POST['passlength'], $text); - $text = preg_replace("'%SPECIALCHARS%'", $_POST['specialchars'], $text); - $text = preg_replace("'%ACTIVATE%'", $_POST['activate'], $text); - $text = preg_replace("'%ARANK%'", $_POST['admin_rank'], $text); - $text = preg_replace("'%QUEST%'", $_POST['quest'], $text); - $text = preg_replace("'%QTYPE%'", $_POST['qtype'], $text); - $text = preg_replace("'%BEGINNER%'", $_POST['beginner'], $text); - $text = preg_replace("'%STARTTIME%'", time(), $text); - $text = preg_replace("'%DOMAIN%'", $_POST['domain'], $text); - $text = preg_replace("'%HOMEPAGE%'", $_POST['homepage'], $text); - $text = preg_replace("'%SERVER%'", $_POST['server'], $text); - $text = preg_replace("'%LIMIT_MAILBOX%'", $_POST['limit_mailbox'], $text); - $text = preg_replace("'%MAX_MAILS%'", $_POST['max_mails'], $text); - $text = preg_replace("'%DEMOLISH%'", $_POST['demolish'], $text); - $text = preg_replace("'%BOX1%'", $_POST['box1'], $text); - $text = preg_replace("'%BOX2%'", $_POST['box2'], $text); - $text = preg_replace("'%BOX3%'", $_POST['box3'], $text); - $text = preg_replace("'%VILLAGE_EXPAND%'", $_POST['village_expand'], $text); - $text = preg_replace("'%ERRORREPORT%'", $_POST['error'], $text); - $text = preg_replace("'%ERROR%'", $_POST['error'], $text); - $text = preg_replace("'%GP_LOCATE%'", $_POST['gp_locate'], $text); - $text = preg_replace("'%PLUS_TIME%'", $_POST['plus_time'], $text); - $text = preg_replace("'%PLUS_PRODUCTION%'", $_POST['plus_production'], $text); - $text = preg_replace("'%MEDALINTERVAL%'", $_POST['medalinterval'], $text); - $text = preg_replace("'%GREAT_WKS%'", $_POST['great_wks'], $text); - $text = preg_replace("'%TS_THRESHOLD%'", $_POST['ts_threshold'], $text); - $text = preg_replace("'%WW%'", $_POST['ww'], $text); - $text = preg_replace("'%SHOW_NATARS%'", $_POST['show_natars'], $text); - $text = preg_replace("'%NATARS_UNITS%'", $_POST['natars_units'], $text); - $text = preg_replace("'%NATURE_REGTIME%'", $_POST['nature_regtime'], $text); - $text = preg_replace("'%T4_COMING%'", $_POST['t4_coming'], $text); - $text = preg_replace("'%REG_OPEN%'", $_POST['reg_open'], $text); - $text = preg_replace("'%PEACE%'", $_POST['peace'], $text); - - fwrite($fh, $text); - - if(file_exists("include/constant.php")) { - header("Location: index.php?s=2"); - } else { - header("Location: index.php?s=1&c=1"); - } - - fclose($fh); - } - - function createStruc() { - global $database; - $str = file_get_contents("data/sql.sql"); - $str = preg_replace("'%PREFIX%'", TB_PREFIX, $str); - if(DB_TYPE) { - $result = $database->connection->multi_query($str); - } else { - $result = $database->mysql_exec_batch($str); - } - if($result) { - header("Location: index.php?s=3"); - } else { - header("Location: index.php?s=2&c=1"); - } - } - - function createWdata() { - header("Location: include/wdata.php"); - } - -} -; - -$process = new Process; - -?> diff --git a/install/templates/.htaccess b/install/templates/.htaccess deleted file mode 100755 index 85b65c30..00000000 --- a/install/templates/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - -Order allow,deny -Deny from all - \ No newline at end of file diff --git a/install/templates/config.tpl b/install/templates/config.tpl deleted file mode 100755 index 0a6b0ab1..00000000 --- a/install/templates/config.tpl +++ /dev/null @@ -1,343 +0,0 @@ -Error creating constant.php check cmod.

"; -} -?> - -
- -

- SERVER RELATED - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Server name:
Server Timezone: - -
Server speed:
Troop speed:
Evasion speed:
Trader capacity (1 = 1x...):
Cranny capacity:
Trapper capacity:
Natars Units Multiplier:
World size: - -
Register Open: - -
Server:
Domain:
Homepage:
Language: - -
Beginners protection length: - -
Plus account length: - -
+25% production length: - -
Nature troops regeneration time: - -
Medal Interval: - -
Storage Multipler:
Tourn Threshold:
Great Workshop: - -
ww: - -
Show Natars in Statistics: - -
Peace system: - -
-

- -

- ADMIN ACCOUNT - - - - - -
Admin name:
Admin email:
Show admin in stats: - -
-

- -

- SQL RELATED - - - - - - - -
Hostname:
Username:
Password:
DB name:
Prefix:
Type:MYSQLi (MYSQL is deprecated)
-

- - - - - - - -

- NEWSBOX OPTIONS - - - - -
Newsbox 1:
Newsbox 2:
Newsbox 3:
-

- -

- LOG RELATED (You should disable them) - - - - - - - - - - - -
Log Building:
Log Tech:
Log Login:
Log Gold:
Log Admin:
Log War:
Log Market:
Log Illegal:
Log :
-

- -

- EXTRA OPTIONS - - - - - - - - - - - -
Quest:
Quest Type:
Activate:
Limit Mailbox: (NOT DONE)
Max mails: (NOT DONE)
Demolish - lvl required:
Village Expand:
Error Reporting:
T4 is Coming screen:
-

-
- Server Start Settings - - - -
Start Date:
Start Time:
- -
- -
-
- - diff --git a/install/templates/dataform.tpl b/install/templates/dataform.tpl deleted file mode 100755 index 76ec6380..00000000 --- a/install/templates/dataform.tpl +++ /dev/null @@ -1,33 +0,0 @@ -Error importing database. Check configuration.
"; -} -?> -
- - -

- Create SQL Structure - - - -
Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..
-

-
- diff --git a/install/templates/end.tpl b/install/templates/end.tpl deleted file mode 100755 index 9c087704..00000000 --- a/install/templates/end.tpl +++ /dev/null @@ -1,43 +0,0 @@ - -

-Thanks for installing TravianZ. -

Please remove/rename the installation folder.

-All the files are placed. The database is created, so you can now start playing on your own Travian. -

- - -

-

> My TravianZ homepage <
-

-
-
-

Please support our developers and donate.

-
-
- - - - -
-
- diff --git a/install/templates/field.tpl b/install/templates/field.tpl deleted file mode 100755 index 812b2000..00000000 --- a/install/templates/field.tpl +++ /dev/null @@ -1,33 +0,0 @@ -Error creating wdata. Check configuration or file.
"; -} -?> -
- - -

- Create World Data - - - -
Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..
-

-
- diff --git a/install/templates/greet.tpl b/install/templates/greet.tpl deleted file mode 100755 index b8d36ebb..00000000 --- a/install/templates/greet.tpl +++ /dev/null @@ -1,50 +0,0 @@ - -
- -

  Disclaimer

- -
    -
  • Along with the installation/usage of this game, you shall be fully responsible for any legal results that may raised initiated by the owners of any unlicensed content you permit your copy of this game to publish.
  • - -
  • Neither the team that created this script nor the team that customised it to create this distribution/release shall be responsible for any damage done to your computer/server system.
  • - -
  • All code was confirmed to be running correctly by the creation team without any visible security risk they were aware of at the time the released it. Similarly for the customisation team who customised it to create this distribution/release.
  • - -
  • Users are asked to review the code on their own accord and behalf.
  • - -
  • Any customization to the source code are the property of each customisation's author, it is up to each author's discretion whether to share it by including it in free open source distributions such as this one.
  • - -
  • You have no rights to edit copyright notices or/and claim this script as your own.
  • - -
  • Last but not least, Enjoy.
  • -
- -
-
    -
  • Before Installation (Linux):

  • -
  • CHMOD install to 777 (chmod -R 777 install)
  • -
  • CHMOD GameEngine to 777 (chmod -R 777 GameEngine)
  • -
  • After Installation

  • -
  • Delete install folder (sudo rm -R install)
  • -
  • CHMOD GameEngine back to 755 (sudo chmod -R 755 GameEngine)
  • -
  • CHMOD Prevention to 777 (sudo chmod -R 777 GameEngine/Prevention)
  • -
  • CHMOD Notes to 777 (sudo chmod -R 777 GameEngine/Notes)
  • -
- -
    -
  • After Installation

  • -
  • Protect folder /Admin with password protect directory
  • -
- -
- TravianZ Team -
-
- -
-
- -
-
- - diff --git a/install/templates/menu.tpl b/install/templates/menu.tpl deleted file mode 100755 index cc2bf27e..00000000 --- a/install/templates/menu.tpl +++ /dev/null @@ -1,44 +0,0 @@ - diff --git a/install/templates/multihunter.tpl b/install/templates/multihunter.tpl deleted file mode 100755 index 59e8a44b..00000000 --- a/install/templates/multihunter.tpl +++ /dev/null @@ -1,37 +0,0 @@ - - - - -
- -

- Create Multihunter account - - - - -
Name:
Password:
Note: Rember this password! You need it for the ACP
-

- -
-
-
- - diff --git a/install/templates/oasis.tpl b/install/templates/oasis.tpl deleted file mode 100755 index 85d8f52e..00000000 --- a/install/templates/oasis.tpl +++ /dev/null @@ -1,19 +0,0 @@ - -
-

- Populate Oasis - - - -
Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..
-

-
- diff --git a/install/templates/script.tpl b/install/templates/script.tpl deleted file mode 100755 index 26c9141f..00000000 --- a/install/templates/script.tpl +++ /dev/null @@ -1,145 +0,0 @@ - - -bar_id = uniqid('progressbar'); - $this->label = $label; - - $this->max_ticks = $max_ticks; - $this->ticks = 0; - } - - public function tick() { - $this->ticks++; - $this->draw_progress(); - } - - public function draw() { - $this->draw_bar(); - $this->draw_progress(); - } - - static public function draw_css() { - echo ' - - '; - } - - protected function draw_bar() { - echo ' -
- -
- -
-
- '; - echo ' - - '; - - $this->flush(); - } - - protected function draw_progress() { - - $width = round($this->ticks / $this->max_ticks * 100, 2); - $label = sprintf($this->label, $this->ticks, $this->max_ticks); - - echo ' - - - '; - $this->flush(); - } - - protected function flush() { - while(ob_get_level() > 0) { - ob_end_flush(); - } - - flush(); - } -} -?> \ No newline at end of file diff --git a/karte.php b/karte.php index 424aaab2..77cdfb9a 100644 --- a/karte.php +++ b/karte.php @@ -32,7 +32,7 @@ else{ <?php echo SERVER_NAME ?> - + @@ -82,7 +82,7 @@ else { include("Templates/Map/mapview.tpl"); } ?> -



+



plus){ <?php echo SERVER_NAME ?> - + diff --git a/login.php b/login.php index 466d7d68..8002be45 100644 --- a/login.php +++ b/login.php @@ -33,7 +33,7 @@ $_SESSION[ 'csrf' ] = $key; <?php echo SERVER_NAME; ?> - + @@ -76,7 +76,7 @@ else $stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME); if($stime > time()){ ?> -
Server will start in:
+
Server will start in:
- gpack == null || GP_ENABLE == false) { echo " @@ -151,7 +150,7 @@ if (isset($_GET['send']) && isset($_GET['from'])) -



+



<?php echo SERVER_NAME ?> - + @@ -187,13 +187,13 @@ $q = "
- +
- +

Dear Players,

@@ -222,9 +222,9 @@ $q = " (By: Shadow v7.0.0)



-
» Continue
+
-



+



Date: Mon, 28 Aug 2017 17:37:08 +0200 Subject: [PATCH 44/73] chore: restoring installation folder --- install/data/.htaccess | 4 + install/data/constant_format.tpl | 296 ++++++ install/data/sql.sql | 1618 +++++++++++++++++++++++++++++ install/include/database.php | 55 + install/include/multihunter.php | 31 + install/include/oasis.php | 23 + install/include/wdata.php | 116 +++ install/index.php | 130 +++ install/process.php | 145 +++ install/templates/.htaccess | 4 + install/templates/config.tpl | 345 ++++++ install/templates/dataform.tpl | 33 + install/templates/end.tpl | 43 + install/templates/field.tpl | 33 + install/templates/greet.tpl | 50 + install/templates/menu.tpl | 44 + install/templates/multihunter.tpl | 37 + install/templates/oasis.tpl | 19 + install/templates/script.tpl | 145 +++ 19 files changed, 3171 insertions(+) create mode 100644 install/data/.htaccess create mode 100644 install/data/constant_format.tpl create mode 100644 install/data/sql.sql create mode 100644 install/include/database.php create mode 100644 install/include/multihunter.php create mode 100644 install/include/oasis.php create mode 100644 install/include/wdata.php create mode 100644 install/index.php create mode 100644 install/process.php create mode 100644 install/templates/.htaccess create mode 100644 install/templates/config.tpl create mode 100644 install/templates/dataform.tpl create mode 100644 install/templates/end.tpl create mode 100644 install/templates/field.tpl create mode 100644 install/templates/greet.tpl create mode 100644 install/templates/menu.tpl create mode 100644 install/templates/multihunter.tpl create mode 100644 install/templates/oasis.tpl create mode 100644 install/templates/script.tpl diff --git a/install/data/.htaccess b/install/data/.htaccess new file mode 100644 index 00000000..85b65c30 --- /dev/null +++ b/install/data/.htaccess @@ -0,0 +1,4 @@ + +Order allow,deny +Deny from all + \ No newline at end of file diff --git a/install/data/constant_format.tpl b/install/data/constant_format.tpl new file mode 100644 index 00000000..942588b7 --- /dev/null +++ b/install/data/constant_format.tpl @@ -0,0 +1,296 @@ + diff --git a/install/data/sql.sql b/install/data/sql.sql new file mode 100644 index 00000000..fe43c664 --- /dev/null +++ b/install/data/sql.sql @@ -0,0 +1,1618 @@ +-- phpMyAdmin SQL Dump +-- version 3.3.9 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Jul 21, 2011 at 02:49 AM +-- Server version: 5.5.8 +-- PHP Version: 5.3.5 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%a2b` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%a2b` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` varchar(255) NULL, + `time_check` int(11) NULL DEFAULT '0', + `to_vid` int(11) NULL, + `u1` int(11) NULL, + `u2` int(11) NULL, + `u3` int(11) NULL, + `u4` int(11) NULL, + `u5` int(11) NULL, + `u6` int(11) NULL, + `u7` int(11) NULL, + `u8` int(11) NULL, + `u9` int(11) NULL, + `u10` int(11) NULL, + `u11` int(11) NULL, + `type` smallint(1) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%a2b` +-- + +-- +-- Table structure for table `%PREFIX%links` +-- + +CREATE TABLE `%PREFIX%links` ( + `id` INT( 25 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , + `userid` INT( 25 ) NULL , + `name` VARCHAR( 50 ) NULL , + `url` VARCHAR( 150 ) NULL , + `pos` INT( 10 ) NULL +) ENGINE = InnoDB; + +-- +-- Dumping data for table `%PREFIX%links` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%abdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%abdata` ( + `vref` int(11) NOT NULL, + `a1` tinyint(2) NULL DEFAULT '0', + `a2` tinyint(2) NULL DEFAULT '0', + `a3` tinyint(2) NULL DEFAULT '0', + `a4` tinyint(2) NULL DEFAULT '0', + `a5` tinyint(2) NULL DEFAULT '0', + `a6` tinyint(2) NULL DEFAULT '0', + `a7` tinyint(2) NULL DEFAULT '0', + `a8` tinyint(2) NULL DEFAULT '0', + `b1` tinyint(2) NULL DEFAULT '0', + `b2` tinyint(2) NULL DEFAULT '0', + `b3` tinyint(2) NULL DEFAULT '0', + `b4` tinyint(2) NULL DEFAULT '0', + `b5` tinyint(2) NULL DEFAULT '0', + `b6` tinyint(2) NULL DEFAULT '0', + `b7` tinyint(2) NULL DEFAULT '0', + `b8` tinyint(2) NULL DEFAULT '0', + PRIMARY KEY (`vref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%abdata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%activate` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%activate` ( + `id` int(255) NOT NULL AUTO_INCREMENT, + `username` varchar(100) NULL, + `password` varchar(100) NULL, + `email` text NULL, + `tribe` tinyint(1) NULL, + `access` tinyint(1) NULL DEFAULT '1', + `act` varchar(10) NULL, + `timestamp` int(11) NULL DEFAULT '0', + `location` text NULL, + `act2` varchar(10) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%activate` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%active` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%active` ( + `username` varchar(100) NOT NULL, + `timestamp` int(11) NULL, + PRIMARY KEY (`username`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%PREFIX%active` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%admin_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%admin_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user` text NULL, + `log` text NULL, + `time` int(25) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=80 ; + +-- +-- Dumping data for table `%PREFIX%admin_log` +-- + + +-- -------------------------------------------------------- +-- +-- Table structure for table `%PREFIX%allimedal` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%allimedal` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `allyid` int(11) NULL, + `categorie` int(11) NULL, + `plaats` int(11) NULL, + `week` int(11) NULL, + `points` bigint(255) NULL, + `img` varchar(255) NULL, + `del` tinyint(1) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%artefacts` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%artefacts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vref` int(11) NULL, + `owner` int(11) NULL, + `type` tinyint(2) NULL, + `size` tinyint(1) NULL, + `conquered` int(11) NULL, + `name` varchar(100) NULL, + `desc` text NULL, + `effect` varchar(100) NULL, + `img` varchar(20) NULL, + `active` tinyint(1) NULL, + `kind` tinyint(1) NULL DEFAULT '0', + `bad_effect` tinyint(1) NULL DEFAULT '0', + `effect2` tinyint(2) NULL DEFAULT '0', + `lastupdate` int(11) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Table structure for table `s1_artefacts` +-- +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%alidata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%alidata` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NULL, + `tag` varchar(100) NULL, + `leader` int(11) NULL, + `coor` int(11) NULL, + `advisor` int(11) NULL, + `recruiter` int(11) NULL, + `notice` text NULL, + `desc` text NULL, + `max` tinyint(2) NULL, + `ap` bigint(255) NULL DEFAULT '0', + `dp` bigint(255) NULL DEFAULT '0', + `Rc` bigint(255) NULL DEFAULT '0', + `RR` bigint(255) NULL DEFAULT '0', + `Aap` bigint(255) NULL DEFAULT '0', + `Adp` bigint(255) NULL DEFAULT '0', + `clp` bigint(255) NULL DEFAULT '0', + `oldrank` bigint(255) NULL DEFAULT '0', + `forumlink` varchar(150) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%alidata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%ali_invite` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%ali_invite` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `alliance` int(11) NULL, + `sender` int(11) NULL, + `timestamp` int(11) NULL, + `accept` int(1) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%ali_invite` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%ali_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%ali_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `aid` int(11) NULL, + `comment` text NULL, + `date` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%ali_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%ali_permission` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%ali_permission` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `alliance` int(11) NULL, + `rank` varchar(100) NULL, + `opt1` int(1) NULL DEFAULT '0', + `opt2` int(1) NULL DEFAULT '0', + `opt3` int(1) NULL DEFAULT '0', + `opt4` int(1) NULL DEFAULT '0', + `opt5` int(1) NULL DEFAULT '0', + `opt6` int(1) NULL DEFAULT '0', + `opt7` int(1) NULL DEFAULT '0', + `opt8` int(1) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%ali_permission` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%attacks` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%attacks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vref` int(11) NULL, + `t1` int(11) NULL, + `t2` int(11) NULL, + `t3` int(11) NULL, + `t4` int(11) NULL, + `t5` int(11) NULL, + `t6` int(11) NULL, + `t7` int(11) NULL, + `t8` int(11) NULL, + `t9` int(11) NULL, + `t10` int(11) NULL, + `t11` int(11) NULL, + `attack_type` tinyint(1) NULL, + `ctar1` int(11) NULL, + `ctar2` int(11) NULL, + `spy` int(11) NULL, + `b1` tinyint(1) NULL, + `b2` tinyint(1) NULL, + `b3` tinyint(1) NULL, + `b4` tinyint(1) NULL, + `b5` tinyint(1) NULL, + `b6` tinyint(1) NULL, + `b7` tinyint(1) NULL, + `b8` tinyint(1) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%attacks` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%banlist` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%banlist` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `name` varchar(100) NULL, + `reason` varchar(30) NULL, + `time` int(11) NULL, + `end` varchar(10) NULL, + `admin` int(11) NULL, + `active` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%banlist` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%bdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%bdata` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wid` int(11) NULL, + `field` tinyint(2) NULL, + `type` tinyint(2) NULL, + `loopcon` tinyint(1) NULL, + `timestamp` int(11) NULL, + `master` tinyint(1) NULL, + `level` tinyint(3) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%bdata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%build_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%build_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wid` int(11) NULL, + `log` text NULL, + `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%build_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%chat` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%chat` ( + `id` int(20) NOT NULL AUTO_INCREMENT, + `id_user` int(11) NULL, + `name` varchar(255) NULL, + `alli` varchar(255) NULL, + `date` varchar(255) NULL, + `msg` varchar(255) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%chat` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%config` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%config` ( + `lastgavemedal` int(11) NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +INSERT INTO `%PREFIX%config` VALUES (0); + +-- +-- Dumping data for table `%prefix%config` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%deleting` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%deleting` ( + `uid` int(11) NOT NULL, + `timestamp` int(11) NULL, + PRIMARY KEY (`uid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%prefix%deleting` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%demolition` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%demolition` ( + `vref` int(11) NOT NULL, + `buildnumber` int(11) NULL DEFAULT '0', + `lvl` int(11) NULL DEFAULT '0', + `timetofinish` int(11) NULL, + PRIMARY KEY (`vref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%demolition` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%diplomacy` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%diplomacy` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `alli1` int(11) NULL, + `alli2` int(11) NULL, + `type` tinyint(1) NULL, + `accepted` tinyint(1) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +-- +-- Dumping data for table `%prefix%diplomacy` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%enforcement` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%enforcement` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `u1` int(11) NULL DEFAULT '0', + `u2` int(11) NULL DEFAULT '0', + `u3` int(11) NULL DEFAULT '0', + `u4` int(11) NULL DEFAULT '0', + `u5` int(11) NULL DEFAULT '0', + `u6` int(11) NULL DEFAULT '0', + `u7` int(11) NULL DEFAULT '0', + `u8` int(11) NULL DEFAULT '0', + `u9` int(11) NULL DEFAULT '0', + `u10` int(11) NULL DEFAULT '0', + `u11` int(11) NULL DEFAULT '0', + `u12` int(11) NULL DEFAULT '0', + `u13` int(11) NULL DEFAULT '0', + `u14` int(11) NULL DEFAULT '0', + `u15` int(11) NULL DEFAULT '0', + `u16` int(11) NULL DEFAULT '0', + `u17` int(11) NULL DEFAULT '0', + `u18` int(11) NULL DEFAULT '0', + `u19` int(11) NULL DEFAULT '0', + `u20` int(11) NULL DEFAULT '0', + `u21` int(11) NULL DEFAULT '0', + `u22` int(11) NULL DEFAULT '0', + `u23` int(11) NULL DEFAULT '0', + `u24` int(11) NULL DEFAULT '0', + `u25` int(11) NULL DEFAULT '0', + `u26` int(11) NULL DEFAULT '0', + `u27` int(11) NULL DEFAULT '0', + `u28` int(11) NULL DEFAULT '0', + `u29` int(11) NULL DEFAULT '0', + `u30` int(11) NULL DEFAULT '0', + `u31` int(11) NULL DEFAULT '0', + `u32` int(11) NULL DEFAULT '0', + `u33` int(11) NULL DEFAULT '0', + `u34` int(11) NULL DEFAULT '0', + `u35` int(11) NULL DEFAULT '0', + `u36` int(11) NULL DEFAULT '0', + `u37` int(11) NULL DEFAULT '0', + `u38` int(11) NULL DEFAULT '0', + `u39` int(11) NULL DEFAULT '0', + `u40` int(11) NULL DEFAULT '0', + `u41` int(11) NULL DEFAULT '0', + `u42` int(11) NULL DEFAULT '0', + `u43` int(11) NULL DEFAULT '0', + `u44` int(11) NULL DEFAULT '0', + `u45` int(11) NULL DEFAULT '0', + `u46` int(11) NULL DEFAULT '0', + `u47` int(11) NULL DEFAULT '0', + `u48` int(11) NULL DEFAULT '0', + `u49` int(11) NULL DEFAULT '0', + `u50` int(11) NULL DEFAULT '0', + `hero` tinyint(1) NULL DEFAULT '0', + `from` int(11) NULL DEFAULT '0', + `vref` int(11) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%enforcement` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%farmlist` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%farmlist` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wref` int(11) NULL, + `owner` int(11) NULL, + `name` varchar(100) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%farmlist` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%fdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%fdata` ( + `vref` int(11) NOT NULL, + `f1` tinyint(2) NULL DEFAULT '0', + `f1t` tinyint(2) NULL DEFAULT '0', + `f2` tinyint(2) NULL DEFAULT '0', + `f2t` tinyint(2) NULL DEFAULT '0', + `f3` tinyint(2) NULL DEFAULT '0', + `f3t` tinyint(2) NULL DEFAULT '0', + `f4` tinyint(2) NULL DEFAULT '0', + `f4t` tinyint(2) NULL DEFAULT '0', + `f5` tinyint(2) NULL DEFAULT '0', + `f5t` tinyint(2) NULL DEFAULT '0', + `f6` tinyint(2) NULL DEFAULT '0', + `f6t` tinyint(2) NULL DEFAULT '0', + `f7` tinyint(2) NULL DEFAULT '0', + `f7t` tinyint(2) NULL DEFAULT '0', + `f8` tinyint(2) NULL DEFAULT '0', + `f8t` tinyint(2) NULL DEFAULT '0', + `f9` tinyint(2) NULL DEFAULT '0', + `f9t` tinyint(2) NULL DEFAULT '0', + `f10` tinyint(2) NULL DEFAULT '0', + `f10t` tinyint(2) NULL DEFAULT '0', + `f11` tinyint(2) NULL DEFAULT '0', + `f11t` tinyint(2) NULL DEFAULT '0', + `f12` tinyint(2) NULL DEFAULT '0', + `f12t` tinyint(2) NULL DEFAULT '0', + `f13` tinyint(2) NULL DEFAULT '0', + `f13t` tinyint(2) NULL DEFAULT '0', + `f14` tinyint(2) NULL DEFAULT '0', + `f14t` tinyint(2) NULL DEFAULT '0', + `f15` tinyint(2) NULL DEFAULT '0', + `f15t` tinyint(2) NULL DEFAULT '0', + `f16` tinyint(2) NULL DEFAULT '0', + `f16t` tinyint(2) NULL DEFAULT '0', + `f17` tinyint(2) NULL DEFAULT '0', + `f17t` tinyint(2) NULL DEFAULT '0', + `f18` tinyint(2) NULL DEFAULT '0', + `f18t` tinyint(2) NULL DEFAULT '0', + `f19` tinyint(2) NULL DEFAULT '0', + `f19t` tinyint(2) NULL DEFAULT '0', + `f20` tinyint(2) NULL DEFAULT '0', + `f20t` tinyint(2) NULL DEFAULT '0', + `f21` tinyint(2) NULL DEFAULT '0', + `f21t` tinyint(2) NULL DEFAULT '0', + `f22` tinyint(2) NULL DEFAULT '0', + `f22t` tinyint(2) NULL DEFAULT '0', + `f23` tinyint(2) NULL DEFAULT '0', + `f23t` tinyint(2) NULL DEFAULT '0', + `f24` tinyint(2) NULL DEFAULT '0', + `f24t` tinyint(2) NULL DEFAULT '0', + `f25` tinyint(2) NULL DEFAULT '0', + `f25t` tinyint(2) NULL DEFAULT '0', + `f26` tinyint(2) NULL DEFAULT '0', + `f26t` tinyint(2) NULL DEFAULT '0', + `f27` tinyint(2) NULL DEFAULT '0', + `f27t` tinyint(2) NULL DEFAULT '0', + `f28` tinyint(2) NULL DEFAULT '0', + `f28t` tinyint(2) NULL DEFAULT '0', + `f29` tinyint(2) NULL DEFAULT '0', + `f29t` tinyint(2) NULL DEFAULT '0', + `f30` tinyint(2) NULL DEFAULT '0', + `f30t` tinyint(2) NULL DEFAULT '0', + `f31` tinyint(2) NULL DEFAULT '0', + `f31t` tinyint(2) NULL DEFAULT '0', + `f32` tinyint(2) NULL DEFAULT '0', + `f32t` tinyint(2) NULL DEFAULT '0', + `f33` tinyint(2) NULL DEFAULT '0', + `f33t` tinyint(2) NULL DEFAULT '0', + `f34` tinyint(2) NULL DEFAULT '0', + `f34t` tinyint(2) NULL DEFAULT '0', + `f35` tinyint(2) NULL DEFAULT '0', + `f35t` tinyint(2) NULL DEFAULT '0', + `f36` tinyint(2) NULL DEFAULT '0', + `f36t` tinyint(2) NULL DEFAULT '0', + `f37` tinyint(2) NULL DEFAULT '0', + `f37t` tinyint(2) NULL DEFAULT '0', + `f38` tinyint(2) NULL DEFAULT '0', + `f38t` tinyint(2) NULL DEFAULT '0', + `f39` tinyint(2) NULL DEFAULT '0', + `f39t` tinyint(2) NULL DEFAULT '0', + `f40` tinyint(2) NULL DEFAULT '0', + `f40t` tinyint(2) NULL DEFAULT '0', + `f99` tinyint(2) NULL DEFAULT '0', + `f99t` tinyint(2) NULL DEFAULT '0', + `wwname` varchar(100) NULL DEFAULT 'World Wonder', + PRIMARY KEY (`vref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%prefix%fdata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%forum_cat` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%forum_cat` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `owner` varchar(255) NULL, + `alliance` varchar(255) NULL, + `forum_name` varchar(255) NULL, + `forum_des` text NULL, + `forum_area` varchar(255) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%forum_cat` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%forum_edit` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%forum_edit` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `alliance` varchar(255) NULL, + `result` varchar(255) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%forum_edit` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%forum_post` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%forum_post` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `post` longtext NULL, + `topic` varchar(255) NULL, + `owner` varchar(255) NULL, + `date` varchar(255) NULL, + `alliance0` int(11) NULL, + `player0` int(11) NULL, + `coor0` int(11) NULL, + `report0` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%forum_post` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%forum_survey` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%forum_survey` ( + `topic` int(11) NULL, + `title` varchar(255) NULL, + `option1` varchar(255) NULL, + `option2` varchar(255) NULL, + `option3` varchar(255) NULL, + `option4` varchar(255) NULL, + `option5` varchar(255) NULL, + `option6` varchar(255) NULL, + `option7` varchar(255) NULL, + `option8` varchar(255) NULL, + `vote1` int(11) NULL DEFAULT '0', + `vote2` int(11) NULL DEFAULT '0', + `vote3` int(11) NULL DEFAULT '0', + `vote4` int(11) NULL DEFAULT '0', + `vote5` int(11) NULL DEFAULT '0', + `vote6` int(11) NULL DEFAULT '0', + `vote7` int(11) NULL DEFAULT '0', + `vote8` int(11) NULL DEFAULT '0', + `voted` text NULL, + `ends` int(11) NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%forum_survey` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%forum_topic` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%forum_topic` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(255) NULL, + `post` longtext NULL, + `date` varchar(255) NULL, + `post_date` varchar(255) NULL, + `cat` varchar(255) NULL, + `owner` varchar(255) NULL, + `alliance` varchar(255) NULL, + `ends` varchar(255) NULL, + `close` varchar(255) NULL, + `stick` varchar(255) NULL, + `alliance0` int(11) NULL, + `player0` int(11) NULL, + `coor0` int(11) NULL, + `report0` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%forum_topic` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%general` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%general` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `casualties` int(11) NULL, + `time` int(11) NULL, + `shown` tinyint(1) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%general` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%gold_fin_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%gold_fin_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wid` int(11) NULL, + `log` text NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%gold_fin_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%hero` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%hero` ( + `heroid` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `unit` smallint(2) NULL, + `name` tinytext NULL, + `wref` int(11) NULL, + `level` tinyint(3) NULL, + `points` int(3) NULL, + `experience` int(11) NULL, + `dead` tinyint(1) NULL, + `health` float(12,9) NULL, + `attack` tinyint(3) NULL, + `defence` tinyint(3) NULL, + `attackbonus` tinyint(3) NULL, + `defencebonus` tinyint(3) NULL, + `regeneration` tinyint(3) NULL, + `autoregen` int(2) NULL, + `lastupdate` int(11) NULL, + `trainingtime` int(11) NULL, + `inrevive` tinyint(1) NULL, + `intraining` tinyint(1) NULL, + PRIMARY KEY (`heroid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; + +-- +-- Dumping data for table `%prefix%hero` +-- + + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%illegal_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%illegal_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user` int(11) NULL, + `log` text NULL, + `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%illegal_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%login_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%login_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `ip` varchar(15) NULL, + `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%login_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%market` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%market` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vref` int(11) NULL, + `gtype` tinyint(1) NULL, + `gamt` int(11) NULL, + `wtype` tinyint(1) NULL, + `wamt` int(11) NULL, + `accept` tinyint(1) NULL, + `maxtime` int(11) NULL, + `alliance` int(11) NULL, + `merchant` tinyint(2) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%market` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%market_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%market_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wid` int(11) NULL, + `log` text NULL, + `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%market_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%mdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%mdata` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `target` int(11) NULL, + `owner` int(11) NULL, + `topic` varchar(100) NULL, + `message` text NULL, + `viewed` tinyint(1) NULL, + `archived` tinyint(1) NULL, + `send` tinyint(1) NULL, + `time` int(11) NULL DEFAULT '0', + `deltarget` int(11) NULL, + `delowner` int(11) NULL, + `alliance` int(11) NULL, + `player` int(11) NULL, + `coor` int(11) NULL, + `report` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%mdata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%medal` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%medal` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) NULL, + `categorie` int(11) NULL, + `plaats` int(11) NULL, + `week` int(11) NULL, + `points` varchar(15) NULL, + `img` varchar(10) NULL, + `del` tinyint(1) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%medal` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%movement` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%movement` ( + `moveid` int(11) NOT NULL AUTO_INCREMENT, + `sort_type` tinyint(4) NULL DEFAULT '0', + `from` int(11) NULL DEFAULT '0', + `to` int(11) NULL DEFAULT '0', + `ref` int(11) NULL DEFAULT '0', + `ref2` int(11) NULL DEFAULT '0', + `starttime` int(11) NULL DEFAULT '0', + `endtime` int(11) NULL DEFAULT '0', + `proc` tinyint(1) NULL DEFAULT '0', + `send` tinyint(1) NULL, + `wood` int(11) NULL, + `clay` int(11) NULL, + `iron` int(11) NULL, + `crop` int(11) NULL, + PRIMARY KEY (`moveid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%movement` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%ndata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%ndata` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `toWref` int(11) NULL, + `ally` int(11) NULL, + `topic` text NULL, + `ntype` tinyint(1) NULL, + `data` text NULL, + `time` int(11) NULL, + `viewed` tinyint(1) NULL, + `archive` tinyint(1) NULL DEFAULT '0', + `del` tinyint(1) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%ndata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%odata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%odata` ( + `wref` int(11) NOT NULL, + `type` tinyint(2) NULL, + `conqured` int(11) NULL, + `wood` int(11) NULL, + `iron` int(11) NULL, + `clay` int(11) NULL, + `maxstore` int(11) NULL, + `crop` int(11) NULL, + `maxcrop` int(11) NULL, + `lastupdated` int(11) NULL, + `lastupdated2` int(11) NULL, + `loyalty` float(9,6) NULL DEFAULT '100', + `owner` int(11) NULL DEFAULT '2', + `name` varchar(32) NULL DEFAULT 'Unoccupied Oasis', + `high` tinyint(1) NULL, + PRIMARY KEY (`wref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%prefix%odata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%online` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%online` ( + `name` varchar(32) NULL, + `uid` int(11) NULL, + `time` varchar(32) NULL, + `sit` tinyint(1) NULL, + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%prefix%online` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%prisoners` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%prisoners` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wref` int(11) NULL, + `from` int(11) NULL, + `t1` int(11) NULL, + `t2` int(11) NULL, + `t3` int(11) NULL, + `t4` int(11) NULL, + `t5` int(11) NULL, + `t6` int(11) NULL, + `t7` int(11) NULL, + `t8` int(11) NULL, + `t9` int(11) NULL, + `t10` int(11) NULL, + `t11` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%PREFIX%prisoners` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%raidlist` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%raidlist` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `lid` int(11) NULL, + `towref` int(11) NULL, + `x` int(11) NULL, + `y` int(11) NULL, + `distance` varchar(5) NULL DEFAULT '0', + `t1` int(11) NULL, + `t2` int(11) NULL, + `t3` int(11) NULL, + `t4` int(11) NULL, + `t5` int(11) NULL, + `t6` int(11) NULL, + `t7` int(11) NULL, + `t8` int(11) NULL, + `t9` int(11) NULL, + `t10` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%raidlist` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%research` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%research` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vref` int(11) NULL, + `tech` varchar(3) NULL, + `timestamp` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%research` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%route` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%route` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NULL, + `wid` int(11) NULL, + `from` int(11) NULL, + `wood` int(5) NULL, + `clay` int(5) NULL, + `iron` int(5) NULL, + `crop` int(5) NULL, + `start` tinyint(2) NULL, + `deliveries` tinyint(1) NULL, + `merchant` int(11) NULL, + `timestamp` int(11) NULL, + `timeleft` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%route` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%send` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%send` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wood` int(11) NULL, + `clay` int(11) NULL, + `iron` int(11) NULL, + `crop` int(11) NULL, + `merchant` tinyint(2) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%send` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%tdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%tdata` ( + `vref` int(11) NOT NULL, + `t2` tinyint(1) NULL DEFAULT '0', + `t3` tinyint(1) NULL DEFAULT '0', + `t4` tinyint(1) NULL DEFAULT '0', + `t5` tinyint(1) NULL DEFAULT '0', + `t6` tinyint(1) NULL DEFAULT '0', + `t7` tinyint(1) NULL DEFAULT '0', + `t8` tinyint(1) NULL DEFAULT '0', + `t9` tinyint(1) NULL DEFAULT '0', + `t12` tinyint(1) NULL DEFAULT '0', + `t13` tinyint(1) NULL DEFAULT '0', + `t14` tinyint(1) NULL DEFAULT '0', + `t15` tinyint(1) NULL DEFAULT '0', + `t16` tinyint(1) NULL DEFAULT '0', + `t17` tinyint(1) NULL DEFAULT '0', + `t18` tinyint(1) NULL DEFAULT '0', + `t19` tinyint(1) NULL DEFAULT '0', + `t22` tinyint(1) NULL DEFAULT '0', + `t23` tinyint(1) NULL DEFAULT '0', + `t24` tinyint(1) NULL DEFAULT '0', + `t25` tinyint(1) NULL DEFAULT '0', + `t26` tinyint(1) NULL DEFAULT '0', + `t27` tinyint(1) NULL DEFAULT '0', + `t28` tinyint(1) NULL DEFAULT '0', + `t29` tinyint(1) NULL DEFAULT '0', + `t32` tinyint(1) NULL DEFAULT '0', + `t33` tinyint(1) NULL DEFAULT '0', + `t34` tinyint(1) NULL DEFAULT '0', + `t35` tinyint(1) NULL DEFAULT '0', + `t36` tinyint(1) NULL DEFAULT '0', + `t37` tinyint(1) NULL DEFAULT '0', + `t38` tinyint(1) NULL DEFAULT '0', + `t39` tinyint(1) NULL DEFAULT '0', + `t42` tinyint(1) NULL DEFAULT '0', + `t43` tinyint(1) NULL DEFAULT '0', + `t44` tinyint(1) NULL DEFAULT '0', + `t45` tinyint(1) NULL DEFAULT '0', + `t46` tinyint(1) NULL DEFAULT '0', + `t47` tinyint(1) NULL DEFAULT '0', + `t48` tinyint(1) NULL DEFAULT '0', + `t49` tinyint(1) NULL DEFAULT '0', + PRIMARY KEY (`vref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%prefix%tdata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%tech_log` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%tech_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `wid` int(11) NULL, + `log` text NULL, + `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%tech_log` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%training` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%training` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vref` int(11) NULL, + `unit` tinyint(2) NULL, + `amt` int(11) NULL, + `pop` int(11) NULL, + `timestamp` int(11) NULL, + `eachtime` int(11) NULL, + `timestamp2` int(11) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%training` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%units` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%units` ( + `vref` int(11) NOT NULL, + `u1` int(11) NULL DEFAULT '0', + `u2` int(11) NULL DEFAULT '0', + `u3` int(11) NULL DEFAULT '0', + `u4` int(11) NULL DEFAULT '0', + `u5` int(11) NULL DEFAULT '0', + `u6` int(11) NULL DEFAULT '0', + `u7` int(11) NULL DEFAULT '0', + `u8` int(11) NULL DEFAULT '0', + `u9` int(11) NULL DEFAULT '0', + `u10` int(11) NULL DEFAULT '0', + `u11` int(11) NULL DEFAULT '0', + `u12` int(11) NULL DEFAULT '0', + `u13` int(11) NULL DEFAULT '0', + `u14` int(11) NULL DEFAULT '0', + `u15` int(11) NULL DEFAULT '0', + `u16` int(11) NULL DEFAULT '0', + `u17` int(11) NULL DEFAULT '0', + `u18` int(11) NULL DEFAULT '0', + `u19` int(11) NULL DEFAULT '0', + `u20` int(11) NULL DEFAULT '0', + `u21` int(11) NULL DEFAULT '0', + `u22` int(11) NULL DEFAULT '0', + `u23` int(11) NULL DEFAULT '0', + `u24` int(11) NULL DEFAULT '0', + `u25` int(11) NULL DEFAULT '0', + `u26` int(11) NULL DEFAULT '0', + `u27` int(11) NULL DEFAULT '0', + `u28` int(11) NULL DEFAULT '0', + `u29` int(11) NULL DEFAULT '0', + `u30` int(11) NULL DEFAULT '0', + `u31` int(11) NULL DEFAULT '0', + `u32` int(11) NULL DEFAULT '0', + `u33` int(11) NULL DEFAULT '0', + `u34` int(11) NULL DEFAULT '0', + `u35` int(11) NULL DEFAULT '0', + `u36` int(11) NULL DEFAULT '0', + `u37` int(11) NULL DEFAULT '0', + `u38` int(11) NULL DEFAULT '0', + `u39` int(11) NULL DEFAULT '0', + `u40` int(11) NULL DEFAULT '0', + `u41` int(11) NULL DEFAULT '0', + `u42` int(11) NULL DEFAULT '0', + `u43` int(11) NULL DEFAULT '0', + `u44` int(11) NULL DEFAULT '0', + `u45` int(11) NULL DEFAULT '0', + `u46` int(11) NULL DEFAULT '0', + `u47` int(11) NULL DEFAULT '0', + `u48` int(11) NULL DEFAULT '0', + `u49` int(11) NULL DEFAULT '0', + `u50` int(11) NULL DEFAULT '0', + `u99` int(11) NULL DEFAULT '0', + `u99o` int(11) NULL DEFAULT '0', + `hero` int(11) NULL DEFAULT '0', + PRIMARY KEY (`vref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `%prefix%units` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%PREFIX%users` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(100) NULL, + `password` varchar(100) NULL, + `email` text NULL, + `tribe` tinyint(1) NULL, + `access` tinyint(1) NULL DEFAULT '1', + `gold` int(9) NULL DEFAULT '0', + `gender` tinyint(1) NULL DEFAULT '0', + `birthday` date NULL DEFAULT '1970-01-01', + `location` text NULL, + `desc1` text NULL, + `desc2` text NULL, + `plus` int(11) NULL DEFAULT '0', + `goldclub` int(11) NULL DEFAULT '0', + `b1` int(11) NULL DEFAULT '0', + `b2` int(11) NULL DEFAULT '0', + `b3` int(11) NULL DEFAULT '0', + `b4` int(11) NULL DEFAULT '0', + `sit1` int(11) NULL DEFAULT '0', + `sit2` int(11) NULL DEFAULT '0', + `alliance` int(11) NULL DEFAULT '0', + `sessid` varchar(100) NULL, + `act` varchar(10) NULL, + `timestamp` int(11) NULL DEFAULT '0', + `ap` int(11) NULL DEFAULT '0', + `apall` int(11) NULL DEFAULT '0', + `dp` int(11) NULL DEFAULT '0', + `dpall` int(11) NULL DEFAULT '0', + `protect` int(11) NULL, + `quest` tinyint(2) NULL, + `quest_time` int(11) NULL, + `gpack` varchar(255) NULL DEFAULT 'gpack/travian_default/', + `cp` float(14,5) NULL DEFAULT '1', + `lastupdate` int(11) NULL, + `RR` int(255) NULL DEFAULT '0', + `Rc` int(255) NULL DEFAULT '0', + `ok` tinyint(1) NULL DEFAULT '0', + `clp` bigint(255) NULL DEFAULT '0', + `oldrank` bigint(255) NULL DEFAULT '0', + `regtime` int(11) NULL DEFAULT '0', + `invited` int(11) NULL DEFAULT '0', + `friend0` int(11) NULL DEFAULT '0', + `friend1` int(11) NULL DEFAULT '0', + `friend2` int(11) NULL DEFAULT '0', + `friend3` int(11) NULL DEFAULT '0', + `friend4` int(11) NULL DEFAULT '0', + `friend5` int(11) NULL DEFAULT '0', + `friend6` int(11) NULL DEFAULT '0', + `friend7` int(11) NULL DEFAULT '0', + `friend8` int(11) NULL DEFAULT '0', + `friend9` int(11) NULL DEFAULT '0', + `friend10` int(11) NULL DEFAULT '0', + `friend11` int(11) NULL DEFAULT '0', + `friend12` int(11) NULL DEFAULT '0', + `friend13` int(11) NULL DEFAULT '0', + `friend14` int(11) NULL DEFAULT '0', + `friend15` int(11) NULL DEFAULT '0', + `friend16` int(11) NULL DEFAULT '0', + `friend17` int(11) NULL DEFAULT '0', + `friend18` int(11) NULL DEFAULT '0', + `friend19` int(11) NULL DEFAULT '0', + `friend0wait` int(11) NULL DEFAULT '0', + `friend1wait` int(11) NULL DEFAULT '0', + `friend2wait` int(11) NULL DEFAULT '0', + `friend3wait` int(11) NULL DEFAULT '0', + `friend4wait` int(11) NULL DEFAULT '0', + `friend5wait` int(11) NULL DEFAULT '0', + `friend6wait` int(11) NULL DEFAULT '0', + `friend7wait` int(11) NULL DEFAULT '0', + `friend8wait` int(11) NULL DEFAULT '0', + `friend9wait` int(11) NULL DEFAULT '0', + `friend10wait` int(11) NULL DEFAULT '0', + `friend11wait` int(11) NULL DEFAULT '0', + `friend12wait` int(11) NULL DEFAULT '0', + `friend13wait` int(11) NULL DEFAULT '0', + `friend14wait` int(11) NULL DEFAULT '0', + `friend15wait` int(11) NULL DEFAULT '0', + `friend16wait` int(11) NULL DEFAULT '0', + `friend17wait` int(11) NULL DEFAULT '0', + `friend18wait` int(11) NULL DEFAULT '0', + `friend19wait` int(11) NULL DEFAULT '0', + `maxevasion` mediumint(3) NULL DEFAULT '0', + `village_select` bigint(20) DEFAULT NULL, + `vac_time` varchar(255) NULL DEFAULT '0', + `vac_mode` int(2) NULL DEFAULT '0', + `vactwoweeks` varchar(255) NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; + +-- +-- Dumping data for table `%prefix%users` +-- + +INSERT INTO `%PREFIX%users` (`id`, `username`, `password`, `email`, `tribe`, `access`, `gold`, `gender`, `birthday`, `location`, `desc1`, `desc2`, `plus`, `b1`, `b2`, `b3`, `b4`, `sit1`, `sit2`, `alliance`, `sessid`, `act`, `timestamp`, `ap`, `apall`, `dp`, `dpall`, `protect`, `quest`, `gpack`, `cp`, `lastupdate`, `RR`, `Rc`, `ok`) VALUES +(5, 'Multihunter', '', 'multihunter@travianx.mail', 0, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(1, 'Support', '', 'support@travianx.mail', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(2, 'Nature', '4262cc190152adfc1a3fcf32af6aa430', 'support@travianx.mail', 4, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(4, 'Taskmaster', '', 'support@travianx.mail', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%vdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%vdata` ( +`wref` int(11) NOT NULL, +`owner` int(11) NULL, +`name` varchar(100) NULL, +`capital` tinyint(1) NULL, +`pop` int(11) NULL, +`cp` int(11) NULL, +`celebration` int(11) NULL DEFAULT '0', +`type` int(11) NULL DEFAULT '0', +`wood` float(12,2) NULL, +`clay` float(12,2) NULL, +`iron` float(12,2) NULL, +`maxstore` int(11) NULL, +`crop` float(12,2) NULL, +`maxcrop` int(11) NULL, +`lastupdate` int(11) NULL, +`lastupdate2` int(11) NULL DEFAULT '0', +`loyalty` float(9,6) NULL DEFAULT '100', +`exp1` int(11) NULL DEFAULT '0', +`exp2` int(11) NULL DEFAULT '0', +`exp3` int(11) NULL DEFAULT '0', +`created` int(11) NULL, +`natar` tinyint(1) NULL DEFAULT '0', +`starv` int(11) NULL DEFAULT '0', +`starvupdate` int(11) NULL DEFAULT '0', +`evasion` tinyint(1) NULL DEFAULT '0', +PRIMARY KEY (`wref`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%vdata` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `%prefix%wdata` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%wdata` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `fieldtype` tinyint(2) NULL, + `oasistype` tinyint(2) NULL, + `x` int(11) NULL, + `y` int(11) NULL, + `occupied` tinyint(1) NULL, + `image` varchar(3) NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `%prefix%wdata` +-- + +-- -------------------------------------------------------- +-- +-- Table structure for table `%prefix%password` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%password` ( + `uid` int(11) NOT NULL, + `npw` varchar(100) NULL, + `cpw` varchar(100) NULL, + `used` tinyint(1) NULL DEFAULT '0', + `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`uid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `%prefix%password` +-- + +-- -------------------------------------------------------- +-- +-- Table structure for table `%prefix%ww_attacks` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%ww_attacks` ( + `vid` int(25) NULL, + `attack_time` int(25) NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `%prefix%password` +-- + +-- -------------------------------------------------------- diff --git a/install/include/database.php b/install/include/database.php new file mode 100644 index 00000000..cc7ce341 --- /dev/null +++ b/install/include/database.php @@ -0,0 +1,55 @@ +connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die(mysqli_error()); + } + function query($query) { + return mysqli_query($this->connection, $query); + } +}; +class MYSQL_DB { + var $connection; + function MYSQL_DB() { + $this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); + mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); + } + + function mysql_exec_batch ($p_query, $p_transaction_safe = true) { + if ($p_transaction_safe) { + $p_query = 'START TRANSACTION;' . $p_query . '; COMMIT;'; + }; + $query_split = preg_split ("/[;]+/", $p_query); + foreach ($query_split as $command_line) { + $command_line = trim($command_line); + if ($command_line != '') { + $query_result = mysql_query($command_line); + if ($query_result == 0) { + break; + }; + }; + }; + return $query_result; +} + + function query($query) { + return mysql_query($query, $this->connection); + } +}; + +if(DB_TYPE) { + $database = new MYSQLi_DB; +} +else { + $database = new MYSQL_DB; +} +?> diff --git a/install/include/multihunter.php b/install/include/multihunter.php new file mode 100644 index 00000000..3fee7536 --- /dev/null +++ b/install/include/multihunter.php @@ -0,0 +1,31 @@ +getWref(0, 0); + $uid = 5; + $status = $database->getVillageState($wid); + if($status == 0) { + $database->setFieldTaken($wid); + $database->addVillage($wid, $uid, 'Multihunter', '0'); + $database->addResourceFields($wid, $database->getVillageType($wid)); + $database->addUnits($wid); + $database->addTech($wid); + $database->addABTech($wid); + } + } + +$gameinstall = 0; + header("Location: ../index.php?s=5"); + +?> \ No newline at end of file diff --git a/install/include/oasis.php b/install/include/oasis.php new file mode 100644 index 00000000..e5b9417c --- /dev/null +++ b/install/include/oasis.php @@ -0,0 +1,23 @@ +populateOasisdata(); + $database->populateOasis(); + $database->populateOasisUnits2(); + + + + + header("Location: ../index.php?s=6"); + +?> \ No newline at end of file diff --git a/install/include/wdata.php b/install/include/wdata.php new file mode 100644 index 00000000..f70b1b44 --- /dev/null +++ b/install/include/wdata.php @@ -0,0 +1,116 @@ += $rand){ + $typ='1'; + $otype='0'; + } else if("90" >= $rand){ + $typ='2'; + $otype='0'; + } else if("400" >= $rand){ + $typ='3'; + $otype='0'; + } else if("480" >= $rand){ + $typ='4'; + $otype='0'; + } else if("560" >= $rand){ + $typ='5'; + $otype='0'; + } else if("570" >= $rand){ + $typ='6'; + $otype='0'; + } else if("600" >= $rand){ + $typ='7'; + $otype='0'; + } else if("630" >= $rand){ + $typ='8'; + $otype='0'; + } else if("660" >= $rand){ + $typ='9'; + $otype='0'; + } else if("740" >= $rand){ + $typ='10'; + $otype='0'; + } else if("820" >= $rand){ + $typ='11'; + $otype='0'; + } else if("900" >= $rand){ + $typ='12'; + $otype='0'; + } else if("908" >= $rand){ + $typ='0'; + $otype='1'; + } else if("916" >= $rand){ + $typ='0'; + $otype='2'; + } else if("924" >= $rand){ + $typ='0'; + $otype='3'; + } else if("932" >= $rand){ + $typ='0'; + $otype='4'; + } else if("940" >= $rand){ + $typ='0'; + $otype='5'; + } else if("948" >= $rand){ + $typ='0'; + $otype='6'; + } else if("956" >= $rand){ + $typ='0'; + $otype='7'; + } else if("964" >= $rand){ + $typ='0'; + $otype='8'; + } else if("972" >= $rand){ + $typ='0'; + $otype='9'; + } else if("980" >= $rand){ + $typ='0'; + $otype='10'; + } else if("988" >= $rand){ + $typ='0'; + $otype='11'; + } else { + $typ='0'; + $otype='12'; + } + } + //image pick + if($otype=='0'){ + $image="t".rand(0,9).""; + } else { + $image="o".$otype.""; + } + + //into database + $q = "INSERT into ".TB_PREFIX."wdata values (0,'".$typ."','".$otype."','".$x."','".$y."',0,'".$image."')"; + $database->query($q); + } +} + + header("Location: ../index.php?s=4"); + +?> diff --git a/install/index.php b/install/index.php new file mode 100644 index 00000000..892ad921 --- /dev/null +++ b/install/index.php @@ -0,0 +1,130 @@ + + + + + + + TravianZ Installation + + + + + + + + + + + + + + + + +
+ + +
+ + + +
+
+ +
+ + + + + +
+ + +
+ +
+ + diff --git a/install/process.php b/install/process.php new file mode 100644 index 00000000..21031210 --- /dev/null +++ b/install/process.php @@ -0,0 +1,145 @@ +constForm(); + } else + if(isset($_POST['substruc'])) { + $this->createStruc(); + } else + if(isset($_POST['subwdata'])) { + $this->createWdata(); + } else + if(isset($_POST['subacc'])) { + $this->createAcc(); + } else { + header("Location: index.php"); + } + } + + function constForm() { + $myFile = "include/constant.php"; + $fh = fopen($myFile, 'w') or die("


Can't open file: install\include\constant.php"); + $text = file_get_contents("data/constant_format.tpl"); + $text = preg_replace("'%SERVERNAME%'", $_POST['servername'], $text); + $text = preg_replace("'%SSTARTDATE%'", $_POST['start_date'], $text); + $text = preg_replace("'%SSTARTTIME%'", $_POST['start_time'], $text); + $tz = explode(",",$_POST['tzone']); + $text = preg_replace("'%STIMEZONE%'", $tz[1], $text); + $text = preg_replace("'%LANG%'", $_POST['lang'], $text); + $text = preg_replace("'%SPEED%'", $_POST['speed'], $text); + $text = preg_replace("'%INCSPEED%'", $_POST['incspeed'], $text); + $text = preg_replace("'%EVASIONSPEED%'", $_POST['evasionspeed'], $text); + $text = preg_replace("'%TRADERCAP%'", $_POST['tradercap'], $text); + $text = preg_replace("'%CRANNYCAP%'", $_POST['crannycap'], $text); + $text = preg_replace("'%TRAPPERCAP%'", $_POST['trappercap'], $text); + $text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text); + $text = preg_replace("'%UTRACK%'", $_POST['trackusers'], $text); + $text = preg_replace("'%UTOUT%'", $_POST['timeout'], $text); + $text = preg_replace("'%AUTOD%'", $_POST['autodel'], $text); + $text = preg_replace("'%AUTODT%'", $_POST['autodeltime'], $text); + $text = preg_replace("'%MAX%'", $_POST['wmax'], $text); + $text = preg_replace("'%GP%'", $_POST['gpack'], $text); + $text = preg_replace("'%SSERVER%'", $_POST['sserver'], $text); + $text = preg_replace("'%SUSER%'", $_POST['suser'], $text); + $text = preg_replace("'%SPASS%'", $_POST['spass'], $text); + $text = preg_replace("'%SDB%'", $_POST['sdb'], $text); + $text = preg_replace("'%PREFIX%'", $_POST['prefix'], $text); + $text = preg_replace("'%CONNECTT%'", $_POST['connectt'], $text); + $text = preg_replace("'%AEMAIL%'", $_POST['aemail'], $text); + $text = preg_replace("'%ANAME%'", $_POST['aname'], $text); + $text = preg_replace("'%SUBDOM%'", $_POST['subdom'], $text); + $text = preg_replace("'%LOGBUILD%'", $_POST['log_build'], $text); + $text = preg_replace("'%LOGTECH%'", $_POST['log_tech'], $text); + $text = preg_replace("'%LOGLOGIN%'", $_POST['log_login'], $text); + $text = preg_replace("'%LOGGOLDFIN%'", $_POST['log_gold_fin'], $text); + $text = preg_replace("'%LOGADMIN%'", $_POST['log_admin'], $text); + $text = preg_replace("'%LOGWAR%'", $_POST['log_war'], $text); + $text = preg_replace("'%LOGMARKET%'", $_POST['log_market'], $text); + $text = preg_replace("'%LOGILLEGAL%'", $_POST['log_illegal'], $text); + $text = preg_replace("'%MINUSERLENGTH%'", $_POST['userlength'], $text); + $text = preg_replace("'%MINPASSLENGTH%'", $_POST['passlength'], $text); + $text = preg_replace("'%SPECIALCHARS%'", $_POST['specialchars'], $text); + $text = preg_replace("'%ACTIVATE%'", $_POST['activate'], $text); + $text = preg_replace("'%ARANK%'", $_POST['admin_rank'], $text); + $text = preg_replace("'%QUEST%'", $_POST['quest'], $text); + $text = preg_replace("'%QTYPE%'", $_POST['qtype'], $text); + $text = preg_replace("'%BEGINNER%'", $_POST['beginner'], $text); + $text = preg_replace("'%STARTTIME%'", time(), $text); + $text = preg_replace("'%DOMAIN%'", $_POST['domain'], $text); + $text = preg_replace("'%HOMEPAGE%'", $_POST['homepage'], $text); + $text = preg_replace("'%SERVER%'", $_POST['server'], $text); + $text = preg_replace("'%LIMIT_MAILBOX%'", $_POST['limit_mailbox'], $text); + $text = preg_replace("'%MAX_MAILS%'", $_POST['max_mails'], $text); + $text = preg_replace("'%DEMOLISH%'", $_POST['demolish'], $text); + $text = preg_replace("'%BOX1%'", $_POST['box1'], $text); + $text = preg_replace("'%BOX2%'", $_POST['box2'], $text); + $text = preg_replace("'%BOX3%'", $_POST['box3'], $text); + $text = preg_replace("'%VILLAGE_EXPAND%'", $_POST['village_expand'], $text); + $text = preg_replace("'%ERRORREPORT%'", $_POST['error'], $text); + $text = preg_replace("'%ERROR%'", $_POST['error'], $text); + $text = preg_replace("'%GP_LOCATE%'", $_POST['gp_locate'], $text); + $text = preg_replace("'%PLUS_TIME%'", $_POST['plus_time'], $text); + $text = preg_replace("'%PLUS_PRODUCTION%'", $_POST['plus_production'], $text); + $text = preg_replace("'%MEDALINTERVAL%'", $_POST['medalinterval'], $text); + $text = preg_replace("'%GREAT_WKS%'", $_POST['great_wks'], $text); + $text = preg_replace("'%TS_THRESHOLD%'", $_POST['ts_threshold'], $text); + $text = preg_replace("'%WW%'", $_POST['ww'], $text); + $text = preg_replace("'%SHOW_NATARS%'", $_POST['show_natars'], $text); + $text = preg_replace("'%NATARS_UNITS%'", $_POST['natars_units'], $text); + $text = preg_replace("'%NATURE_REGTIME%'", $_POST['nature_regtime'], $text); + $text = preg_replace("'%T4_COMING%'", $_POST['t4_coming'], $text); + $text = preg_replace("'%REG_OPEN%'", $_POST['reg_open'], $text); + $text = preg_replace("'%PEACE%'", $_POST['peace'], $text); + + fwrite($fh, $text); + + if(file_exists("include/constant.php")) { + header("Location: index.php?s=2"); + } else { + header("Location: index.php?s=1&c=1"); + } + + fclose($fh); + } + + function createStruc() { + global $database; + $str = file_get_contents("data/sql.sql"); + $str = preg_replace("'%PREFIX%'", TB_PREFIX, $str); + if(DB_TYPE) { + $result = $database->connection->multi_query($str); + } else { + $result = $database->mysql_exec_batch($str); + } + if($result) { + header("Location: index.php?s=3"); + } else { + header("Location: index.php?s=2&c=1"); + } + } + + function createWdata() { + header("Location: include/wdata.php"); + } + +} +; + +$process = new Process; + +?> diff --git a/install/templates/.htaccess b/install/templates/.htaccess new file mode 100644 index 00000000..85b65c30 --- /dev/null +++ b/install/templates/.htaccess @@ -0,0 +1,4 @@ + +Order allow,deny +Deny from all + \ No newline at end of file diff --git a/install/templates/config.tpl b/install/templates/config.tpl new file mode 100644 index 00000000..9db82845 --- /dev/null +++ b/install/templates/config.tpl @@ -0,0 +1,345 @@ +Error creating constant.php check cmod.

"; +} +?> + +
+ +

+ SERVER RELATED + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Server name:
Server Timezone: + +
Server speed:
Troop speed:
Evasion speed:
Trader capacity (1 = 1x...):
Cranny capacity:
Trapper capacity:
Natars Units Multiplier:
World size: + +
Register Open: + +
Server:
Domain:
Homepage:
Language: + +
Beginners protection length: + +
Plus account length: + +
+25% production length: + +
Nature troops regeneration time: + +
Medal Interval: + +
Storage Multipler:
Tourn Threshold:
Great Workshop: + +
ww: + +
Show Natars in Statistics: + +
Peace system: + +
+

+ +

+ ADMIN ACCOUNT + + + + + +
Admin name:
Admin email:
Show admin in stats: + +
+

+ +

+ SQL RELATED + + + + + + + +
Hostname:
Username:
Password:
DB name:
Prefix:
Type:
+

+ + + + + + + +

+ NEWSBOX OPTIONS + + + + +
Newsbox 1:
Newsbox 2:
Newsbox 3:
+

+ +

+ LOG RELATED (You should disable them) + + + + + + + + + + + +
Log Building:
Log Tech:
Log Login:
Log Gold:
Log Admin:
Log War:
Log Market:
Log Illegal:
Log :
+

+ +

+ EXTRA OPTIONS + + + + + + + + + + + +
Quest:
Quest Type:
Activate:
Limit Mailbox: (NOT DONE)
Max mails: (NOT DONE)
Demolish - lvl required:
Village Expand:
Error Reporting:
T4 is Coming screen:
+

+
+ Server Start Settings + + + +
Start Date:
Start Time:
+ +
+ +
+
+ +
diff --git a/install/templates/dataform.tpl b/install/templates/dataform.tpl new file mode 100644 index 00000000..76ec6380 --- /dev/null +++ b/install/templates/dataform.tpl @@ -0,0 +1,33 @@ +Error importing database. Check configuration.

"; +} +?> +
+ + +

+ Create SQL Structure + + + +
Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..
+

+
+
diff --git a/install/templates/end.tpl b/install/templates/end.tpl new file mode 100644 index 00000000..9c087704 --- /dev/null +++ b/install/templates/end.tpl @@ -0,0 +1,43 @@ + +

+Thanks for installing TravianZ. +

Please remove/rename the installation folder.

+All the files are placed. The database is created, so you can now start playing on your own Travian. +

+ + +

+

> My TravianZ homepage <
+

+
+
+

Please support our developers and donate.

+
+
+ + + + +
+
+
diff --git a/install/templates/field.tpl b/install/templates/field.tpl new file mode 100644 index 00000000..812b2000 --- /dev/null +++ b/install/templates/field.tpl @@ -0,0 +1,33 @@ +Error creating wdata. Check configuration or file.

"; +} +?> +
+ + +

+ Create World Data + + + +
Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..
+

+
+
diff --git a/install/templates/greet.tpl b/install/templates/greet.tpl new file mode 100644 index 00000000..b8d36ebb --- /dev/null +++ b/install/templates/greet.tpl @@ -0,0 +1,50 @@ + +
+ +

  Disclaimer

+ +
    +
  • Along with the installation/usage of this game, you shall be fully responsible for any legal results that may raised initiated by the owners of any unlicensed content you permit your copy of this game to publish.
  • + +
  • Neither the team that created this script nor the team that customised it to create this distribution/release shall be responsible for any damage done to your computer/server system.
  • + +
  • All code was confirmed to be running correctly by the creation team without any visible security risk they were aware of at the time the released it. Similarly for the customisation team who customised it to create this distribution/release.
  • + +
  • Users are asked to review the code on their own accord and behalf.
  • + +
  • Any customization to the source code are the property of each customisation's author, it is up to each author's discretion whether to share it by including it in free open source distributions such as this one.
  • + +
  • You have no rights to edit copyright notices or/and claim this script as your own.
  • + +
  • Last but not least, Enjoy.
  • +
+ +
+
    +
  • Before Installation (Linux):

  • +
  • CHMOD install to 777 (chmod -R 777 install)
  • +
  • CHMOD GameEngine to 777 (chmod -R 777 GameEngine)
  • +
  • After Installation

  • +
  • Delete install folder (sudo rm -R install)
  • +
  • CHMOD GameEngine back to 755 (sudo chmod -R 755 GameEngine)
  • +
  • CHMOD Prevention to 777 (sudo chmod -R 777 GameEngine/Prevention)
  • +
  • CHMOD Notes to 777 (sudo chmod -R 777 GameEngine/Notes)
  • +
+ +
    +
  • After Installation

  • +
  • Protect folder /Admin with password protect directory
  • +
+ +
+ TravianZ Team +
+
+ +
+
+ +
+
+ +
diff --git a/install/templates/menu.tpl b/install/templates/menu.tpl new file mode 100644 index 00000000..cc2bf27e --- /dev/null +++ b/install/templates/menu.tpl @@ -0,0 +1,44 @@ + diff --git a/install/templates/multihunter.tpl b/install/templates/multihunter.tpl new file mode 100644 index 00000000..59e8a44b --- /dev/null +++ b/install/templates/multihunter.tpl @@ -0,0 +1,37 @@ + + + + +
+ +

+ Create Multihunter account + + + + +
Name:
Password:
Note: Rember this password! You need it for the ACP
+

+ +
+
+
+ +
diff --git a/install/templates/oasis.tpl b/install/templates/oasis.tpl new file mode 100644 index 00000000..85d8f52e --- /dev/null +++ b/install/templates/oasis.tpl @@ -0,0 +1,19 @@ + +
+

+ Populate Oasis + + + +
Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..
+

+
+ diff --git a/install/templates/script.tpl b/install/templates/script.tpl new file mode 100644 index 00000000..26c9141f --- /dev/null +++ b/install/templates/script.tpl @@ -0,0 +1,145 @@ + + +bar_id = uniqid('progressbar'); + $this->label = $label; + + $this->max_ticks = $max_ticks; + $this->ticks = 0; + } + + public function tick() { + $this->ticks++; + $this->draw_progress(); + } + + public function draw() { + $this->draw_bar(); + $this->draw_progress(); + } + + static public function draw_css() { + echo ' + + '; + } + + protected function draw_bar() { + echo ' +
+ +
+ +
+
+ '; + echo ' + + '; + + $this->flush(); + } + + protected function draw_progress() { + + $width = round($this->ticks / $this->max_ticks * 100, 2); + $label = sprintf($this->label, $this->ticks, $this->max_ticks); + + echo ' + + + '; + $this->flush(); + } + + protected function flush() { + while(ob_get_level() > 0) { + ob_end_flush(); + } + + flush(); + } +} +?> \ No newline at end of file From 192b45bc05a7d26763d898c756199f10ddda2ec7 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 17:38:52 +0200 Subject: [PATCH 45/73] fix: missing auto-clear constant --- GameEngine/Admin/Mods/constant_format.tpl | 2 ++ install/data/constant_format.tpl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/GameEngine/Admin/Mods/constant_format.tpl b/GameEngine/Admin/Mods/constant_format.tpl index 04b8750d..7e62811b 100755 --- a/GameEngine/Admin/Mods/constant_format.tpl +++ b/GameEngine/Admin/Mods/constant_format.tpl @@ -252,6 +252,8 @@ define("ADMIN_NAME", "%ANAME%"); ////////////////////////////////////////// // **** DO NOT EDIT SETTINGS **** // ////////////////////////////////////////// +define("AUTO_DEL_INACTIVE",false); // auto-delete inactive players; default = false +define("UN_ACT_TIME", 3628800); // 6 weeks to consider a player inactive define("TRACK_USR","%UTRACK%"); define("USER_TIMEOUT","%UTOUT%"); define("ALLOW_BURST",false); diff --git a/install/data/constant_format.tpl b/install/data/constant_format.tpl index 942588b7..a8bafc88 100644 --- a/install/data/constant_format.tpl +++ b/install/data/constant_format.tpl @@ -252,6 +252,8 @@ define("ADMIN_NAME", "%ANAME%"); ////////////////////////////////////////// // **** DO NOT EDIT SETTINGS **** // ////////////////////////////////////////// +define("AUTO_DEL_INACTIVE",false); // auto-delete inactive players; default = false +define("UN_ACT_TIME", 3628800); // 6 weeks to consider a player inactive define("TRACK_USR","%UTRACK%"); define("USER_TIMEOUT","%UTOUT%"); define("ALLOW_BURST",false); From d497674badccda04da9832784185f8f952e5fe89 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 17:49:37 +0200 Subject: [PATCH 46/73] fix: MySQLi now only enabled during installation --- install/templates/config.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/templates/config.tpl b/install/templates/config.tpl index 9db82845..ec6006e0 100644 --- a/install/templates/config.tpl +++ b/install/templates/config.tpl @@ -195,8 +195,8 @@ echo "
Error creating constant.php
DB name:
Prefix:
Type:

From d48e0c02b5e2b124ac11724da480bf20cf52f40c Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 17:50:27 +0200 Subject: [PATCH 47/73] fix: multihunter setup step uses MySQLi --- install/include/multihunter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/include/multihunter.php b/install/include/multihunter.php index 3fee7536..dd7bc8bd 100644 --- a/install/include/multihunter.php +++ b/install/include/multihunter.php @@ -6,12 +6,12 @@ $gameinstall = 1; include ("../../GameEngine/Admin/database.php"); include ("../../GameEngine/Lang/" . LANG . ".php"); - mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); - mysql_select_db(SQL_DB); + mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); + mysqli_select_db(SQL_DB); if(isset($_POST['mhpw'])) { $password = $_POST['mhpw']; - mysql_query("UPDATE " . TB_PREFIX . "users SET password = '" . md5($password) . "' WHERE username = 'Multihunter'"); + mysqli_query("UPDATE " . TB_PREFIX . "users SET password = '" . md5($password) . "' WHERE username = 'Multihunter'"); $wid = $admin->getWref(0, 0); $uid = 5; $status = $database->getVillageState($wid); From b4b33f5f5a0a28e41ab7b13b960dad06a8842142 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 17:51:04 +0200 Subject: [PATCH 48/73] fix: oasis population installation step uses MySQLi --- install/include/oasis.php | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 install/include/oasis.php diff --git a/install/include/oasis.php b/install/include/oasis.php deleted file mode 100644 index e5b9417c..00000000 --- a/install/include/oasis.php +++ /dev/null @@ -1,23 +0,0 @@ -populateOasisdata(); - $database->populateOasis(); - $database->populateOasisUnits2(); - - - - - header("Location: ../index.php?s=6"); - -?> \ No newline at end of file From 261933b1bedc5e5303c674bff0dd381ca7937631 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 17:52:46 +0200 Subject: [PATCH 49/73] chore: git-ignoring installed templates --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0c1062c0..9d89f1ad 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ GameEngine/Notes/* install/installation_done /.buildpath /.project -/installed_1503932880/ +/installed_*/ From dfc076b88d858621fd18d932bef1d960b46b414e Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 18:08:26 +0200 Subject: [PATCH 50/73] fix: MySQLi DB queries properly given MySQLi link as first param --- GameEngine/Database.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index f2d8e7ad..89b0cf6a 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -140,11 +140,11 @@ class MYSQLi_DB { function caststruc($user) { //loop search village user - $query = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); + $query = mysqli_query($this->dblink,"SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); while($villaggi_array = mysqli_fetch_array($query)) //loop structure village - $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); + $query1 = mysqli_query($this->dblink,"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); $strutture= mysqli_fetch_array($query1); return $strutture; } @@ -497,7 +497,7 @@ class MYSQLi_DB { public function countOasisTroops($vref){ //count oasis troops: $troops_o $troops_o=0; - $o_unit2=mysqli_query($GLOBALS['link'],"select * from ".TB_PREFIX."units where `vref`='".$vref."'"); + $o_unit2=mysqli_query($this->dblink,"select * from ".TB_PREFIX."units where `vref`='".$vref."'"); $o_unit=mysqli_fetch_array($o_unit2); for ($i=1;$i<51;$i++) @@ -506,7 +506,7 @@ class MYSQLi_DB { } $troops_o+=$o_unit['hero']; - $o_unit2=mysqli_query($GLOBALS['link'],"select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'"); + $o_unit2=mysqli_query($this->dblink,"select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'"); while ($o_unit=@mysqli_fetch_array($o_unit2)) { for ($i=1;$i<51;$i++) @@ -1352,7 +1352,7 @@ class MYSQLi_DB { References: *****************************************/ function deleteAlliance($aid) { - $result = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"); + $result = mysqli_query($this->dblink,"SELECT * FROM " . TB_PREFIX . "users where alliance = $aid"); $num_rows = mysqli_num_rows($result); if($num_rows == 0) { $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid"; @@ -1648,9 +1648,9 @@ class MYSQLi_DB { $y1 = intval($coor['y']); $prevdist = 0; $q2 = "SELECT * FROM " . TB_PREFIX . "vdata where owner = 4"; - $array2 = mysqli_fetch_array(mysqli_query($q2)); + $array2 = mysqli_fetch_array(mysqli_query($this->dblink,$q2)); $vill = $array2['wref']; - if(mysqli_num_rows(mysqli_query($q)) > 0){ + if(mysqli_num_rows(mysqli_query($this->dblink,$q)) > 0){ foreach($array as $village){ $coor2 = $this->getCoor($village['wref']); $max = 2 * WORLD_MAX + 1; @@ -2131,7 +2131,7 @@ class MYSQLi_DB { function FinishWoodcutter($wid) { $time = time()-1; $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by master,timestamp ASC"; - $result = mysqli_query($q); + $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); $q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'"; $this->query($q); @@ -2141,7 +2141,7 @@ class MYSQLi_DB { }else{ $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 order by master,timestamp ASC"; } - $result2 = mysqli_query($q2); + $result2 = mysqli_query($this->dblink,$q2); if(mysqli_num_rows($result2) > 0){ $dbarray2 = mysqli_fetch_array($result2); $wc_time = $dbarray['timestamp']; @@ -3353,7 +3353,7 @@ class MYSQLi_DB { function getMovementById($id){ $q = "SELECT * FROM ".TB_PREFIX."movement WHERE moveid = ".$id.""; - $result = mysqli_query($q); + $result = mysqli_query($this->dblink,$q); $array = $this->mysqli_fetch_all($result); return $array; } From 8c2343bdbbc196d7435e1b012e90021134d84516 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 18:56:52 +0200 Subject: [PATCH 51/73] fix: removal of snowballing memory problems in JS countdowns --- new.js | 6 +++--- unx.js | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/new.js b/new.js index 9df3ac64..f1797087 100644 --- a/new.js +++ b/new.js @@ -132,7 +132,7 @@ window // IE MooTools Fix -if (Browser.Engine.trident) // fr IE +if (Browser.Engine.trident) // f�r IE { @@ -372,7 +372,7 @@ var BBEditor = new Class ({ /** - * Fgt den klickbaren Objekten die Events hinzu + * F�gt den klickbaren Objekten die Events hinzu * @@ -402,7 +402,7 @@ var BBEditor = new Class ({ /** - * Fgt einen ausgewhlten Tag in die + * F�gt einen ausgew�hlten Tag in die * Textarea ein diff --git a/unx.js b/unx.js index a8d01b96..065aaaee 100644 --- a/unx.js +++ b/unx.js @@ -62,12 +62,22 @@ executeCounter();} function executeCounter(){ for(var i in ab){ wb = db() - cb; - xb = rb(ab[i].counter_time + wb); + if (ab[i] && ab[i]['counter_time']) { + xb = rb(ab[i].counter_time + wb); + } else { + xb = 0; + } ab[i].node.innerHTML = xb; } for(i in bb){ wb = db() - cb; - yb = bb[i].counter_time - wb; + + if (bb[i] && bb[i]['counter_time']) { + yb = bb[i].counter_time - wb; + } else { + eb = 0; + yb = -1; + } // console.log('yb: ' + yb); if(eb == 0 && yb < 0){ bb[i] = null; @@ -86,9 +96,9 @@ function executeCounter(){ xb=rb(yb); bb[i].node.innerHTML = xb; } - if(eb == 0 && yb >= 0){ + /*if(eb == 0 && yb >= 0){ setTimeout("executeCounter()",1000); - } + }*/ } setTimeout("executeCounter()",1000); } From 921179012e68b9b928d845d3aca9aeef4f65a426 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 20:33:20 +0200 Subject: [PATCH 52/73] fix: removal a crazy MySQL on-column calculation --- GameEngine/Automation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 6944e59a..d0e52977 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -4700,7 +4700,8 @@ $wallimg = "query_return($q); foreach($array as $oasis) { $database->populateOasisUnits($oasis['wref'],$oasis['high']); From 28c0a199ae0051d9f0451ae22d6decbef76a02d5 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 22:05:16 +0200 Subject: [PATCH 53/73] fix: SQL optimization --- GameEngine/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 89b0cf6a..4a56b477 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -2995,7 +2995,7 @@ class MYSQLi_DB { } function getTrainingList() { - $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''"; + $q = "SELECT * FROM " . TB_PREFIX . "training where vref IS NOT NULL"; $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } From d8f349d2f37c4e2165bda40aef95f1e01510fc8d Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 22:07:33 +0200 Subject: [PATCH 54/73] chore: first wave of SQL updates, mostly adding indexes --- install/data/sql.sql | 98 +++++++++++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 29 deletions(-) diff --git a/install/data/sql.sql b/install/data/sql.sql index fe43c664..d0e6fcb2 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -54,7 +54,8 @@ CREATE TABLE `%PREFIX%links` ( `userid` INT( 25 ) NULL , `name` VARCHAR( 50 ) NULL , `url` VARCHAR( 150 ) NULL , - `pos` INT( 10 ) NULL + `pos` INT( 10 ) NULL, + KEY `userid-pos` (`userid`,`pos`) USING BTREE ) ENGINE = InnoDB; -- @@ -85,7 +86,11 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%abdata` ( `b6` tinyint(2) NULL DEFAULT '0', `b7` tinyint(2) NULL DEFAULT '0', `b8` tinyint(2) NULL DEFAULT '0', - PRIMARY KEY (`vref`) + PRIMARY KEY (`vref`), + KEY `master` (`master`), + KEY `timestamp` (`timestamp`), + KEY `master-timestamp` (`master`,`timestamp`) USING BTREE, + KEY `wid` (`wid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -168,7 +173,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%allimedal` ( `points` bigint(255) NULL, `img` varchar(255) NULL, `del` tinyint(1) NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `week` (`week`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -197,7 +203,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%artefacts` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- --- Table structure for table `s1_artefacts` +-- Table structure for table `%PREFIX%artefacts` -- -- -------------------------------------------------------- @@ -225,7 +231,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%alidata` ( `clp` bigint(255) NULL DEFAULT '0', `oldrank` bigint(255) NULL DEFAULT '0', `forumlink` varchar(150) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `vref-type` (`vref`,`type`), + KEY `owner-active` (`owner`,`active`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -348,14 +356,15 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%attacks` ( CREATE TABLE IF NOT EXISTS `%PREFIX%banlist` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NULL, - `name` varchar(100) NULL, - `reason` varchar(30) NULL, - `time` int(11) NULL, - `end` varchar(10) NULL, - `admin` int(11) NULL, - `active` int(11) NULL, - PRIMARY KEY (`id`) + `uid` int(11) DEFAULT NULL, + `name` varchar(100) DEFAULT NULL, + `reason` varchar(30) DEFAULT NULL, + `time` int(11) UNSIGNED DEFAULT NULL, + `end` int(11) UNSIGNED DEFAULT NULL, + `admin` int(11) DEFAULT NULL, + `active` tinyint(1) UNSIGNED DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `active-end` (`active`,`end`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -470,7 +479,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%demolition` ( `buildnumber` int(11) NULL DEFAULT '0', `lvl` int(11) NULL DEFAULT '0', `timetofinish` int(11) NULL, - PRIMARY KEY (`vref`) + PRIMARY KEY (`vref`), + KEY `timetofinish` (`timetofinish`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -558,7 +568,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%enforcement` ( `hero` tinyint(1) NULL DEFAULT '0', `from` int(11) NULL DEFAULT '0', `vref` int(11) NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `vref` (`vref`), + KEY `from` (`from`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -821,7 +833,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%general` ( `casualties` int(11) NULL, `time` int(11) NULL, `shown` tinyint(1) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `shown` (`shown`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -874,7 +887,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%hero` ( `trainingtime` int(11) NULL, `inrevive` tinyint(1) NULL, `intraining` tinyint(1) NULL, - PRIMARY KEY (`heroid`) + PRIMARY KEY (`heroid`), + KEY `uid` (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; -- @@ -987,7 +1001,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%mdata` ( `player` int(11) NULL, `coor` int(11) NULL, `report` int(11) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `target-time` (`target`,`time`) USING BTREE, + KEY `owner` (`owner`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1065,7 +1081,10 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%ndata` ( `viewed` tinyint(1) NULL, `archive` tinyint(1) NULL DEFAULT '0', `del` tinyint(1) NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `time` (`time`), + KEY `uid-time` (`uid`,`time`) USING BTREE, + KEY `del` (`del`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1095,7 +1114,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%odata` ( `owner` int(11) NULL DEFAULT '2', `name` varchar(32) NULL DEFAULT 'Unoccupied Oasis', `high` tinyint(1) NULL, - PRIMARY KEY (`wref`) + PRIMARY KEY (`wref`), + KEY `lastupdated2` (`lastupdated2`) USING BTREE, + KEY `conqured` (`conqured`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1114,7 +1135,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%online` ( `uid` int(11) NULL, `time` varchar(32) NULL, `sit` tinyint(1) NULL, - UNIQUE KEY `name` (`name`) + UNIQUE KEY `name` (`name`), + KEY `uid` (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1142,7 +1164,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%prisoners` ( `t9` int(11) NULL, `t10` int(11) NULL, `t11` int(11) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `wref` (`wref`), + KEY `from` (`from`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1192,7 +1216,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%research` ( `vref` int(11) NULL, `tech` varchar(3) NULL, `timestamp` int(11) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `vref` (`vref`), + KEY `timestamp` (`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1220,7 +1246,11 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%route` ( `merchant` int(11) NULL, `timestamp` int(11) NULL, `timeleft` int(11) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `uid` (`uid`), + KEY `wid` (`wid`), + KEY `timestamp` (`timestamp`), + KEY `timeleft` (`timeleft`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1339,7 +1369,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%training` ( `timestamp` int(11) NULL, `eachtime` int(11) NULL, `timestamp2` int(11) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `vref` (`vref`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1509,7 +1540,11 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( `vac_time` varchar(255) NULL DEFAULT '0', `vac_mode` int(2) NULL DEFAULT '0', `vactwoweeks` varchar(255) NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `invited` (`invited`), + KEY `lastupdate` (`lastupdate`), + KEY `alliance` (`alliance`), + KEY `username` (`username`(25)) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; -- @@ -1554,7 +1589,11 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%vdata` ( `starv` int(11) NULL DEFAULT '0', `starvupdate` int(11) NULL DEFAULT '0', `evasion` tinyint(1) NULL DEFAULT '0', -PRIMARY KEY (`wref`) +PRIMARY KEY (`wref`), +KEY `owner-capital-pop` (`owner`,`capital`,`pop`), +KEY `maxstore` (`maxstore`), +KEY `maxcrop` (`maxcrop`), +KEY `celebration` (`celebration`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1607,8 +1646,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%password` ( -- CREATE TABLE IF NOT EXISTS `%PREFIX%ww_attacks` ( - `vid` int(25) NULL, - `attack_time` int(25) NULL + `vid` int(25) DEFAULT NULL, + `attack_time` int(11) DEFAULT NULL, + KEY `attack_time` (`attack_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- From 9a3aff2efe0a2083ac904800ddde57fcc8dccb22 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 22:22:37 +0200 Subject: [PATCH 55/73] fix: MySQLi in MultiHunter installation step works now :P --- install/include/multihunter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/include/multihunter.php b/install/include/multihunter.php index dd7bc8bd..9ea1bf9c 100644 --- a/install/include/multihunter.php +++ b/install/include/multihunter.php @@ -6,12 +6,12 @@ $gameinstall = 1; include ("../../GameEngine/Admin/database.php"); include ("../../GameEngine/Lang/" . LANG . ".php"); - mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); - mysqli_select_db(SQL_DB); + $conn = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); + mysqli_select_db($conn, SQL_DB); if(isset($_POST['mhpw'])) { $password = $_POST['mhpw']; - mysqli_query("UPDATE " . TB_PREFIX . "users SET password = '" . md5($password) . "' WHERE username = 'Multihunter'"); + mysqli_query($conn, "UPDATE " . TB_PREFIX . "users SET password = '" . md5($password) . "' WHERE username = 'Multihunter'"); $wid = $admin->getWref(0, 0); $uid = 5; $status = $database->getVillageState($wid); From 0dffbda6201a1332cb0f2cb885d65bb5e3a02ca6 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 22:47:20 +0200 Subject: [PATCH 56/73] chore: some SQL indexes fell out of place :P --- install/data/sql.sql | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install/data/sql.sql b/install/data/sql.sql index d0e6fcb2..3b2dd9cd 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -86,11 +86,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%abdata` ( `b6` tinyint(2) NULL DEFAULT '0', `b7` tinyint(2) NULL DEFAULT '0', `b8` tinyint(2) NULL DEFAULT '0', - PRIMARY KEY (`vref`), - KEY `master` (`master`), - KEY `timestamp` (`timestamp`), - KEY `master-timestamp` (`master`,`timestamp`) USING BTREE, - KEY `wid` (`wid`) + PRIMARY KEY (`vref`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -199,7 +195,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%artefacts` ( `bad_effect` tinyint(1) NULL DEFAULT '0', `effect2` tinyint(2) NULL DEFAULT '0', `lastupdate` int(11) NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `vref-type` (`vref`,`type`), + KEY `owner-active` (`owner`,`active`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -231,9 +229,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%alidata` ( `clp` bigint(255) NULL DEFAULT '0', `oldrank` bigint(255) NULL DEFAULT '0', `forumlink` varchar(150) NULL, - PRIMARY KEY (`id`), - KEY `vref-type` (`vref`,`type`), - KEY `owner-active` (`owner`,`active`) + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -387,7 +383,11 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%bdata` ( `timestamp` int(11) NULL, `master` tinyint(1) NULL, `level` tinyint(3) NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `master` (`master`), + KEY `timestamp` (`timestamp`), + KEY `master-timestamp` (`master`,`timestamp`) USING BTREE, + KEY `wid` (`wid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- From edae50ecb47d6fb72b3237b684bbd8056ebb0d86 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 22:47:48 +0200 Subject: [PATCH 57/73] fix: removal of non-existant form field replacements --- install/process.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install/process.php b/install/process.php index 21031210..9e51aa4d 100644 --- a/install/process.php +++ b/install/process.php @@ -48,12 +48,12 @@ class Process { $text = preg_replace("'%CRANNYCAP%'", $_POST['crannycap'], $text); $text = preg_replace("'%TRAPPERCAP%'", $_POST['trappercap'], $text); $text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text); - $text = preg_replace("'%UTRACK%'", $_POST['trackusers'], $text); - $text = preg_replace("'%UTOUT%'", $_POST['timeout'], $text); - $text = preg_replace("'%AUTOD%'", $_POST['autodel'], $text); - $text = preg_replace("'%AUTODT%'", $_POST['autodeltime'], $text); + //$text = preg_replace("'%UTRACK%'", $_POST['trackusers'], $text); + //$text = preg_replace("'%UTOUT%'", $_POST['timeout'], $text); + //$text = preg_replace("'%AUTOD%'", $_POST['autodel'], $text); + //$text = preg_replace("'%AUTODT%'", $_POST['autodeltime'], $text); $text = preg_replace("'%MAX%'", $_POST['wmax'], $text); - $text = preg_replace("'%GP%'", $_POST['gpack'], $text); + //$text = preg_replace("'%GP%'", $_POST['gpack'], $text); $text = preg_replace("'%SSERVER%'", $_POST['sserver'], $text); $text = preg_replace("'%SUSER%'", $_POST['suser'], $text); $text = preg_replace("'%SPASS%'", $_POST['spass'], $text); @@ -62,7 +62,7 @@ class Process { $text = preg_replace("'%CONNECTT%'", $_POST['connectt'], $text); $text = preg_replace("'%AEMAIL%'", $_POST['aemail'], $text); $text = preg_replace("'%ANAME%'", $_POST['aname'], $text); - $text = preg_replace("'%SUBDOM%'", $_POST['subdom'], $text); + //$text = preg_replace("'%SUBDOM%'", $_POST['subdom'], $text); $text = preg_replace("'%LOGBUILD%'", $_POST['log_build'], $text); $text = preg_replace("'%LOGTECH%'", $_POST['log_tech'], $text); $text = preg_replace("'%LOGLOGIN%'", $_POST['log_login'], $text); @@ -71,9 +71,9 @@ class Process { $text = preg_replace("'%LOGWAR%'", $_POST['log_war'], $text); $text = preg_replace("'%LOGMARKET%'", $_POST['log_market'], $text); $text = preg_replace("'%LOGILLEGAL%'", $_POST['log_illegal'], $text); - $text = preg_replace("'%MINUSERLENGTH%'", $_POST['userlength'], $text); - $text = preg_replace("'%MINPASSLENGTH%'", $_POST['passlength'], $text); - $text = preg_replace("'%SPECIALCHARS%'", $_POST['specialchars'], $text); + //$text = preg_replace("'%MINUSERLENGTH%'", $_POST['userlength'], $text); + //$text = preg_replace("'%MINPASSLENGTH%'", $_POST['passlength'], $text); + //$text = preg_replace("'%SPECIALCHARS%'", $_POST['specialchars'], $text); $text = preg_replace("'%ACTIVATE%'", $_POST['activate'], $text); $text = preg_replace("'%ARANK%'", $_POST['admin_rank'], $text); $text = preg_replace("'%QUEST%'", $_POST['quest'], $text); @@ -92,7 +92,7 @@ class Process { $text = preg_replace("'%VILLAGE_EXPAND%'", $_POST['village_expand'], $text); $text = preg_replace("'%ERRORREPORT%'", $_POST['error'], $text); $text = preg_replace("'%ERROR%'", $_POST['error'], $text); - $text = preg_replace("'%GP_LOCATE%'", $_POST['gp_locate'], $text); + //$text = preg_replace("'%GP_LOCATE%'", $_POST['gp_locate'], $text); $text = preg_replace("'%PLUS_TIME%'", $_POST['plus_time'], $text); $text = preg_replace("'%PLUS_PRODUCTION%'", $_POST['plus_production'], $text); $text = preg_replace("'%MEDALINTERVAL%'", $_POST['medalinterval'], $text); From a0072e65d4ba52771c5159386e1bbd9e87edb67d Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 22:52:58 +0200 Subject: [PATCH 58/73] chore: restoration of accidentally removed oasis installation step --- install/include/oasis.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 install/include/oasis.php diff --git a/install/include/oasis.php b/install/include/oasis.php new file mode 100644 index 00000000..c30d8c3e --- /dev/null +++ b/install/include/oasis.php @@ -0,0 +1,23 @@ +populateOasisdata(); + $database->populateOasis(); + $database->populateOasisUnits2(); + + + + + header("Location: ../index.php?s=6"); + +?> \ No newline at end of file From 60bd2d4059250b7be07d8d5d0afefc2b249f8df7 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:06:21 +0200 Subject: [PATCH 59/73] chore: inactive users now being auto-logged-out after 1 hour --- install/data/constant_format.tpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install/data/constant_format.tpl b/install/data/constant_format.tpl index a8bafc88..e5e240db 100644 --- a/install/data/constant_format.tpl +++ b/install/data/constant_format.tpl @@ -254,8 +254,10 @@ define("ADMIN_NAME", "%ANAME%"); ////////////////////////////////////////// define("AUTO_DEL_INACTIVE",false); // auto-delete inactive players; default = false define("UN_ACT_TIME", 3628800); // 6 weeks to consider a player inactive -define("TRACK_USR","%UTRACK%"); -define("USER_TIMEOUT","%UTOUT%"); +//define("TRACK_USR","%UTRACK%"); +//define("USER_TIMEOUT","%UTOUT%"); +define("TRACK_USR",true); // track users' being active or not +define("USER_TIMEOUT",3600); // 1 hour of no activity counts as inactivity define("ALLOW_BURST",false); define("BASIC_MAX",1); define("INNER_MAX",1); From d39220d98063b02af3178373eb11e517d455120f Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:10:54 +0200 Subject: [PATCH 60/73] fix: installation_done file creation in root works now --- install/templates/end.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/templates/end.tpl b/install/templates/end.tpl index 9c087704..047d7adb 100644 --- a/install/templates/end.tpl +++ b/install/templates/end.tpl @@ -24,7 +24,7 @@ All the files are placed. The database is created, so you can now start playing

> My TravianZ homepage <
From 5baf68465f6af3e4e4bf089965b38c917dd66145 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:14:32 +0200 Subject: [PATCH 61/73] chore: installation_done does not need to be in repo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9d89f1ad..e892e70d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ install/installation_done /.buildpath /.project /installed_*/ +/installation_done From 0f93a79a230127dd8ef6e8825d8ca52639843690 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:18:32 +0200 Subject: [PATCH 62/73] fix: database class in admin area now being loaded correctly --- GameEngine/Admin/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php index 1369be7a..5808431d 100755 --- a/GameEngine/Admin/database.php +++ b/GameEngine/Admin/database.php @@ -24,7 +24,7 @@ include_once("../GameEngine/Data/unitdata.php"); include_once("../GameEngine/Technology.php"); include_once("../GameEngine/Data/buidata.php"); } -include_once("../../GameEngine/Database.php"); +include_once("../GameEngine/Database.php"); class adm_DB { var $connection; From 399d23cefe583ba00e9cd01e09a51f113da22a9b Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:29:57 +0200 Subject: [PATCH 63/73] fix: MySQLi used in server info Admin template --- Admin/Templates/server_info.tpl | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Admin/Templates/server_info.tpl b/Admin/Templates/server_info.tpl index 76f9460b..3a2004cc 100644 --- a/Admin/Templates/server_info.tpl +++ b/Admin/Templates/server_info.tpl @@ -9,11 +9,11 @@ ## Enhanced: aggenkeech ## ################################################################################# -$tribe1 = mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users WHERE tribe = 1"); -$tribe2 = mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users WHERE tribe = 2"); -$tribe3 = mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users WHERE tribe = 3"); -$tribes = Array(mysql_num_rows($tribe1),mysql_num_rows($tribe2),mysql_num_rows($tribe3)); -$users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users")) - 1; +$tribe1 = mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM ".TB_PREFIX."users WHERE tribe = 1"); +$tribe2 = mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM ".TB_PREFIX."users WHERE tribe = 2"); +$tribe3 = mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM ".TB_PREFIX."users WHERE tribe = 3"); +$tribes = Array(mysqli_num_rows($tribe1),mysqli_num_rows($tribe2),mysqli_num_rows($tribe3)); +$users = mysqli_num_rows(mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM ".TB_PREFIX."users")) - 1; ?>

@@ -30,29 +30,29 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" Active players - + Players online Players Banned Villages settled @@ -101,8 +101,8 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" Gold Gold - - + + @@ -120,8 +120,8 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" echo ''; for($i=1; $i<11; $i++) { - $t = mysql_query("SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); - $troop = mysql_fetch_assoc($t); + $t = mysqli_query($GLOBALS["link"], "SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); + $troop = mysqli_fetch_assoc($t); echo ''.$troop['sumof'].''; } @@ -133,8 +133,8 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" echo ''; for($i=11; $i<21; $i++) { - $t = mysql_query("SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); - $troop = mysql_fetch_assoc($t); + $t = mysqli_query($GLOBALS["link"], "SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); + $troop = mysqli_fetch_assoc($t); echo ''.$troop['sumof'].''; } @@ -146,8 +146,8 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" echo ''; for($i=21; $i<31; $i++) { - $t = mysql_query("SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); - $troop = mysql_fetch_assoc($t); + $t = mysqli_query($GLOBALS["link"], "SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); + $troop = mysqli_fetch_assoc($t); echo ''.$troop['sumof'].''; } @@ -159,8 +159,8 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" echo ''; for($i=31; $i<41; $i++) { - $t = mysql_query("SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); - $troop = mysql_fetch_assoc($t); + $t = mysqli_query($GLOBALS["link"], "SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); + $troop = mysqli_fetch_assoc($t); echo ''.$troop['sumof'].''; } @@ -172,8 +172,8 @@ $users = mysql_num_rows(mysql_query("SELECT SQL_CACHE * FROM ".TB_PREFIX."users" echo ''; for($i=41; $i<51; $i++) { - $t = mysql_query("SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); - $troop = mysql_fetch_assoc($t); + $t = mysqli_query($GLOBALS["link"], "SELECT SUM(u".$i.") AS sumof FROM ".TB_PREFIX."units"); + $troop = mysqli_fetch_assoc($t); echo ''.$troop['sumof'].''; } ?> From 52ba99d2f0a3dd42130687eefbc70ccc6a086e1f Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:32:56 +0200 Subject: [PATCH 64/73] fix: Admin DB file used MySQLi --- Admin/database.php | 136 ++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/Admin/database.php b/Admin/database.php index 12012599..4986d35f 100644 --- a/Admin/database.php +++ b/Admin/database.php @@ -31,20 +31,20 @@ class adm_DB { function adm_DB(){ global $database; - $this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); + $this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); + mysqli_select_db($this->connection, SQL_DB) or die(mysqli_error()); } function Login($username,$password){ $q = "SELECT password FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER; - $result = mysql_query($q, $this->connection); - $dbarray = mysql_fetch_array($result); + $result = mysqli_query($this->connection, $q); + $dbarray = mysqli_fetch_array($result); if($dbarray['password'] == md5($password)) { - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP: ".$_SERVER['REMOTE_ADDR'].")',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP: ".$_SERVER['REMOTE_ADDR'].")',".time().")"); return true; } else { - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username $username but access was denied!',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,'X','IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username $username but access was denied!',".time().")"); return false; } } @@ -71,7 +71,7 @@ class adm_DB { } } $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } function buildingPOP($f,$lvl){ @@ -109,13 +109,13 @@ class adm_DB { } } $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } function getWref($x,$y) { $q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y"; - $result = mysql_query($q, $this->connection); - $r = mysql_fetch_array($result); + $result = mysqli_query($this->connection, $q); + $r = mysqli_fetch_array($result); return $r['id']; } @@ -126,7 +126,7 @@ class adm_DB { $status = $database->getVillageState($wid); $status = 0; if($status == 0){ - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Added new village $wid to user $uid',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Added new village $wid to user $uid',".time().")"); $database->setFieldTaken($wid); $database->addVillage($wid,$uid,'new village','0'); $database->addResourceFields($wid,$database->getVillageType($wid)); @@ -164,23 +164,23 @@ class adm_DB { if($post['clean_ware']){ $time = time(); $q = "UPDATE ".TB_PREFIX."vdata SET `wood` = '0', `clay` = '0', `iron` = '0', `crop` = '0', `lastupdate` = '$time' WHERE wref = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } } - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Punished user: ".$post['uid']." with -".$post['punish']."% population',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Punished user: ".$post['uid']." with -".$post['punish']."% population',".time().")"); } function PunishBuilding($vid,$proc,$pop){ global $database; $q = "UPDATE ".TB_PREFIX."vdata set pop = $pop where wref = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $fdata = $database->getResourceLevel($vid); for ($i = 1; $i <= 40; $i++) { if($fdata['f'.$i]>1){ $zm = ($fdata['f'.$i]/100)*$proc; if($zm < 1){$zm = 1;}else{$zm = floor($zm);} $q = "UPDATE ".TB_PREFIX."fdata SET `f$i` = '$zm' WHERE `vref` = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } } } @@ -193,7 +193,7 @@ class adm_DB { function DelUnits2($vid,$unit){ $q = "UPDATE ".TB_PREFIX."units SET `u$unit` = '0' WHERE `vref` = $vid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } function DelPlayer($uid,$pass){ @@ -205,26 +205,26 @@ class adm_DB { $this->DelVillage($villages[$i]['wref'], 1); } $q = "DELETE FROM ".TB_PREFIX."hero where uid = $uid"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $name = $database->getUserField($uid,"username",0); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user $name',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user $name',".time().")"); $q = "DELETE FROM ".TB_PREFIX."users WHERE `id` = $uid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } } function getUserActive() { $time = time() - (60*5); $q = "SELECT * FROM ".TB_PREFIX."users where timestamp > $time and username != 'support'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function CheckPass($password,$uid){ $q = "SELECT password FROM ".TB_PREFIX."users where id = '$uid' and access = ".ADMIN; - $result = mysql_query($q, $this->connection); - $dbarray = mysql_fetch_array($result); + $result = mysqli_query($this->connection, $q); + $dbarray = mysqli_fetch_array($result); if($dbarray['password'] == md5($password)) { return true; }else{ @@ -239,37 +239,37 @@ class adm_DB { }else{ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref"; } - $result = mysql_query($q, $this->connection); - if(mysql_num_rows($result) > 0){ - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village $wref',".time().")"); + $result = mysqli_query($this->connection, $q); + if(mysqli_num_rows($result) > 0){ + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village $wref',".time().")"); $database->clearExpansionSlot($wref); $q = "DELETE FROM ".TB_PREFIX."abdata where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."bdata where wid = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."market where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."odata where wref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."research where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."tdata where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."fdata where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."training where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."units where vref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."farmlist where wref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."raidlist where towref = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."movement where `from` = $wref and proc=0"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $getmovement = $database->getMovement(3,$wref,1); foreach($getmovement as $movedata) { @@ -284,11 +284,11 @@ class adm_DB { $this->returnTroops($wref); $q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); - if (mysql_affected_rows()>0) { + if (mysqli_affected_rows()>0) { $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = $wref"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $getprisoners = $database->getPrisoners($wref); foreach($getprisoners as $pris) { @@ -355,8 +355,8 @@ class adm_DB { if( intval($enforce['hero']) > 0){ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; - $result = mysql_query($q); - $hero_f=mysql_fetch_array($result); + $result = mysqli_query($q); + $hero_f=mysqli_fetch_array($result); $hero_unit=$hero_f['unit']; $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } else { @@ -471,83 +471,83 @@ class adm_DB { function DelBan($uid,$id){ global $database; $name = addslashes($database->getUserField($uid,"username",0)); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user $name',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user $name',".time().")"); $q = "UPDATE ".TB_PREFIX."users SET `access` = '".USER."' WHERE `id` = $uid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "UPDATE ".TB_PREFIX."banlist SET `active` = '0' WHERE `id` = $id;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } function AddBan($uid,$end,$reason){ global $database; $name = addslashes($database->getUserField($uid,"username",0)); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user $name',".time().")"); + mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user $name',".time().")"); $q = "UPDATE ".TB_PREFIX."users SET `access` = '0' WHERE `id` = $uid;"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); $time = time(); $admin = $_SESSION['id']; //$database->getUserField($_SESSION['username'],'id',1); $name = addslashes($database->getUserField($uid,'username',0)); $q = "INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES ($uid, '$name' , '$reason', '$time', '$end', '$admin', '1');"; - mysql_query($q, $this->connection); + mysqli_query($this->connection, $q); } function search_player($player){ $q = "SELECT id,username FROM ".TB_PREFIX."users WHERE `username` LIKE '%$player%' and username != 'support'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function search_email($email){ $q = "SELECT id,email FROM ".TB_PREFIX."users WHERE `email` LIKE '%$email%' and username != 'support'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function search_village($village){ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function search_alliance($alliance){ $q = "SELECT * FROM ".TB_PREFIX."alidata WHERE `name` LIKE '%$alliance%' or `tag` LIKE '%$alliance%' or `id` LIKE '%$alliance%'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function search_ip($ip){ $q = "SELECT * FROM ".TB_PREFIX."login_log WHERE `ip` LIKE '%$ip%'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function search_banned(){ $q = "SELECT * FROM ".TB_PREFIX."banlist where active = '1'"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } function Del_banned(){ //$q = "SELECT * FROM ".TB_PREFIX."banlist"; - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } /*************************** Function to process MYSQLi->fetch_all (Only exist in MYSQL) References: Result ***************************/ - function mysql_fetch_all($result) { + function mysqli_fetch_all($result) { $all = array(); if($result) { - while ($row = mysql_fetch_assoc($result)){ $all[] = $row; } + while ($row = mysqli_fetch_assoc($result)){ $all[] = $row; } return $all; } } function query_return($q) { - $result = mysql_query($q, $this->connection); - return $this->mysql_fetch_all($result); + $result = mysqli_query($this->connection, $q); + return $this->mysqli_fetch_all($result); } /*************************** @@ -555,7 +555,7 @@ class adm_DB { References: Query ***************************/ function query($query) { - return mysql_query($query, $this->connection); + return mysqli_query($query, $this->connection); } From cbb9d40fd0a102514c788e5d26f5d8087e9c9762 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:33:28 +0200 Subject: [PATCH 65/73] fix: correction of order of MySQLi parameters in mysqli_query() --- GameEngine/Admin/database.php | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php index 5808431d..6967bf0a 100755 --- a/GameEngine/Admin/database.php +++ b/GameEngine/Admin/database.php @@ -71,7 +71,7 @@ class adm_DB { } $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); } function recountCP($vid){ @@ -181,7 +181,7 @@ class adm_DB { $zm = ($fdata['f'.$i]/100)*$proc; if($zm < 1){$zm = 1;}else{$zm = floor($zm);} $q = "UPDATE ".TB_PREFIX."fdata SET `f$i` = '$zm' WHERE `vref` = $vid;"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); } } } @@ -218,13 +218,13 @@ class adm_DB { function getUserActive() { $time = time() - (60*5); $q = "SELECT * FROM ".TB_PREFIX."users where timestamp > $time and username != 'support'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function CheckPass($password,$uid){ $q = "SELECT password FROM ".TB_PREFIX."users where id = '$uid' and access = ".ADMIN; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); $dbarray = mysqli_fetch_array($result); if($dbarray['password'] == md5($password)) { return true; @@ -240,37 +240,37 @@ class adm_DB { }else{ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref"; } - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); if(mysqli_num_rows($result) > 0){ mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village $wref',".time().")"); $database->clearExpansionSlot($wref); $q = "DELETE FROM ".TB_PREFIX."abdata where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."bdata where wid = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."market where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."odata where wref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."research where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."tdata where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."fdata where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."training where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."units where vref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."farmlist where wref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."raidlist where towref = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "DELETE FROM ".TB_PREFIX."movement where `from` = $wref and proc=0"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $getmovement = $database->getMovement(3,$wref,1); foreach($getmovement as $movedata) { @@ -285,11 +285,11 @@ class adm_DB { $this->returnTroops($wref); $q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); if (mysqli_affected_rows()>0) { $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = $wref"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $getprisoners = $database->getPrisoners($wref); foreach($getprisoners as $pris) { @@ -318,9 +318,9 @@ class adm_DB { $name = addslashes($database->getUserField($uid,"username",0)); mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user $name',".time().")"); $q = "UPDATE ".TB_PREFIX."users SET `access` = '".USER."' WHERE `id` = $uid;"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $q = "UPDATE ".TB_PREFIX."banlist SET `active` = '0' WHERE `id` = $id;"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); } function AddBan($uid,$end,$reason){ @@ -328,53 +328,53 @@ class adm_DB { $name = addslashes($database->getUserField($uid,"username",0)); mysqli_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user $name',".time().")"); $q = "UPDATE ".TB_PREFIX."users SET `access` = '0' WHERE `id` = $uid;"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); $time = time(); $admin = $_SESSION['id']; //$database->getUserField($_SESSION['username'],'id',1); $name = addslashes($database->getUserField($uid,'username',0)); $q = "INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES ($uid, '$name' , '$reason', '$time', '$end', '$admin', '1');"; - mysqli_query($q, $this->connection); + mysqli_query($this->connection, $q); } function search_player($player){ $q = "SELECT id,username FROM ".TB_PREFIX."users WHERE `username` LIKE '%$player%' and username != 'support'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function search_email($email){ $q = "SELECT id,email FROM ".TB_PREFIX."users WHERE `email` LIKE '%$email%' and username != 'support'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function search_village($village){ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function search_alliance($alliance){ $q = "SELECT * FROM ".TB_PREFIX."alidata WHERE `name` LIKE '%$alliance%' or `tag` LIKE '%$alliance%' or `id` LIKE '%$alliance%'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function search_ip($ip){ $q = "SELECT * FROM ".TB_PREFIX."login_log WHERE `ip` LIKE '%$ip%'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function search_banned(){ $q = "SELECT * FROM ".TB_PREFIX."banlist where active = '1'"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } function Del_banned(){ //$q = "SELECT * FROM ".TB_PREFIX."banlist"; - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } @@ -391,7 +391,7 @@ class adm_DB { } function query_return($q) { - $result = mysqli_query($q, $this->connection); + $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } From 814a904343c8014f98e3da2bd81672aca55f3f19 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:56:35 +0200 Subject: [PATCH 66/73] fix: for multihunters & admins, this select can return 0 rows --- GameEngine/Ranking.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/GameEngine/Ranking.php b/GameEngine/Ranking.php index 5ce47d57..7ba8abf9 100755 --- a/GameEngine/Ranking.php +++ b/GameEngine/Ranking.php @@ -270,15 +270,17 @@ $datas[] = $row; } - foreach($datas as $result) { - $value['userid'] = $result['userid']; - $value['username'] = $result['username']; - $value['oldrank'] = $result['oldrank']; - $value['alliance'] = $result['alliance']; - $value['aname'] = $result['allitag']; - $value['totalpop'] = $result['totalpop']; - $value['totalvillage'] = $result['totalvillages']; - array_push($holder, $value); + if (count($datas)) { + foreach($datas as $result) { + $value['userid'] = $result['userid']; + $value['username'] = $result['username']; + $value['oldrank'] = $result['oldrank']; + $value['alliance'] = $result['alliance']; + $value['aname'] = $result['allitag']; + $value['totalpop'] = $result['totalpop']; + $value['totalvillage'] = $result['totalvillages']; + array_push($holder, $value); + } } $newholder = array("pad"); From 92b9a7b043de00836cdbcf5b170339603e91745e Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 28 Aug 2017 23:56:59 +0200 Subject: [PATCH 67/73] fix: a lot of MySQL calls in templates replaced by MySQLi ones --- Admin/Mods/addTroops.php | 16 +-- Admin/Mods/cp.php | 8 +- Admin/Mods/deletemedalbyuser.php | 6 +- Admin/Mods/deletemedalbyweek.php | 6 +- Admin/Mods/editUser.php | 8 +- Admin/Mods/gold.php | 8 +- Admin/Mods/gold_1.php | 8 +- Admin/Mods/medals.php | 14 +- Admin/Mods/renameVillage.php | 6 +- Admin/Mods/sendMessage.php | 6 +- Admin/Templates/Notice/all.tpl | 4 +- Admin/Templates/alliance.tpl | 30 ++--- Admin/Templates/ban_msg.tpl | 4 +- Admin/Templates/delallymedal.tpl | 24 ++-- Admin/Templates/deletion.tpl | 4 +- Admin/Templates/delmedal.tpl | 24 ++-- Admin/Templates/editAccess.tpl | 6 +- Admin/Templates/editHero.tpl | 4 +- Admin/Templates/editPassword.tpl | 2 +- Admin/Templates/inactive.tpl | 2 +- Admin/Templates/map.tpl | 2 +- Admin/Templates/notregistered.tpl | 4 +- Admin/Templates/player.tpl | 6 +- Admin/Templates/playerheroinfo.tpl | 4 +- Admin/Templates/report.tpl | 4 +- Admin/Templates/resetServer.php | 124 +++++++++--------- Admin/Templates/userillegallog.tpl | 6 +- Admin/Templates/userlogin.tpl | 6 +- Admin/Templates/villagelog.tpl | 4 +- Admin/function.php | 2 +- GameEngine/Admin/Mods/addUsers.php | 16 +-- GameEngine/Admin/Mods/additional.php | 12 +- GameEngine/Admin/Mods/cp.php | 10 +- GameEngine/Admin/Mods/delallymedal.php | 10 +- GameEngine/Admin/Mods/delallymedalbyaid.php | 10 +- GameEngine/Admin/Mods/delallymedalbyweek.php | 10 +- GameEngine/Admin/Mods/deletemedalbyuser.php | 10 +- GameEngine/Admin/Mods/deletemedalbyweek.php | 10 +- GameEngine/Admin/Mods/editAccess.php | 12 +- GameEngine/Admin/Mods/editBuildings.php | 8 +- GameEngine/Admin/Mods/editOverall.php | 12 +- GameEngine/Admin/Mods/editPassword.php | 12 +- GameEngine/Admin/Mods/editPlus.php | 16 +-- GameEngine/Admin/Mods/editProtection.php | 12 +- GameEngine/Admin/Mods/editResources.php | 12 +- GameEngine/Admin/Mods/editSitter.php | 12 +- GameEngine/Admin/Mods/editUser.php | 12 +- GameEngine/Admin/Mods/editUsername.php | 10 +- GameEngine/Admin/Mods/editVillageOwner.php | 12 +- GameEngine/Admin/Mods/editWeek.php | 12 +- GameEngine/Admin/Mods/givePlus.php | 16 +-- GameEngine/Admin/Mods/givePlusRes.php | 16 +-- GameEngine/Admin/Mods/giveResBonus.php | 10 +- GameEngine/Admin/Mods/gold.php | 10 +- GameEngine/Admin/Mods/gold_1.php | 10 +- GameEngine/Admin/Mods/mainteneceBan.php | 20 +-- .../Admin/Mods/mainteneceCleanBanData.php | 10 +- GameEngine/Admin/Mods/mainteneceResetGold.php | 10 +- GameEngine/Admin/Mods/mainteneceResetPlus.php | 10 +- .../Admin/Mods/mainteneceResetPlusBonus.php | 10 +- GameEngine/Admin/Mods/mainteneceUnban.php | 18 +-- GameEngine/Admin/Mods/medals.php | 14 +- GameEngine/Admin/Mods/natarbuildingplan.php | 20 +-- GameEngine/Admin/Mods/natarend.php | 12 +- GameEngine/Admin/Mods/recalcWH.php | 12 +- GameEngine/Admin/Mods/renameVillage.php | 10 +- GameEngine/Admin/Mods/sendMessage.php | 10 +- GameEngine/Admin/function.php | 2 +- GameEngine/Data/hunitdata.php | 4 +- Templates/Build/avaliable.tpl | 4 +- Templates/Manual/52.tpl | 8 +- Templates/text.tpl | 4 +- install/include/database.php | 16 +-- install/process.php | 2 +- winner.php | 14 +- 75 files changed, 427 insertions(+), 427 deletions(-) diff --git a/Admin/Mods/addTroops.php b/Admin/Mods/addTroops.php index 0304c294..e34d8199 100644 --- a/Admin/Mods/addTroops.php +++ b/Admin/Mods/addTroops.php @@ -13,8 +13,8 @@ include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); @@ -85,22 +85,22 @@ $u50 = $_POST['u50']; if($user['tribe'] == 1){ $q = "UPDATE ".TB_PREFIX."units SET u1 = $u1, u2 = $u2, u3 = $u3, u4 = $u4, u5 = $u5, u6 = $u6, u7 = $u7, u8 = $u8, u9 = $u9, u10 = $u10 WHERE vref = $id"; -mysql_query($q); +mysqli_query($GLOBALS["link"], $q); } else if($user['tribe'] == 2){ $q = "UPDATE ".TB_PREFIX."units SET u11 = '$u11', u12 = '$u12', u13 = '$u13', u14 = '$u14', u15 = '$u15', u16 = '$u16', u17 = '$u17', u18 = '$u18', u19 = '$u19', u20 = '$u20' WHERE vref = $id"; -mysql_query($q); +mysqli_query($GLOBALS["link"], $q); } else if($user['tribe'] == 3){ $q = "UPDATE ".TB_PREFIX."units SET u21 = '$u21', u22 = '$u22', u23 = '$u23', u24 = '$u24', u25 = '$u25', u26 = '$u26', u27 = '$u27', u28 = '$u28', u29 = '$u29', u30 = '$u30' WHERE vref = $id"; -mysql_query($q); +mysqli_query($GLOBALS["link"], $q); } else if($user['tribe'] == 4){ $q = "UPDATE ".TB_PREFIX."units SET u31 = '$u31', u32 = '$u32', u33 = '$u33', u34 = '$u34', u35 = '$u35', u36 = '$u36', u37 = '$u37', u38 = '$u38', u39 = '$u39', u40 = '$u40' WHERE vref = $id"; -mysql_query($q); +mysqli_query($GLOBALS["link"], $q); } else if($user['tribe'] == 5){ $q = "UPDATE ".TB_PREFIX."units SET u41 = '$u41', u42 = '$u42', u43 = '$u43', u44 = '$u44', u45 = '$u45', u46 = '$u46', u47 = '$u47', u48 = '$u48', u49 = '$u49', u50 = '$u50' WHERE vref = $id"; -mysql_query($q); +mysqli_query($GLOBALS["link"], $q); } -mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed troop anmount in village $id ',".time().")"); +mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed troop anmount in village $id ',".time().")"); header("Location: ../../../Admin/admin.php?p=addTroops&did=".$id."&d"); diff --git a/Admin/Mods/cp.php b/Admin/Mods/cp.php index e1dc72e7..d9dc0290 100644 --- a/Admin/Mods/cp.php +++ b/Admin/Mods/cp.php @@ -10,17 +10,17 @@ ## ## ################################################################################# include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $id = $_POST['id']; $admid = $_POST['admid']; -mysql_query("UPDATE ".TB_PREFIX."users SET cp = cp + ".$_POST['cp']." WHERE id = ".$id.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET cp = cp + ".$_POST['cp']." WHERE id = ".$id.""); $name = $database->getUserField($id,"username",0); -mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$admid,'Added ".$_POST['cp']." Cultural Points to user $name ',".time().")"); +mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$admid,'Added ".$_POST['cp']." Cultural Points to user $name ',".time().")"); header("Location: ../../../Admin/admin.php?p=player&uid=".$id."&cp=ok"); ?> \ No newline at end of file diff --git a/Admin/Mods/deletemedalbyuser.php b/Admin/Mods/deletemedalbyuser.php index 54b0e0ba..726c8810 100644 --- a/Admin/Mods/deletemedalbyuser.php +++ b/Admin/Mods/deletemedalbyuser.php @@ -10,15 +10,15 @@ ################################################################################# include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $userid = $_POST['userid']; -mysql_query("DELETE FROM ".TB_PREFIX."medal WHERE userid = ".$userid.""); +mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."medal WHERE userid = ".$userid.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$userid.""); ?> \ No newline at end of file diff --git a/Admin/Mods/deletemedalbyweek.php b/Admin/Mods/deletemedalbyweek.php index 1db8e02b..5d58b0fd 100644 --- a/Admin/Mods/deletemedalbyweek.php +++ b/Admin/Mods/deletemedalbyweek.php @@ -10,15 +10,15 @@ ################################################################################# include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $deleteweek = $_POST['medalweek']; -mysql_query("DELETE FROM ".TB_PREFIX."medal WHERE week = ".$deleteweek.""); +mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."medal WHERE week = ".$deleteweek.""); header("Location: ../../../Admin/admin.php?p=delmedal"); ?> \ No newline at end of file diff --git a/Admin/Mods/editUser.php b/Admin/Mods/editUser.php index f0e391e0..be7f051b 100644 --- a/Admin/Mods/editUser.php +++ b/Admin/Mods/editUser.php @@ -10,15 +10,15 @@ ## ## ################################################################################# include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $id = $_POST['id']; $user = $database->getUserArray($id,1); -mysql_query("UPDATE ".TB_PREFIX."users SET email = '".$_POST['email']."', tribe = ".$_POST['tribe'].", location = '".$_POST['location']."', desc1 = '".$_POST['desc1']."', `desc2` = '".$_POST['desc2']."' WHERE id = ".$_POST['id'].""); -mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed ".$user['username']."\'s profile',".time().")"); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET email = '".$_POST['email']."', tribe = ".$_POST['tribe'].", location = '".$_POST['location']."', desc1 = '".$_POST['desc1']."', `desc2` = '".$_POST['desc2']."' WHERE id = ".$_POST['id'].""); +mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed ".$user['username']."\'s profile',".time().")"); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); diff --git a/Admin/Mods/gold.php b/Admin/Mods/gold.php index fb7d379d..0b026aa5 100644 --- a/Admin/Mods/gold.php +++ b/Admin/Mods/gold.php @@ -10,8 +10,8 @@ ## ## ################################################################################# include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); @@ -19,8 +19,8 @@ $id = $_POST['id']; $gold = $_POST['gold']; $q = "UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id != '0'"; - mysql_query($q); - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$id,'Added $gold gold to all users',".time().")"); + mysqli_query($GLOBALS["link"], $q); + mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$id,'Added $gold gold to all users',".time().")"); header("Location: ../../../Admin/admin.php?p=gold&g"); diff --git a/Admin/Mods/gold_1.php b/Admin/Mods/gold_1.php index 0fec94a8..e1f20969 100644 --- a/Admin/Mods/gold_1.php +++ b/Admin/Mods/gold_1.php @@ -10,17 +10,17 @@ ## ## ################################################################################# include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $id = $_POST['id']; $admid = $_POST['admid']; -mysql_query("UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id = ".$id.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id = ".$id.""); $name = $database->getUserField($id,"username",0); -mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$admid,'Added ".$_POST['gold']." gold to user $name ',".time().")"); +mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$admid,'Added ".$_POST['gold']." gold to user $name ',".time().")"); header("Location: ../../../Admin/admin.php?p=player&uid=".$id."&g=ok"); ?> \ No newline at end of file diff --git a/Admin/Mods/medals.php b/Admin/Mods/medals.php index 573a0610..ce73b29b 100644 --- a/Admin/Mods/medals.php +++ b/Admin/Mods/medals.php @@ -11,8 +11,8 @@ include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); @@ -20,16 +20,16 @@ if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $medalid = $_POST['medalid']; $uid = $_POST['uid']; -mysql_query("DELETE FROM ".TB_PREFIX."medal WHERE id = ".$medalid.""); +mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."medal WHERE id = ".$medalid.""); -$name = mysql_query("SELECT name FROM ".TB_PREFIX."users WHERE id= ".$uid.""); -$name = mysql_result($name, 0); +$name = mysqli_query($GLOBALS["link"], "SELECT name FROM ".TB_PREFIX."users WHERE id= ".$uid.""); +$name = mysqli_result($name, 0); -mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$admid,'Deleted medal id [#".$medalid."] from the user $name ',".time().")"); +mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$admid,'Deleted medal id [#".$medalid."] from the user $name ',".time().")"); $deleteweek = $_POST['medalweek']; -mysql_query("DELETE FROM ".TB_PREFIX."medal WHERE week = ".$deleteweek.""); +mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."medal WHERE week = ".$deleteweek.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$uid.""); ?> \ No newline at end of file diff --git a/Admin/Mods/renameVillage.php b/Admin/Mods/renameVillage.php index 062675c8..85d5afc1 100644 --- a/Admin/Mods/renameVillage.php +++ b/Admin/Mods/renameVillage.php @@ -10,8 +10,8 @@ include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); @@ -20,7 +20,7 @@ $did = $_POST['did']; $name = $_POST['villagename']; $sql = "UPDATE ".TB_PREFIX."vdata SET name = '$name' WHERE wref = $did"; -mysql_query($sql); +mysqli_query($GLOBALS["link"], $sql); header("Location: ../../../Admin/admin.php?p=village&did=".$did."&name=".$name.""); ?> \ No newline at end of file diff --git a/Admin/Mods/sendMessage.php b/Admin/Mods/sendMessage.php index 51c2ee90..15affd0c 100644 --- a/Admin/Mods/sendMessage.php +++ b/Admin/Mods/sendMessage.php @@ -9,8 +9,8 @@ ################################################################################# include_once("../../GameEngine/Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); @@ -21,7 +21,7 @@ $time = time(); $query = "INSERT INTO ".TB_PREFIX."mdata (target, owner, topic, message, viewed, time) VALUES ('$uid', 1, '$topic', '$message', 0, '$time')"; -mysql_query($query); +mysqli_query($GLOBALS["link"], $query); header("Location: ../../../Admin/admin.php?p=Newmessage&uid=".$uid."&msg=ok"); ?> \ No newline at end of file diff --git a/Admin/Templates/Notice/all.tpl b/Admin/Templates/Notice/all.tpl index 2f6d3f68..0ebda1d0 100644 --- a/Admin/Templates/Notice/all.tpl +++ b/Admin/Templates/Notice/all.tpl @@ -12,8 +12,8 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att uid."'") or die(mysql_error()); - $golds = mysql_fetch_array($MyGold); + $MyGold = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error()); + $golds = mysqli_fetch_array($MyGold); $date2=strtotime("NOW"); if ($golds['plus'] <= $date2) { ?> diff --git a/Admin/Templates/alliance.tpl b/Admin/Templates/alliance.tpl index 3e1d41ac..b3bffc50 100644 --- a/Admin/Templates/alliance.tpl +++ b/Admin/Templates/alliance.tpl @@ -78,10 +78,10 @@ if($_GET['aid']) @@ -265,8 +265,8 @@ if($_GET['aid']) "; } if($row['accepted'] ==1) { $accepted = ""; } - $ally = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli2']."")); + $ally = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli2']."")); echo ' '.$ally['tag'].' @@ -300,8 +300,8 @@ if($_GET['aid']) "; } if($row['accepted'] ==1) { $accepted = ""; } - $ally = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli1']."")); + $ally = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli1']."")); echo ' '.$ally['tag'].' @@ -336,8 +336,8 @@ if($_GET['aid']) "; } if($row['accepted'] == 1) { $accepted = ""; } - $ally1 = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli1']."")); - $ally2 = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli2']."")); + $ally1 = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli1']."")); + $ally2 = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."alidata WHERE id = ".$row['alli2']."")); echo ' '.$ally1['tag'].' & '.$ally2['tag'].' diff --git a/Admin/Templates/ban_msg.tpl b/Admin/Templates/ban_msg.tpl index c9f11903..e3c5095e 100644 --- a/Admin/Templates/ban_msg.tpl +++ b/Admin/Templates/ban_msg.tpl @@ -8,8 +8,8 @@ ## ## ################################################################################# $time = time(); -$ban = mysql_query("SELECT * FROM ".TB_PREFIX."banlist WHERE `uid` = '".$session->uid."' and active = 1"); -$ban1 = mysql_fetch_array($ban); +$ban = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."banlist WHERE `uid` = '".$session->uid."' and active = 1"); +$ban1 = mysqli_fetch_array($ban); ?>


diff --git a/Admin/Templates/delallymedal.tpl b/Admin/Templates/delallymedal.tpl index d80bba8b..2315afc3 100644 --- a/Admin/Templates/delallymedal.tpl +++ b/Admin/Templates/delallymedal.tpl @@ -12,8 +12,8 @@ if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); include("../GameEngine/config.php"); $id = $_SESSION['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."allimedal"); -$nummedals = mysql_num_rows($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."allimedal"); +$nummedals = mysqli_num_rows($sql); ?> @@ -36,11 +36,11 @@ $nummedals = mysql_num_rows($sql); 0){ - $week = mysql_result($sql, 0); + $sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."allimedal"); + $tot = mysqli_num_rows($sql); + $sql = mysqli_query($GLOBALS["link"], "SELECT week FROM ".TB_PREFIX."allimedal ORDER BY week DESC LIMIT 1"); + if(mysqli_num_rows($sql) > 0){ + $week = mysqli_result($sql, 0); echo "

$week
$tot
"; }else{ echo "
0
$tot
"; @@ -75,8 +75,8 @@ $nummedals = mysql_num_rows($sql); for($j = 0; $j<$week; $j++) { $newweek = $j+1; - $sql = mysql_query("SELECT * FROM ".TB_PREFIX."allimedal WHERE week = $newweek"); - $tot = mysql_num_rows($sql); + $sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."allimedal WHERE week = $newweek"); + $tot = mysqli_num_rows($sql); echo " $newweek $tot @@ -111,8 +111,8 @@ $nummedals = mysql_num_rows($sql); '.$allyname.''; diff --git a/Admin/Templates/deletion.tpl b/Admin/Templates/deletion.tpl index b5ef2730..87865d10 100644 --- a/Admin/Templates/deletion.tpl +++ b/Admin/Templates/deletion.tpl @@ -50,8 +50,8 @@ if($_GET['uid']) Villages: diff --git a/Admin/Templates/delmedal.tpl b/Admin/Templates/delmedal.tpl index 34a02338..4c5e2139 100644 --- a/Admin/Templates/delmedal.tpl +++ b/Admin/Templates/delmedal.tpl @@ -13,8 +13,8 @@ if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); include("../GameEngine/config.php"); $id = $_SESSION['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."medal"); -$nummedals = mysql_num_rows($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."medal"); +$nummedals = mysqli_num_rows($sql); ?> @@ -37,11 +37,11 @@ $nummedals = mysql_num_rows($sql); 0){ - $week = mysql_result($sql, 0); + $sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."medal"); + $tot = mysqli_num_rows($sql); + $sql = mysqli_query($GLOBALS["link"], "SELECT week FROM ".TB_PREFIX."medal ORDER BY week DESC LIMIT 1"); + if(mysqli_num_rows($sql) > 0){ + $week = mysqli_result($sql, 0); echo "
$week
$tot
"; }else{ echo "
0
$tot
"; @@ -77,8 +77,8 @@ $nummedals = mysql_num_rows($sql); { $newweek = $j+1; - $sql = mysql_query("SELECT * FROM ".TB_PREFIX."medal WHERE week = $newweek"); - $tot = mysql_num_rows($sql); + $sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."medal WHERE week = $newweek"); + $tot = mysqli_num_rows($sql); echo "$newweek$tot"; } @@ -116,8 +116,8 @@ $nummedals = mysql_num_rows($sql); $username"; diff --git a/Admin/Templates/editAccess.tpl b/Admin/Templates/editAccess.tpl index 22359877..e90027c0 100644 --- a/Admin/Templates/editAccess.tpl +++ b/Admin/Templates/editAccess.tpl @@ -13,9 +13,9 @@ if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $id = $_SESSION['id']; if(isset($_GET['uid'])) { - $sql = mysql_query("SELECT access FROM ".TB_PREFIX."users WHERE id = ".$_GET['uid'].""); - $curaccess = mysql_result($sql, 0); - $player = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$id."")); + $sql = mysqli_query($GLOBALS["link"], "SELECT access FROM ".TB_PREFIX."users WHERE id = ".$_GET['uid'].""); + $curaccess = mysqli_result($sql, 0); + $player = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$id."")); ?>
diff --git a/Admin/Templates/editHero.tpl b/Admin/Templates/editHero.tpl index 85644bf2..08db5e06 100644 --- a/Admin/Templates/editHero.tpl +++ b/Admin/Templates/editHero.tpl @@ -14,8 +14,8 @@ if(isset($_GET['uid'])){ include_once("../GameEngine/Data/hero_full.php"); include_once("../GameEngine/Units.php"); $user = $database->getUserArray($id,1); - $result = mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = ".$id); - $hero_info = mysql_fetch_array($result); + $result = mysqli_query($GLOBALS["link"], "SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = ".$id); + $hero_info = mysqli_fetch_array($result); $hero = $units->Hero($id,1); $unarray = array(1=>U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33,U34,U35,U36,U37,U38,U39,U40,U41,U42,U43,U44,U45,U46,U47,U48,U49,U50,U99,U0); $utribe=($user['tribe']-1)*10; diff --git a/Admin/Templates/editPassword.tpl b/Admin/Templates/editPassword.tpl index 9bdc14a3..de2ebae3 100644 --- a/Admin/Templates/editPassword.tpl +++ b/Admin/Templates/editPassword.tpl @@ -1,7 +1,7 @@ + $user = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$_GET['uid']."")); ?> diff --git a/Admin/Templates/inactive.tpl b/Admin/Templates/inactive.tpl index e679713e..ca62378f 100644 --- a/Admin/Templates/inactive.tpl +++ b/Admin/Templates/inactive.tpl @@ -46,7 +46,7 @@ global $database; } $result = $database->query($q); - $active = $database->mysql_fetch_all($result); + $active = $database->mysqli_fetch_all($result); for ($i = 0; $i <= count($active)-1; $i++){ $uid = $database->getUserField($active[$i]['username'],'id',1); $varray = $database->getProfileVillages($uid); diff --git a/Admin/Templates/map.tpl b/Admin/Templates/map.tpl index 2e654c17..a6a6f198 100644 --- a/Admin/Templates/map.tpl +++ b/Admin/Templates/map.tpl @@ -68,7 +68,7 @@ if ($check1=="" && $check2=="") {$criteria="WHERE tribe=0)";} $player_info=$database->query_return($q); foreach($player_info as $p_array) { $p_name=$p_array['username']; - $p_village=mysql_real_escape_string($p_array['name']); + $p_village=mysqli_real_escape_string($GLOBALS["link"], $p_array['name']); $p_coor="(".$p_array['x']."|".$p_array['y'].")"; $p_pop=$p_array['pop']; $p_tribe=$array_tribe[$p_array['tribe']]; diff --git a/Admin/Templates/notregistered.tpl b/Admin/Templates/notregistered.tpl index 505e5675..51f8516e 100644 --- a/Admin/Templates/notregistered.tpl +++ b/Admin/Templates/notregistered.tpl @@ -17,8 +17,8 @@ @@ -74,8 +74,8 @@ if(isset($id)) diff --git a/Admin/Templates/playerheroinfo.tpl b/Admin/Templates/playerheroinfo.tpl index 6d0175da..d29f7838 100644 --- a/Admin/Templates/playerheroinfo.tpl +++ b/Admin/Templates/playerheroinfo.tpl @@ -12,8 +12,8 @@ include_once("../GameEngine/Data/hero_full.php"); include_once("../GameEngine/Units.php"); $id=$user['id']; -$hero = mysql_query("SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = ".$id); -$hero_info = mysql_fetch_array($hero); +$hero = mysqli_query($GLOBALS["link"], "SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = ".$id); +$hero_info = mysqli_fetch_array($hero); if (!empty($hero_info)) { $hero = $units->Hero($id,1); }else { diff --git a/Admin/Templates/report.tpl b/Admin/Templates/report.tpl index d980e11b..657d4c8e 100644 --- a/Admin/Templates/report.tpl +++ b/Admin/Templates/report.tpl @@ -15,8 +15,8 @@ if ($_GET['bid']){ $rep = $database->getNotice4($_GET['bid']); }else $sql = "SELECT * FROM ".TB_PREFIX."ndata ORDER BY time DESC "; -$result = mysql_query($sql); -$rep1 = $database->mysql_fetch_all($result); +$result = mysqli_query($GLOBALS["link"], $sql); +$rep1 = $database->mysqli_fetch_all($result); if($rep1) { //$att = $database->getUserArray($rep1['uid'],1); diff --git a/Admin/Templates/resetServer.php b/Admin/Templates/resetServer.php index 04f7c170..4114ca38 100644 --- a/Admin/Templates/resetServer.php +++ b/Admin/Templates/resetServer.php @@ -12,67 +12,67 @@ include_once("../../GameEngine/config.php"); include_once("../../GameEngine/Database.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db(SQL_DB); if (!isset($_SESSION)) { session_start(); } if($_SESSION['access'] != ADMIN) die("

Access Denied: You are not Admin!

"); set_time_limit(0); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."a2b"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."abdata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."activate"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."active"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."admin_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."alidata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."ali_invite"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."ali_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."ali_permission"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."allimedal"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."artefacts"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."attacks"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."banlist"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."bdata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."build_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."chat"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."config"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."deleting"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."demolition"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."diplomacy"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."enforcement"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."farmlist"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."fdata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."forum_cat"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."forum_edit"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."forum_post"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."forum_survey"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."forum_topic"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."general"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."gold_fin_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."hero"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."illegal_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."links"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."login_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."market"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."market_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."mdata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."medal"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."movement"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."ndata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."online"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."password"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."prisoners"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."raidlist"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."research"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."route"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."send"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."tdata"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."tech_log"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."training"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."units"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."a2b"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."abdata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."activate"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."active"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."admin_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."alidata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ali_invite"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ali_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ali_permission"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."allimedal"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."artefacts"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."attacks"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."banlist"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."bdata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."build_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."chat"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."config"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."deleting"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."demolition"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."diplomacy"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."enforcement"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."farmlist"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."fdata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."forum_cat"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."forum_edit"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."forum_post"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."forum_survey"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."forum_topic"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."general"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."gold_fin_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."hero"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."illegal_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."links"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."login_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."market"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."market_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."mdata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."medal"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."movement"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ndata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."online"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."password"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."prisoners"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."raidlist"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."research"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."route"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."send"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."tdata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."tech_log"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."training"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."units"); $time=time(); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."odata"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."odata"); $database->populateOasisdata(); $database->populateOasis(); @@ -80,21 +80,21 @@ $database->populateOasisUnits2(); $uid=$database->getVillageID(5); $passw=md5('123456'); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."users"); -mysql_query("INSERT INTO ".TB_PREFIX."users (id, username, password, email, tribe, access, gold, gender, birthday, location, desc1, desc2, plus, b1, b2, b3, b4, sit1, sit2, alliance, sessid, act, timestamp, ap, apall, dp, dpall, protect, quest, gpack, cp, lastupdate, RR, Rc, ok) VALUES +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."users"); +mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."users (id, username, password, email, tribe, access, gold, gender, birthday, location, desc1, desc2, plus, b1, b2, b3, b4, sit1, sit2, alliance, sessid, act, timestamp, ap, apall, dp, dpall, protect, quest, gpack, cp, lastupdate, RR, Rc, ok) VALUES (5, 'Multihunter', '".$passw."', 'multihunter@travianx.mail', 0, 9, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), (1, 'Support', '', 'support@travianx.mail', 0, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), (2, 'Nature', '', 'support@travianx.mail', 4, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), (4, 'Taskmaster', '', 'support@travianx.mail', 0, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0)"); -mysql_query("INSERT INTO ".TB_PREFIX."units (vref) VALUES ($uid)"); -mysql_query("INSERT INTO ".TB_PREFIX."tdata (vref) VALUES ($uid)"); +mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."units (vref) VALUES ($uid)"); +mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."tdata (vref) VALUES ($uid)"); -mysql_query("INSERT INTO ".TB_PREFIX."fdata (vref, f1t, f2t, f3t, f4t, f5t, f6t, f7t, f8t, f9t, f10t, f11t, f12t, f13t, f14t, f15t, f16t, f17t, f18t, f26, f26t, wwname) VALUES ($uid, '1', '4', '1', '3', '2', '2', '3', '4', '4', '3', '3', '4', '4', '1', '4', '2', '1', '2', '1', '15', 'World Wonder')"); +mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."fdata (vref, f1t, f2t, f3t, f4t, f5t, f6t, f7t, f8t, f9t, f10t, f11t, f12t, f13t, f14t, f15t, f16t, f17t, f18t, f26, f26t, wwname) VALUES ($uid, '1', '4', '1', '3', '2', '2', '3', '4', '4', '3', '3', '4', '4', '1', '4', '2', '1', '2', '1', '15', 'World Wonder')"); -mysql_query("DELETE FROM ".TB_PREFIX."vdata WHERE owner<>5"); -mysql_query("UPDATE ".TB_PREFIX."wdata SET occupied=0 WHERE id<>$uid"); -mysql_query("TRUNCATE TABLE ".TB_PREFIX."ww_attacks"); +mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."vdata WHERE owner<>5"); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."wdata SET occupied=0 WHERE id<>$uid"); +mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ww_attacks"); header("Location: ../admin.php?p=resetdone"); ?> diff --git a/Admin/Templates/userillegallog.tpl b/Admin/Templates/userillegallog.tpl index 47085fcb..31e26459 100644 --- a/Admin/Templates/userillegallog.tpl +++ b/Admin/Templates/userillegallog.tpl @@ -2,7 +2,7 @@ $id = $_GET['uid']; if(isset($id)) { - $player = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = $id")); + $player = mysqli_fetch_assoc(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = $id")); ?>
@@ -18,8 +18,8 @@ if(isset($id))
@@ -18,8 +18,8 @@ if(isset($id)) query("SELECT * FROM ".TB_PREFIX."hero WHERE uid='".$get['uid']."'"); - $hdata=mysql_fetch_array($result); + $hdata=mysqli_fetch_array($result); $database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".$hdata['wref']); $database->query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".time()." WHERE `uid` = '".$get['uid']."'"); header("Location: admin.php?p=player&uid=".$get['uid']."&rc=1"); diff --git a/GameEngine/Admin/Mods/addUsers.php b/GameEngine/Admin/Mods/addUsers.php index 53e2f634..c131c2c8 100755 --- a/GameEngine/Admin/Mods/addUsers.php +++ b/GameEngine/Admin/Mods/addUsers.php @@ -11,8 +11,8 @@ include_once("../../config.php"); include_once("../../Session.php"); include_once("../../Automation.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $wgarray=array(1=>1200,1700,2300,3100,4000,5000,6300,7800,9600,11800,14400,17600,21400,25900,31300,37900,45700,55100,66400,80000); @@ -102,7 +102,7 @@ else // Need a $database function for this // (assuming we don't already have one as creating Natars also updates this way) $q = "UPDATE " . TB_PREFIX . "users SET desc2 = '[#0]' WHERE id = $uid"; - mysql_query($q) or die(mysql_error()); + mysqli_query($GLOBALS["link"], $q) or die(mysqli_error()); if (!$beginnersProtection) { @@ -111,9 +111,9 @@ else // also used in editProtection.php so assuming no function // already exists $protection = time(); - mysql_query("UPDATE ".TB_PREFIX."users SET + mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET protect = '".$protection."' -WHERE id = $uid") or die(mysql_error()); +WHERE id = $uid") or die(mysqli_error()); } $database->updateUserField($uid,"act","",1); @@ -129,9 +129,9 @@ WHERE id = $uid") or die(mysql_error()); //insert village with all resource and building with random level $time = time(); $q = "INSERT INTO ".TB_PREFIX."vdata (`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values ('$wid','$uid','".$userName."\'s village',1,200,1,0,0,$rand_resource,$rand_resource,$rand_resource,$cap_storage,$rand_resource,$cap_storage,$time,100,0,0,0,$time)"; - mysql_query($q) or die(mysql_error()); + mysqli_query($GLOBALS["link"], $q) or die(mysqli_error()); $q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid ,".rand(5,10).",1,".rand(5,10).",4,".rand(5,10).",1,".rand(5,10).",3,".rand(5,10).",2,".rand(5,10).",2,".rand(5,10).",3,".rand(5,10).",4,".rand(5,10).",4,".rand(5,10).",3,".rand(5,10).",3,".rand(5,10).",4,".rand(5,10).",4,".rand(5,10).",1,".rand(5,10).",4,".rand(5,10).",2,".rand(5,10).",1,".rand(5,10).",2,".rand(2,5).",8,".rand(5,20).",37,".rand(10,20).",26,".rand(10,20).",22,".rand(10,20).",19,".rand(2,5).",9,$level_storage,11,".rand(10,20).",15,".rand(10,20).",20,0,0,".rand(10,15).",17,$level_storage,10,".rand(5,10).",12,0,0,10,23,0,0,0,0,0,0,0,0,".rand(5,10).",18,".rand(5,10).",16,0,0,0,0,'World Wonder')"; - mysql_query($q); + mysqli_query($GLOBALS["link"], $q); $pop = $automation->recountPop($wid); $cp = $automation->recountPop($wid); $database->addUnits($wid); @@ -141,7 +141,7 @@ WHERE id = $uid") or die(mysql_error()); //insert units randomly generate the number of troops $q = "UPDATE " . TB_PREFIX . "units SET u".(($tribe-1)*10+1)." = ".rand(100, 2000).", u".(($tribe-1)*10+2)." = ".rand(100, 2400).", u".(($tribe-1)*10+3)." = ".rand(100, 1600).", u".(($tribe-1)*10+4)." = ".rand(100, 1500).", u".(($tribe-1)*10+5)." = " .rand(48, 1700).", u".(($tribe-1)*10+6)." = ".rand(60, 1800)." WHERE vref = '".$wid."'"; - mysql_query($q); + mysqli_query($GLOBALS["link"], $q); $created ++; diff --git a/GameEngine/Admin/Mods/additional.php b/GameEngine/Admin/Mods/additional.php index 914418f8..673cd9d1 100755 --- a/GameEngine/Admin/Mods/additional.php +++ b/GameEngine/Admin/Mods/additional.php @@ -11,14 +11,14 @@ include_once("../../config.php"); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $id = $_POST['id']; $admid = $_POST['admid']; -//$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$admid.""); -//$access = mysql_fetch_array($sql); +//$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$admid.""); +//$access = mysqli_fetch_array($sql); //$sessionaccess = $access['access']; if (!isset($_SESSION)) { session_start(); @@ -30,7 +30,7 @@ $access = $_POST['access']; $dur = $_POST['protect'] * 86400; $protection = (time() + $dur); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET access = ".$access.", gold = ".$_POST['gold'].", sit1 = '".$_POST['sitter1']."', @@ -42,7 +42,7 @@ mysql_query("UPDATE ".TB_PREFIX."users SET RR = '".$_POST['res']."', apall = '".$_POST['ooff']."', dpall = '".$_POST['odef']."' - WHERE id = ".$id."") or die(mysql_error()); + WHERE id = ".$id."") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/cp.php b/GameEngine/Admin/Mods/cp.php index 8955efd0..2e496929 100755 --- a/GameEngine/Admin/Mods/cp.php +++ b/GameEngine/Admin/Mods/cp.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $id = $_POST['id']; $admid = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$admid.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$admid.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET cp = cp + ".$_POST['cp']." WHERE id = ".$id.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET cp = cp + ".$_POST['cp']." WHERE id = ".$id.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/delallymedal.php b/GameEngine/Admin/Mods/delallymedal.php index 8ac886fc..c5ae8d4a 100755 --- a/GameEngine/Admin/Mods/delallymedal.php +++ b/GameEngine/Admin/Mods/delallymedal.php @@ -12,20 +12,20 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $delete = $_POST['medalid']; $aid = $_POST['aid']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."allimedal set del = 1 WHERE id = ".$delete.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."allimedal set del = 1 WHERE id = ".$delete.""); header("Location: ../../../Admin/admin.php?p=alliance&aid=".$aid.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/delallymedalbyaid.php b/GameEngine/Admin/Mods/delallymedalbyaid.php index 7160a3d6..817200f3 100755 --- a/GameEngine/Admin/Mods/delallymedalbyaid.php +++ b/GameEngine/Admin/Mods/delallymedalbyaid.php @@ -12,20 +12,20 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $allyid = $_POST['allyid']; $aid = $_POST['aid']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."allimedal set del = 1 WHERE allyid = ".$aid.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."allimedal set del = 1 WHERE allyid = ".$aid.""); header("Location: ../../../Admin/admin.php?p=alliance&aid=".$aid.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/delallymedalbyweek.php b/GameEngine/Admin/Mods/delallymedalbyweek.php index 3605fc08..57cb331c 100755 --- a/GameEngine/Admin/Mods/delallymedalbyweek.php +++ b/GameEngine/Admin/Mods/delallymedalbyweek.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $deleteweek = $_POST['deleteweek']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."allimedal set del = 1 WHERE week = ".$deleteweek.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."allimedal set del = 1 WHERE week = ".$deleteweek.""); header("Location: ../../../Admin/admin.php?p=delallymedal"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/deletemedalbyuser.php b/GameEngine/Admin/Mods/deletemedalbyuser.php index aba4f3c3..020aa9d1 100755 --- a/GameEngine/Admin/Mods/deletemedalbyuser.php +++ b/GameEngine/Admin/Mods/deletemedalbyuser.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $userid = $_POST['userid']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."medal set del = 1 WHERE userid = ".$userid.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."medal set del = 1 WHERE userid = ".$userid.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$userid.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/deletemedalbyweek.php b/GameEngine/Admin/Mods/deletemedalbyweek.php index 018fbf23..cb6d55fe 100755 --- a/GameEngine/Admin/Mods/deletemedalbyweek.php +++ b/GameEngine/Admin/Mods/deletemedalbyweek.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $deleteweek = $_POST['medalweek']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."medal set del = 1 WHERE week = ".$deleteweek.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."medal set del = 1 WHERE week = ".$deleteweek.""); header("Location: ../../../Admin/admin.php?p=delmedal"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editAccess.php b/GameEngine/Admin/Mods/editAccess.php index ec834cbf..9cdb998b 100755 --- a/GameEngine/Admin/Mods/editAccess.php +++ b/GameEngine/Admin/Mods/editAccess.php @@ -12,23 +12,23 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['uid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $access = $_POST['access']; -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET access = ".$access." - WHERE id = ".$id."") or die(mysql_error()); + WHERE id = ".$id."") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editBuildings.php b/GameEngine/Admin/Mods/editBuildings.php index 428b8a2b..7680a8df 100755 --- a/GameEngine/Admin/Mods/editBuildings.php +++ b/GameEngine/Admin/Mods/editBuildings.php @@ -15,12 +15,12 @@ if($_SESSION['access'] < 9) die("

Access Denied: You are include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $id = $_POST['id']; -mysql_query("UPDATE ".TB_PREFIX."fdata SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."fdata SET f1 = '".$_POST['id1level']."', f1t = '".$_POST['id1gid']."', f2 = '".$_POST['id2level']."', @@ -101,7 +101,7 @@ mysql_query("UPDATE ".TB_PREFIX."fdata SET f39t = '".$_POST['id39gid']."', f40 = '".$_POST['id40level']."', f40t = '".$_POST['id40gid']."' - WHERE vref = $id") or die(mysql_error()); + WHERE vref = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=village&did=".$id.""); ?> diff --git a/GameEngine/Admin/Mods/editOverall.php b/GameEngine/Admin/Mods/editOverall.php index 4331cc5f..c8616341 100755 --- a/GameEngine/Admin/Mods/editOverall.php +++ b/GameEngine/Admin/Mods/editOverall.php @@ -12,22 +12,22 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET apall = '".$_POST['off']."', dpall = '".$_POST['def']."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editPassword.php b/GameEngine/Admin/Mods/editPassword.php index 98aec328..fe90213d 100755 --- a/GameEngine/Admin/Mods/editPassword.php +++ b/GameEngine/Admin/Mods/editPassword.php @@ -12,22 +12,22 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['uid']; $pass = md5($_POST['newpw']); -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET password = '".$pass."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editPlus.php b/GameEngine/Admin/Mods/editPlus.php index 51ca0a09..e63a329b 100755 --- a/GameEngine/Admin/Mods/editPlus.php +++ b/GameEngine/Admin/Mods/editPlus.php @@ -12,14 +12,14 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); @@ -30,8 +30,8 @@ $b2dur = $_POST['clay'] * 86400; $b3dur = $_POST['iron'] * 86400; $b4dur = $_POST['crop'] * 86400; -$sql1 = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$id.""); -$user = mysql_fetch_array($sql1); +$sql1 = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$id.""); +$user = mysqli_fetch_array($sql1); if($user['plus'] < time()){ if($pdur > 1){ $plus = (time() + $pdur); } else { $plus = time(); } @@ -59,13 +59,13 @@ if($b4dur > 1){ $crop = (time() + $b4dur); } else { $crop = time(); } if($b4dur > 1){ $crop = ($user['b4'] + $b4dur); } else { $crop = $user['b4']; } } -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET plus = '".$plus."', b1 = '".$wood."', b2 = '".$clay."', b3 = '".$iron."', b4 = '".$crop."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editProtection.php b/GameEngine/Admin/Mods/editProtection.php index 7f2caf11..94b5ac35 100755 --- a/GameEngine/Admin/Mods/editProtection.php +++ b/GameEngine/Admin/Mods/editProtection.php @@ -12,14 +12,14 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); @@ -27,9 +27,9 @@ if($sessionaccess != 9) die("

Access Denied: You are not $dur = $_POST['protect'] * 86400; $protection = (time() + $dur); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET protect = '".$protection."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editResources.php b/GameEngine/Admin/Mods/editResources.php index 28784775..868ea4bc 100755 --- a/GameEngine/Admin/Mods/editResources.php +++ b/GameEngine/Admin/Mods/editResources.php @@ -12,26 +12,26 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['did']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."vdata SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."vdata SET wood = '".$_POST['wood']."', clay = '".$_POST['clay']."', iron = '".$_POST['iron']."', crop = '".$_POST['crop']."', maxstore = '".$_POST['maxstore']."', maxcrop = '".$_POST['maxcrop']."' - WHERE wref = '".$id."'") or die(mysql_error()); + WHERE wref = '".$id."'") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=village&did=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editSitter.php b/GameEngine/Admin/Mods/editSitter.php index d155a2d5..44d7320b 100755 --- a/GameEngine/Admin/Mods/editSitter.php +++ b/GameEngine/Admin/Mods/editSitter.php @@ -12,22 +12,22 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET sit1 = '".$_POST['sitter1']."', sit2 = '".$_POST['sitter2']."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editUser.php b/GameEngine/Admin/Mods/editUser.php index dc37b6f0..07df4466 100755 --- a/GameEngine/Admin/Mods/editUser.php +++ b/GameEngine/Admin/Mods/editUser.php @@ -12,26 +12,26 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET email = '".$_POST['email']."', tribe = ".$_POST['tribe'].", location = '".$_POST['location']."', desc1 = '".$_POST['desc1']."', desc2 = '".$_POST['desc2']."', quest = '".$_POST['quest']."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editUsername.php b/GameEngine/Admin/Mods/editUsername.php index 742e5cfa..69876d08 100755 --- a/GameEngine/Admin/Mods/editUsername.php +++ b/GameEngine/Admin/Mods/editUsername.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $uid = $_POST['uid']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET username = '".$_POST['username']."' WHERE id = ".$uid.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET username = '".$_POST['username']."' WHERE id = ".$uid.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$uid.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editVillageOwner.php b/GameEngine/Admin/Mods/editVillageOwner.php index 12f0901b..fc2a1424 100755 --- a/GameEngine/Admin/Mods/editVillageOwner.php +++ b/GameEngine/Admin/Mods/editVillageOwner.php @@ -12,21 +12,21 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['did']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."vdata SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."vdata SET owner = '".$_POST['newowner']."' - WHERE wref = $id") or die(mysql_error()); + WHERE wref = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$_POST['newowner'].""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/editWeek.php b/GameEngine/Admin/Mods/editWeek.php index 2d5e0271..0ff224d7 100755 --- a/GameEngine/Admin/Mods/editWeek.php +++ b/GameEngine/Admin/Mods/editWeek.php @@ -12,23 +12,23 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET ap = '".$_POST['off']."', dp = '".$_POST['def']."', RR = '".$_POST['res']."' - WHERE id = $id") or die(mysql_error()); + WHERE id = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/givePlus.php b/GameEngine/Admin/Mods/givePlus.php index c21917f1..8c114de5 100755 --- a/GameEngine/Admin/Mods/givePlus.php +++ b/GameEngine/Admin/Mods/givePlus.php @@ -12,30 +12,30 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1"; -$loops = mysql_result(mysql_query($sql), 0); +$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0); $plusdur = $_POST['plus'] * 86400; for($i = 0; $i < $loops + 1; $i++) { $query = "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$i.""; - $result = mysql_query($query); - while($row = mysql_fetch_assoc($result)) + $result = mysqli_query($GLOBALS["link"], $query); + while($row = mysqli_fetch_assoc($result)) { if($row['plus'] < time()) { $plusbefore = time(); $addplus = $plusbefore + $plusdur; } elseif($row['plus'] > time()) { $plusbefore = $row['plus']; $addplus = $plusbefore + $plusdur; } - mysql_query("UPDATE ".TB_PREFIX."users SET + mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET plus = '".$addplus."' WHERE id = '".$row['id']."'"); } diff --git a/GameEngine/Admin/Mods/givePlusRes.php b/GameEngine/Admin/Mods/givePlusRes.php index 6afe55f3..d4ec10c3 100755 --- a/GameEngine/Admin/Mods/givePlusRes.php +++ b/GameEngine/Admin/Mods/givePlusRes.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1"; -$loops = mysql_result(mysql_query($sql), 0); +$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0); $wood = $_POST['wood'] * 86400; $clay = $_POST['clay'] * 86400; @@ -34,14 +34,14 @@ $crop = $_POST['crop'] * 86400; for($i = 0; $i < $loops + 1; $i++) { $query = "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$i.""; - $result = mysql_query($query); - while($row = mysql_fetch_assoc($result)) + $result = mysqli_query($GLOBALS["link"], $query); + while($row = mysqli_fetch_assoc($result)) { if($row['b1'] < time()) { $b1before = time(); $addb1 = $b1before + $wood; } elseif($row['b1'] > time()) { $b1before = $row['b1']; $addb1 = $b1before + $wood; } if($row['b2'] < time()) { $b2before = time(); $addb2 = $b1before + $clay; } elseif($row['b2'] > time()) { $b2before = $row['b2']; $addb2 = $b1before + $clay; } if($row['b3'] < time()) { $b3before = time(); $addb3 = $b1before + $iron; } elseif($row['b3'] > time()) { $b3before = $row['b3']; $addb3 = $b1before + $iron; } if($row['b4'] < time()) { $b4before = time(); $addb4 = $b1before + $crop; } elseif($row['b4'] > time()) { $b4before = $row['b4']; $addb4 = $b1before + $crop; } - mysql_query("UPDATE ".TB_PREFIX."users SET + mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET b1 = '".$addb1."', b2 = '".$addb2."', b3 = '".$addb3."', diff --git a/GameEngine/Admin/Mods/giveResBonus.php b/GameEngine/Admin/Mods/giveResBonus.php index e674b9d1..25355534 100755 --- a/GameEngine/Admin/Mods/giveResBonus.php +++ b/GameEngine/Admin/Mods/giveResBonus.php @@ -14,19 +14,19 @@ include_once("../../config.php"); error_reporting(E_ALL); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $q = "UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id != '0'"; -mysql_query($q) or die(mysql_error()); +mysqli_query($GLOBALS["link"], $q) or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=maintenenceResetPlusBonus&g"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/gold.php b/GameEngine/Admin/Mods/gold.php index 56a95dca..8a9a105f 100755 --- a/GameEngine/Admin/Mods/gold.php +++ b/GameEngine/Admin/Mods/gold.php @@ -14,19 +14,19 @@ include_once("../../config.php"); error_reporting(E_ALL); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $q = "UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id != '0'"; -mysql_query($q) or die(mysql_error()); +mysqli_query($GLOBALS["link"], $q) or die(mysqli_error()); header("Location: ../../../Admin/admin.php?p=gold&g"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/gold_1.php b/GameEngine/Admin/Mods/gold_1.php index accb1869..1599b3a9 100755 --- a/GameEngine/Admin/Mods/gold_1.php +++ b/GameEngine/Admin/Mods/gold_1.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id = ".$id.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id = ".$id.""); header("Location: ../../../Admin/admin.php?p=usergold&g"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/mainteneceBan.php b/GameEngine/Admin/Mods/mainteneceBan.php index a2cae567..ffe750f9 100755 --- a/GameEngine/Admin/Mods/mainteneceBan.php +++ b/GameEngine/Admin/Mods/mainteneceBan.php @@ -12,18 +12,18 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -$users = mysql_num_rows(mysql_query("SELECT * FROM ".TB_PREFIX."users")); +$users = mysqli_num_rows(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users")); $duration = $_POST['duration'] * 3600; $start = $_POST['start']; @@ -35,16 +35,16 @@ $active = '1'; $access = '2'; $sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1"; -$loops = mysql_result(mysql_query($sql), 0); +$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0); for($i = 0; $i < $loops + 1; $i++) { $query = "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$i." AND access = ".$access.""; - $result = mysql_query($query); - while($row = mysql_fetch_assoc($result)) + $result = mysqli_query($GLOBALS["link"], $query); + while($row = mysqli_fetch_assoc($result)) { - mysql_query("INSERT INTO ".TB_PREFIX."banlist ".$row['id'].", ".$row['username'].", ".$reason.", ".$startts.", ".$endts.", ".$admin.", ".$active.""); - ##mysql_query("INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES (".$row['id'].", '".$row['username']."' , '$reason', '$startts', '$endts', '$admin', '1')"); + mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."banlist ".$row['id'].", ".$row['username'].", ".$reason.", ".$startts.", ".$endts.", ".$admin.", ".$active.""); + ##mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES (".$row['id'].", '".$row['username']."' , '$reason', '$startts', '$endts', '$admin', '1')"); } } diff --git a/GameEngine/Admin/Mods/mainteneceCleanBanData.php b/GameEngine/Admin/Mods/mainteneceCleanBanData.php index 3287b794..316fb7e7 100755 --- a/GameEngine/Admin/Mods/mainteneceCleanBanData.php +++ b/GameEngine/Admin/Mods/mainteneceCleanBanData.php @@ -12,18 +12,18 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("TRUNCATE ".TB_PREFIX."banlist"); +mysqli_query($GLOBALS["link"], "TRUNCATE ".TB_PREFIX."banlist"); header("Location: ../../../Admin/admin.php?p=ban"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/mainteneceResetGold.php b/GameEngine/Admin/Mods/mainteneceResetGold.php index 0e9982d0..37fe22cb 100755 --- a/GameEngine/Admin/Mods/mainteneceResetGold.php +++ b/GameEngine/Admin/Mods/mainteneceResetGold.php @@ -12,18 +12,18 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET gold = '0' WHERE id !=0"); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET gold = '0' WHERE id !=0"); header("Location: ../../../Admin/admin.php?p=maintenenceResetGold&g"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/mainteneceResetPlus.php b/GameEngine/Admin/Mods/mainteneceResetPlus.php index b27bbcdc..181d32d4 100755 --- a/GameEngine/Admin/Mods/mainteneceResetPlus.php +++ b/GameEngine/Admin/Mods/mainteneceResetPlus.php @@ -12,18 +12,18 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET plus = '0' WHERE id !=0"); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET plus = '0' WHERE id !=0"); header("Location: ../../../Admin/admin.php?p=resetPlusBonus&g"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/mainteneceResetPlusBonus.php b/GameEngine/Admin/Mods/mainteneceResetPlusBonus.php index 27915af8..c91db6d1 100755 --- a/GameEngine/Admin/Mods/mainteneceResetPlusBonus.php +++ b/GameEngine/Admin/Mods/mainteneceResetPlusBonus.php @@ -12,18 +12,18 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."users SET b1 = '0', b2 = '0', b3='0', b4='0' WHERE id !=0"); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET b1 = '0', b2 = '0', b3='0', b4='0' WHERE id !=0"); header("Location: ../../../Admin/admin.php?p=givePlus&g"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/mainteneceUnban.php b/GameEngine/Admin/Mods/mainteneceUnban.php index cca25b97..2d177889 100755 --- a/GameEngine/Admin/Mods/mainteneceUnban.php +++ b/GameEngine/Admin/Mods/mainteneceUnban.php @@ -12,18 +12,18 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -$users = mysql_num_rows(mysql_query("SELECT * FROM ".TB_PREFIX."users")); +$users = mysqli_num_rows(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users")); $reason = $_POST['unbanreason']; $admin = $session; @@ -32,15 +32,15 @@ $access = '2'; $actualend = time(); $sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1"; -$loops = mysql_result(mysql_query($sql), 0); +$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0); for($i = 0; $i < $loops + 1; $i++) { $query = "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$i." AND access = ".$access.""; - $result = mysql_query($query); - while($row = mysql_fetch_assoc($result)) + $result = mysqli_query($GLOBALS["link"], $query); + while($row = mysqli_fetch_assoc($result)) { - mysql_query("UPDATE ".TB_PREFIX."banlist SET active = '".$active."', end = '".$actualend."' WHERE reason = '".$reason."'"); + mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."banlist SET active = '".$active."', end = '".$actualend."' WHERE reason = '".$reason."'"); } } diff --git a/GameEngine/Admin/Mods/medals.php b/GameEngine/Admin/Mods/medals.php index 9e924ac2..a9777aea 100755 --- a/GameEngine/Admin/Mods/medals.php +++ b/GameEngine/Admin/Mods/medals.php @@ -12,8 +12,8 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../Account.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); @@ -21,16 +21,16 @@ if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); $medalid = $_POST['medalid']; $uid = $_POST['uid']; -mysql_query("UPDATE ".TB_PREFIX."medal set del = 1 WHERE id = ".$medalid.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."medal set del = 1 WHERE id = ".$medalid.""); -$name = mysql_query("SELECT name FROM ".TB_PREFIX."users WHERE id= ".$uid.""); -$name = mysql_result($name, 0); +$name = mysqli_query($GLOBALS["link"], "SELECT name FROM ".TB_PREFIX."users WHERE id= ".$uid.""); +$name = mysqli_result($name, 0); -mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$admid,'Deleted medal id [#".$medalid."] from the user $name ',".time().")"); +mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$admid,'Deleted medal id [#".$medalid."] from the user $name ',".time().")"); $deleteweek = $_POST['medalweek']; -mysql_query("UPDATE ".TB_PREFIX."medal set del = 1 WHERE week = ".$deleteweek.""); +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."medal set del = 1 WHERE week = ".$deleteweek.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$uid.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/natarbuildingplan.php b/GameEngine/Admin/Mods/natarbuildingplan.php index 5836ed1b..cc41c21f 100755 --- a/GameEngine/Admin/Mods/natarbuildingplan.php +++ b/GameEngine/Admin/Mods/natarbuildingplan.php @@ -12,8 +12,8 @@ include_once("../../config.php"); include_once("../../Session.php"); include_once("../../Automation.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $id = $_POST['id']; $amt = $_POST['vill_amount']; @@ -25,9 +25,9 @@ for($i=1;$i<=$amt;$i++) { $database->setFieldTaken($wid); $time = time(); $q = "insert into ".TB_PREFIX."vdata (`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values ('$wid','3','".PLANVILLAGE."',0,0,0,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,1314968914)"; - mysql_query($q) or die(mysql_error()); + mysqli_query($GLOBALS["link"], $q) or die(mysqli_error()); $q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,10,27,20,10,10,22,10,25,0,0,20,15,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,0,'World Wonder')"; - mysql_query($q); + mysqli_query($GLOBALS["link"], $q); $pop = $automation->recountPop($wid); $cp = $automation->recountPop($wid); $database->addUnits($wid); @@ -35,7 +35,7 @@ for($i=1;$i<=$amt;$i++) { $database->addABTech($wid); $speed = NATARS_UNITS; $q = "UPDATE ".TB_PREFIX."units SET u41 = u41 + " . (1500 * $speed) . ", u42 = u42 + " . (1500 * $speed) . ", u43 = u43 + " . (1500 * $speed) . ", u44 = u44 + " . (1500 * $speed) . ", u45 = u45 + " . (1500 * $speed) . ", u46 = u46 + " . (1500 * $speed) . ", u47 = u47 + " . (1500 * $speed) . ", u48 = u48 + " . (1500 * $speed) . " , u49 = u49 + " . (1500 * $speed) . ", u50 = u50 + " . (1500 * $speed) . " WHERE vref = '".$wid."'"; - mysql_query($q); + mysqli_query($GLOBALS["link"], $q); $desc = PLAN_DESC; $database->addArtefact($wid, 3, 11, 1, PLAN, $desc, '', 'typeww.gif'); } @@ -46,13 +46,13 @@ for($i=1;$i<=$amt;$i++) { fwrite($fh, $text); $query="SELECT * FROM ".TB_PREFIX."users ORDER BY id + 0 DESC"; - $result=mysql_query($query) or die (mysql_error()); - for ($i=0; $row=mysql_fetch_row($result); $i++) { - $updateattquery = mysql_query("UPDATE ".TB_PREFIX."users SET ok = '1' WHERE id = '".$row[0]."'") - or die(mysql_error()); + $result=mysqli_query($GLOBALS["link"], $query) or die (mysqli_error()); + for ($i=0; $row=mysqli_fetch_row($result); $i++) { + $updateattquery = mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET ok = '1' WHERE id = '".$row[0]."'") + or die(mysqli_error()); } - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$id,'Added $amt WW Buildingplan Villages',".time().")"); + mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$id,'Added $amt WW Buildingplan Villages',".time().")"); header("Location: ../../../Admin/admin.php?p=natarbuildingplan&g"); diff --git a/GameEngine/Admin/Mods/natarend.php b/GameEngine/Admin/Mods/natarend.php index f89db0fd..2e3596ed 100755 --- a/GameEngine/Admin/Mods/natarend.php +++ b/GameEngine/Admin/Mods/natarend.php @@ -12,8 +12,8 @@ include_once("../../config.php"); include_once("../../Session.php"); include_once("../../Automation.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $id = $_POST['id']; $amt = $_POST['vill_amount']; @@ -26,9 +26,9 @@ for($i=1;$i<=$amt;$i++) { $database->setFieldTaken($wid); $time = time(); $q = "insert into ".TB_PREFIX."vdata (`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`,`natar`) values ('$wid','3','".WWVILLAGE."',0,0,0,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,$time,1)"; - mysql_query($q) or die(mysql_error()); + mysqli_query($GLOBALS["link"], $q) or die(mysqli_error()); $q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,20,15,20,10,10,22,10,25,0,0,0,0,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,40,'World Wonder')"; - mysql_query($q); + mysqli_query($GLOBALS["link"], $q); $pop = $automation->recountPop($wid); $cp = $automation->recountPop($wid); $database->addUnits($wid); @@ -38,11 +38,11 @@ for($i=1;$i<=$amt;$i++) { //new with random amount of troops $q = "UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(50, 1200) * $speed) . ", u42 = " . (rand(100, 1400) * $speed) . ", u43 = " . (rand(200, 1600) * $speed) . ", u44 = " . (rand(10, 50) * $speed) . ", u45 = " . (rand(48, 1700) * $speed) . ", u46 = " . (rand(60, 1800) * $speed) . ", u47 = " . (rand(200, 1600) * $speed) . ", u48 = " . (rand(40, 200) * $speed) . " , u49 = " . (rand(4, 20) * $speed) . ", u50 = " . (rand(5, 25) * $speed) . " WHERE vref = '".$wid."'"; - mysql_query($q); + mysqli_query($GLOBALS["link"], $q); } - mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$id,'Added $amt WW Villages',".time().")"); + mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,$id,'Added $amt WW Villages',".time().")"); header("Location: ../../../Admin/admin.php?p=natarend&g"); diff --git a/GameEngine/Admin/Mods/recalcWH.php b/GameEngine/Admin/Mods/recalcWH.php index 2d99ec56..f4244f36 100755 --- a/GameEngine/Admin/Mods/recalcWH.php +++ b/GameEngine/Admin/Mods/recalcWH.php @@ -12,19 +12,19 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; $id = $_POST['id']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); -mysql_query("UPDATE ".TB_PREFIX."fdata SET +mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."fdata SET f1 = '".$_POST['id1level']."', f1t = '".$_POST['id1gid']."', f2 = '".$_POST['id2level']."', @@ -105,7 +105,7 @@ mysql_query("UPDATE ".TB_PREFIX."fdata SET f39t = '".$_POST['id39gid']."', f40 = '".$_POST['id40level']."', f40t = '".$_POST['id40gid']."' - WHERE vref = $id") or die(mysql_error()); + WHERE vref = $id") or die(mysqli_error()); header("Location: ../../../Admin/admin.php?action=recountPop&did=".$id.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/renameVillage.php b/GameEngine/Admin/Mods/renameVillage.php index 392b3e9b..255520ed 100755 --- a/GameEngine/Admin/Mods/renameVillage.php +++ b/GameEngine/Admin/Mods/renameVillage.php @@ -12,21 +12,21 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $did = $_POST['did']; $name = $_POST['villagename']; $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $sql = "UPDATE ".TB_PREFIX."vdata SET name = '$name' WHERE wref = $did"; -mysql_query($sql); +mysqli_query($GLOBALS["link"], $sql); header("Location: ../../../Admin/admin.php?p=village&did=".$did."&name=".$name.""); ?> \ No newline at end of file diff --git a/GameEngine/Admin/Mods/sendMessage.php b/GameEngine/Admin/Mods/sendMessage.php index cf6e1ecb..fb3bee1b 100755 --- a/GameEngine/Admin/Mods/sendMessage.php +++ b/GameEngine/Admin/Mods/sendMessage.php @@ -12,21 +12,21 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); +$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +mysqli_select_db($GLOBALS["link"], SQL_DB); $session = $_POST['admid']; -$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); -$access = mysql_fetch_array($sql); +$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); +$access = mysqli_fetch_array($sql); $sessionaccess = $access['access']; if($sessionaccess != 9) die("

Access Denied: You are not Admin!

"); $query = "INSERT INTO ".TB_PREFIX."mdata (target, owner, topic, message, viewed, time) VALUES ('$uid', 1, '$topic', '$message', 0, '$time')"; -mysql_query($query); +mysqli_query($GLOBALS["link"], $query); header("Location: ../../../Admin/admin.php?p=Newmessage&uid=".$uid."&msg=ok"); ?> \ No newline at end of file diff --git a/GameEngine/Admin/function.php b/GameEngine/Admin/function.php index 205cee0d..7b97d5b2 100755 --- a/GameEngine/Admin/function.php +++ b/GameEngine/Admin/function.php @@ -93,7 +93,7 @@ class funct { exit; case "reviveHero": $result=$database->query("SELECT * FROM ".TB_PREFIX."hero WHERE uid='".$get['uid']."'"); - $hdata=mysql_fetch_array($result); + $hdata=mysqli_fetch_array($result); $database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".$hdata['wref']); $database->query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".time()." WHERE `uid` = '".$get['uid']."'"); header("Location: admin.php?p=player&uid=".$get['uid']."&rc=1"); diff --git a/GameEngine/Data/hunitdata.php b/GameEngine/Data/hunitdata.php index 9a81a55f..c71c3a5c 100755 --- a/GameEngine/Data/hunitdata.php +++ b/GameEngine/Data/hunitdata.php @@ -8,8 +8,8 @@ ## Copyright: TravianX (c) 2010-2011. All rights reserved. ## ## ## ################################################################################# -$getheroinfo = mysql_query("SELECT * FROM ".TB_PREFIX."hero WHERE `uid`='".$session->uid."'") or die(mysql_error()); -$heroinfo = mysql_fetch_array($getheroinfo); +$getheroinfo = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."hero WHERE `uid`='".$session->uid."'") or die(mysqli_error()); +$heroinfo = mysqli_fetch_array($getheroinfo); echo $heroinfo['attackpower']; $hero=array('atk'=>40*$heroinfo['attackpower'],'di'=>35,'dc'=>50,'wood'=>120,'clay'=>100,'iron'=>150,'crop'=>30,'pop'=>6,'speed'=>6,'time'=>1600,'cap'=>0); diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index 21f1ec5f..1354b84d 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -284,8 +284,8 @@ if($embassy == 0 || $mainbuilding >= 2 && $mainbuilding <= 4 && $village->natar $user = $session->uid; //connect to DB -//mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -//mysql_select_db(SQL_DB); +//mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); +//mysqli_select_db(SQL_DB); //loop search village user $query = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); diff --git a/Templates/Manual/52.tpl b/Templates/Manual/52.tpl index 09038553..af9ddcfb 100644 --- a/Templates/Manual/52.tpl +++ b/Templates/Manual/52.tpl @@ -2,12 +2,12 @@ $count="0"; include("GameEngine/Config.php"); - $connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $connection) or die(mysql_error()); + $connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); + mysqli_select_db(SQL_DB, $connection) or die(mysqli_error()); $q = "SELECT * FROM ".TB_PREFIX."movement where endtime < ".time()." and proc = 0"; - $result = mysql_query($q, $connection); - $count=mysql_num_rows($result); + $result = mysqli_query($GLOBALS["link"], $q, $connection); + $count=mysqli_num_rows($result); ?> diff --git a/Templates/text.tpl b/Templates/text.tpl index d7a54e19..a9a17c34 100644 --- a/Templates/text.tpl +++ b/Templates/text.tpl @@ -1,4 +1,4 @@ -', $txt); diff --git a/install/include/database.php b/install/include/database.php index cc7ce341..bae5e9e8 100644 --- a/install/include/database.php +++ b/install/include/database.php @@ -17,14 +17,14 @@ class MYSQLi_DB { return mysqli_query($this->connection, $query); } }; -class MYSQL_DB { +class mysqli_DB { var $connection; - function MYSQL_DB() { - $this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); - mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); + function mysqli_DB() { + $this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); + mysqli_select_db(SQL_DB, $this->connection) or die(mysqli_error()); } - function mysql_exec_batch ($p_query, $p_transaction_safe = true) { + function mysqli_exec_batch ($p_query, $p_transaction_safe = true) { if ($p_transaction_safe) { $p_query = 'START TRANSACTION;' . $p_query . '; COMMIT;'; }; @@ -32,7 +32,7 @@ class MYSQL_DB { foreach ($query_split as $command_line) { $command_line = trim($command_line); if ($command_line != '') { - $query_result = mysql_query($command_line); + $query_result = mysqli_query($GLOBALS["link"], $command_line); if ($query_result == 0) { break; }; @@ -42,7 +42,7 @@ class MYSQL_DB { } function query($query) { - return mysql_query($query, $this->connection); + return mysqli_query($GLOBALS["link"], $query, $this->connection); } }; @@ -50,6 +50,6 @@ if(DB_TYPE) { $database = new MYSQLi_DB; } else { - $database = new MYSQL_DB; + $database = new mysqli_DB; } ?> diff --git a/install/process.php b/install/process.php index 9e51aa4d..54782de1 100644 --- a/install/process.php +++ b/install/process.php @@ -124,7 +124,7 @@ class Process { if(DB_TYPE) { $result = $database->connection->multi_query($str); } else { - $result = $database->mysql_exec_batch($str); + $result = $database->mysqli_exec_batch($str); } if($result) { header("Location: index.php?s=3"); diff --git a/winner.php b/winner.php index edf63fca..529ba527 100644 --- a/winner.php +++ b/winner.php @@ -121,25 +121,25 @@ $q = " ## Get WW Winner Details $sql = mysqli_query($GLOBALS['link'],"SELECT vref FROM ".TB_PREFIX."fdata WHERE f99 = '100' and f99t = '40'"); - $vref = mysql_result($sql, 0); + $vref = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT name FROM ".TB_PREFIX."vdata WHERE wref = '$vref'")or die(mysqli_error()); - $winningvillagename = mysql_result($sql, 0); + $winningvillagename = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT owner FROM ".TB_PREFIX."vdata WHERE wref = '$vref'")or die(mysqli_error()); - $owner = mysql_result($sql, 0); + $owner = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT username FROM ".TB_PREFIX."users WHERE id = '$owner'")or die(mysqli_error()); - $username = mysql_result($sql, 0); + $username = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT alliance FROM ".TB_PREFIX."users WHERE id = '$owner'")or die(mysqli_error()); - $allianceid = mysql_result($sql, 0); + $allianceid = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT name, tag FROM ".TB_PREFIX."alidata WHERE id = '$allianceid'")or die(mysqli_error()); - $winningalliance = mysql_result($sql, 0); + $winningalliance = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT tag FROM ".TB_PREFIX."alidata WHERE id = '$allianceid'")or die(mysqli_error()); - $winningalliancetag = mysql_result($sql, 0); + $winningalliancetag = mysqli_result($sql, 0); $sql = mysqli_query($GLOBALS['link'],"SELECT vref FROM ".TB_PREFIX."fdata WHERE f99 = '100' and f99t = '40'"); $winner = mysqli_num_rows($sql); From a7ec4da65503ea109c9894aa2d37b76e1167b05d Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 29 Aug 2017 00:03:04 +0200 Subject: [PATCH 68/73] fix: mysqli_result() function added after conversion from MySQL adapter --- GameEngine/Admin/Mods/mainteneceBan.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GameEngine/Admin/Mods/mainteneceBan.php b/GameEngine/Admin/Mods/mainteneceBan.php index ffe750f9..c9b07a8a 100755 --- a/GameEngine/Admin/Mods/mainteneceBan.php +++ b/GameEngine/Admin/Mods/mainteneceBan.php @@ -34,6 +34,12 @@ $admin = $session; $active = '1'; $access = '2'; +function mysqli_result($res, $row, $field=0) { + $res->data_seek($row); + $datarow = $res->fetch_array(); + return $datarow[$field]; +} + $sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1"; $loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0); From 7caf6cf501a1ae4916c461cffffec2527cc8b370 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 29 Aug 2017 00:05:52 +0200 Subject: [PATCH 69/73] fix: mysqli_result() function added after conversion from MySQL adapter --- GameEngine/Admin/Mods/givePlus.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GameEngine/Admin/Mods/givePlus.php b/GameEngine/Admin/Mods/givePlus.php index 8c114de5..38e4a653 100755 --- a/GameEngine/Admin/Mods/givePlus.php +++ b/GameEngine/Admin/Mods/givePlus.php @@ -12,6 +12,12 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); +function mysqli_result($res, $row, $field=0) { + $res->data_seek($row); + $datarow = $res->fetch_array(); + return $datarow[$field]; +} + $GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); mysqli_select_db($GLOBALS["link"], SQL_DB); From ae8a552ee762c6cef791c69769d390d55a9a3180 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 29 Aug 2017 00:07:02 +0200 Subject: [PATCH 70/73] fix: mysqli_result() function added after conversion from MySQL adapter --- GameEngine/Admin/Mods/givePlusRes.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GameEngine/Admin/Mods/givePlusRes.php b/GameEngine/Admin/Mods/givePlusRes.php index d4ec10c3..a0522e56 100755 --- a/GameEngine/Admin/Mods/givePlusRes.php +++ b/GameEngine/Admin/Mods/givePlusRes.php @@ -12,6 +12,12 @@ if (!isset($_SESSION)) session_start(); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); include_once("../../config.php"); +function mysqli_result($res, $row, $field=0) { + $res->data_seek($row); + $datarow = $res->fetch_array(); + return $datarow[$field]; +} + $GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); mysqli_select_db($GLOBALS["link"], SQL_DB); From a08f329857e6d690e7b9e11bd74c27d6251aca3a Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 29 Aug 2017 00:36:53 +0200 Subject: [PATCH 71/73] chore: some readme and version change updates --- README | 14 ++++++++++---- version.php | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README b/README index 764c2248..0adb455c 100644 --- a/README +++ b/README @@ -1,16 +1,22 @@ -TravianZ Version v.8.0.0 FINAL TEST +TravianZ Version v.8.0.1, PHPv7 -Download and updates : https://github.com/Shadowss/TravianZ +Download and updates : https://github.com/martinambrus/TravianZ/ -Thank you to : Shadowss , advocaite , brainiacX , MisterX , yi12345 , ronix , Elio , and many others that make that version posible. +Thank you to : Shadowss , advocaite , brainiacX , MisterX , yi12345 , ronix , Elio , martinambrus and many others that make that version posible. -This version is same as yi12345. +This version is forked from the one of Shadowss (https://github.com/Shadowss/TravianZ). First i want to say THANKS for all who worked on that version , will find a list on Version file. TravianZ is based on TravianX v6.0.0 or TravianZ or TravianX with some grapich changes from ZravianX. +martinambrus changes: +1. PHP7 compatibility (mysql functions converted to mysqli) +2. a lot of database optimizations (not in code but in MySQL tables themselves, mostly adding indexes to speed things up) + + +Shadowss changes: 1. Modified Plus System with packages.
2. Modified in Plus System and added Account Statement.
3. Enabled Report Player in Profile. Send message to Multihunter.
diff --git a/version.php b/version.php index 98cf37ad..845b0028 100644 --- a/version.php +++ b/version.php @@ -96,6 +96,7 @@ $automation->isWinner(); 30. Armando
31. aggenkeech
32. Niko28
+33. martinambrus




From 298e6feb58fb4ce8e307fca27504d7106601dfbf Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 29 Aug 2017 10:49:36 +0200 Subject: [PATCH 72/73] fix: mysql (without the "i") class returned to its original state this got replaced by all those mysql-to-mysqli find and replace mumbo-jumbo tricks :) --- install/include/database.php | 16 ++++++++-------- install/process.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) mode change 100644 => 100755 install/include/database.php mode change 100644 => 100755 install/process.php diff --git a/install/include/database.php b/install/include/database.php old mode 100644 new mode 100755 index bae5e9e8..4e5d6daf --- a/install/include/database.php +++ b/install/include/database.php @@ -17,14 +17,14 @@ class MYSQLi_DB { return mysqli_query($this->connection, $query); } }; -class mysqli_DB { +class mysql_DB { var $connection; - function mysqli_DB() { - $this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error()); - mysqli_select_db(SQL_DB, $this->connection) or die(mysqli_error()); + function mysql_DB() { + $this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error()); + mysql_select_db(SQL_DB, $this->connection) or die(mysql_error()); } - function mysqli_exec_batch ($p_query, $p_transaction_safe = true) { + function mysql_exec_batch ($p_query, $p_transaction_safe = true) { if ($p_transaction_safe) { $p_query = 'START TRANSACTION;' . $p_query . '; COMMIT;'; }; @@ -32,7 +32,7 @@ class mysqli_DB { foreach ($query_split as $command_line) { $command_line = trim($command_line); if ($command_line != '') { - $query_result = mysqli_query($GLOBALS["link"], $command_line); + $query_result = mysql_query($command_line); if ($query_result == 0) { break; }; @@ -42,7 +42,7 @@ class mysqli_DB { } function query($query) { - return mysqli_query($GLOBALS["link"], $query, $this->connection); + return mysql_query($query, $this->connection); } }; @@ -50,6 +50,6 @@ if(DB_TYPE) { $database = new MYSQLi_DB; } else { - $database = new mysqli_DB; + $database = new mysql_DB; } ?> diff --git a/install/process.php b/install/process.php old mode 100644 new mode 100755 index 54782de1..9e51aa4d --- a/install/process.php +++ b/install/process.php @@ -124,7 +124,7 @@ class Process { if(DB_TYPE) { $result = $database->connection->multi_query($str); } else { - $result = $database->mysqli_exec_batch($str); + $result = $database->mysql_exec_batch($str); } if($result) { header("Location: index.php?s=3"); From 0d75bb2a5fa14bb5302ccf4ec0f1e4ec234a465c Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Sat, 2 Sep 2017 10:46:08 +0200 Subject: [PATCH 73/73] Update README --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 0adb455c..e961a073 100644 --- a/README +++ b/README @@ -14,6 +14,7 @@ TravianZ is based on TravianX v6.0.0 or TravianZ or TravianX with some grapich c martinambrus changes: 1. PHP7 compatibility (mysql functions converted to mysqli) 2. a lot of database optimizations (not in code but in MySQL tables themselves, mostly adding indexes to speed things up) +3. fix for a nasty JavaScript bug which was killing the browser with any number of countdown(s) running on page (even one!) Shadowss changes: