fix: fix even more PHP errors and warnings
This commit is contained in:
parent
077f97d5fc
commit
7debdba37c
28 changed files with 80 additions and 72 deletions
|
@ -81,16 +81,17 @@ function disableTicks() {
|
|||
$statusMessage = "";
|
||||
|
||||
// Start / stop manager
|
||||
if ($_GET['c'] == 'sm') {
|
||||
$command = $_GET['c'] ?? '';
|
||||
if ($command == 'sm') {
|
||||
startManager();
|
||||
} elseif ($_GET['c'] == 'km') {
|
||||
} elseif ($command == 'km') {
|
||||
killManager();
|
||||
} else {
|
||||
$mRunning = __isManagerRunning();
|
||||
$tActive = ($mRunning !== false) ? ticksActive() : false;
|
||||
|
||||
// Run tick manually
|
||||
if ($_GET['c'] == 'rt' && $_GET['g'] != '' && $_GET['t'] != '') {
|
||||
if ($command == 'rt' && $_GET['g'] != '' && $_GET['t'] != '') {
|
||||
$__runFromAdmin = true;
|
||||
$__adminParams = array($_GET['g'], $_GET['t']);
|
||||
__logAdmin("is running tick " . join("::", $__adminParams));
|
||||
|
@ -102,10 +103,10 @@ if ($_GET['c'] == 'sm') {
|
|||
|
||||
} else {
|
||||
// Enable / disable ticks
|
||||
if ($tActive === true && $_GET['c'] == 'dt') {
|
||||
if ($tActive === true && $command == 'dt') {
|
||||
disableTicks();
|
||||
$tActive = 'pending';
|
||||
} elseif ($mRunning !== false && $tActive === false && $_GET['c'] == 'et') {
|
||||
} elseif ($mRunning !== false && $tActive === false && $command == 'et') {
|
||||
enableTicks();
|
||||
$tActive = 'pending';
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ if (!class_exists('config')) {
|
|||
if ($mRunning === false) {
|
||||
?>
|
||||
<b>not running</b> - <a href="?c=sm">Start manager</a>
|
||||
<?php
|
||||
<?php
|
||||
} else {
|
||||
?> <b>running</b>, process ID #<?=$mRunning?> - <a href="?c=km">Kill manager</a><br/>
|
||||
<?php
|
||||
|
|
|
@ -72,7 +72,8 @@ class beta5_getUniverseOverview
|
|||
return array(
|
||||
$pc, $gr['points'], $gr['ranking'], $cr['points'], $cr['ranking'],
|
||||
$mr['points'], $mr['ranking'], $fr['points'], $fr['ranking'],
|
||||
$or['points'], $or['ranking'], $ir['points'], $ir['ranking']
|
||||
$or['points'] ?? "", $or['ranking'] ?? "",
|
||||
$ir['points'] ?? "", $ir['ranking'] ?? ""
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class beta5_alliance_getPrivileges {
|
|||
);
|
||||
|
||||
$pi = $this->players->call('get', $p);
|
||||
if (is_null($pi['aid'])) {
|
||||
if (!isset($pi['aid'])) {
|
||||
return $nr;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class beta5_fleet_getPower {
|
|||
|
||||
// Computes a fleet's power
|
||||
function run($pl, $g, $f, $c, $b) {
|
||||
if (!is_array($this->ePower[$pl])) {
|
||||
if (!isset($this->ePower[$pl])) {
|
||||
$r = $this->rules->call('get', $pl);
|
||||
$a = array('gaship','fighter','cruiser','bcruiser');
|
||||
$this->ePower[$pl] = array();
|
||||
|
|
|
@ -69,7 +69,7 @@ class beta5_forums_getStructure {
|
|||
|
||||
// Get alliance forums
|
||||
$ap = $this->alliance->call('getPrivileges', $player);
|
||||
if ($ap['f_read'] || $ap['f_mod']) {
|
||||
if (($ap['f_read'] ?? false) || ($ap['f_mod'] ?? false)) {
|
||||
$rv['A#'.$pi['aid']] = array(
|
||||
"id" => $pi['aid'],
|
||||
"type" => "A",
|
||||
|
|
|
@ -55,7 +55,7 @@ class beta5_planet_library {
|
|||
$r = dbFetchHash($q);
|
||||
$r["rename"] = ($r['rename'] == 't') ? 1 : 0;
|
||||
|
||||
if (is_null($this->pOwner[$r['id']])) {
|
||||
if (!isset($this->pOwner[$r['id']])) {
|
||||
$this->pOwner[$r['id']] = $r['owner'];
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class beta5_player_get {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (is_array($this->lib->mainClass->players[$id])) {
|
||||
if (isset($this->lib->mainClass->players[$id])) {
|
||||
if (!$quitOk && $this->lib->mainClass->players[$id]["quit"] == "1") {
|
||||
return null;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class beta5_player_get {
|
|||
"vac" => ($a[10] == 't'),
|
||||
);
|
||||
|
||||
if (is_null($this->lib->mainClass->pNames[$id])) {
|
||||
if (!isset($this->lib->mainClass->pNames[$id])) {
|
||||
$this->lib->mainClass->pNames[$id] = $pinf['name'];
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class beta5_player_isOnVacation {
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($this->lib->game->params['novacation'] == 1) {
|
||||
if ($this->lib->game->params['novacation'] ?? 0 == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
class beta5_rules_library {
|
||||
var $index = array(
|
||||
public $index = array(
|
||||
'change',
|
||||
'get'
|
||||
);
|
||||
);
|
||||
public $rules = [];
|
||||
|
||||
|
||||
public function __construct($lib) {
|
||||
|
|
|
@ -11,7 +11,7 @@ class beta5_rules_get {
|
|||
// Loads rules for a player
|
||||
function run($pid) {
|
||||
$apid = is_null($pid) ? ' ' : $pid;
|
||||
if (is_array($this->lib->mainClass->rules[$apid])) {
|
||||
if (isset($this->lib->mainClass->rules[$apid])) {
|
||||
return $this->lib->mainClass->rules[$apid];
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ class main_manual_search {
|
|||
$required = $excluded = $normal = array();
|
||||
$tl = explode(' ', $text);
|
||||
foreach ($tl as $word) {
|
||||
if ($word{0} == '+' || $word{0} == '-') {
|
||||
$qual = $word{0};
|
||||
if ($word[0] == '+' || $word[0] == '-') {
|
||||
$qual = $word[0];
|
||||
$word = substr($word, 1);
|
||||
} else {
|
||||
$qual = '';
|
||||
|
|
|
@ -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'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class page_handler {
|
|||
public function getOverview() {
|
||||
$overview = $this->game->action('getOverview', $_SESSION[game::sessName()]['player'],
|
||||
getLanguage());
|
||||
$result = array($_SESSION[game::sessName()]['ov_complete'] ? "1" : "0");
|
||||
$result = array($_SESSION[game::sessName()]['ov_complete'] ?? false ? "1" : "0");
|
||||
|
||||
// Protection level
|
||||
array_push($result, $overview['protection']);
|
||||
|
@ -18,7 +18,7 @@ class page_handler {
|
|||
// Communications overview
|
||||
$data = $overview['comms'];
|
||||
array_push($result, count($data['folders']['CUS']) . "#" . count($data['forums']['general'])
|
||||
. "#" . count($data['forums']['alliance']) . "#" . $data['forums']['allianceID']);
|
||||
. "#" . count($data['forums']['alliance']) . "#" . ($data['forums']['allianceID'] ?? ''));
|
||||
|
||||
// Messages in default folders
|
||||
$dFld = array('IN', 'INT', 'OUT');
|
||||
|
@ -75,7 +75,7 @@ class page_handler {
|
|||
}
|
||||
|
||||
public function switchOvMode() {
|
||||
$_SESSION[game::sessName()]['ov_complete'] = ! $_SESSION[game::sessName()]['ov_complete'];
|
||||
$_SESSION[game::sessName()]['ov_complete'] = !( $_SESSION[game::sessName()]['ov_complete'] ?? false );
|
||||
}
|
||||
|
||||
public function handle($input) {
|
||||
|
|
|
@ -2,17 +2,20 @@
|
|||
|
||||
class page_handler
|
||||
{
|
||||
var $needsAuth = true;
|
||||
var $ajax = array();
|
||||
private $mailError = null;
|
||||
private $passError = null;
|
||||
|
||||
function checkMail($a) {
|
||||
public $needsAuth = true;
|
||||
public $ajax = array();
|
||||
|
||||
private static function checkMail($a) {
|
||||
return preg_match(
|
||||
'/^[A-Za-z0-9_\.\-\+]+@([A-Za-z0-9_\.\-\+]+)+\.[A-Za-z]{2,6}/',
|
||||
'/^[A-Za-z0-9_\.\-\+]+@([A-Za-z0-9_\.\-\+]+)+\.[A-Za-z]{2,6}$/',
|
||||
$a
|
||||
);
|
||||
}
|
||||
|
||||
function checkPassword($op, $np, $cp) {
|
||||
private function checkPassword($op, $np, $cp) {
|
||||
$q = dbQuery("SELECT password FROM account WHERE id=".$_SESSION['userid']);
|
||||
if (!$q) {
|
||||
$this->passError = 1;
|
||||
|
@ -44,8 +47,7 @@ class page_handler
|
|||
}
|
||||
}
|
||||
|
||||
function checkFormData($input)
|
||||
{
|
||||
private function checkFormData($input) {
|
||||
$pLang = array('fr', 'en');
|
||||
if (in_array($input['lang'], $pLang))
|
||||
prefs::set('main/language', $input['lang']);
|
||||
|
@ -65,7 +67,7 @@ class page_handler
|
|||
if (preg_match('/^[0-4]$/', $input['fs']))
|
||||
prefs::set('main/font_size', $input['fs']);
|
||||
|
||||
if ($this->checkMail($input['mail']))
|
||||
if (self::checkMail($input['mail']))
|
||||
dbQuery("UPDATE account SET email='".$input['mail']."' WHERE id=".$_SESSION['userid']);
|
||||
else
|
||||
$this->mailError = preg_replace('/"/', '"', $input['mail']);
|
||||
|
@ -91,7 +93,7 @@ class page_handler
|
|||
$this->checkPassword($input['opass'], $input['npass'], $input['cpass']);
|
||||
}
|
||||
|
||||
function handleQuit() {
|
||||
private function handleQuit() {
|
||||
if (gameAction('isFinished')) {
|
||||
return;
|
||||
}
|
||||
|
@ -103,9 +105,9 @@ class page_handler
|
|||
gameAction('setPlayerQuit', $pid);
|
||||
}
|
||||
|
||||
function handle($input)
|
||||
public function handle($input)
|
||||
{
|
||||
if (!is_null($input['quit']))
|
||||
if (isset($input['quit']))
|
||||
$this->handleQuit();
|
||||
elseif ($input['col'] != "")
|
||||
$this->checkFormData($input);
|
||||
|
|
|
@ -7,7 +7,8 @@ function thm_getHeaderData() {
|
|||
|
||||
$pi = $pLib->call('get', $player);
|
||||
$newMsg = ($mLib->call('getNew', $player) > 0) ? 1 : 0;
|
||||
return time() . "#{$pi['name']}#{$pi['cash']}#$newMsg#{$pi['alliance']}";
|
||||
$alliance = $pi['alliance'] ?? '';
|
||||
return time() . "#{$pi['name']}#{$pi['cash']}#$newMsg#$alliance";
|
||||
}
|
||||
|
||||
function thm_getHeaderPList() {
|
||||
|
|
|
@ -71,7 +71,7 @@ $alliance = $game->getLib('beta5/alliance');
|
|||
|
||||
$player = $_SESSION[game::sessName()]['player'];
|
||||
$pInfo = $players->call('get', $player);
|
||||
if ($pInfo['aid']) {
|
||||
if (isset($pInfo['aid'])) {
|
||||
$privileges = $alliance->call('getPrivileges', $player);
|
||||
$techTrade = ($privileges['tech_trade'] > 0);
|
||||
} else {
|
||||
|
|
|
@ -22,10 +22,10 @@ class page_layout {
|
|||
|
||||
// Generate CSS and JS resources
|
||||
$this->generateStylesheets($pg, $thm, $fs, $col);
|
||||
if (is_null(handler::$h->customJS)) {
|
||||
$this->generateJS($pg, $thm, $col, $lg, $tt, $fs);
|
||||
} else {
|
||||
if (isset(handler::$h->customJS)) {
|
||||
$this->jsRes = handler::$h->customJS;
|
||||
} else {
|
||||
$this->generateJS($pg, $thm, $col, $lg, $tt, $fs);
|
||||
}
|
||||
|
||||
if (!is_null($this->cssRes)) {
|
||||
|
@ -37,7 +37,14 @@ class page_layout {
|
|||
|
||||
// Generate HTML body tag
|
||||
echo "</head><body";
|
||||
if (is_null(handler::$h->customJS)) {
|
||||
if (isset(handler::$h->customJS)) {
|
||||
if (!is_null(handler::$h->customJS['load'])) {
|
||||
echo " onload='" . handler::$h->customJS['load'] . "'";
|
||||
}
|
||||
if (!is_null(handler::$h->customJS['unload'])) {
|
||||
echo " onunload='" . handler::$h->customJS['unload'] ."'";
|
||||
}
|
||||
} else {
|
||||
if (ajax::$init != "" || $tt) {
|
||||
echo " onload='lwAutoInit();'";
|
||||
}
|
||||
|
@ -45,20 +52,13 @@ class page_layout {
|
|||
echo " onunload='tt_Disable()'";
|
||||
}
|
||||
echo ">\n";
|
||||
} else {
|
||||
if (!is_null(handler::$h->customJS['load'])) {
|
||||
echo " onload='" . handler::$h->customJS['load'] . "'";
|
||||
}
|
||||
if (!is_null(handler::$h->customJS['unload'])) {
|
||||
echo " onunload='" . handler::$h->customJS['unload'] ."'";
|
||||
}
|
||||
}
|
||||
|
||||
// Load the header
|
||||
if (is_null(handler::$h->customHeader)) {
|
||||
$hdr = "header";
|
||||
} else {
|
||||
if (isset(handler::$h->customHeader)) {
|
||||
$hdr = handler::$h->customHeader;
|
||||
} else {
|
||||
$hdr = "header";
|
||||
}
|
||||
$this->includeFile("{$this->dir}/layout/$thm/$hdr.$lg.inc");
|
||||
}
|
||||
|
@ -69,15 +69,15 @@ class page_layout {
|
|||
$col = prefs::get('main/colour', 'purple');
|
||||
$thm = prefs::get('beta5/theme', "default");
|
||||
|
||||
if (is_null(handler::$h->customFooter)) {
|
||||
$ftr = "footer";
|
||||
} else {
|
||||
if (isset(handler::$h->customFooter)) {
|
||||
$ftr = handler::$h->customFooter;
|
||||
} else {
|
||||
$ftr = "footer";
|
||||
}
|
||||
$this->includeFile("{$this->dir}/layout/$thm/$ftr.$lg.inc");
|
||||
|
||||
// Tooltips
|
||||
if ($tt && is_null(handler::$h->customJS)) {
|
||||
if ($tt && !isset(handler::$h->customJS)) {
|
||||
echo "<div id='ttPlaceHolderReserved'></div>";
|
||||
$f = getStatic("beta5/js/tt_{$thm}_$col.js");
|
||||
if (!is_null($f)) {
|
||||
|
|
|
@ -104,7 +104,7 @@ class page_handler {
|
|||
tracking::$data['readDisclaimer'] = true;
|
||||
$this->output = "disclaimer";
|
||||
$this->data = true;
|
||||
} elseif (tracking::$data['bat']) {
|
||||
} elseif (isset(tracking::$data['bat'])) {
|
||||
$this->output = "kicked";
|
||||
} elseif ($input['create'] == "") {
|
||||
$this->output = "create";
|
||||
|
|
Loading…
Reference in a new issue