#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
+2 -2
View File
@@ -111,7 +111,7 @@ class funct
if(!isset($selectedArtifact) || !isset($artifactQuantity) || !isset($playerId) || empty($selectedArtifact) ||
!is_numeric($artifactQuantity) || !is_numeric($playerId) || strpos($selectedArtifact, ':') === false ||
$database->getUserField($playerId, "username", 0) == "[?]"){
header("location: admin.php");
header("location: admin.php?p=artifacts&error=0");
exit;
}
@@ -125,7 +125,7 @@ class funct
//Check if the artifact has been found or if doesn't exist
if(empty($chosenArtifact)){
header("location: admin.php");
header("location: admin.php?p=artifacts&error=1");
exit;
}
+5 -5
View File
@@ -2,16 +2,16 @@
class Artifacts
{
public const
const
/**
* @var integer Default Natars' uid
* @var int Default Natars' uid
*/
NATARS_UID = 3,
/**
* @var integer Default Natars' tribe
* @var int Default Natars' tribe
*/
NATARS_TRIBE = 5,
@@ -128,7 +128,7 @@ class Artifacts
"f2" => 6, "f8" => 6, "f9" => 6, "f12" => 6, "f13" => 6, "f15" => 6],
/**
* @var integer The base amount of Natars' spying units, used when Natars account is created
* @var int The base amount of Natars' spying units, used when Natars account is created
*/
NATARS_BASE_SPY = 1500;
@@ -178,7 +178,7 @@ class Artifacts
}
/**
* Called when Natars account need to be created, creates his account and capital village
* Called when Natars account needs to be created, creates his account and capital village
*
*/
+1
View File
@@ -1031,6 +1031,7 @@ define("YOU_CONSTRUCT","You can construct ");
define("CRANNY_INCREASED","Cranny capacity is increased by");
define("CRANNY_DECRESE","Cranny capacity is decrese by");
define("WW_BUILDING_PLAN","You can build the Wonder of the World");
define("NO_WW","There are no Wonders of the World");
define("NO_PREVIOUS_OWNERS","There are no previous owners.");
define("TREASURY_DESC","The riches of your empire are kept in the treasury. The treasury has room for one treasure. After you have captured an artefact it takes 24 hours on a normal server or 12 hours on a thrice speed server to be effective.");
+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) {