Apply automated PHP8 safety transforms
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/89922108-1604-44ae-949d-358d32b9d70a Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
aca850b6cd
commit
e44519c030
465 changed files with 1716 additions and 1716 deletions
|
|
@ -52,7 +52,7 @@ $replace_texts = $server_xml->replace_texts->text;
|
|||
$replace_id = 0;
|
||||
if($replace_texts)
|
||||
{
|
||||
foreach ($replace_texts as $text => $array )
|
||||
foreach ((array)$replace_texts as $text => $array )
|
||||
{
|
||||
$param = (string)$array['key'];
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ if($replace_texts)
|
|||
|
||||
$replacements[$replace_id]['info_param'] = $info_param;
|
||||
|
||||
foreach ($array as $key => $value )
|
||||
foreach ((array)$array as $key => $value )
|
||||
{
|
||||
if ($key == "default")
|
||||
$replacements[$replace_id]['default'] = (string)$value;
|
||||
|
|
@ -85,9 +85,9 @@ $custom_fields = json_decode($db->getCustomFields($server_home["home_id"]), True
|
|||
$fields = $server_xml->custom_fields->field;
|
||||
if($fields)
|
||||
{
|
||||
foreach ($fields as $text => $array )
|
||||
foreach ((array)$fields as $text => $array )
|
||||
{
|
||||
foreach ($array as $key => $value )
|
||||
foreach ((array)$array as $key => $value )
|
||||
{
|
||||
if ($key == "default_value")
|
||||
{
|
||||
|
|
@ -111,7 +111,7 @@ if($fields)
|
|||
}
|
||||
}
|
||||
|
||||
foreach($replacements as $key => $replacement)
|
||||
foreach ((array)$replacements as $key => $replacement)
|
||||
{
|
||||
$filepath = $replacement['filepath'];
|
||||
$file_replacements[$filepath][$key] = $replacement;
|
||||
|
|
@ -124,7 +124,7 @@ echo "</xmp>"; */
|
|||
require_once('includes/lib_remote.php');
|
||||
$remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
|
||||
|
||||
foreach($file_replacements as $filepath => $replacements)
|
||||
foreach ((array)$file_replacements as $filepath => $replacements)
|
||||
{
|
||||
$file_info = $remote->remote_readfile($server_home['home_path']."/$filepath",$file_content);
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ foreach($file_replacements as $filepath => $replacements)
|
|||
$file_info = "";
|
||||
}
|
||||
|
||||
foreach($replacements as $replacement)
|
||||
foreach ((array)$replacements as $replacement)
|
||||
{
|
||||
$info_param = $replacement['info_param'];
|
||||
$default = $replacement['default'];
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ function get_start_cmd($remote,$server_xml,$home_info,$mod_id,$ip,$port,$db)
|
|||
{
|
||||
foreach($server_xml->server_params->param as $param)
|
||||
{
|
||||
foreach ($last_param as $paramKey => $paramValue)
|
||||
foreach ((array)$last_param as $paramKey => $paramValue)
|
||||
{
|
||||
if (!isset($paramValue))
|
||||
$paramValue = (string)$param->default;
|
||||
|
|
@ -197,7 +197,7 @@ function get_start_cmd($remote,$server_xml,$home_info,$mod_id,$ip,$port,$db)
|
|||
|
||||
$extra_param_access_enabled = preg_match("/e/",$home_info['access_rights']) > 0 ? TRUE:FALSE;
|
||||
|
||||
if ( array_key_exists('extra', $last_param) && $extra_param_access_enabled )
|
||||
if ( array_key_exists('extra', (array)$last_param) && $extra_param_access_enabled )
|
||||
$extra_default = $last_param['extra'];
|
||||
else
|
||||
$extra_default = $home_info['mods'][$mod_id]['extra_params'];
|
||||
|
|
@ -271,7 +271,7 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
|
|||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
foreach ((array)$ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
|
|
@ -431,7 +431,7 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
|
|||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
foreach ((array)$ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
|
|
@ -467,7 +467,7 @@ function get_monitor_buttons($server_home, $server_xml)
|
|||
if (!is_array($installed_modules)) {
|
||||
$installed_modules = [];
|
||||
}
|
||||
foreach($installed_modules as $installed_module)
|
||||
foreach ((array)$installed_modules as $installed_module)
|
||||
{
|
||||
$buttons_file = "modules/$installed_module[folder]/monitor_buttons.php";
|
||||
if(file_exists($buttons_file))
|
||||
|
|
@ -481,7 +481,7 @@ function get_monitor_buttons($server_home, $server_xml)
|
|||
}
|
||||
$buttons_html = "";
|
||||
if (is_array($buttons)) {
|
||||
foreach($buttons as $button)
|
||||
foreach ((array)$buttons as $button)
|
||||
$buttons_html .= $button."\n";
|
||||
}
|
||||
return $buttons_html;
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ require_once("modules/config_games/server_config_parser.php");
|
|||
if(isset($_GET['view_player_commands']))
|
||||
$intSel .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
|
||||
$intSel .= get_lang("refresh_interval") . ':<select name="setInterval" onchange="this.form.submit();">';
|
||||
foreach ($intervals as $interval => $value )
|
||||
foreach ((array)$intervals as $interval => $value )
|
||||
{
|
||||
$selected = "";
|
||||
if ( isset( $_GET['setInterval'] ) AND $_GET['setInterval'] == $value )
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ if( !isset( $_POST['start_server'] ) )
|
|||
echo "</td></tr>\n";
|
||||
|
||||
//get last used param or get default
|
||||
if (array_key_exists('extra', $last_param))
|
||||
if (array_key_exists('extra', (array)$last_param))
|
||||
$extra_default = $last_param['extra'];
|
||||
else
|
||||
$extra_default = $server_home['extra_params'];
|
||||
|
|
@ -454,7 +454,7 @@ elseif($server_home['home_id'] == $_POST['home_id'])
|
|||
$paramKey = (string)$param['key'];
|
||||
$paramType = (string)$param['type'];
|
||||
// Get the last saved value of this param or its default value
|
||||
if (array_key_exists($paramKey, $last_param))
|
||||
if (array_key_exists($paramKey, (array)$last_param))
|
||||
$savedValue = (string)$last_param[$paramKey];
|
||||
|
||||
$lockedByAdmin = (property_exists($param, 'access') and $param->access == "admin" and !$isAdmin);
|
||||
|
|
@ -574,7 +574,7 @@ elseif($server_home['home_id'] == $_POST['home_id'])
|
|||
{
|
||||
// If user does not have access to modify extra params then we use
|
||||
// the last param or default set by admins.
|
||||
$extra = ($last_param !== NULL and array_key_exists('extra', $last_param) and (string)$last_param['extra'] != "") ?
|
||||
$extra = ($last_param !== NULL and array_key_exists('extra', (array)$last_param) and (string)$last_param['extra'] != "") ?
|
||||
$last_param['extra'] : $server_home['extra_params'];
|
||||
|
||||
$start_cmd .= " ".str_replace("\\\\", "\\", clean_server_param_value($extra, $server_xml->cli_allow_chars));
|
||||
|
|
@ -668,7 +668,7 @@ elseif($server_home['home_id'] == $_POST['home_id'])
|
|||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($server_home['home_id']);
|
||||
foreach ($ip_ports as $ip_port)
|
||||
foreach ((array)$ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ if(isset($_POST['command']) and !is_array($_POST['command']))
|
|||
elseif(isset($_POST['base64_command']))
|
||||
{
|
||||
if (is_array($_POST['base64_command'])) {
|
||||
foreach($_POST['base64_command'] as $key => $command)
|
||||
foreach ((array)$_POST['base64_command'] as $key => $command)
|
||||
{
|
||||
$_POST['command'][$key] = isset($_POST['input']) ? str_replace("%input%", $_POST['input'], base64_decode($command)) : base64_decode($command);
|
||||
}
|
||||
|
|
@ -88,13 +88,13 @@ elseif(isset($_POST['base64_command']))
|
|||
}
|
||||
|
||||
$presets = $db->getRconPresets($home_info['home_cfg_id'],$home_info['mods'][$mod_id]['mod_cfg_id']);
|
||||
if(is_array($presets) && (is_array($presets) ? count($presets) : 0) > 0)
|
||||
if(is_array($presets) && (is_array($presets) ? count((array)$presets) : 0) > 0)
|
||||
{
|
||||
echo '<form action="" method="post">'.
|
||||
get_lang("rcon_presets") . ':
|
||||
<select onchange="this.form.submit()" name="command" >
|
||||
<option></option>\n';
|
||||
foreach ($presets as $preset)
|
||||
foreach ((array)$presets as $preset)
|
||||
{
|
||||
echo '<option value="'.$preset['command'].'" >'.$preset['name'].'</option>\n';
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ if(isset($_POST['remote_send_rcon_command']))
|
|||
{
|
||||
$response = "";
|
||||
if (is_array($_POST['command'])) {
|
||||
foreach($_POST['command'] as $command)
|
||||
foreach ((array)$_POST['command'] as $command)
|
||||
{
|
||||
$ret = send_command($command, $remote, $server_xml, $home_info, $home_id, $ip, $port );
|
||||
if(!$ret)
|
||||
|
|
@ -170,7 +170,7 @@ if($server_xml->list_players_command)
|
|||
$key = (string)$index['key'];
|
||||
$name = (string)$index;
|
||||
$infos[] = $name;
|
||||
foreach($matches[$key] as $info)
|
||||
foreach ((array)$matches[$key] as $info)
|
||||
{
|
||||
$data[$i][$name] = $info;
|
||||
$i++;
|
||||
|
|
@ -201,7 +201,7 @@ if($server_xml->list_players_command)
|
|||
$replaced_actions = array();
|
||||
for($id = 0; $id < $i; $id++)
|
||||
{
|
||||
foreach($actions as $key => $action)
|
||||
foreach ((array)$actions as $key => $action)
|
||||
{
|
||||
foreach($replacements[$key][1] as $index)
|
||||
{
|
||||
|
|
@ -221,20 +221,20 @@ if($server_xml->list_players_command)
|
|||
}
|
||||
$headers = array_merge( $infos, $commands );
|
||||
$player_actions_table = "<table class='center'>\n<thead>\n<tr>";
|
||||
foreach($headers as $name)
|
||||
foreach ((array)$headers as $name)
|
||||
{
|
||||
$player_actions_table .= "<th>$name</th>";
|
||||
}
|
||||
|
||||
$player_actions_table .= "</tr>\n</thead>\n<tbody>\n";
|
||||
foreach($data as $player)
|
||||
foreach ((array)$data as $player)
|
||||
{
|
||||
$player_actions_table .= "<tr>\n";
|
||||
foreach($infos as $info)
|
||||
foreach ((array)$infos as $info)
|
||||
{
|
||||
$player_actions_table .= "<td>".htmlentities($player[$info])."</td>\n";
|
||||
}
|
||||
foreach($commands as $command)
|
||||
foreach ((array)$commands as $command)
|
||||
{
|
||||
$actions = $player['commands'][$command]['actions'];
|
||||
$type = $player['commands'][$command]['type'];
|
||||
|
|
@ -246,21 +246,21 @@ if($server_xml->list_players_command)
|
|||
$player_actions_table .= "<td>\n<form method='post'>\n";
|
||||
if($type == 'hidden')
|
||||
{
|
||||
foreach($actions as $key => $action)
|
||||
foreach ((array)$actions as $key => $action)
|
||||
$player_actions_table .= "<input type='hidden' name='base64_command[$key]' value='$action'/>\n";
|
||||
}
|
||||
elseif($type == 'text')
|
||||
{
|
||||
foreach($actions as $key => $action)
|
||||
foreach ((array)$actions as $key => $action)
|
||||
$player_actions_table .= "<input type='hidden' name='base64_command[$key]' value='$action'/>\n";
|
||||
$player_actions_table .= "<input type='text' name='input' value='$default'/>\n";
|
||||
}
|
||||
elseif($type == 'select')
|
||||
{
|
||||
foreach($actions as $key => $action)
|
||||
foreach ((array)$actions as $key => $action)
|
||||
$player_actions_table .= "<input type='hidden' name='base64_command[$key]' value='$action'/>\n";
|
||||
$player_actions_table .= "<select name='input'>";
|
||||
foreach($options as $key => $value)
|
||||
foreach ((array)$options as $key => $value)
|
||||
{
|
||||
$player_actions_table .= "<option value='$value' >$key</option>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,12 +106,12 @@ function exec_ogp_module() {
|
|||
<br>
|
||||
<?php
|
||||
$presets = $db->getRconPresets($home_cfg_id,$mod_cfg_id);
|
||||
if(is_array($presets) && (is_array($presets) ? count($presets) : 0) > 0)
|
||||
if(is_array($presets) && (is_array($presets) ? count((array)$presets) : 0) > 0)
|
||||
{
|
||||
|
||||
echo "<h2>".get_lang("edit_presets")."</h2>";
|
||||
echo "<table>";
|
||||
foreach ($presets as $preset)
|
||||
foreach ((array)$presets as $preset)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function do_progress($kbytes,$rsyncPath)
|
|||
$totalsize = 0;
|
||||
|
||||
# loops all available sizes to work over a string instead of an array.
|
||||
foreach($sizes as $key => $size)
|
||||
foreach ((array)$sizes as $key => $size)
|
||||
{
|
||||
# If the rsync path matches the path at the string on the variable $size
|
||||
# then lists the path and the total size on separated variables
|
||||
|
|
@ -83,10 +83,10 @@ function update_local_copies()
|
|||
)
|
||||
);
|
||||
|
||||
foreach($update_files as $file_chk)
|
||||
foreach ((array)$update_files as $file_chk)
|
||||
{
|
||||
#echo "Trying to update $file_chk<br>";
|
||||
foreach($update_urls as $site)
|
||||
foreach ((array)$update_urls as $site)
|
||||
{
|
||||
#echo "Trying $file_chk from $site<br>";
|
||||
if(!is_writable("modules/gamemanager/$file_chk"))
|
||||
|
|
@ -251,7 +251,7 @@ function exec_ogp_module() {
|
|||
else
|
||||
{
|
||||
$url_id = (isset($_POST['url_id']) && (int)$_POST['url_id'] > 0 ? (int)$_POST['url_id'] -1 : null);
|
||||
if (!is_null($url_id) && array_key_exists($url_id, $rsync_sites)) {
|
||||
if (!is_null($url_id) && array_key_exists($url_id, (array)$rsync_sites)) {
|
||||
$urlArr = explode('|', $rsync_sites[$url_id]);
|
||||
$url = $urlArr[0] . "/rsync_installer/$rs_gname/$os/";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ function renderParam($param, $last_param, $param_access_enabled, $home_id)
|
|||
|
||||
$inputElementString = "<select $idString name='params[" . $param['key'] . "{DEPENDS:$paramType}]'" . $disabledString . ">";
|
||||
if (is_array($homes)) {
|
||||
foreach($homes as $home){
|
||||
foreach ((array)$homes as $home){
|
||||
if($home["home_path"][strlen($home["home_path"])-1] != "/"){
|
||||
$home["home_path"] = $home["home_path"] . "/";
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ $home_info = $db->getGameHomeWithoutMods($home_id);
|
|||
<input type="submit" value="<?php echo get_lang('search'); ?>" />
|
||||
</form>
|
||||
<?php
|
||||
foreach($_POST as $key => $value)
|
||||
foreach ((array)$_POST as $key => $value)
|
||||
{
|
||||
if( preg_match( "/^action/", $key ) )
|
||||
{
|
||||
|
|
@ -303,7 +303,7 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
|||
$post_port ) = explode( "-", $_GET['home_id-mod_id-ip-port'] );
|
||||
|
||||
$j = 1;
|
||||
foreach( $server_homes as $server_home )
|
||||
foreach ((array)$server_homes as $server_home)
|
||||
{
|
||||
if( ( $show_all or isset($_GET['home_cfg_id']) ) AND ( !isset($server_home['ip']) or !isset($server_home['mod_id']) ) ){
|
||||
$j++;
|
||||
|
|
@ -391,7 +391,7 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
|||
$groupsus = "";
|
||||
if(is_array($groupusers))
|
||||
{
|
||||
foreach($groupusers as $groupu)
|
||||
foreach ((array)$groupusers as $groupu)
|
||||
{
|
||||
if($groupu['user_id'] == $server_home['user_id_main'])
|
||||
continue;
|
||||
|
|
@ -404,7 +404,7 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
|||
$other_owners = "";
|
||||
if(is_array($owners))
|
||||
{
|
||||
foreach($owners as $owner)
|
||||
foreach ((array)$owners as $owner)
|
||||
{
|
||||
if($owner['user_id'] == $server_home['user_id_main'])
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function exec_ogp_module()
|
|||
|
||||
$mod_id = $_REQUEST['mod_id'];
|
||||
|
||||
if ( !array_key_exists($mod_id,$home_info['mods']) )
|
||||
if ( !array_key_exists($mod_id, (array)$home_info['mods']) )
|
||||
{
|
||||
print_failure("Unable to retrieve mod information from database.");
|
||||
return;
|
||||
|
|
@ -75,7 +75,7 @@ function exec_ogp_module()
|
|||
$ip_info = [];
|
||||
}
|
||||
|
||||
foreach ( $ip_info as $ip_ports_row )
|
||||
foreach ((array)$ip_info as $ip_ports_row)
|
||||
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ function exec_ogp_module() {
|
|||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
foreach ((array)$ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
|
|
@ -148,7 +148,7 @@ function exec_ogp_module() {
|
|||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
foreach ((array)$ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ function exec_ogp_module()
|
|||
if(isset($_GET['view_player_commands']))
|
||||
$intSel .= "<input type='hidden' name='view_player_commands' value='" . $_GET['view_player_commands'] . "' />";
|
||||
$intSel .= get_lang("refresh_interval") . ':<select name="setInterval" onchange="this.form.submit();">';
|
||||
foreach ($intervals as $interval => $value )
|
||||
foreach ((array)$intervals as $interval => $value )
|
||||
{
|
||||
$selected = "";
|
||||
if ( isset( $_GET['setInterval'] ) AND $_GET['setInterval'] == $value )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue