fix: fix various PHP problems and a few bugs

This commit is contained in:
Emmanuel BENOîT 2024-12-31 11:24:12 +01:00
parent c91440af72
commit a4b45ddaa4
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
34 changed files with 27 additions and 66 deletions

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
include('config.inc'); include('config.inc');
include('../scripts/config.inc'); include('../scripts/config.inc');
include('as_manager.inc'); include('as_manager.inc');

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
?> ?>

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || $_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || $_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) {
echo "Sorry, can't do that."; echo "Sorry, can't do that.";

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
session_start(); session_start();
if (!is_array($_SESSION['lw_new_game']) || $_GET['reset']) { if (!is_array($_SESSION['lw_new_game']) || $_GET['reset']) {
$_SESSION['lw_new_game'] = array( $_SESSION['lw_new_game'] = array(

View file

@ -9,8 +9,6 @@
Select page: Select page:
<?php <?php
set_magic_quotes_runtime(false);
include('config.inc'); include('config.inc');
switch ($_GET['p']) { switch ($_GET['p']) {

View file

@ -6,8 +6,6 @@
<h1><a href="index.html">LWB5 > Administration</a> > Maintenance mode</h1> <h1><a href="index.html">LWB5 > Administration</a> > Maintenance mode</h1>
<?php <?php
set_magic_quotes_runtime(false);
include('../scripts/config.inc'); include('../scripts/config.inc');
include('as_log.inc'); include('as_log.inc');

View file

@ -37,19 +37,19 @@ function handleInput() {
for ($y = $minY; $y <= $maxY; $y ++) { for ($y = $minY; $y <= $maxY; $y ++) {
$str = array_shift($layout); $str = array_shift($layout);
for ($x = $minX; $x <= $maxX; $x ++) { for ($x = $minX; $x <= $maxX; $x ++) {
$type = $str{0}; $type = $str[0];
$map->setSystemType($x, $y, $type); $map->setSystemType($x, $y, $type);
if ($type != 'S') { if ($type != 'S') {
$str = substr($str, 1); $str = substr($str, 1);
continue; continue;
} }
$alloc = (int) $str{1}; $alloc = (int) $str[1];
$map->setSystemAlloc($x, $y, $alloc); $map->setSystemAlloc($x, $y, $alloc);
if ($alloc == 0) { if ($alloc == 0) {
$str = substr($str, 2); $str = substr($str, 2);
continue; continue;
} }
$map->setSystemSpawn($x, $y, $str{2} == '1'); $map->setSystemSpawn($x, $y, $str[2] == '1');
$str = substr($str, 3); $str = substr($str, 3);
} }
} }

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
include('config.inc'); include('config.inc');
include('../scripts/config.inc'); include('../scripts/config.inc');
include('as_manager.inc'); include('as_manager.inc');

View file

@ -1,7 +1,5 @@
<?php <?php
set_magic_quotes_runtime(false);
include('config.inc'); include('config.inc');
include('as_log.inc'); include('as_log.inc');

View file

@ -26,11 +26,12 @@ class beta5_fleet_sendMoveMessages {
$ownArrivals = array(); $ownArrivals = array();
while ($r = dbFetchArray($q)) { while ($r = dbFetchArray($q)) {
list($player,$status,$location) = $r; list($player,$status,$location) = $r;
$status = (int) $status;
$oa = $ha = $hd = $fa = $fd = array(); $oa = $ha = $hd = $fa = $fd = array();
// Generate the list of fleet departures // Generate the list of fleet departures
if (is_array($this->lib->mainClass->fleetDepartures[$location])) { if (is_array($this->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); $f = $this->lib->call('get', $fId);
if ($f['owner'] == $player) { if ($f['owner'] == $player) {
continue; continue;
@ -48,7 +49,7 @@ class beta5_fleet_sendMoveMessages {
// Generate the list of fleet arrivals // Generate the list of fleet arrivals
if (is_array($this->lib->mainClass->fleetArrivals[$location])) { 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; list($fId, $from) = $fdt;
$f = $this->lib->call('get', $fId); $f = $this->lib->call('get', $fId);
$f['from'] = $from; $f['from'] = $from;

View file

@ -105,10 +105,12 @@ class beta5_listing {
$rStr = array("$nMD5#$nPages"); $rStr = array("$nMD5#$nPages");
foreach ($data as $e) { foreach ($data as $e) {
$a = array(); $a = array();
l::debug("\$a is " . var_export($a, true));
foreach ($conf['output'] as $f) { foreach ($conf['output'] as $f) {
array_push($a, utf8entities($e[$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); return join("\n", $rStr);

View file

@ -99,7 +99,7 @@ class beta5_updateRankings {
$income += $ir[0]; $income += $ir[0];
} }
$upkeep = $this->fleets->call('getUpkeep', $r[0], $fld[0], $fld[1], $fld[2], $fld[3]); $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($cash / 2000);
$fr += round($profit / 2) + round($income / 1.5); $fr += round($profit / 2) + round($income / 1.5);
$fr += round($pld[1] * 201); $fr += round($pld[1] * 201);

View file

@ -513,7 +513,7 @@ class beta5_ticks_battle_library {
function btQuery($q) { function btQuery($q) {
$r = $this->db->query($q); $r = $this->db->query($q);
l::trace("Result '$r' for query: $q"); //l::trace("Result '$r' for query: $q");
return $r; return $r;
} }
} }

View file

@ -105,7 +105,7 @@ class beta5_ticks_hour_library {
$losses = array(); $losses = array();
$planets = array(); $planets = array();
foreach ($fWait as $fw) { foreach ($fWait as $fw) {
if ($this->handleWait($fw, &$losses)) { if ($this->handleWait($fw, $losses)) {
array_push($planets, $fw['drop_point']); array_push($planets, $fw['drop_point']);
} }
} }

View file

@ -633,7 +633,7 @@ class main_ticks_deathofrats_library {
"SELECT account, tracking, ip_addr, action, t FROM account_log " "SELECT account, tracking, ip_addr, action, t FROM account_log "
. "WHERE action IN ('IN', 'OUT', 'CREATE') " . "WHERE action IN ('IN', 'OUT', 'CREATE') "
. "AND t > {$this->lastExec} AND t <= {$this->now}" . "AND t > {$this->lastExec} AND t <= {$this->now}"
. "ORDER BY t" . " ORDER BY t"
); );
$records = array(); $records = array();
while ($r = dbFetchHash($q)) { while ($r = dbFetchHash($q)) {

View file

@ -812,7 +812,7 @@ class page_handler {
$s .= "$id#" . $afd['order'] . "#" . ($afd['user_post'] ? 1 : 0) . "#" . $afd['title']; $s .= "$id#" . $afd['order'] . "#" . ($afd['user_post'] ? 1 : 0) . "#" . $afd['title'];
if ($afd['description'] != '') if ($afd['description'] != '')
{ {
$dll = split("\n", $afd['description']); $dll = explode("\n", $afd['description']);
foreach ($dll as $dl) foreach ($dll as $dl)
$s .= "\n+#$dl"; $s .= "\n+#$dl";
} }
@ -1087,7 +1087,7 @@ class page_handler {
} }
// Check privileges // Check privileges
$pl = split('#', $privileges); $pl = explode('#', $privileges);
$pnames = array('list_access', 'attacks', 'can_set_grades', 'can_kick', $pnames = array('list_access', 'attacks', 'can_set_grades', 'can_kick',
'can_accept', 'forum_admin', 'dipl_contact', 'can_vote', 'can_be_cand', 'can_accept', 'forum_admin', 'dipl_contact', 'can_vote', 'can_be_cand',
'tech_trade'); 'tech_trade');
@ -1110,7 +1110,7 @@ class page_handler {
// Check kickable ranks // Check kickable ranks
if ($privs['can_kick'] && $rkick != "") { if ($privs['can_kick'] && $rkick != "") {
$rkl = split('#', $rkick); $rkl = explode('#', $rkick);
for ($i=0;$i<count($rkl);$i++) { for ($i=0;$i<count($rkl);$i++) {
$rkl[$i] = (int)$rkl[$i]; $rkl[$i] = (int)$rkl[$i];
if (!in_array($rkl[$i], $rl)) { if (!in_array($rkl[$i], $rl)) {
@ -1123,7 +1123,7 @@ class page_handler {
// Check changeable ranks // Check changeable ranks
if ($privs['can_set_grades'] && $rchange != "") { if ($privs['can_set_grades'] && $rchange != "") {
$rcl = split('#', $rchange); $rcl = explode('#', $rchange);
for ($i=0;$i<count($rcl);$i++) { for ($i=0;$i<count($rcl);$i++) {
$rcl[$i] = (int)$rcl[$i]; $rcl[$i] = (int)$rcl[$i];
if (!in_array($rcl[$i], $rl)) { if (!in_array($rcl[$i], $rl)) {
@ -1138,7 +1138,7 @@ class page_handler {
if (!$privs['forum_admin']) { if (!$privs['forum_admin']) {
// Check readable forums // Check readable forums
if ($fread != '') { if ($fread != '') {
$frl = split('#', $fread); $frl = explode('#', $fread);
for ($i=0;$i<count($frl);$i++) { for ($i=0;$i<count($frl);$i++) {
$frl[$i] = (int)$frl[$i]; $frl[$i] = (int)$frl[$i];
if (!in_array($frl[$i], $fl)) { if (!in_array($frl[$i], $fl)) {
@ -1151,7 +1151,7 @@ class page_handler {
// Check moderated forums // Check moderated forums
if ($fmod != '') { if ($fmod != '') {
$mrl = split('#', $fmod); $mrl = explode('#', $fmod);
for ($i=0;$i<count($mrl);$i++) { for ($i=0;$i<count($mrl);$i++) {
$mrl[$i] = (int)$mrl[$i]; $mrl[$i] = (int)$mrl[$i];
if (!in_array($mrl[$i], $fl)) { if (!in_array($mrl[$i], $fl)) {

View file

@ -135,7 +135,7 @@ class page_handler
function doForumMod(&$forum, $in, &$cats) function doForumMod(&$forum, $in, &$cats)
{ {
$sel = $in['msel']; $sel = $in['msel'];
if (!count($sel)) if (!$sel)
return; return;
if ($in['dt'] != '') if ($in['dt'] != '')
{ {

View file

@ -166,7 +166,7 @@ class page_handler
switch ($type) : switch ($type) :
case 0: case 0:
list($x,$y) = split('#',$parm); list($x,$y) = explode('#',$parm);
$map['x'] = (int)$x; $map['x'] = (int)$x;
$map['y'] = (int)$y; $map['y'] = (int)$y;
$map['type'] = 0; $map['type'] = 0;

View file

@ -460,7 +460,7 @@ class page_handler
// Check fleets // Check fleets
if ($fleets != "") if ($fleets != "")
{ {
$sFleets = split('#', $fleets); $sFleets = explode('#', $fleets);
$flist = array_keys(gameAction('getFleetsAt', $pid, $cPlayer)); $flist = array_keys(gameAction('getFleetsAt', $pid, $cPlayer));
foreach ($sFleets as $fid) foreach ($sFleets as $fid)
{ {

View file

@ -31,7 +31,7 @@ class page_handler
return "ERR#0"; return "ERR#0";
// Set new value // Set new value
$ePolicy{$element} = $value; $ePolicy[$element] = $value;
gameAction('setPlayerPolicy', $player, $ePolicy); gameAction('setPlayerPolicy', $player, $ePolicy);
return "1\n$ePolicy"; return "1\n$ePolicy";
@ -84,7 +84,7 @@ class page_handler
$pPolicy = gameAction('getPlanetPolicy', $planet); $pPolicy = gameAction('getPlanetPolicy', $planet);
if (is_null($pPolicy)) if (is_null($pPolicy))
return "ERR#1"; return "ERR#1";
$pPolicy{$element} = $value; $pPolicy[$element] = $value;
gameAction('setPlanetPolicy', $planet, $pPolicy); gameAction('setPlanetPolicy', $planet, $pPolicy);
return "2\n$planet#$pPolicy"; return "2\n$planet#$pPolicy";
@ -120,7 +120,7 @@ class page_handler
} }
// Generate the return value // Generate the return value
$mainData .= count($hsFleets) . "#" . count($mvFleets) . "#" . utf8entities($pinf['name']); $mainData .= count($hsFleets) . "#0#" . utf8entities($pinf['name']);
$rv = array($mainData); $rv = array($mainData);
if (count($hsFleets)) { if (count($hsFleets)) {
$rv = array_merge($rv, $hsFleets); $rv = array_merge($rv, $hsFleets);

View file

@ -47,7 +47,7 @@ class page_handler
function getDescriptions($lst) function getDescriptions($lst)
{ {
$l = getLanguage(); $l = getLanguage();
$a = split('#', $lst); $a = explode('#', $lst);
$s = ""; $s = "";
foreach ($a as $id) foreach ($a as $id)
{ {
@ -110,7 +110,7 @@ class page_handler
return "ERR#200"; return "ERR#200";
} }
$a = split('#', $b); $a = explode('#', $b);
if (count($a) != 3) { if (count($a) != 3) {
return "ERR#0"; return "ERR#0";
} }