diff --git a/modules/addonsmanager/addons_installer.php b/modules/addonsmanager/addons_installer.php index 861da668..163741c8 100644 --- a/modules/addonsmanager/addons_installer.php +++ b/modules/addonsmanager/addons_installer.php @@ -59,6 +59,9 @@ function exec_ogp_module() { { $home_info = $db->getUserGameHome($user_id,$home_id); $groups = $db->getUsersGroups($_SESSION['user_id']); + if (!is_array($groups)) { + $groups = []; + } $query_groups .= " AND ("; foreach($groups as $group) $query_groups .= "group_id=".$group['group_id']." OR "; @@ -86,6 +89,9 @@ function exec_ogp_module() { $addon_id = (int)$_REQUEST['addon_id']; $addons_rows = $db->resultQuery("SELECT url, path, post_script FROM OGP_DB_PREFIXaddons WHERE addon_id=".$addon_id.$query_groups); + if (!is_array($addons_rows)) { + $addons_rows = []; + } if (!$addons_rows) { print_failure(get_lang('invalid_addon')); @@ -105,6 +111,9 @@ function exec_ogp_module() { $check_passed = FALSE; $address_at_post = $ip.":".$port; $ip_ports = $db->getHomeIpPorts($home_info['home_id']); + if (!is_array($ip_ports)) { + $ip_ports = []; + } foreach($ip_ports as $ip_port); { $address_owned = $ip_port['ip'].":".$ip_port['port']; @@ -234,7 +243,7 @@ function exec_ogp_module() { elseif( $addon_type != "" ) { - if (!in_array($addon_type, $addon_types)) { + if (!(is_array($addon_types) && in_array($addon_type, $addon_types))) { print_failure(get_lang('invalid_addon_type')); $view->refresh('?m=addonsmanager&p=user_addons&home_id='. $home_id .'&mod_id='. $mod_id .'&ip='. $ip .'&port='.$port); @@ -261,6 +270,9 @@ function exec_ogp_module() { getGameCfgs(); + if (!is_array($game_cfgs)) { + $game_cfgs = []; + } echo "\n"; foreach ( $game_cfgs as $row ) @@ -186,6 +192,9 @@ function exec_ogp_module() { getGroupList(); + if (!is_array($groups)) { + $groups = []; + } foreach($groups as $group) { $selected = (isset($group_id) AND $group['group_id'] == $group_id) ? 'selected=selected' : ''; @@ -315,7 +324,7 @@ function exec_ogp_module() { } $home_cfg_id = !empty($_GET['home_cfg_id']) && (int)$_GET['home_cfg_id'] > 0 ? (int)$_GET['home_cfg_id'] : 0; - $addon_type = !empty($_GET['addon_type']) && in_array($_GET['addon_type'], $addon_types) ? $_GET['addon_type'] : ""; + $addon_type = !empty($_GET['addon_type']) && is_array($addon_types) && in_array($_GET['addon_type'], $addon_types) ? $_GET['addon_type'] : ""; $group_id = isset($_GET['group_id']) && is_numeric($_GET['group_id']) ? (int)$_GET['group_id'] : 0; if ( isset($_GET['show']) ) @@ -339,6 +348,9 @@ function exec_ogp_module() { $group_id = $group_id == '0' ? $group_id." OR group_id IS NULL" : $group_id; $result = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name, url, path, group_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE group_id=".$group_id); } + if (isset($result) && !is_array($result)) { + $result = []; + } ?> 0) + if (isset($result) and is_array($result) and (is_array($result) ? count($result) : 0) > 0) { foreach($result as $row) { @@ -376,4 +388,4 @@ function exec_ogp_module() {
\ No newline at end of file +?> diff --git a/modules/addonsmanager/monitor_buttons.php b/modules/addonsmanager/monitor_buttons.php index 8a546da0..656dd027 100644 --- a/modules/addonsmanager/monitor_buttons.php +++ b/modules/addonsmanager/monitor_buttons.php @@ -26,13 +26,16 @@ $query_groups = ""; if($_SESSION['users_role'] != "admin") { $groups = $db->getUsersGroups($_SESSION['user_id']); + if (!is_array($groups)) { + $groups = []; + } $query_groups .= " AND ("; foreach($groups as $group) $query_groups .= "group_id=".$group['group_id']." OR "; $query_groups .= "group_id=0 OR group_id IS NULL)"; } $addons = $db->resultQuery("SELECT addon_id FROM OGP_DB_PREFIXaddons WHERE home_cfg_id=".$server_home['home_cfg_id'].$query_groups); -$addons_qty = count($addons); +$addons_qty = is_array($addons) ? count($addons) : 0; if($addons and $addons_qty >= 1){ $module_buttons = array( ""; echo ""; echo "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; } ?> diff --git a/modules/gamemanager/monitor_buttons.php b/modules/gamemanager/monitor_buttons.php index 6aac0eb3..14864194 100644 --- a/modules/gamemanager/monitor_buttons.php +++ b/modules/gamemanager/monitor_buttons.php @@ -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[] = " @@ -117,4 +117,3 @@ if($_SESSION['users_role'] == "admin") } } ?> - diff --git a/modules/gamemanager/rcon.php b/modules/gamemanager/rcon.php index d006bf77..e52283fc 100644 --- a/modules/gamemanager/rcon.php +++ b/modules/gamemanager/rcon.php @@ -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) && (is_array($presets) ? count($presets) : 0) > 0) { echo '
'. 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) { diff --git a/modules/gamemanager/rcon_presets.php b/modules/gamemanager/rcon_presets.php index a3bca712..854d19fd 100644 --- a/modules/gamemanager/rcon_presets.php +++ b/modules/gamemanager/rcon_presets.php @@ -106,7 +106,7 @@ function exec_ogp_module() {
getRconPresets($home_cfg_id,$mod_cfg_id); - if($presets > 0) + if(is_array($presets) && (is_array($presets) ? count($presets) : 0) > 0) { echo "

".get_lang("edit_presets")."

"; diff --git a/modules/gamemanager/restart_server.php b/modules/gamemanager/restart_server.php index 1142d78c..923314f6 100644 --- a/modules/gamemanager/restart_server.php +++ b/modules/gamemanager/restart_server.php @@ -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'); diff --git a/modules/gamemanager/rsync_install.php b/modules/gamemanager/rsync_install.php index bb1f725c..f949f7e4 100644 --- a/modules/gamemanager/rsync_install.php +++ b/modules/gamemanager/rsync_install.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 " @@ -412,4 +415,3 @@ function exec_ogp_module() { } } ?> - diff --git a/modules/gamemanager/server_monitor.php b/modules/gamemanager/server_monitor.php index 29a01510..82deb3ef 100644 --- a/modules/gamemanager/server_monitor.php +++ b/modules/gamemanager/server_monitor.php @@ -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 = ""; 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 = []; + } ?> : @@ -378,7 +389,7 @@ echo "
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; } ?> - diff --git a/modules/gamemanager/stop_server.php b/modules/gamemanager/stop_server.php index aa8d2ab9..2185d46a 100644 --- a/modules/gamemanager/stop_server.php +++ b/modules/gamemanager/stop_server.php @@ -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")