From a4b45ddaa4c921c2df50a62d924d9c5734de2365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20BENO=C3=8ET?= Date: Tue, 31 Dec 2024 11:24:12 +0100 Subject: [PATCH] fix: fix various PHP problems and a few bugs --- admin/bot.php | 2 -- admin/cg_done.php | 2 -- admin/cg_step0.php | 2 -- admin/cg_step1.php | 2 -- admin/cg_step10.php | 2 -- admin/cg_step11.php | 2 -- admin/cg_step12.php | 2 -- admin/cg_step13.php | 2 -- admin/cg_step2.php | 2 -- admin/cg_step3.php | 2 -- admin/cg_step4.php | 2 -- admin/cg_step5.php | 2 -- admin/cg_step6.php | 2 -- admin/cg_step7.php | 2 -- admin/cg_step8.php | 2 -- admin/cg_step9.php | 2 -- admin/create.php | 2 -- admin/deathofrats.php | 2 -- admin/maintenance.php | 2 -- admin/maps.php | 6 +++--- admin/proxy.php | 2 -- admin/set_default.php | 2 -- .../game/beta5/fleet/library/sendMoveMessages.inc | 5 +++-- scripts/game/beta5/library/listing.inc | 4 +++- scripts/game/beta5/library/updateRankings.inc | 2 +- scripts/game/beta5/ticks/battle/library.inc | 2 +- scripts/game/beta5/ticks/hour/library.inc | 2 +- scripts/game/main/ticks/deathofrats/library.inc | 2 +- scripts/site/beta5/handlers/alliance.inc | 12 ++++++------ scripts/site/beta5/handlers/forums.inc | 2 +- scripts/site/beta5/handlers/market.inc | 2 +- scripts/site/beta5/handlers/planet.inc | 2 +- scripts/site/beta5/handlers/probes.inc | 6 +++--- scripts/site/beta5/handlers/research.inc | 4 ++-- 34 files changed, 27 insertions(+), 66 deletions(-) diff --git a/admin/bot.php b/admin/bot.php index a69d4ca..69f21cf 100644 --- a/admin/bot.php +++ b/admin/bot.php @@ -1,7 +1,5 @@ diff --git a/admin/cg_step0.php b/admin/cg_step0.php index 51f370b..82b64c6 100644 --- a/admin/cg_step0.php +++ b/admin/cg_step0.php @@ -1,7 +1,5 @@ LWB5 > Administration > Maintenance mode setSystemType($x, $y, $type); if ($type != 'S') { $str = substr($str, 1); continue; } - $alloc = (int) $str{1}; + $alloc = (int) $str[1]; $map->setSystemAlloc($x, $y, $alloc); if ($alloc == 0) { $str = substr($str, 2); continue; } - $map->setSystemSpawn($x, $y, $str{2} == '1'); + $map->setSystemSpawn($x, $y, $str[2] == '1'); $str = substr($str, 3); } } diff --git a/admin/proxy.php b/admin/proxy.php index 76054f9..e2ad00b 100644 --- a/admin/proxy.php +++ b/admin/proxy.php @@ -1,7 +1,5 @@ lib->mainClass->fleetDepartures[$location])) { - foreach ($this->lib->mainClass->fleetDepartures[$location][(int)$status] as $fId) { + foreach ($this->lib->mainClass->fleetDepartures[$location][$status] as $fId) { $f = $this->lib->call('get', $fId); if ($f['owner'] == $player) { continue; @@ -48,7 +49,7 @@ class beta5_fleet_sendMoveMessages { // Generate the list of fleet arrivals if (is_array($this->lib->mainClass->fleetArrivals[$location])) { - foreach ($this->lib->mainClass->fleetArrivals[$location][(int)$status] as $fdt) { + foreach ($this->lib->mainClass->fleetArrivals[$location][$status] as $fdt) { list($fId, $from) = $fdt; $f = $this->lib->call('get', $fId); $f['from'] = $from; diff --git a/scripts/game/beta5/library/listing.inc b/scripts/game/beta5/library/listing.inc index b044b47..b29f32b 100644 --- a/scripts/game/beta5/library/listing.inc +++ b/scripts/game/beta5/library/listing.inc @@ -105,10 +105,12 @@ class beta5_listing { $rStr = array("$nMD5#$nPages"); foreach ($data as $e) { $a = array(); + l::debug("\$a is " . var_export($a, true)); foreach ($conf['output'] as $f) { array_push($a, utf8entities($e[$f])); + l::debug("\$a is " . var_export($a, true)); } - array_push($rStr, join($a, "#")); + array_push($rStr, join("#", $a)); } return join("\n", $rStr); diff --git a/scripts/game/beta5/library/updateRankings.inc b/scripts/game/beta5/library/updateRankings.inc index 16e79a8..01adf4a 100644 --- a/scripts/game/beta5/library/updateRankings.inc +++ b/scripts/game/beta5/library/updateRankings.inc @@ -99,7 +99,7 @@ class beta5_updateRankings { $income += $ir[0]; } $upkeep = $this->fleets->call('getUpkeep', $r[0], $fld[0], $fld[1], $fld[2], $fld[3]); - $profit = max(0, $income[0] - $upkeep); + $profit = max(0, $income - $upkeep); $fr = round($cash / 2000); $fr += round($profit / 2) + round($income / 1.5); $fr += round($pld[1] * 201); diff --git a/scripts/game/beta5/ticks/battle/library.inc b/scripts/game/beta5/ticks/battle/library.inc index 4e8fd64..72dd359 100644 --- a/scripts/game/beta5/ticks/battle/library.inc +++ b/scripts/game/beta5/ticks/battle/library.inc @@ -513,7 +513,7 @@ class beta5_ticks_battle_library { function btQuery($q) { $r = $this->db->query($q); - l::trace("Result '$r' for query: $q"); + //l::trace("Result '$r' for query: $q"); return $r; } } diff --git a/scripts/game/beta5/ticks/hour/library.inc b/scripts/game/beta5/ticks/hour/library.inc index ca9a272..b96402b 100644 --- a/scripts/game/beta5/ticks/hour/library.inc +++ b/scripts/game/beta5/ticks/hour/library.inc @@ -105,7 +105,7 @@ class beta5_ticks_hour_library { $losses = array(); $planets = array(); foreach ($fWait as $fw) { - if ($this->handleWait($fw, &$losses)) { + if ($this->handleWait($fw, $losses)) { array_push($planets, $fw['drop_point']); } } diff --git a/scripts/game/main/ticks/deathofrats/library.inc b/scripts/game/main/ticks/deathofrats/library.inc index 38b85b7..e02e218 100644 --- a/scripts/game/main/ticks/deathofrats/library.inc +++ b/scripts/game/main/ticks/deathofrats/library.inc @@ -633,7 +633,7 @@ class main_ticks_deathofrats_library { "SELECT account, tracking, ip_addr, action, t FROM account_log " . "WHERE action IN ('IN', 'OUT', 'CREATE') " . "AND t > {$this->lastExec} AND t <= {$this->now}" - . "ORDER BY t" + . " ORDER BY t" ); $records = array(); while ($r = dbFetchHash($q)) { diff --git a/scripts/site/beta5/handlers/alliance.inc b/scripts/site/beta5/handlers/alliance.inc index d8880f5..0087566 100644 --- a/scripts/site/beta5/handlers/alliance.inc +++ b/scripts/site/beta5/handlers/alliance.inc @@ -812,7 +812,7 @@ class page_handler { $s .= "$id#" . $afd['order'] . "#" . ($afd['user_post'] ? 1 : 0) . "#" . $afd['title']; if ($afd['description'] != '') { - $dll = split("\n", $afd['description']); + $dll = explode("\n", $afd['description']); foreach ($dll as $dl) $s .= "\n+#$dl"; } @@ -1087,7 +1087,7 @@ class page_handler { } // Check privileges - $pl = split('#', $privileges); + $pl = explode('#', $privileges); $pnames = array('list_access', 'attacks', 'can_set_grades', 'can_kick', 'can_accept', 'forum_admin', 'dipl_contact', 'can_vote', 'can_be_cand', 'tech_trade'); @@ -1110,7 +1110,7 @@ class page_handler { // Check kickable ranks if ($privs['can_kick'] && $rkick != "") { - $rkl = split('#', $rkick); + $rkl = explode('#', $rkick); for ($i=0;$i