diff --git a/admin/ticks.php b/admin/ticks.php
index 82ef87e..ec5d791 100644
--- a/admin/ticks.php
+++ b/admin/ticks.php
@@ -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) {
?>
not running - Start manager
- running, process ID #=$mRunning?> - Kill manager
players->call('get', $p);
- if (is_null($pi['aid'])) {
+ if (!isset($pi['aid'])) {
return $nr;
}
diff --git a/scripts/game/beta5/fleet/library/getPower.inc b/scripts/game/beta5/fleet/library/getPower.inc
index 4a84104..8a01bbc 100644
--- a/scripts/game/beta5/fleet/library/getPower.inc
+++ b/scripts/game/beta5/fleet/library/getPower.inc
@@ -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();
diff --git a/scripts/game/beta5/forums/library/getStructure.inc b/scripts/game/beta5/forums/library/getStructure.inc
index 4d954fe..43799f9 100644
--- a/scripts/game/beta5/forums/library/getStructure.inc
+++ b/scripts/game/beta5/forums/library/getStructure.inc
@@ -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",
diff --git a/scripts/game/beta5/planet/library.inc b/scripts/game/beta5/planet/library.inc
index db6758c..66525ff 100644
--- a/scripts/game/beta5/planet/library.inc
+++ b/scripts/game/beta5/planet/library.inc
@@ -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'];
}
diff --git a/scripts/game/beta5/player/library/get.inc b/scripts/game/beta5/player/library/get.inc
index 58643cf..9347339 100644
--- a/scripts/game/beta5/player/library/get.inc
+++ b/scripts/game/beta5/player/library/get.inc
@@ -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'];
}
diff --git a/scripts/game/beta5/player/library/isOnVacation.inc b/scripts/game/beta5/player/library/isOnVacation.inc
index bbbcbb3..007ab5a 100644
--- a/scripts/game/beta5/player/library/isOnVacation.inc
+++ b/scripts/game/beta5/player/library/isOnVacation.inc
@@ -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;
}
diff --git a/scripts/game/beta5/rules/library.inc b/scripts/game/beta5/rules/library.inc
index 5a54ffd..773a77f 100644
--- a/scripts/game/beta5/rules/library.inc
+++ b/scripts/game/beta5/rules/library.inc
@@ -1,10 +1,11 @@
lib->mainClass->rules[$apid])) {
+ if (isset($this->lib->mainClass->rules[$apid])) {
return $this->lib->mainClass->rules[$apid];
}
diff --git a/scripts/game/main/manual/library/search.inc b/scripts/game/main/manual/library/search.inc
index c531fac..218d1d8 100644
--- a/scripts/game/main/manual/library/search.inc
+++ b/scripts/game/main/manual/library/search.inc
@@ -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 = '';
diff --git a/scripts/lib/ajax.inc b/scripts/lib/ajax.inc
index c28d6aa..5c6e79a 100644
--- a/scripts/lib/ajax.inc
+++ b/scripts/lib/ajax.inc
@@ -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'] ?? '');
}
diff --git a/scripts/lib/db_connection.inc b/scripts/lib/db_connection.inc
index 4cfc166..dc35dde 100644
--- a/scripts/lib/db_connection.inc
+++ b/scripts/lib/db_connection.inc
@@ -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];
diff --git a/scripts/lib/engines/page.inc b/scripts/lib/engines/page.inc
index a5a7f94..24c2ca2 100644
--- a/scripts/lib/engines/page.inc
+++ b/scripts/lib/engines/page.inc
@@ -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();
diff --git a/scripts/lib/engines/rpc.inc b/scripts/lib/engines/rpc.inc
index 20dd3ac..77c66a9 100644
--- a/scripts/lib/engines/rpc.inc
+++ b/scripts/lib/engines/rpc.inc
@@ -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();
diff --git a/scripts/lib/game.inc b/scripts/lib/game.inc
index 1ef41f0..8c91af3 100644
--- a/scripts/lib/game.inc
+++ b/scripts/lib/game.inc
@@ -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;
}
diff --git a/scripts/lib/handler.inc b/scripts/lib/handler.inc
index 7402954..50db6c9 100644
--- a/scripts/lib/handler.inc
+++ b/scripts/lib/handler.inc
@@ -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');
diff --git a/scripts/lib/output.inc b/scripts/lib/output.inc
index 0d94136..c7f34d7 100644
--- a/scripts/lib/output.inc
+++ b/scripts/lib/output.inc
@@ -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;
diff --git a/scripts/lib/prefs.inc b/scripts/lib/prefs.inc
index 0670938..ac13ebe 100644
--- a/scripts/lib/prefs.inc
+++ b/scripts/lib/prefs.inc
@@ -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;
diff --git a/scripts/lib/tick.inc b/scripts/lib/tick.inc
index 84f5a70..05b03e2 100644
--- a/scripts/lib/tick.inc
+++ b/scripts/lib/tick.inc
@@ -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() {
diff --git a/scripts/lib/tick_manager.inc b/scripts/lib/tick_manager.inc
index 955075e..5c70f04 100644
--- a/scripts/lib/tick_manager.inc
+++ b/scripts/lib/tick_manager.inc
@@ -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;
diff --git a/scripts/lib/tracking.inc b/scripts/lib/tracking.inc
index 4f70bc6..f71098b 100644
--- a/scripts/lib/tracking.inc
+++ b/scripts/lib/tracking.inc
@@ -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;
}
diff --git a/scripts/site/beta5/handlers/overview.inc b/scripts/site/beta5/handlers/overview.inc
index 1c13894..b8f4162 100644
--- a/scripts/site/beta5/handlers/overview.inc
+++ b/scripts/site/beta5/handlers/overview.inc
@@ -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) {
diff --git a/scripts/site/beta5/handlers/preferences.inc b/scripts/site/beta5/handlers/preferences.inc
index dbf88a9..08e43ae 100644
--- a/scripts/site/beta5/handlers/preferences.inc
+++ b/scripts/site/beta5/handlers/preferences.inc
@@ -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);
diff --git a/scripts/site/beta5/layout/default/ajax.inc b/scripts/site/beta5/layout/default/ajax.inc
index 0f0d9cb..8e8842c 100644
--- a/scripts/site/beta5/layout/default/ajax.inc
+++ b/scripts/site/beta5/layout/default/ajax.inc
@@ -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() {
diff --git a/scripts/site/beta5/layout/default/header.en.inc b/scripts/site/beta5/layout/default/header.en.inc
index 9d5c322..f379d08 100644
--- a/scripts/site/beta5/layout/default/header.en.inc
+++ b/scripts/site/beta5/layout/default/header.en.inc
@@ -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 {
diff --git a/scripts/site/beta5/page.inc b/scripts/site/beta5/page.inc
index f0afd4b..a7f12e1 100644
--- a/scripts/site/beta5/page.inc
+++ b/scripts/site/beta5/page.inc
@@ -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 "