fix: fix even more PHP errors and warnings

This commit is contained in:
Emmanuel BENOîT 2024-12-31 13:43:31 +01:00
parent 077f97d5fc
commit 7debdba37c
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
28 changed files with 80 additions and 72 deletions

View file

@ -21,28 +21,28 @@ class ajax {
// Get AJAX functions from handler
$a1 = is_array($handler->ajax) ? $handler->ajax : array();
if (is_array($a1['func'])) {
if (isset($a1['func'])) {
ajax::$fHandler = $a1['func'];
$ml = is_array($a1['method']) ? $a1['method'] : array();
$ml = is_array($a1['method'] ?? null) ? $a1['method'] : array();
foreach ($a1['func'] as $f) {
$m = ($ml[$f] == "") ? ($handler->ajaxPOST ? "POST" : "GET") : $ml[$f];
$m = ($ml[$f] ?? "" == "") ? ($handler->ajaxPOST ?? false ? "POST" : "GET") : $ml[$f];
ajax::$method[$f] = $m;
}
}
// Get theme-specific AJAX functions
$a2 = ajax::getTheme();
if (is_array($a2['func'])) {
if (isset($a2['func'])) {
ajax::$fTheme = $a2['func'];
$ml = is_array($a2['method']) ? $a2['method'] : array();
$ml = is_array($a2['method'] ?? null) ? $a2['method'] : array();
foreach ($a2['func'] as $f) {
$m = ($ml[$f] == "") ? ($handler->ajaxPOST ? "POST" : "GET") : $ml[$f];
$m = ($ml[$f] ?? "" == "") ? ($handler->ajaxPOST ?? false ? "POST" : "GET") : $ml[$f];
ajax::$method[$f] = $m;
}
}
// Create init string
ajax::$init = $a2['init'] . $a1['init'];
ajax::$init = ($a2['init'] ?? '') . ($a1['init'] ?? '');
}

View file

@ -307,7 +307,7 @@ class db {
}
public function getGameAccess($prefix) {
if (is_null($this->accessors[$prefix])) {
if (!isset($this->accessors[$prefix])) {
$this->accessors[$prefix] = new db_accessor($this, $prefix);
}
return $this->accessors[$prefix];

View file

@ -316,7 +316,7 @@ class display_engine {
return;
}
if (tracking::$data['bat']) {
if (tracking::$data['bat'] ?? false) {
// User tried to log in after being kicked
session::kill();
$this->displayKicked();

View file

@ -54,7 +54,7 @@ class display_engine {
return;
}
if (tracking::$data['bat']) {
if (isset(tracking::$data['bat'])) {
// User tried to log in after being kicked
session::kill();

View file

@ -6,6 +6,7 @@ class game {
private $__status = null;
private $__firstTick = null;
private $__lastTick = null;
public $db = null;
function __construct($version, $name, $namespace, $public, $canJoin, $text) {
$this->version = $version;
@ -48,7 +49,7 @@ class game {
private function __loadActionObject() {
if ($this->actionObj) {
if (isset($this->actionObj)) {
return;
}

View file

@ -47,7 +47,7 @@ class handler {
*/
// Get the list of supported engines
if (is_array($handler->engines)) {
if (isset($handler->engines) && is_array($handler->engines)) {
$engines = $handler->engines;
} else {
$engines = array('page', 'css', 'js', 'rpc');

View file

@ -111,7 +111,7 @@ function handleInput() {
engine::$e->initSession();
engine::$e->checkAuth();
if (is_array($_SESSION) && is_array(config::$main['trace'])
if (isset($_SESSION) && is_array(config::$main['trace'])
&& in_array($_SESSION['userid'], config::$main['trace'])) {
$path = input::$path;

View file

@ -15,7 +15,7 @@ class prefs {
while ($r = dbFetchHash($qr)) {
$v = $r['version'];
$i = $r['id'];
if (!is_array(prefs::$prefs[$v])) {
if (!isset(prefs::$prefs[$v])) {
prefs::$prefs[$v] = array();
}
prefs::$prefs[$v][$i] = $r['value'];
@ -96,7 +96,7 @@ class prefs {
}
list($version, $name) = explode('/', $path);
if (is_array(prefs::$prefs[$version])) {
if (isset(prefs::$prefs[$version])) {
$v = prefs::$prefs[$version][$name];
} else {
$v = null;

View file

@ -19,11 +19,11 @@ class tick_definition {
}
function getName($lang) {
return ($this->text[$lang] ? $this->text[$lang][0] : "");
return isset($this->text[$lang]) ? $this->text[$lang][0] : "";
}
function getDescription($lang) {
return ($this->text[$lang] ? $this->text[$lang][1] : "");
return isset($this->text[$lang]) ? $this->text[$lang][1] : "";
}
function getPath() {

View file

@ -34,6 +34,7 @@ class tick_manager {
}
}
l::debug("cache dir : " . config::$main['cachedir']);
if (file_exists(config::$main['cachedir'] . "/stop_ticks")) {
unlink(config::$main['cachedir'] . "/stop_ticks");
$this->ticksStopped = true;

View file

@ -121,7 +121,7 @@ class tracking {
tracking::$cName = config::getParam('trackname');
list($trackId,$trackNew) = tracking::readId();
if (handler::$h->noTracking && (is_null($trackId) || $trackNew)) {
if (handler::$h->noTracking ?? false && (is_null($trackId) || $trackNew)) {
tracking::$disabled = true;
return;
}