diff --git a/Admin/Templates/delallymedal.tpl b/Admin/Templates/delallymedal.tpl
index 9bf6d9df..5b5436f8 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 = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."allimedal");
-$nummedals = mysqli_num_rows($sql);
+$sql = mysqli_fetch_array(mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."allimedal"), MYSQLI_ASSOC);
+$nummedals = $sql['Total'];
?>
@@ -36,8 +36,8 @@ $nummedals = mysqli_num_rows($sql);
0){
$week = mysqli_result($sql, 0);
@@ -75,8 +75,8 @@ $nummedals = mysqli_num_rows($sql);
for($j = 0; $j<$week; $j++)
{
$newweek = $j+1;
- $sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."allimedal WHERE week = $newweek");
- $tot = mysqli_num_rows($sql);
+ $sql = mysqli_fetch_array(mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."allimedal WHERE week = $newweek"), MYSQLI_ASSOC);
+ $tot = $sql['Total'];
echo "
| $newweek |
$tot |
diff --git a/Admin/Templates/delmedal.tpl b/Admin/Templates/delmedal.tpl
index 8798a0a8..ec6ddedd 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 = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."medal");
-$nummedals = mysqli_num_rows($sql);
+$sql = mysqli_fetch_array(mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."medal"), MYSQLI_ASSOC);
+$nummedals = $sql['Total'];
?>
@@ -37,8 +37,8 @@ $nummedals = mysqli_num_rows($sql);
0){
$week = mysqli_result($sql, 0);
@@ -77,8 +77,8 @@ $nummedals = mysqli_num_rows($sql);
{
$newweek = $j+1;
- $sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."medal WHERE week = $newweek");
- $tot = mysqli_num_rows($sql);
+ $sql = mysqli_fetch_array(mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."medal WHERE week = $newweek"), MYSQLI_ASSOC);
+ $tot = $sql['Total'];
echo "| $newweek | $tot | | ";
}
diff --git a/GameEngine/Admin/Mods/mainteneceUnban.php b/GameEngine/Admin/Mods/mainteneceUnban.php
index de8cdd6e..385ae1b3 100755
--- a/GameEngine/Admin/Mods/mainteneceUnban.php
+++ b/GameEngine/Admin/Mods/mainteneceUnban.php
@@ -28,7 +28,8 @@ $sessionaccess = $access['access'];
if($sessionaccess != 9) die("Access Denied: You are not Admin!
");
-$users = mysqli_num_rows(mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users"));
+$users = mysqli_fetch_array(mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."users"), MYSQLI_ASSOC);
+$users = $users['Total'];
$reason = $_POST['unbanreason'];
$admin = $session;
diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php
index 5b2fbded..6d852d84 100755
--- a/GameEngine/Admin/database.php
+++ b/GameEngine/Admin/database.php
@@ -318,13 +318,14 @@ class adm_DB {
function DelVillage($wref, $mode=0){
global $database;
$wref = (int) $wref;
- if($mode==0){
- $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref and capital = 0";
- }else{
- $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref";
- }
- $result = mysqli_query($this->connection, $q);
- if(mysqli_num_rows($result) > 0){
+ if ($mode==0) {
+ $q = "SELECT Count(*) as Total FROM ".TB_PREFIX."vdata WHERE `wref` = $wref and capital = 0";
+ } else {
+ $q = "SELECT Count(*) as Total FROM ".TB_PREFIX."vdata WHERE `wref` = $wref";
+ }
+
+ $result = mysqli_fetch_array(mysqli_query($this->connection, $q), MYSQLI_ASSOC);
+ if($result['Total'] > 0){
mysqli_query($this->connection,"Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Deleted village $wref',".time().")");
$database->clearExpansionSlot($wref);
diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
index e983bd85..d231a226 100755
--- a/GameEngine/Automation.php
+++ b/GameEngine/Automation.php
@@ -30,14 +30,12 @@ class Automation {
private $bountyOpop = 1;
public function isWinner() {
- $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)
+ // 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);
+ if($q['Total'] > 0)
{
header('Location: winner.php');
exit;
- }else{
- ## there is no winner
}
}
diff --git a/GameEngine/Database.php b/GameEngine/Database.php
index 9fdfeb52..72a81c82 100755
--- a/GameEngine/Database.php
+++ b/GameEngine/Database.php
@@ -652,9 +652,9 @@ class MYSQLi_DB implements IDbConnection {
function checkactiveSession($username, $sessid) {
list($username, $sessid) = $this->escape_input($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) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "users where username = '$username' and sessid = '$sessid' LIMIT 1";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if($result['Total'] > 0) {
return true;
} else {
return false;
@@ -1208,9 +1208,9 @@ class MYSQLi_DB implements IDbConnection {
function CheckForum($id) {
list($id) = $this->escape_input((int) $id);
- $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "forum_cat where alliance = $id";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
return true;
} else {
return false;
@@ -1237,9 +1237,9 @@ class MYSQLi_DB implements IDbConnection {
function CheckLastTopic($id) {
list($id) = $this->escape_input($id);
- $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total from " . TB_PREFIX . "forum_topic where cat = $id";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if($result['Total']) {
return true;
} else {
return false;
@@ -1249,9 +1249,9 @@ class MYSQLi_DB implements IDbConnection {
function CheckLastPost($id) {
list($id) = $this->escape_input($id);
- $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total from " . TB_PREFIX . "forum_post where topic = $id";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
return true;
} else {
return false;
@@ -1325,9 +1325,9 @@ class MYSQLi_DB implements IDbConnection {
function CheckCatTopic($id) {
list($id) = $this->escape_input($id);
- $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total from " . TB_PREFIX . "forum_topic where cat = $id";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
return true;
} else {
return false;
@@ -1337,9 +1337,9 @@ class MYSQLi_DB implements IDbConnection {
function CheckResultEdit($alli) {
list($alli) = $this->escape_input($alli);
- $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total from " . TB_PREFIX . "forum_edit where alliance = $alli";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
return true;
} else {
return false;
@@ -1409,9 +1409,9 @@ class MYSQLi_DB implements IDbConnection {
function checkVilExist($wref) {
list($wref) = $this->escape_input((int) $wref);
- $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "vdata where wref = '$wref'";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
return true;
} else {
return false;
@@ -1421,9 +1421,9 @@ class MYSQLi_DB implements IDbConnection {
function checkOasisExist($wref) {
list($wref) = $this->escape_input((int) $wref);
- $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "odata where wref = '$wref'";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if($result['Total']) {
return true;
} else {
return false;
@@ -1530,9 +1530,9 @@ class MYSQLi_DB implements IDbConnection {
function checkSurvey($topic) {
list($topic) = $this->escape_input((int) $topic);
- $q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "forum_survey where topic = $topic";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
return true;
} else {
return false;
@@ -3293,9 +3293,9 @@ class MYSQLi_DB implements IDbConnection {
function getBuildingByField2($wid,$field) {
list($wid,$field) = $this->escape_input((int) $wid,(int) $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);
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ return $result['Total'];
}
function getBuildingByType($wid,$type) {
@@ -3309,9 +3309,9 @@ class MYSQLi_DB implements IDbConnection {
function getBuildingByType2($wid,$type) {
list($wid,$type) = $this->escape_input((int) $wid,(int) $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);
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ return $result['Total'];
}
function getDorf1Building($wid) {
@@ -4133,9 +4133,9 @@ class MYSQLi_DB implements IDbConnection {
***************************/
function getWW() {
- $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40";
- $result = mysqli_query($this->dblink,$q);
- if(mysqli_num_rows($result)) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "fdata WHERE f99t = 40";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if($result['Total']) {
return true;
} else {
return false;
@@ -5123,9 +5123,9 @@ References:
function getHeroDead($id) {
list($id) = $this->escape_input((int) $id);
- $q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND dead = 0";
- $result = mysqli_query($this->dblink,$q);
- if (mysqli_num_rows($result) > 0) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND dead = 0";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total'] > 0) {
return 0;
} else {
return 1;
@@ -5140,9 +5140,9 @@ References:
function getHeroInRevive($id) {
list($id) = $this->escape_input((int) $id);
- $q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND inrevive = 1";
- $result = mysqli_query($this->dblink,$q);
- if (mysqli_num_rows($result) > 0) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND inrevive = 1";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total'] > 0) {
return 1;
} else {
return 0;
@@ -5157,9 +5157,9 @@ References:
function getHeroInTraining($id) {
list($id) = $this->escape_input((int) $id);
- $q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND intraining = 1";
- $result = mysqli_query($this->dblink,$q);
- if (mysqli_num_rows($result) > 0) {
+ $q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND intraining = 1";
+ $result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total'] > 0) {
return 1;
} else {
return 0;
@@ -5300,15 +5300,16 @@ References:
***************************/
function checkAttack($wref, $toWref) {
- list($wref, $toWref) = $this->escape_input((int) $wref, (int) $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;
- }
- }
+ list($wref, $toWref) = $this->escape_input((int) $wref, (int) $toWref);
+
+ $q = "SELECT Count(*) as Total 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_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if ($result['Total']) {
+ return true;
+ } else {
+ return false;
+ }
+ }
/***************************
Function checkEnforce
@@ -5318,9 +5319,9 @@ References:
function checkEnforce($wref, $toWref) {
list($wref, $toWref) = $this->escape_input((int) $wref, (int) $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)) {
+ $q = "SELECT Count(*) as Total 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_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if($result['Total']) {
return true;
}else{
return false;
@@ -5335,9 +5336,9 @@ References:
function checkScout($wref, $toWref) {
list($wref, $toWref) = $this->escape_input((int) $wref, (int) $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)) {
+ $q = "SELECT Count(*) as Total 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_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
+ if($result['Total']) {
return true;
}else{
return false;
diff --git a/GameEngine/Message.php b/GameEngine/Message.php
index 82ba5bff..48432759 100755
--- a/GameEngine/Message.php
+++ b/GameEngine/Message.php
@@ -335,9 +335,9 @@ class Message {
// Vulnerability closed by Shadow
- $q = "SELECT * FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".(time() - 60);
- $res = mysqli_query($GLOBALS['link'],$q) or die(mysqli_error($database->dblink). " query ".$q);
- $flood = mysqli_num_rows($res);
+ $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);
+ $flood = $res['Total'];
if($flood > 5)
return; //flood
@@ -425,9 +425,9 @@ class Message {
// Vulnerability closed by Shadow
if ($security_check) {
- $q = "SELECT * FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".(time() - 60);
- $res = mysqli_query($GLOBALS['link'],$q) or die(mysqli_error($database->dblink). " query ".$q);
- $flood = mysqli_num_rows($res);
+ $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);
+ $flood = $res['Total'];
if($flood > 5)
return; //flood
}
diff --git a/GameEngine/Ranking.php b/GameEngine/Ranking.php
index d6d2e357..cc8624a5 100755
--- a/GameEngine/Ranking.php
+++ b/GameEngine/Ranking.php
@@ -20,8 +20,9 @@
public function getUserRank($id) {
$ranking = $this->getRank();
- $users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . "";
- $users2 = mysqli_num_rows(mysqli_query($GLOBALS['link'],$users));
+ $users = "SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8");
+ $users2 = mysqli_fetch_array(mysqli_query($GLOBALS['link'],$users), MYSQLI_ASSOC);
+ $users2 = $users2['Total'];
$users3 = $users2+1;
$myrank = 0;
if(count($ranking) > 0) {
diff --git a/GameEngine/Units.php b/GameEngine/Units.php
index dbdd785c..4b28943f 100755
--- a/GameEngine/Units.php
+++ b/GameEngine/Units.php
@@ -443,8 +443,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 = mysqli_query($GLOBALS['link'],"SELECT vref FROM ".TB_PREFIX."fdata WHERE f99t = '40' AND vref = ".(int) $data['to_vid']."");
- $isThere = mysqli_num_rows($q);
+ $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);
+ $isThere = $q['Total'];
if($isThere > 0)
{
$iswwvilla = 1;
diff --git a/README.md b/README.md
index 8908e71d..d8b38b96 100644
--- a/README.md
+++ b/README.md
@@ -189,7 +189,7 @@ TienTN changes:
1. Change install/templates/config.tpl to deal with deprecated warning from new PHP version.
2. Fix install/data/sql.sql, to be executable in current MySQL version.
3. Fix db_MYSQL.php
- with safe_mysql_fetch_all, and safe_mysql_fetch_array wrappers, to avoid
+ with safe_mysql_fetch_all, and safe_mysqli_fetch_array wrappers, to avoid
Warning: mysql_fetch_all/array() expects parameter 1 to be resource, boolean given
4. Fix the db_MYSQLi.php in class object declaration(if anybody want to use db_MYSQLi.php again)
5. Fix the unx.js file for error:
diff --git a/Templates/Alliance/Forum/forum_2.tpl b/Templates/Alliance/Forum/forum_2.tpl
index 259d42f7..5b45d575 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 = 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);
+$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);
+$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);
+$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);
+$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);
+$closed1 = $closed['Total'];
if($public1 != 0){
?>
diff --git a/Templates/Build/27_1.tpl b/Templates/Build/27_1.tpl
index 69eaf0c6..3dfa1281 100644
--- a/Templates/Build/27_1.tpl
+++ b/Templates/Build/27_1.tpl
@@ -83,8 +83,9 @@ Treasury ' . $reqlvl . ', Effect ' . $effect . '
'.NO_ARTIFACTS_AREA.'';
} else {
diff --git a/Templates/Build/27_2.tpl b/Templates/Build/27_2.tpl
index 1eac2cda..ba1b1346 100644
--- a/Templates/Build/27_2.tpl
+++ b/Templates/Build/27_2.tpl
@@ -31,7 +31,9 @@
'.NO_ARTIFACTS.'';
} else {
diff --git a/Templates/Build/27_3.tpl b/Templates/Build/27_3.tpl
index 58ff4ebe..d07d8f28 100644
--- a/Templates/Build/27_3.tpl
+++ b/Templates/Build/27_3.tpl
@@ -31,7 +31,9 @@
'.NO_ARTIFACTS.'';
} else {
diff --git a/Templates/Manual/52.tpl b/Templates/Manual/52.tpl
index 771e34e6..d986f34b 100644
--- a/Templates/Manual/52.tpl
+++ b/Templates/Manual/52.tpl
@@ -5,9 +5,9 @@ include("GameEngine/Config.php");
$connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error($database->dblink));
mysqli_select_db(SQL_DB, $connection) or die(mysqli_error($database->dblink));
- $q = "SELECT * FROM ".TB_PREFIX."movement where endtime < ".time()." and proc = 0";
- $result = mysqli_query($GLOBALS["link"], $q, $connection);
- $count=mysqli_num_rows($result);
+ $q = "SELECT Count(*) as Total FROM ".TB_PREFIX."movement where endtime < ".time()." and proc = 0";
+ $result = mysqli_fetch_array(mysqli_query($GLOBALS["link"], $q, $connection), MYSQLI_ASSOC);
+ $count=$result['Total'];
?>
diff --git a/Templates/Plus/14.tpl b/Templates/Plus/14.tpl
index fd005405..b256c280 100644
--- a/Templates/Plus/14.tpl
+++ b/Templates/Plus/14.tpl
@@ -10,7 +10,7 @@ if($session->access != BANNED){
$totalT = ($T1+$T2+$T3+$T4);
$totalR = ($uuVilid['6']+$uuVilid['7']+$uuVilid['8']+$uuVilid['10']);
- $goldlog = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."gold_fin_log") or die(mysqli_error($database->dblink));
+ $goldlog = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."gold_fin_log"), MYSQLI_ASSOC) or die(mysqli_error($database->dblink));
if($totalT <= $totalR) {
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."vdata set wood = '".$T1."' where `wref`='".$village->wid."'") or die(mysqli_error($database->dblink));
@@ -18,11 +18,11 @@ mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."vdata set clay = '".$T2."' wh
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."vdata set iron = '".$T3."' where `wref`='".$village->wid."'") or die(mysqli_error($database->dblink));
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."vdata set crop = '".$T4."' where `wref`='".$village->wid."'") or die(mysqli_error($database->dblink));
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."users set gold = ".($session->gold-3)." where `id`='".$session->uid."'") or die(mysqli_error($database->dblink));
- mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', 'trade 1:1')") or die(mysqli_error($database->dblink));
+ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".($goldlog['Total']+1)."', '".$village->wid."', 'trade 1:1')") or die(mysqli_error($database->dblink));
echo "done";
} else {
echo "failed";
- mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".(mysqli_num_rows($goldlog)+1)."', '".$village->wid."', 'Failed trade 1:1')") or die(mysqli_error($database->dblink));
+ mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."gold_fin_log VALUES ('".($goldlog['Total']+1)."', '".$village->wid."', 'Failed trade 1:1')") or die(mysqli_error($database->dblink));
}
diff --git a/Templates/Ranking/general.tpl b/Templates/Ranking/general.tpl
index cc296593..33917de2 100644
--- a/Templates/Ranking/general.tpl
+++ b/Templates/Ranking/general.tpl
@@ -9,11 +9,13 @@
| Copyright: TravianX Project All rights reserved |
\** --------------------------------------------------- **/
- $tribe1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE tribe = 1");
- $tribe2 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."users WHERE tribe = 2");
- $tribe3 = mysqli_query($GLOBALS['link'],"SELECT * 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 * FROM " . TB_PREFIX . "users WHERE tribe!=0 AND tribe!=4 AND tribe!=5")); ?>
+ $tribe1 = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 1"), MYSQLI_ASSOC);
+ $tribe2 = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 2"), MYSQLI_ASSOC);
+ $tribe3 = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 3"), MYSQLI_ASSOC);
+ $tribes = array($tribe1['Total'], $tribe2['Total'], $tribe3['Total']);
+ $users = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE tribe!=0 AND tribe!=4 AND tribe!=5"), MYSQLI_ASSOC);
+ $users = $users['Total'];
+?>
diff --git a/build.php b/build.php
index 2df46d1b..b6060d08 100644
--- a/build.php
+++ b/build.php
@@ -260,10 +260,10 @@ $oldmovement=$database->getMovementById($_GET['moveid']);
$now=time();
if(($now-$oldmovement[0]['starttime'])<90 && $oldmovement[0]['from'] == $village->wid){
- $qc="SELECT * FROM " . TB_PREFIX . "movement where proc = 0 and moveid = ".$database->escape((int) $_GET['moveid']);
-$resultc=$database->query($qc) or die(mysqli_error($database->dblink));
+ $qc="SELECT Count(*) as Total FROM " . TB_PREFIX . "movement where proc = 0 and moveid = ".$database->escape((int) $_GET['moveid']);
+ $resultc=mysqli_fetch_array(mysqli_query($database->dblink, $qc), MYSQLI_ASSOC);
- if (mysqli_num_rows($resultc)==1){
+ if ($resultc['Total']==1){
$q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where proc = 0 and moveid = ".$database->escape((int) $_GET['moveid']);
$database->query($q);