mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-11 22:01:00 +00:00
Some important fixes PHP 8.1
Some important fixes PHP 8.1
This commit is contained in:
@@ -388,6 +388,19 @@ trait DatabaseUserQueries {
|
||||
$q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED ." LIMIT 1";
|
||||
$result = mysqli_query($this->dblink,$q);
|
||||
$dbarray = mysqli_fetch_array($result);
|
||||
|
||||
/**
|
||||
* Daca username-ul nu exista (sau contul e banat), fetch intoarce NULL
|
||||
* si toate citirile de mai jos dadeau "Trying to access array offset on
|
||||
* null". Iesim din start - oricum nu are cine sa fie sitter.
|
||||
*/
|
||||
if (!is_array($dbarray)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbarray2 = null;
|
||||
$dbarray3 = null;
|
||||
|
||||
if($dbarray['sit1'] != 0) {
|
||||
$q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . (int) $dbarray['sit1'] . " and access != " . BANNED . " LIMIT 1";
|
||||
$result2 = mysqli_query($this->dblink,$q2);
|
||||
@@ -399,7 +412,10 @@ trait DatabaseUserQueries {
|
||||
$dbarray3 = mysqli_fetch_array($result3);
|
||||
}
|
||||
if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) {
|
||||
if(password_verify($password, $dbarray2['password']) || password_verify($password, $dbarray3['password'])) {
|
||||
// sit1/sit2 pot fi setati independent, deci unul dintre randuri
|
||||
// poate lipsi; fara ?? '' iesea acelasi warning pe null.
|
||||
if(password_verify($password, (string) ($dbarray2['password'] ?? ''))
|
||||
|| password_verify($password, (string) ($dbarray3['password'] ?? ''))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+16
-10
@@ -513,11 +513,14 @@
|
||||
}
|
||||
$value['players'] = count($memberlist);
|
||||
$value['totalap'] = $totalap;
|
||||
if($value['avg'] > 0) {
|
||||
$value['avg'] = ($totalap > 0 && count($memberlist) > 0) ? round($totalap / count($memberlist)) : 0;
|
||||
} else {
|
||||
$value['avg'] = 0;
|
||||
}
|
||||
/**
|
||||
* BUG: aici era "if($value['avg'] > 0)", dar getARanking()
|
||||
* selecteaza doar id,name,tag,oldrank,Aap,Adp - cheia 'avg' nu
|
||||
* exista niciodata. Conditia pica mereu pe ramura else, deci
|
||||
* media pe membru era intotdeauna 0 in clasament (pe langa
|
||||
* warning-ul "Undefined array key"). Calculam direct.
|
||||
*/
|
||||
$value['avg'] = (count($memberlist) > 0) ? (int) round($totalap / count($memberlist)) : 0;
|
||||
$holder[] = $value;
|
||||
}
|
||||
$holder = $multisort->sorte($holder, "Aap", false, 2);
|
||||
@@ -540,11 +543,14 @@
|
||||
}
|
||||
$value['players'] = count($memberlist);
|
||||
$value['totaldp'] = $totaldp;
|
||||
if($value['avg'] > 0) {
|
||||
$value['avg'] = ($totaldp > 0 && count($memberlist) > 0) ? round($totaldp / count($memberlist)) : 0;
|
||||
} else {
|
||||
$value['avg'] = 0;
|
||||
}
|
||||
/**
|
||||
* BUG: aici era "if($value['avg'] > 0)", dar getARanking()
|
||||
* selecteaza doar id,name,tag,oldrank,Aap,Adp - cheia 'avg' nu
|
||||
* exista niciodata. Conditia pica mereu pe ramura else, deci
|
||||
* media pe membru era intotdeauna 0 in clasament (pe langa
|
||||
* warning-ul "Undefined array key"). Calculam direct.
|
||||
*/
|
||||
$value['avg'] = (count($memberlist) > 0) ? (int) round($totaldp / count($memberlist)) : 0;
|
||||
$holder[] = $value;
|
||||
}
|
||||
$holder = $multisort->sorte($holder, "Adp", false, 2);
|
||||
|
||||
@@ -616,6 +616,20 @@ class Units {
|
||||
exit;
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Formularul de retragere trimite doar casutele completate,
|
||||
* deci $post['t1'..'t10'] pot lipsi cu totul. Bucla de mai jos
|
||||
* avea deja isset(), dar addAttack() si getWalkingTroopsTime()
|
||||
* le citeau direct si scoteau "Undefined array key t10".
|
||||
* Le normalizam o singura data, aici, ca toti consumatorii de
|
||||
* mai jos sa primeasca numere.
|
||||
*/
|
||||
for ($t = 1; $t <= 10; $t++) {
|
||||
if (!isset($post['t'.$t]) || !is_numeric($post['t'.$t])) {
|
||||
$post['t'.$t] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//change units
|
||||
$tribe = $database->getUserField($to['owner'], 'tribe', 0);
|
||||
$start = ($tribe - 1 ) * 10 + 1;
|
||||
|
||||
Reference in New Issue
Block a user