#554 Fixes and General fixes

+Fixed a bug that could have happened in the statistics if there were 0
users in the server
+Fixed a compatibility bug with PHP 7.0
This commit is contained in:
iopietro
2018-07-24 18:19:44 +02:00
parent 81dcd16e3d
commit ee0b4984c2
18 changed files with 375 additions and 418 deletions
+26 -33
View File
@@ -11,7 +11,7 @@
class Ranking {
public $rankarray = array();
public $rankarray = [];
private $rlastupdate;
public function getRank() {
@@ -20,14 +20,15 @@
public function getUserRank($id) {
global $database;
$ranking = $this->getRank();
$users = "SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8");
$users2 = mysqli_fetch_array(mysqli_query($database->dblink,$users), MYSQLI_ASSOC);
$users2 = $users2['Total'];
$users3 = $users2+1;
$users3 = $users2 + 1;
$myrank = 0;
if(count($ranking) > 0) {
for($i=0;$i<($users3);$i++) {
for($i = 0;$i < $users3; $i++) {
if( isset( $ranking[$i]['userid'] ) ) {
if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") {
$myrank = $i;
@@ -197,31 +198,25 @@
}
public function searchRank($name, $field) {
while(1) {
//$key = key($this->rankarray);
for($key=0;$key<count($this->rankarray);$key++){
if($this->rankarray[$key]!="pad") {
if($this->rankarray[$key][$field] == $name) {
return $key;
break;
}
}
}
if(!next($this->rankarray)) {
if($field != "userid"){
return $name;
break;
}else{
return 0;
break;
}
}
}
while(1) {
//$key = key($this->rankarray);
for($key = 0; $key < count($this->rankarray); $key++){
if($this->rankarray[$key]!="pad") {
if($this->rankarray[$key][$field] == $name) return $key;
}
}
if(!next($this->rankarray)) {
if($field != "userid") return $name;
else return 0;
}
}
}
public function procRankArray() {
global $multisort, $database;
if($GLOBALS['db']->countUser() > 0){
$holder = array();
if(SHOW_NATARS == True){
@@ -272,12 +267,10 @@
ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
}
$datas = array();
$datas = [];
$result = (mysqli_query($database->dblink,$q));
while($row = mysqli_fetch_assoc($result)) {
$datas[] = $row;
}
while($row = mysqli_fetch_assoc($result)) $datas[] = $row;
if (count($datas)) {
foreach($datas as $result) {
@@ -292,12 +285,12 @@
}
}
$newholder = array("pad");
foreach($holder as $key) {
array_push($newholder, $key);
}
$newholder = ["pad"];
foreach($holder as $key) array_push($newholder, $key);
$this->rankarray = $newholder;
}
}
}
public function procRankRaceArray($race) {