diff --git a/GameEngine/Account.php b/GameEngine/Account.php
index b730be41..816e545e 100755
--- a/GameEngine/Account.php
+++ b/GameEngine/Account.php
@@ -158,7 +158,7 @@ class Account {
{
global $database;
$q = "SELECT act, username, password, email, tribe, location FROM ".TB_PREFIX."activate where act = '".$database->escape($_POST['id'])."'";
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
$dbarray = mysqli_fetch_array($result);
if($dbarray['act'] == $_POST['id']) {
$uid = $database->register($dbarray['username'],$dbarray['password'],$dbarray['email'],$dbarray['tribe'],"");
@@ -186,7 +186,7 @@ class Account {
private function Unreg() {
global $database;
$q = "SELECT password, username FROM ".TB_PREFIX."activate where id = ".(int) $_POST['id'];
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
$dbarray = mysqli_fetch_array($result);
if(password_verify($_POST['pw'], $dbarray['password'])) {
$database->unreg($dbarray['username']);
diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
index e2b3a65f..ab47a39c 100755
--- a/GameEngine/Automation.php
+++ b/GameEngine/Automation.php
@@ -99,8 +99,9 @@ class Automation {
}
public function isWinner() {
+ global $database;
// check whether someone already built a level 100 Wonder of the World
- $q = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."fdata WHERE f99 = 100 and f99t = 40"), MYSQLI_ASSOC);
+ $q = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."fdata WHERE f99 = 100 and f99t = 40"), MYSQLI_ASSOC);
if($q['Total'] > 0)
{
header('Location: winner.php');
@@ -178,7 +179,7 @@ class Automation {
}
$this->recountCP($vid);
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
- mysqli_query($GLOBALS['link'],$q);
+ mysqli_query($database->dblink,$q);
$owner = $database->getVillageField($vid,"owner");
$this->procClimbers($owner);
@@ -201,7 +202,7 @@ class Automation {
}
$q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
- mysqli_query($GLOBALS['link'],$q);
+ mysqli_query($database->dblink,$q);
return $popTot;
@@ -669,7 +670,7 @@ class Automation {
//now can't be more than one winner if ww to level 100 is build by 2 users or more on same time
if ($indi['type'] == 40 && $indi['level'] == 100) {
- mysqli_query($GLOBALS['link'],"TRUNCATE ".TB_PREFIX."bdata");
+ mysqli_query($database->dblink,"TRUNCATE ".TB_PREFIX."bdata");
}
// TODO: find out what exactly these conditions are for
@@ -875,7 +876,7 @@ class Automation {
}
// get the capital village from the natars
- $query = mysqli_query($GLOBALS['link'],'SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysqli_error($database->dblink));
+ $query = mysqli_query($database->dblink,'SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysqli_error($database->dblink));
$row = mysqli_fetch_assoc($query);
// start the attacks
@@ -883,8 +884,8 @@ class Automation {
// -.-
$vid = (int) $vid;
- 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) . ')');
+ mysqli_query($database->dblink,'INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . $endtime . ')');
+ mysqli_query($database->dblink,'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);
@@ -896,11 +897,13 @@ class Automation {
}
private function checkWWAttacks() {
- $query = mysqli_query($GLOBALS['link'],'SELECT vid, attack_time FROM `' . TB_PREFIX . 'ww_attacks` WHERE `attack_time` <= ' . time());
+ global $database;
+
+ $query = mysqli_query($database->dblink,'SELECT vid, attack_time FROM `' . TB_PREFIX . 'ww_attacks` WHERE `attack_time` <= ' . time());
while ($row = mysqli_fetch_assoc($query))
{
// delete the attack
- $query3 = mysqli_query($GLOBALS['link'],'DELETE FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . (int) $row['vid'] . ' AND `attack_time` = ' . (int) $row['attack_time']);
+ $query3 = mysqli_query($database->dblink,'DELETE FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . (int) $row['vid'] . ' AND `attack_time` = ' . (int) $row['attack_time']);
}
}
@@ -4618,7 +4621,7 @@ class Automation {
$villunits = $unitData[$hdata['wref']];
if($hdata['trainingtime'] < time() && $hdata['inrevive'] == 1){
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $hdata['wref']."");
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $hdata['wref']."");
$columns[] = 'dead';
$columnValues[] = 0;
@@ -4637,7 +4640,7 @@ class Automation {
}
if($hdata['trainingtime'] < time() && $hdata['intraining'] == 1){
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $hdata['wref']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $hdata['wref']);
$columns[] = 'dead';
$columnValues[] = 0;
@@ -4673,7 +4676,7 @@ class Automation {
}
if (count($lastUpdateIDs)) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET lastupdate = $timeNow WHERE heroid IN(".implode(', ', $lastUpdateIDs).")");
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET lastupdate = $timeNow WHERE heroid IN(".implode(', ', $lastUpdateIDs).")");
}
}
if(file_exists("GameEngine/Prevention/updatehero.txt")) {
@@ -4685,11 +4688,11 @@ class Automation {
// by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com >
private function updateStore() {
- global $bid10, $bid38, $bid11, $bid39;
+ global $database, $bid10, $bid38, $bid11, $bid39;
- $result = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'fdata`');
+ $result = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'fdata`');
- mysqli_begin_transaction($GLOBALS['link']);
+ mysqli_begin_transaction($database->dblink);
while ($row = mysqli_fetch_assoc($result))
{
$ress = $crop = 0;
@@ -4733,9 +4736,9 @@ class Automation {
$crop = STORAGE_BASE;
}
- mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . (int) $ress . ', `maxcrop` = ' . (int) $crop . ' WHERE `wref` = ' . (int) $row['vref']);
+ mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . (int) $ress . ', `maxcrop` = ' . (int) $crop . ' WHERE `wref` = ' . (int) $row['vref']);
}
- mysqli_commit($GLOBALS['link']);
+ mysqli_commit($database->dblink);
}
private function oasisResourcesProduce() {
@@ -4771,7 +4774,7 @@ class Automation {
// continue...
foreach($array as $user) {
- $numusers = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE id = ".(int) $user['invited']), MYSQLI_ASSOC);
+ $numusers = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE id = ".(int) $user['invited']), MYSQLI_ASSOC);
if($numusers['Total'] > 0){
$varray = count($database->getProfileVillages($user['id']));
if($varray > 1){
@@ -5145,7 +5148,7 @@ class Automation {
$climbers = $ranking->getRank();
if(count($ranking->getRank()) > 0){
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
if(mysqli_num_rows($result)) {
$row=mysqli_fetch_assoc($result);
$week=($row['week']+1);
@@ -5194,7 +5197,7 @@ class Automation {
$climbers = $ranking->getRank();
if(count($ranking->getRank()) > 0){
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
if(mysqli_num_rows($result)) {
$row=mysqli_fetch_assoc($result);
$week=($row['week']+1);
@@ -5316,7 +5319,7 @@ class Automation {
public static function updateMax($leader) {
global $bid18, $database;
- $q = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM " . TB_PREFIX . "alidata where leader = ". (int) $leader), MYSQLI_ASSOC);
+ $q = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "alidata where leader = ". (int) $leader), MYSQLI_ASSOC);
if ($q['Total'] > 0) {
$villages = $database->getVillagesID2($leader);
$max = 0;
@@ -5349,13 +5352,13 @@ class Automation {
global $database,$session;
$herodata=$database->getHero($session->uid,1);
if ($herodata[0]['dead']==1){
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".(int) $session->villages[0]."");
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".(int) $session->villages[0]."");
}
if($herodata[0]['trainingtime'] <= time()) {
if($herodata[0]['trainingtime'] != 0) {
if($herodata[0]['dead'] == 0) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE heroid = " . $herodata[0]['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $session->villages[0]);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE heroid = " . $herodata[0]['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $session->villages[0]);
}
}
}
@@ -5372,7 +5375,7 @@ class Automation {
//we may give away ribbons
$giveMedal = false;
$q = "SELECT lastgavemedal FROM ".TB_PREFIX."config";
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
if($result) {
$row=mysqli_fetch_assoc($result);
$stime = strtotime(START_DATE)-strtotime(date('m/d/Y'))+strtotime(START_TIME);
@@ -5391,7 +5394,7 @@ class Automation {
//determine which week we are
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
if(mysqli_num_rows($result)) {
$row=mysqli_fetch_assoc($result);
$week=($row['week']+1);
@@ -5402,7 +5405,7 @@ class Automation {
//Do same for ally week
$q = "SELECT week FROM ".TB_PREFIX."allimedal order by week DESC LIMIT 0, 1";
- $result = mysqli_query($GLOBALS['link'],$q);
+ $result = mysqli_query($database->dblink,$q);
if(mysqli_num_rows($result)) {
$row=mysqli_fetch_assoc($result);
$allyweek=($row['week']+1);
@@ -5412,67 +5415,67 @@ class Automation {
//Attackers of the week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, ap FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, ap FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
$i=0;
while($row = mysqli_fetch_array($result)){
$i++;
$img="t2_".($i)."";
$quer="insert into ".TB_PREFIX."medal (userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", 1, ".($i).", ".(int) $week.", '".$row['ap']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Defender of the week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, dp FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, dp FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
$i=0;
while($row = mysqli_fetch_array($result)){
$i++;
$img="t3_".($i)."";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '2', ".($i).", '".(int) $week."', '".$row['dp']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Climbers of the week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, Rc FROM ".TB_PREFIX."users ORDER BY Rc DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, Rc FROM ".TB_PREFIX."users ORDER BY Rc DESC, id DESC Limit 10");
$i=0;
while($row = mysqli_fetch_array($result)){
$i++;
$img="t1_".($i)."";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '3', ".($i).", '".(int) $week."', '".$row['Rc']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Rank climbers of the week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, clp FROM ".TB_PREFIX."users ORDER BY clp DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, clp FROM ".TB_PREFIX."users ORDER BY clp DESC Limit 10");
$i=0;
while($row = mysqli_fetch_array($result)){
$i++;
$img="t6_".($i)."";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '10', ".($i).", '".(int) $week."', '".$row['clp']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Robbers of the week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, RR FROM ".TB_PREFIX."users ORDER BY RR DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, RR FROM ".TB_PREFIX."users ORDER BY RR DESC, id DESC Limit 10");
$i=0;
while($row = mysqli_fetch_array($result)){
$i++;
$img="t4_".($i)."";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '4', ".($i).", '".(int) $week."', '".$row['RR']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Part of the bonus for top 10 attack + defense out
//Top10 attackers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
//Top 10 defenders
- $result2 = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
+ $result2 = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
while($row2 = mysqli_fetch_array($result2)){
if($row['id']==$row2['id']){
$query3="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 5";
- $result3=mysqli_query($GLOBALS['link'],$query3);
+ $result3=mysqli_query($database->dblink,$query3);
$row3=mysqli_fetch_row($result3);
//Look what color the ribbon must have
@@ -5490,7 +5493,7 @@ class Automation {
break;
}
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '5', '0', '".(int) $week."', '".$tekst."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
}
@@ -5498,11 +5501,11 @@ class Automation {
//you stand for 3rd / 5th / 10th time in the top 3 strikers
//top10 attackers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 1 AND plaats<=3";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5510,29 +5513,29 @@ class Automation {
if($row1[0]=='3'){
$img="t120_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '6', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x at present as it is so 5th medal (silver)
if($row1[0]=='5'){
$img="t121_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '6', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t122_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '6', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//you stand for 3rd / 5th / 10th time in the top 10 attackers
//top10 attackers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY ap DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 1 AND plaats<=10";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5540,29 +5543,29 @@ class Automation {
if($row1[0]=='3'){
$img="t130_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '12', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t131_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '12', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t132_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '12', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 3 verdedigers
//Pak de top10 verdedigers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 2 AND plaats<=3";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5570,29 +5573,29 @@ class Automation {
if($row1[0]=='3'){
$img="t140_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '7', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t141_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '7', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t142_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '7', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 3 verdedigers
//Pak de top10 verdedigers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY dp DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 2 AND plaats<=10";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5600,30 +5603,30 @@ class Automation {
if($row1[0]=='3'){
$img="t150_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '13', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t151_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '13', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t152_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '13', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 3 klimmers
//Pak de top10 klimmers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY Rc DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY Rc DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 3 AND plaats<=3";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5631,28 +5634,28 @@ class Automation {
if($row1[0]=='3'){
$img="t100_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '8', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t101_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '8', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t102_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '8', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 3 klimmers
//Pak de top10 klimmers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY Rc DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY Rc DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 3 AND plaats<=10";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5660,29 +5663,29 @@ class Automation {
if($row1[0]=='3'){
$img="t110_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '14', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t111_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '14', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t112_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '14', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 3 klimmers
//Pak de top3 rank climbers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY clp DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY clp DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 10 AND plaats<=3";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5690,28 +5693,28 @@ class Automation {
if($row1[0]=='3'){
$img="t200_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '11', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t201_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '11', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t202_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '11', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 10klimmers
//Pak de top3 rank climbers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY clp DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY clp DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 10 AND plaats<=10";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5719,29 +5722,29 @@ class Automation {
if($row1[0]=='3'){
$img="t210_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '16', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t211_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '16', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t212_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '16', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 10 overvallers
//Pak de top10 overvallers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY RR DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY RR DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 4 AND plaats<=3";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5749,28 +5752,28 @@ class Automation {
if($row1[0]=='3'){
$img="t160_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '9', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t161_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '9', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t162_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '9', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//je staat voor 3e / 5e / 10e keer in de top 10 overvallers
//Pak de top10 overvallers
- $result = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users ORDER BY RR DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users ORDER BY RR DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
$query1="SELECT Count(*) FROM ".TB_PREFIX."medal WHERE userid=".(int) $row['id']." AND categorie = 4 AND plaats<=10";
- $result1=mysqli_query($GLOBALS['link'],$query1);
+ $result1=mysqli_query($database->dblink,$query1);
$row1=mysqli_fetch_row($result1);
@@ -5778,78 +5781,78 @@ class Automation {
if($row1[0]=='3'){
$img="t170_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '15', '0', '".(int) $week."', 'Three', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//4x in gestaan, dit is 5e dus lintje (zilver)
if($row1[0]=='5'){
$img="t171_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '15', '0', '".(int) $week."', 'Five', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//9x at present as it is so 10th medal (gold)
if($row1[0]=='10'){
$img="t172_1";
$quer="insert into ".TB_PREFIX."medal(userid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '15', '0', '".(int) $week."', 'Ten', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
//Put all true dens to 0
$query="SELECT id FROM ".TB_PREFIX."users ORDER BY id+0 DESC";
- $result=mysqli_query($GLOBALS['link'],$query);
+ $result=mysqli_query($database->dblink,$query);
$userIDs = [];
for ($i=0; $row=mysqli_fetch_row($result); $i++){
$userIDs[] = (int) $row[0];
}
if (count($userIDs)) {
- mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users SET ap=0, dp=0,Rc=0,clp=0, RR=0 WHERE id IN(".implode(', ', $userIDs).")");
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users SET ap=0, dp=0,Rc=0,clp=0, RR=0 WHERE id IN(".implode(', ', $userIDs).")");
}
//Start alliance Medals wooot
//Aanvallers v/d Week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, ap FROM ".TB_PREFIX."alidata ORDER BY ap DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, ap FROM ".TB_PREFIX."alidata ORDER BY ap DESC, id DESC Limit 10");
$i=0; while($row = mysqli_fetch_array($result)){
$i++; $img="a2_".($i)."";
$quer="insert into ".TB_PREFIX."allimedal(allyid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '1', ".($i).", '".$allyweek."', '".$row['ap']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Verdediger v/d Week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, dp FROM ".TB_PREFIX."alidata ORDER BY dp DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, dp FROM ".TB_PREFIX."alidata ORDER BY dp DESC Limit 10");
$i=0; while($row = mysqli_fetch_array($result)){
$i++; $img="a3_".($i)."";
$quer="insert into ".TB_PREFIX."allimedal(allyid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '2', ".($i).", '".$allyweek."', '".$row['dp']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Overvallers v/d Week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, RR FROM ".TB_PREFIX."alidata ORDER BY RR DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, RR FROM ".TB_PREFIX."alidata ORDER BY RR DESC, id DESC Limit 10");
$i=0; while($row = mysqli_fetch_array($result)){
$i++; $img="a4_".($i)."";
$quer="insert into ".TB_PREFIX."allimedal(allyid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '4', ".($i).", '".$allyweek."', '".$row['RR']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
//Rank climbers of the week
- $result = mysqli_query($GLOBALS['link'],"SELECT id, clp FROM ".TB_PREFIX."alidata ORDER BY clp DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT id, clp FROM ".TB_PREFIX."alidata ORDER BY clp DESC Limit 10");
$i=0; while($row = mysqli_fetch_array($result)){
$i++; $img="a1_".($i)."";
$quer="insert into ".TB_PREFIX."allimedal(allyid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '3', ".($i).", '".$allyweek."', '".$row['clp']."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
- $result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."alidata ORDER BY ap DESC, id DESC Limit 10");
+ $result = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."alidata ORDER BY ap DESC, id DESC Limit 10");
while($row = mysqli_fetch_array($result)){
//Pak de top10 verdedigers
- $result2 = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."alidata ORDER BY dp DESC, id DESC Limit 10");
+ $result2 = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."alidata ORDER BY dp DESC, id DESC Limit 10");
while($row2 = mysqli_fetch_array($result2)){
if($row['id']==$row2['id']){
$query3="SELECT Count(*) FROM ".TB_PREFIX."allimedal WHERE allyid=".(int) $row['id']." AND categorie = 5";
- $result3=mysqli_query($GLOBALS['link'],$query3);
+ $result3=mysqli_query($database->dblink,$query3);
$row3=mysqli_fetch_row($result3);
//Look what color the ribbon must have
@@ -5867,14 +5870,14 @@ class Automation {
break;
}
$quer="insert into ".TB_PREFIX."allimedal(allyid, categorie, plaats, week, points, img) values(".(int) $row['id'].", '5', '0', '".$allyweek."', '".$tekst."', '".$img."')";
- $resul=mysqli_query($GLOBALS['link'],$quer);
+ $resul=mysqli_query($database->dblink,$quer);
}
}
}
}
$query="SELECT id FROM ".TB_PREFIX."alidata ORDER BY id+0 DESC";
- $result=mysqli_query($GLOBALS['link'],$query);
+ $result=mysqli_query($database->dblink,$query);
$aliIDs = [];
for ($i=0; $row=mysqli_fetch_row($result); $i++){
@@ -5882,7 +5885,7 @@ class Automation {
}
if (count($aliIDs)) {
- mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."alidata SET ap=0, dp=0,RR=0,clp=0 WHERE id IN(".implode(', ', $aliIDs).")");
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."alidata SET ap=0, dp=0,RR=0,clp=0 WHERE id IN(".implode(', ', $aliIDs).")");
}
$q = "UPDATE ".TB_PREFIX."config SET lastgavemedal=".$time;
@@ -5931,7 +5934,7 @@ class Automation {
$effect = rand(1,6);
break;
}
- mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."artefacts SET kind = ". (int) $kind. ", bad_effect = $bad_effect, effect2 = $effect, lastupdate = $time WHERE id = ".(int) $artefact['id']);
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."artefacts SET kind = ". (int) $kind. ", bad_effect = $bad_effect, effect2 = $effect, lastupdate = $time WHERE id = ".(int) $artefact['id']);
}
}
}
diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php
index d3d17073..44df1ffc 100755
--- a/GameEngine/Battle.php
+++ b/GameEngine/Battle.php
@@ -687,7 +687,7 @@ class Battle {
if (isset($units['Att_unit']['hero']) && $units['Att_unit']['hero'] >0){
- $_result=mysqli_query($GLOBALS['link'],"select heroid, health from " . TB_PREFIX . "hero where `dead`='0' and `heroid`=".(int) $atkhero['heroid']);
+ $_result=mysqli_query($database->dblink,"select heroid, health from " . TB_PREFIX . "hero where `dead`='0' and `heroid`=".(int) $atkhero['heroid']);
$fdb = mysqli_fetch_array($_result);
$hero_id=(int) $fdb['heroid'];
$hero_health=$fdb['health'];
@@ -696,9 +696,9 @@ class Battle {
if ($hero_health<=$damage_health or $damage_health>90){
//hero die
$result['casualties_attacker']['11'] = 1;
- mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
+ mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
}else{
- mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
+ mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
}
}
unset($_result,$fdb,$hero_id,$hero_health,$damage_health);
@@ -706,7 +706,7 @@ class Battle {
if (isset($units['Def_unit']['hero']) && $units['Def_unit']['hero'] >0){
- $_result=mysqli_query($GLOBALS['link'],"select heroid, health from " . TB_PREFIX . "hero where `dead`='0' and `heroid`=".(int) $defenderhero['heroid']);
+ $_result=mysqli_query($database->dblink,"select heroid, health from " . TB_PREFIX . "hero where `dead`='0' and `heroid`=".(int) $defenderhero['heroid']);
$fdb = mysqli_fetch_array($_result);
$hero_id=(int) $fdb['heroid'];
$hero_health=$fdb['health'];
@@ -714,10 +714,10 @@ class Battle {
if ($hero_health<=$damage_health or $damage_health>90){
//hero die
$result['deadherodef'] = 1;
- mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
+ mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
}else{
$result['deadherodef'] = 0;
- mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
+ mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
}
}
unset($_result,$fdb,$hero_id,$hero_health,$damage_health);
@@ -729,7 +729,7 @@ class Battle {
if(!empty($heroarray)) { reset($heroarray); }
$battleHeroesCache[$defenders['from']] = $this->getBattleHero($database->getVillageField($defenders['from'],"owner"));
$heroarraydefender = $battleHeroesCache[$defenders['from']];
- $_result=mysqli_query($GLOBALS['link'],"select heroid, health from " . TB_PREFIX . "hero where `dead`='0' and `heroid`=".(int) $heroarraydefender['heroid']);
+ $_result=mysqli_query($database->dblink,"select heroid, health from " . TB_PREFIX . "hero where `dead`='0' and `heroid`=".(int) $heroarraydefender['heroid']);
$fdb = mysqli_fetch_array($_result);
$hero_id=(int) $fdb['heroid'];
$hero_health=$fdb['health'];
@@ -737,10 +737,10 @@ class Battle {
if ($hero_health<=$damage_health or $damage_health>90){
//hero die
$result['deadheroref'][$defenders['id']] = 1;
- mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
+ mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
}else{
$result['deadheroref'][$defenders['id']] = 0;
- mysqli_query($GLOBALS['link'],"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
+ mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
}
}
}
diff --git a/GameEngine/Chat.php b/GameEngine/Chat.php
index 178166ef..5b1437f0 100755
--- a/GameEngine/Chat.php
+++ b/GameEngine/Chat.php
@@ -363,7 +363,7 @@ if (!isset($SAJAX_INCLUDED)) {
$alliance = $database->escape($session->alliance);
$now = time();
echo $q = "INSERT into ".TB_PREFIX."chat (id_user,name,alli,date,msg) values ($id_user,'$name','$alliance','$now','$msg')";
- mysqli_query($GLOBALS['link'],$q);
+ mysqli_query($database->dblink,$q);
}
}
@@ -371,7 +371,7 @@ if (!isset($SAJAX_INCLUDED)) {
global $session,$database;
$alliance = $database->escape($session->alliance);
- $query = mysqli_query($GLOBALS['link'],"select id_user, name, date, msg from ".TB_PREFIX."chat where alli='$alliance' order by id desc limit 0,13");
+ $query = mysqli_query($database->dblink,"select id_user, name, date, msg 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/Message.php b/GameEngine/Message.php
index 731466de..d574972d 100755
--- a/GameEngine/Message.php
+++ b/GameEngine/Message.php
@@ -244,7 +244,7 @@ class Message {
for($i = 1; $i <= 10; $i++) {
if ( isset( $post[ 'n' . $i ] ) ) {
- $message1 = mysqli_query( $GLOBALS['link'], "SELECT target, owner FROM " . TB_PREFIX . "mdata where id = " . (int) $post[ 'n' . $i ] . "" );
+ $message1 = mysqli_query( $database->dblink, "SELECT target, owner FROM " . TB_PREFIX . "mdata where id = " . (int) $post[ 'n' . $i ] . "" );
$message = mysqli_fetch_array( $message1 );
if ( $message['target'] == $session->uid && $message['owner'] == $session->uid ) {
@@ -407,16 +407,16 @@ class Message {
// Vulnerability closed by Shadow
$q = "SELECT Count(*) as Total FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".(time() - 60);
- $res = mysqli_fetch_array(mysqli_query($GLOBALS['link'],$q) or die(mysqli_error($database->dblink). " query ".$q), MYSQLI_ASSOC);
+ $res = mysqli_fetch_array(mysqli_query($database->dblink,$q) or die(mysqli_error($database->dblink). " query ".$q), MYSQLI_ASSOC);
$flood = $res['Total'];
if($flood > 5)
return; //flood
// Vulnerability closed by Shadow
- $allmembersQ = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'");
+ $allmembersQ = mysqli_query($database->dblink,"SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'");
$userally = $database->getUserField($session->uid,"alliance",0);
- $permission=mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'"));
+ $permission=mysqli_fetch_array(mysqli_query($database->dblink,"SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'"));
if(WORD_CENSOR) {
$topic = $this->wordCensor($topic);
@@ -505,7 +505,7 @@ class Message {
if ($security_check) {
$q = "SELECT Count(*) as Total FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".(time() - 60);
- $res = mysqli_fetch_array(mysqli_query($GLOBALS['link'],$q) or die(mysqli_error($database->dblink). " query ".$q), MYSQLI_ASSOC);
+ $res = mysqli_fetch_array(mysqli_query($database->dblink,$q) or die(mysqli_error($database->dblink). " query ".$q), MYSQLI_ASSOC);
$flood = $res['Total'];
if($flood > 5)
return; //flood
diff --git a/GameEngine/Units.php b/GameEngine/Units.php
index 4303f5c0..95a4cb63 100755
--- a/GameEngine/Units.php
+++ b/GameEngine/Units.php
@@ -473,7 +473,7 @@ class Units {
// 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 = mysqli_fetch_array( mysqli_query( $GLOBALS['link'], "SELECT Count(*) as Total FROM " . TB_PREFIX . "fdata WHERE f99t = '40' AND vref = " . (int) $data['to_vid'] ), MYSQLI_ASSOC );
+ $q = mysqli_fetch_array( mysqli_query( $database->dblink, "SELECT Count(*) as Total FROM " . TB_PREFIX . "fdata WHERE f99t = '40' AND vref = " . (int) $data['to_vid'] ), MYSQLI_ASSOC );
$isThere = $q['Total'];
if ( $isThere > 0 ) {
$iswwvilla = 1;
@@ -575,7 +575,7 @@ class Units {
if ( $checkexist or $checkoexist ) {
$database->addMovement( 3, $village->wid, $data['to_vid'], $reference, time(), ( $time + time() ) );
if ( ( $database->hasBeginnerProtection( $village->wid ) == 1 ) && ( $checkexist ) ) {
- mysqli_query( $GLOBALS['link'], "UPDATE " . TB_PREFIX . "users SET protect = 0 WHERE id = " . (int) $session->uid );
+ mysqli_query( $database->dblink, "UPDATE " . TB_PREFIX . "users SET protect = 0 WHERE id = " . (int) $session->uid );
}
}
diff --git a/Templates/Ajax/mapscroll.tpl b/Templates/Ajax/mapscroll.tpl
index 1669d5b4..f222771e 100644
--- a/Templates/Ajax/mapscroll.tpl
+++ b/Templates/Ajax/mapscroll.tpl
@@ -84,7 +84,7 @@ $query2 = "SELECT
where ".TB_PREFIX."wdata.id IN ($maparray)
ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')";
-$result2 = mysqli_query($GLOBALS['link'],$query2) or die(mysqli_error($database->dblink));
+$result2 = mysqli_query($database->dblink,$query2) or die(mysqli_error($database->dblink));
$i=0;
//Load coor array
diff --git a/Templates/Ajax/mapscroll2.tpl b/Templates/Ajax/mapscroll2.tpl
index b8104bd6..db81d269 100644
--- a/Templates/Ajax/mapscroll2.tpl
+++ b/Templates/Ajax/mapscroll2.tpl
@@ -99,7 +99,7 @@ $query2 = "SELECT
ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')";
//echo $query2;
-$result2 = mysqli_query($GLOBALS['link'],$query2) or die(mysqli_error($database->dblink));
+$result2 = mysqli_query($database->dblink,$query2) or die(mysqli_error($database->dblink));
$i=0;
$i2=0;
diff --git a/Templates/Ajax/quest_core.tpl b/Templates/Ajax/quest_core.tpl
index 4c5b22b2..b4f8491c 100644
--- a/Templates/Ajax/quest_core.tpl
+++ b/Templates/Ajax/quest_core.tpl
@@ -80,7 +80,7 @@ if (isset($qact)){
$_SESSION['qst']= 3;
//Give Reward
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
} else {
$plus=$database->getUserField($_SESSION['username'],'plus','username');
$plus+=86400;
@@ -161,7 +161,7 @@ if (isset($qact)){
$_SESSION['qst']= 11;
//Give Reward
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error());
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$user_sanitized."'") or die(mysqli_error());
} else {
$plus=$database->getUserField($_SESSION['username'],'plus','username');
$plus+=172800;
@@ -348,7 +348,7 @@ if (isset($qact)){
$_SESSION['qst_time'] = time()+$skipp_time;
//Give Reward
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error());
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$user_sanitized."'") or die(mysqli_error());
} else {
$plus=$database->getUserField($_SESSION['username'],'plus','username');
$plus+=86400;
@@ -411,7 +411,7 @@ if (isset($qact)){
$_SESSION['qst']= 97;
//Give Reward 20 gold + 2 days plus
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error());
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$user_sanitized."'") 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 a6aa5e40..0f1868d7 100644
--- a/Templates/Ajax/quest_core25.tpl
+++ b/Templates/Ajax/quest_core25.tpl
@@ -77,7 +77,7 @@ if (isset($qact)){
$_SESSION['qst']= 3;
//Give Reward
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
} else {
$plus=$database->getUserField($_SESSION['username'],'plus','username');
$plus+=86400;
@@ -162,7 +162,7 @@ if (isset($qact)){
$_SESSION['qst']= 11;
//Give Reward
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
} else {
$plus=$database->getUserField($_SESSION['username'],'plus','username');
$plus+=172800;
@@ -330,7 +330,7 @@ if (isset($qact)){
$_SESSION['qst_time'] = time()+$skipp_time;
//Give Reward
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+86400 where `username`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
} else {
$plus=$database->getUserField($_SESSION['username'],'plus',1);
$plus+=86400;
@@ -393,7 +393,7 @@ if (isset($qact)){
$_SESSION['qst']= 97;
//Give Reward 20 gold + 2 days plus
if(!$session->plus){
- 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`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set plus = ('".mktime(date("H"),date("i"), date("s"),date("m") , date("d"), date("Y"))."')+172800 where `username`='".$user_sanitized."'") or die(mysqli_error($database->dblink));
} 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 4e1c30f0..55237888 100644
--- a/Templates/Alliance/Forum/forum_2.tpl
+++ b/Templates/Alliance/Forum/forum_2.tpl
@@ -9,13 +9,13 @@ if($session->access!=BANNED){
$displayarray = $database->getUserArray($session->uid,1);
$forumcat = $database->ForumCat(htmlspecialchars($displayarray['alliance']));
$ally = $session->alliance;
-$public = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 1"), MYSQLI_ASSOC);
+$public = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 1"), MYSQLI_ASSOC);
$public1 = $public['Total'];
-$cofederation = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 2"), MYSQLI_ASSOC);
+$cofederation = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 2"), MYSQLI_ASSOC);
$cofederation1 = $cofederation['Total'];
-$alliance = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 0"), MYSQLI_ASSOC);
+$alliance = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 0"), MYSQLI_ASSOC);
$alliance1 = $alliance['Total'];
-$closed = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 3"), MYSQLI_ASSOC);
+$closed = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."forum_cat WHERE alliance = $ally AND forum_area = 3"), MYSQLI_ASSOC);
$closed1 = $closed['Total'];
if($public1 != 0){
?>
diff --git a/Templates/Alliance/attack-attacker.tpl b/Templates/Alliance/attack-attacker.tpl
index 4e2c9083..1872121a 100644
--- a/Templates/Alliance/attack-attacker.tpl
+++ b/Templates/Alliance/attack-attacker.tpl
@@ -1,7 +1,7 @@
alliance." AND $limit ORDER BY time DESC LIMIT 20");
+$sql = mysqli_query($database->dblink,"SELECT * FROM $prefix WHERE ally = ".(int) $session->alliance." AND $limit ORDER BY time DESC LIMIT 20");
$query = mysqli_num_rows($sql);
$outputList = '';
$name = 1;
diff --git a/Templates/Alliance/attack-defender.tpl b/Templates/Alliance/attack-defender.tpl
index d81c253a..700b439c 100644
--- a/Templates/Alliance/attack-defender.tpl
+++ b/Templates/Alliance/attack-defender.tpl
@@ -1,7 +1,7 @@
alliance." AND $limit ORDER BY time DESC LIMIT 20");
+$sql = mysqli_query($database->dblink,"SELECT * FROM $prefix WHERE ally = ".(int) $session->alliance." AND $limit ORDER BY time DESC LIMIT 20");
$query = mysqli_num_rows($sql);
$outputList = '';
$name = 1;
diff --git a/Templates/Alliance/attacks.tpl b/Templates/Alliance/attacks.tpl
index cececccf..e9ac3253 100644
--- a/Templates/Alliance/attacks.tpl
+++ b/Templates/Alliance/attacks.tpl
@@ -28,7 +28,7 @@ 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 = mysqli_query($GLOBALS['link'],"SELECT * FROM $prefix WHERE ally = ".(int) $session->alliance." AND $limit ORDER BY time DESC LIMIT 20");
+$sql = mysqli_query($database->dblink,"SELECT * FROM $prefix WHERE ally = ".(int) $session->alliance." AND $limit ORDER BY time DESC LIMIT 20");
$query = mysqli_num_rows($sql);
$outputList = '';
$name = 1;
diff --git a/Templates/Build/26.tpl b/Templates/Build/26.tpl
index 896fad99..e1b0aa47 100644
--- a/Templates/Build/26.tpl
+++ b/Templates/Build/26.tpl
@@ -5,33 +5,33 @@ if(time() - (!empty($_SESSION['time_p']) ? $_SESSION['time_p'] : 0) > 5) {
}
if($_POST AND $_GET['action'] == 'change_capital') {
- $pass = mysqli_escape_string($GLOBALS['link'],$_POST['pass']);
- $query = mysqli_query($GLOBALS['link'],'SELECT password FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . (int) $session->uid);
+ $pass = mysqli_escape_string($database->dblink,$_POST['pass']);
+ $query = mysqli_query($database->dblink,'SELECT password FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . (int) $session->uid);
$data = mysqli_fetch_assoc($query);
if(password_verify($pass, $data['password'])) {
- $query1 = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' .(int) $session->uid . ' AND `capital` = 1');
+ $query1 = mysqli_query($database->dblink,'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' .(int) $session->uid . ' AND `capital` = 1');
$data1 = mysqli_fetch_assoc($query1);
- $query2 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'fdata` WHERE `vref` = ' . (int) $data1['wref']);
+ $query2 = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'fdata` WHERE `vref` = ' . (int) $data1['wref']);
$data2 = mysqli_fetch_assoc($query2);
if($data2['vref'] != $village->wid) {
for($i = 1; $i<=18; ++$i) {
if($data2['f' . $i] > 10) {
- $query2 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . '` = 10 WHERE `vref` = ' . (int) $data2['vref']) or die(mysqli_error($database->dblink));
+ $query2 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . '` = 10 WHERE `vref` = ' . (int) $data2['vref']) or die(mysqli_error($database->dblink));
}
}
for($i=19; $i<=40; ++$i) {
if($data2['f' . $i . 't'] == 34) {
- $query3 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . (int) $data2['vref']) or die(mysqli_error($database->dblink));
+ $query3 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . (int) $data2['vref']) or die(mysqli_error($database->dblink));
}
}
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 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . (int) $village->wid) or die(mysqli_error($database->dblink));
+ $query3 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'fdata` SET `f' . $i . 't` = 0, `f' . $i . '` = 0 WHERE `vref` = ' . (int) $village->wid) or die(mysqli_error($database->dblink));
}
}
-$query3 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 0 WHERE `wref` = ' . (int) $data1['wref']);
-$query4 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 1 WHERE `wref` = ' . (int) $village->wid);
+$query3 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 0 WHERE `wref` = ' . (int) $data1['wref']);
+$query4 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'vdata` SET `capital` = 1 WHERE `wref` = ' . (int) $village->wid);
}
} else {
$error = '
'.LOGIN_PW_ERROR.'
';
@@ -67,7 +67,7 @@ else{
?>
uid . ' AND `capital` = 1');
+$query = mysqli_query($database->dblink,'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . (int) $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 9783a57d..43f3dfd2 100644
--- a/Templates/Build/27_1.tpl
+++ b/Templates/Build/27_1.tpl
@@ -14,8 +14,8 @@ function getDistance($coorx1, $coory1, $coorx2, $coory2) {
return round($dist, 1);
}
?>
-
| '.NO_ARTIFACTS_AREA.' | '; @@ -103,18 +103,18 @@ if($count == 0) { unset($reqlvl); unset($effect); - $arts = mysqli_query($GLOBALS['link'],"SELECT type, vref, id, name, size, owner, effect FROM " . TB_PREFIX . "artefacts"); + $arts = mysqli_query($database->dblink,"SELECT type, vref, id, name, size, owner, effect FROM " . TB_PREFIX . "artefacts"); $rows = array(); while($row = mysqli_fetch_array($arts)) { - $query = mysqli_query($GLOBALS['link'],'SELECT x, y FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . (int) $row['vref']); - $coor2 = mysqli_fetch_assoc($query); - - - $dist = round(getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']),1); - - $rows[$dist] = $row; - - } + $query = mysqli_query($database->dblink,'SELECT x, y FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . (int) $row['vref']); + $coor2 = mysqli_fetch_assoc($query); + + + $dist = round(getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']),1); + + $rows[$dist] = $row; + + } ksort($rows); foreach($rows as $row) { $wref = $village->wid; diff --git a/Templates/Build/27_2.tpl b/Templates/Build/27_2.tpl index ea4deff7..8a8ed4cc 100644 --- a/Templates/Build/27_2.tpl +++ b/Templates/Build/27_2.tpl @@ -31,14 +31,14 @@ dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "artefacts"), MYSQLI_ASSOC); + $count = $count['Total']; if($count == 0) { echo ''.NO_ARTIFACTS.' | '; } else { - $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 1"); + $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 1"); while($row = mysqli_fetch_array($artefact)) { echo '|
![]() | ';
@@ -58,7 +58,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 2");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 2");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -78,7 +78,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 3");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 3");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -98,7 +98,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 4");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 4");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -117,7 +117,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 5");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 5");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -136,7 +136,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 6");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 6");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -155,7 +155,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 7");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 7");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -174,7 +174,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 8");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 8");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -188,7 +188,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 1 AND type = 8");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner 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 16e7497a..32c0db8c 100644
--- a/Templates/Build/27_3.tpl
+++ b/Templates/Build/27_3.tpl
@@ -31,13 +31,13 @@
'.NO_ARTIFACTS.' | '; } else { - $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 1"); + $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 1"); while($row = mysqli_fetch_array($artefact)) { echo '|
![]() | ';
@@ -51,7 +51,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 1");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 1");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -71,7 +71,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 2");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 2");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -85,7 +85,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 2");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 2");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -105,7 +105,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 3");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 3");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -119,7 +119,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 3");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 3");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -139,7 +139,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 4");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 4");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -153,7 +153,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 4");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 4");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -172,7 +172,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 5");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 5");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -186,7 +186,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 5");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 5");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -205,7 +205,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 6");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 6");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -219,7 +219,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 6");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 6");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -238,7 +238,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 7");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 2 AND type = 7");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -252,7 +252,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 7");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 7");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
@@ -271,7 +271,7 @@
unset($artefact);
unset($row);
- $artefact = mysqli_query($GLOBALS['link'],"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 8");
+ $artefact = mysqli_query($database->dblink,"SELECT type, id, name, effect, vref, owner FROM `" . TB_PREFIX . "artefacts` WHERE size = 3 AND type = 8");
while($row = mysqli_fetch_array($artefact)) {
echo '||
![]() | ';
diff --git a/Templates/Build/37_hero.tpl b/Templates/Build/37_hero.tpl
index 3fba836d..d5120a3e 100644
--- a/Templates/Build/37_hero.tpl
+++ b/Templates/Build/37_hero.tpl
@@ -14,7 +14,7 @@ global $database;
if (isset($_POST['name']) && !empty($_POST['name'])) {
$_POST['name'] = $database->escape(stripslashes($_POST['name']));
- mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `name`='".$_POST['name']."' where `uid`='".$database->escape($session->uid)."' AND dead = 0") or die("ERROR:".mysqli_error($database->dblink));
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `name`='".$_POST['name']."' where `uid`='".$database->escape($session->uid)."' AND dead = 0") or die("ERROR:".mysqli_error($database->dblink));
$hero_info['name'] = $_POST['name'];
echo "".NAME_CHANGED."";
}
@@ -172,12 +172,12 @@ if (isset($_POST['name']) && !empty($_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){
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `heroid` = " . $hero_info['heroid']);
header("Location: build.php?id=".$id."");
exit;
}
@@ -185,40 +185,40 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
}
if($_GET['add'] == "off" && $hero_info['attack'] < 100) {
if($hero_info['points'] > 0) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
header("Location: build.php?id=".$id."");
exit;
}
}
if($_GET['add'] == "deff" && $hero_info['defence'] < 100) {
if($hero_info['points'] > 0) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
header("Location: build.php?id=".$id."");
exit;
}
}
if($_GET['add'] == "obonus" && $hero_info['attackbonus'] < 100) {
if($hero_info['points'] > 0) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
header("Location: build.php?id=".$id."");
exit;
}
}
if($_GET['add'] == "dbonus" && $hero_info['defencebonus'] < 100) {
if($hero_info['points'] > 0) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
header("Location: build.php?id=".$id."");
exit;
}
}
if($_GET['add'] == "reg" && $hero_info['regeneration'] < 100) {
if($hero_info['points'] > 0) {
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `heroid` = " . $hero_info['heroid']);
- mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `heroid` = " . $hero_info['heroid']);
+ mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']);
header("Location: build.php?id=".$id."");
exit;
}
diff --git a/Templates/Build/37_revive.tpl b/Templates/Build/37_revive.tpl
index d87324df..622970a7 100644
--- a/Templates/Build/37_revive.tpl
+++ b/Templates/Build/37_revive.tpl
@@ -197,8 +197,8 @@
if(isset($_GET['revive']) && $_GET['revive'] == 1 && isset($_GET['hid']) && $_GET['hid'] == $hero_datarow['heroid'] && $hero_datarow['inrevive'] == 0 && $hero_datarow['intraining'] == 0 && $hero_datarow['dead'] == 1){
if($session->access != BANNED){
- mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `heroid` = ".(int) $_GET['hid']." AND `uid` = '".(int) $session->uid."'");
- mysqli_query($GLOBALS['link'],"
+ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `heroid` = ".(int) $_GET['hid']." AND `uid` = '".(int) $session->uid."'");
+ mysqli_query($database->dblink,"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $wood.",
diff --git a/Templates/Build/37_train.tpl b/Templates/Build/37_train.tpl
index e1a81d1f..92c69170 100644
--- a/Templates/Build/37_train.tpl
+++ b/Templates/Build/37_train.tpl
@@ -34,10 +34,10 @@
//check if there is unit needed in the village
-$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid."");
+$result = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid."");
$units_array = mysqli_fetch_array($result);
-$count_hero = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""), MYSQLI_ASSOC);
+$count_hero = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""), MYSQLI_ASSOC);
$count_hero = $count_hero['Total'];
if ($count_hero < 3) {
@@ -667,9 +667,9 @@ $output.="||
| dblink,'SELECT * FROM `' . TB_PREFIX . 'odata` WHERE `wref` = ' . mysqli_escape_string($database->dblink,$_GET['d'])); }else{ - $query1 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysqli_real_escape_string($GLOBALS['link'],$_GET['d'])); + $query1 = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysqli_real_escape_string($database->dblink,$_GET['d'])); } $data1 = mysqli_fetch_assoc($query1); - $query2 = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data1['owner']); + $query2 = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data1['owner']); $data2 = mysqli_fetch_assoc($query2); if($data2['access']=='0' or ($data2['access']== MULTIHUNTER && $data2['id'] == 5) or (!ADMIN_ALLOW_INCOMING_RAIDS && $data2['access']=='9')) { echo "» ".SENDTROOP." (".BAN.")"; diff --git a/Templates/Message/inbox.tpl b/Templates/Message/inbox.tpl index 926994b3..22aebc98 100644 --- a/Templates/Message/inbox.tpl +++ b/Templates/Message/inbox.tpl @@ -11,7 +11,7 @@ | Sent | |
|---|---|---|
| uid."'") or die(mysqli_error($database->dblink)); + $MyGold = mysqli_query($database->dblink,"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink)); $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 08f238d9..725c3989 100644 --- a/Templates/Message/sent.tpl +++ b/Templates/Message/sent.tpl @@ -22,7 +22,7 @@ | Recipient | Sent |
| uid."'") or die(mysqli_error($database->dblink)); + $MyGold = mysqli_query($database->dblink,"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink)); $golds = mysqli_fetch_array($MyGold); $date2=strtotime("NOW"); if ($golds['plus'] <= $date2) { ?> diff --git a/Templates/Notice/all.tpl b/Templates/Notice/all.tpl index 4dacb26c..f8479107 100644 --- a/Templates/Notice/all.tpl +++ b/Templates/Notice/all.tpl @@ -12,7 +12,7 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att | ||
| uid."'") or die(mysqli_error($database->dblink)); + $MyGold = mysqli_query($database->dblink,"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink)); $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 3b2ff7f4..7378ba70 100644 --- a/Templates/Plus/10.tpl +++ b/Templates/Plus/10.tpl @@ -1,25 +1,25 @@ access != BANNED && $session->gold >= 5){ - $MyGold = mysqli_query($GLOBALS['link'],"SELECT gold, b2 FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + $MyGold = mysqli_query($database->dblink,"SELECT gold, b2 FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); $golds = mysqli_fetch_array($MyGold); if($session->sit == 0) { if (mysqli_num_rows($MyGold) == 1) { if($golds['gold'] >= 5) { if($golds['b2'] < time()) { - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b2 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set b2 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); } else { - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b2 = '".($golds['b2']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set b2 = '".($golds['b2']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); } $done1 = "+25% Production: Clay"; - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); - mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Clay')") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Clay')") or die(mysqli_error($database->dblink)); } else { $done1 = "You need more gold"; } } else { $done1 = "Failed clay attempt"; - mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', 'Failed +25% Production: Clay')") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', 'Failed +25% Production: Clay')") or die(mysqli_error($database->dblink)); } } header("Location: plus.php?id=3"); diff --git a/Templates/Plus/11.tpl b/Templates/Plus/11.tpl index ea9ccae1..dd0c20a1 100644 --- a/Templates/Plus/11.tpl +++ b/Templates/Plus/11.tpl @@ -1,25 +1,25 @@ access != BANNED && $session->gold >= 5){ - $MyGold = mysqli_query($GLOBALS['link'],"SELECT gold, b3 FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + $MyGold = mysqli_query($database->dblink,"SELECT gold, b3 FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); $golds = mysqli_fetch_array($MyGold); if($session->sit == 0) { if (mysqli_num_rows($MyGold)) { if($golds['gold'] >= 5) { if($golds['b3'] < time()) { - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b3 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set b3 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); } else { - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b3 = '".($golds['b3']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set b3 = '".($golds['b3']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); } $done1 = "+25% Production: Iron"; - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); - mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Iron')") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Iron')") or die(mysqli_error($database->dblink)); } else { $done1 = "You need more gold"; } } else { $done1 = "Failed iron attempt"; - mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', 'Failed +25% Production: Iron')") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', 'Failed +25% Production: Iron')") or die(mysqli_error($database->dblink)); } } header("Location: plus.php?id=3"); diff --git a/Templates/Plus/12.tpl b/Templates/Plus/12.tpl index baa2006b..c6305c94 100644 --- a/Templates/Plus/12.tpl +++ b/Templates/Plus/12.tpl @@ -1,25 +1,25 @@ access != BANNED && $session->gold >= 5){ - $MyGold = mysqli_query($GLOBALS['link'],"SELECT gold, b4 FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + $MyGold = mysqli_query($database->dblink,"SELECT gold, b4 FROM ".TB_PREFIX."users WHERE `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); $golds = mysqli_fetch_array($MyGold); if($session->sit == 0) { if (mysqli_num_rows($MyGold)) { if($golds['gold'] >= 5) { if($golds['b4'] < time()) { - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b4 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set b4 = '".(time()+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); } else { - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set b4 = '".($golds['b4']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set b4 = '".($golds['b4']+PLUS_PRODUCTION)."' where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); } $done1 = "+25% Production: Crop"; - mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); - mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Crop')") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-5)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', '+25% Production: Crop')") or die(mysqli_error($database->dblink)); } else { $done1 = "You need more gold"; } } else { $done1 = "Failed crop attempt"; - mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', 'Failed +25% Production: Crop')") or die(mysqli_error($database->dblink)); + mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."gold_fin_log (wid,log) VALUES ('".$village->wid."', 'Failed +25% Production: Crop')") or die(mysqli_error($database->dblink)); } } header("Location: plus.php?id=3"); diff --git a/Templates/Plus/13.tpl b/Templates/Plus/13.tpl index d71b8129..86bbd17b 100644 --- a/Templates/Plus/13.tpl +++ b/Templates/Plus/13.tpl @@ -1,6 +1,6 @@ |