Add PHP 8 array guards in gamemanager and addonsmanager modules
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/88949fe0-8891-483a-b5c5-952bc209748d Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
5b80f144e4
commit
54e7f07aa0
13 changed files with 141 additions and 63 deletions
|
|
@ -264,12 +264,15 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
|
|||
return FALSE;
|
||||
else
|
||||
{
|
||||
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
|
||||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
|
||||
foreach ($ip_ports as $ip_port)
|
||||
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
|
||||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
|
||||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
$query_port = get_query_port($server_xml, $ip_port['port']);
|
||||
|
|
@ -298,9 +301,11 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
|
|||
// Do text replacements in cfg file
|
||||
if( $server_xml->replace_texts )
|
||||
{
|
||||
foreach($home_info['mods'][$mod_id] as $key => $value)
|
||||
{
|
||||
$home_info[$key] = $value;
|
||||
if (is_array($home_info['mods'][$mod_id])) {
|
||||
foreach($home_info['mods'][$mod_id] as $key => $value)
|
||||
{
|
||||
$home_info[$key] = $value;
|
||||
}
|
||||
}
|
||||
$server_home = $home_info;
|
||||
if( isset($server_xml->lgsl_query_name) )
|
||||
|
|
@ -362,9 +367,11 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
|
|||
// Do text replacements in cfg file
|
||||
if( $server_xml->replace_texts )
|
||||
{
|
||||
foreach($home_info['mods'][$mod_id] as $key => $value)
|
||||
{
|
||||
$home_info[$key] = $value;
|
||||
if (is_array($home_info['mods'][$mod_id])) {
|
||||
foreach($home_info['mods'][$mod_id] as $key => $value)
|
||||
{
|
||||
$home_info[$key] = $value;
|
||||
}
|
||||
}
|
||||
$server_home = $home_info;
|
||||
if( isset($server_xml->lgsl_query_name) )
|
||||
|
|
@ -417,12 +424,15 @@ function exec_operation( $action, $home_id, $mod_id, $ip, $port, $override = fal
|
|||
return FALSE;
|
||||
else
|
||||
{
|
||||
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
|
||||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
|
||||
foreach ($ip_ports as $ip_port)
|
||||
$firewall_settings = $db->getFirewallSettings($home_info['remote_server_id']);
|
||||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($home_info['home_id']);
|
||||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
{
|
||||
$query_port = get_query_port($server_xml, $ip_port['port']);
|
||||
|
|
@ -453,19 +463,27 @@ function get_monitor_buttons($server_home, $server_xml)
|
|||
{
|
||||
global $db;
|
||||
$buttons = array();
|
||||
foreach($db->getInstalledModules() as $installed_module)
|
||||
$installed_modules = $db->getInstalledModules();
|
||||
if (!is_array($installed_modules)) {
|
||||
$installed_modules = [];
|
||||
}
|
||||
foreach($installed_modules as $installed_module)
|
||||
{
|
||||
$buttons_file = "modules/$installed_module[folder]/monitor_buttons.php";
|
||||
if(file_exists($buttons_file))
|
||||
{
|
||||
require($buttons_file);
|
||||
$buttons = array_merge($buttons, $module_buttons);
|
||||
if (is_array($module_buttons)) {
|
||||
$buttons = array_merge($buttons, $module_buttons);
|
||||
}
|
||||
unset($module_buttons);
|
||||
}
|
||||
}
|
||||
$buttons_html = "";
|
||||
foreach($buttons as $button)
|
||||
if (is_array($buttons)) {
|
||||
foreach($buttons as $button)
|
||||
$buttons_html .= $button."\n";
|
||||
}
|
||||
return $buttons_html;
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ if (preg_match("/u/",$server_home['access_rights']))
|
|||
{
|
||||
$sync_name = $server_xml->game_key;
|
||||
$sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES);
|
||||
if ( in_array($sync_name, $sync_list) OR ($master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) )
|
||||
if ( (is_array($sync_list) && in_array($sync_name, $sync_list)) OR ($master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) )
|
||||
{
|
||||
$module_buttons[] = "<a class='monitorbutton' href='?m=gamemanager&p=rsync_install&home_id=".$server_home['home_id']."&mod_id=".$server_home['mod_id']."&update=update'>
|
||||
<img src='" . check_theme_image("images/rsync.png") . "' title='". rsync_install ."'>
|
||||
|
|
@ -117,4 +117,3 @@ if($_SESSION['users_role'] == "admin")
|
|||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -79,14 +79,16 @@ if(isset($_POST['command']) and !is_array($_POST['command']))
|
|||
$_POST['command'] = array( '0' => stripcslashes($_POST['command']) );
|
||||
elseif(isset($_POST['base64_command']))
|
||||
{
|
||||
foreach($_POST['base64_command'] as $key => $command)
|
||||
{
|
||||
$_POST['command'][$key] = isset($_POST['input']) ? str_replace("%input%", $_POST['input'], base64_decode($command)) : base64_decode($command);
|
||||
if (is_array($_POST['base64_command'])) {
|
||||
foreach($_POST['base64_command'] as $key => $command)
|
||||
{
|
||||
$_POST['command'][$key] = isset($_POST['input']) ? str_replace("%input%", $_POST['input'], base64_decode($command)) : base64_decode($command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$presets = $db->getRconPresets($home_info['home_cfg_id'],$home_info['mods'][$mod_id]['mod_cfg_id']);
|
||||
if($presets > 0)
|
||||
if(is_array($presets) && $presets > 0)
|
||||
{
|
||||
echo '<form action="" method="post">'.
|
||||
get_lang("rcon_presets") . ':
|
||||
|
|
@ -124,16 +126,22 @@ if($presets > 0)
|
|||
if(isset($_POST['remote_send_rcon_command']))
|
||||
{
|
||||
$response = "";
|
||||
foreach($_POST['command'] as $command)
|
||||
{
|
||||
$ret = send_command($command, $remote, $server_xml, $home_info, $home_id, $ip, $port );
|
||||
if(!$ret)
|
||||
if (is_array($_POST['command'])) {
|
||||
foreach($_POST['command'] as $command)
|
||||
{
|
||||
$response = FALSE;
|
||||
break;
|
||||
$ret = send_command($command, $remote, $server_xml, $home_info, $home_id, $ip, $port );
|
||||
if(!$ret)
|
||||
{
|
||||
$response = FALSE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
$response .= $ret;
|
||||
}
|
||||
else
|
||||
$response .= $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = FALSE;
|
||||
}
|
||||
if($response)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ function exec_ogp_module() {
|
|||
<br>
|
||||
<?php
|
||||
$presets = $db->getRconPresets($home_cfg_id,$mod_cfg_id);
|
||||
if($presets > 0)
|
||||
if(is_array($presets) && $presets > 0)
|
||||
{
|
||||
|
||||
echo "<h2>".get_lang("edit_presets")."</h2>";
|
||||
|
|
|
|||
|
|
@ -40,9 +40,11 @@ function exec_ogp_module() {
|
|||
else
|
||||
$home_info = $db->getUserGameHome($user_id,$home_id);
|
||||
|
||||
foreach($home_info['mods'][$mod_id] as $key => $value)
|
||||
{
|
||||
$home_info[$key] = $value;
|
||||
if (is_array($home_info['mods'][$mod_id])) {
|
||||
foreach($home_info['mods'][$mod_id] as $key => $value)
|
||||
{
|
||||
$home_info[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
require_once('includes/lib_remote.php');
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ function do_progress($kbytes,$rsyncPath)
|
|||
$mbytes = round($kbytes / 1024, 2);
|
||||
|
||||
$sizes = file("modules/gamemanager/sizes.list", FILE_IGNORE_NEW_LINES)or print_failure("Can't open sizes.list");
|
||||
if (!is_array($sizes)) {
|
||||
$sizes = [];
|
||||
}
|
||||
|
||||
# Adds a backslash on each slash so it can be used as patern at preg_match
|
||||
$rsyncPath = addcslashes($rsyncPath,"/");
|
||||
|
|
@ -365,7 +368,7 @@ function exec_ogp_module() {
|
|||
}
|
||||
}
|
||||
$master_server_home_id = $db->getMasterServer( $home_info['remote_server_id'], $home_info['home_cfg_id'] );
|
||||
if ( in_array($rs_gname, $sync_list) )
|
||||
if ( is_array($sync_list) && in_array($rs_gname, $sync_list) )
|
||||
{
|
||||
echo "<form action='?m=gamemanager&p=rsync_install' method='post'>
|
||||
<table class='center'>
|
||||
|
|
@ -412,4 +415,3 @@ function exec_ogp_module() {
|
|||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -67,23 +67,28 @@ function renderParam($param, $last_param, $param_access_enabled, $home_id)
|
|||
|
||||
// Get homes
|
||||
$homes = $db->getHomesFor($dbTypeHomesStr, $_SESSION['user_id']);
|
||||
if (!is_array($homes)) {
|
||||
$homes = [];
|
||||
}
|
||||
|
||||
// Move current home_id home_path to the front of the array so that it is selected by default if no other option has been selected.
|
||||
$homes = customShift($homes, "home_id", $home_id);
|
||||
|
||||
$inputElementString = "<select $idString name='params[" . $param['key'] . "{DEPENDS:$paramType}]'" . $disabledString . ">";
|
||||
foreach($homes as $home){
|
||||
if($home["home_path"][strlen($home["home_path"])-1] != "/"){
|
||||
$home["home_path"] = $home["home_path"] . "/";
|
||||
if (is_array($homes)) {
|
||||
foreach($homes as $home){
|
||||
if($home["home_path"][strlen($home["home_path"])-1] != "/"){
|
||||
$home["home_path"] = $home["home_path"] . "/";
|
||||
}
|
||||
|
||||
if(stripos($paramValue, $home["home_path"]) !== false){
|
||||
$selectedString = "selected='selected'";
|
||||
$selectedHome = $home["home_path"];
|
||||
}else{
|
||||
$selectedString = "";
|
||||
}
|
||||
$inputElementString .= '<option value="' . $home["home_path"] . '" ' . $selectedString . '>' . $home["home_path"] . '</option>';
|
||||
}
|
||||
|
||||
if(stripos($paramValue, $home["home_path"]) !== false){
|
||||
$selectedString = "selected='selected'";
|
||||
$selectedHome = $home["home_path"];
|
||||
}else{
|
||||
$selectedString = "";
|
||||
}
|
||||
$inputElementString .= '<option value="' . $home["home_path"] . '" ' . $selectedString . '>' . $home["home_path"] . '</option>';
|
||||
}
|
||||
$inputElementString .="</select>";
|
||||
if($paramType == "other_game_server_path_additional"){
|
||||
|
|
@ -207,6 +212,12 @@ $home_info = $db->getGameHomeWithoutMods($home_id);
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (!is_array($server_homes)) {
|
||||
$server_homes = [];
|
||||
}
|
||||
if (!is_array($show_games_type)) {
|
||||
$show_games_type = [];
|
||||
}
|
||||
?>
|
||||
<form action="home.php" style="float:right;">
|
||||
<b><?php print_lang('search'); ?>:</b>
|
||||
|
|
@ -378,7 +389,7 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
|||
|
||||
$groupusers = $db->getGroupUsersByHomeId($server_home['home_id']);
|
||||
$groupsus = "";
|
||||
if($groupusers)
|
||||
if(is_array($groupusers))
|
||||
{
|
||||
foreach($groupusers as $groupu)
|
||||
{
|
||||
|
|
@ -391,7 +402,7 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
|||
|
||||
$owners = $db->getUsersByHomeId($server_home['home_id']);
|
||||
$other_owners = "";
|
||||
if($owners)
|
||||
if(is_array($owners))
|
||||
{
|
||||
foreach($owners as $owner)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ function exec_ogp_module()
|
|||
$home_id = $home_info['home_id'];
|
||||
|
||||
$ip_info = $db->getHomeIpPorts($home_id);
|
||||
if (!is_array($ip_info)) {
|
||||
$ip_info = [];
|
||||
}
|
||||
|
||||
foreach ( $ip_info as $ip_ports_row )
|
||||
|
||||
|
|
@ -259,4 +262,3 @@ function exec_ogp_module()
|
|||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,9 @@ function exec_ogp_module() {
|
|||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($home_id);
|
||||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
|
|
@ -142,6 +145,9 @@ function exec_ogp_module() {
|
|||
if ($firewall_settings['status'] == "enable")
|
||||
{
|
||||
$ip_ports = $db->getHomeIpPorts($home_id);
|
||||
if (!is_array($ip_ports)) {
|
||||
$ip_ports = [];
|
||||
}
|
||||
foreach ($ip_ports as $ip_port)
|
||||
{
|
||||
if ($server_xml->protocol == "gameq")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue