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:
copilot-swe-agent[bot] 2026-04-23 14:01:37 +00:00 committed by GitHub
parent aca850b6cd
commit e44519c030
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
465 changed files with 1716 additions and 1716 deletions

View file

@ -40,7 +40,7 @@ function exec_ogp_module()
$game_cfgs = $db->getGameCfgs();
$select_game = "<select onchange=".'"this.form.submit()"'." name='home_cfg_id' autofocus='autofocus'>\n".
"<option value='0'>" . get_lang("games_without_specified_rules") . "</option>\n";
foreach ( $game_cfgs as $game_cfg )
foreach ((array)$game_cfgs as $game_cfg)
{
$selected = ( isset( $_GET['home_cfg_id'] ) and
$_GET['home_cfg_id'] == $game_cfg['home_cfg_id'] ) ?
@ -108,7 +108,7 @@ function exec_ogp_module()
echo "<h3>".get_lang("current_access_rules")."</h3>\n";
echo "<table id='servermonitor' class='tablesorter' style='width: 100%;'>\n<thead><tr>".
"<th class='header'>".get_lang("game_name")."</th><th class='header'>".get_lang("match_file_extension")."</th><th class='header'>".get_lang("match_client_ip")."</th></tr></thead>\n<tbody>";
foreach($all_rules as $rule)
foreach ((array)$all_rules as $rule)
{
if($rule['home_cfg_id'] != '0')
{
@ -211,7 +211,7 @@ function exec_ogp_module()
get_lang("select_remote_server").": ".
"<select onchange=".'"this.form.submit()"'." name='remote_server_id'>\n".
"<option></option>\n";
foreach ( $remote_servers as $server )
foreach ((array)$remote_servers as $server)
{
$selected = ( isset( $_GET['remote_server_id'] ) and
$server['remote_server_id'] == $_GET['remote_server_id'] ) ?
@ -275,7 +275,7 @@ function exec_ogp_module()
if( isset( $_POST['delete'] ) )
{
$response_del = $remote->fastdl_del_alias($_POST['aliases']);
foreach($_POST['aliases'] as $alias)
foreach ((array)$_POST['aliases'] as $alias)
{
if( $response_del != -1 and
$remote->rfile_exists($aliases[$alias]['home']) === 1
@ -291,7 +291,7 @@ function exec_ogp_module()
$address = ($fastdl_info['port'] == '80' OR ($fastdl_settings and $fastdl_settings['port_forwarded_to_80'] == '1')) ?
$fastdl_info['ip'] :
$fastdl_info['ip'].":".$fastdl_info['port'];
foreach( $aliases as $alias => $info )
foreach ((array)$aliases as $alias => $info )
{
echo "<input type=checkbox name='aliases[]' value='$alias'/>$alias".
"( <a href='http://$address/$alias' target='_blank' ".
@ -367,7 +367,7 @@ function exec_ogp_module()
$check = check_access_rules_entries();
if(!$check['ip_entry_fail'] and !$check['extension_entry_fail'])
{
if(!array_key_exists($alias , $aliases))
if(!array_key_exists($alias, (array)$aliases))
{
$home = clean_path($server_home['home_path']."/".clean_string($_POST['path']));
$alias = clean_string($_POST['alias']);

View file

@ -16,7 +16,7 @@ function in_array_match($needle, $haystack) {
if (!is_array($haystack))
trigger_error('Argument 2 must be array');
$needle = "#".preg_quote($needle)."#";
foreach ($haystack as $value) {
foreach ((array)$haystack as $value) {
$match = preg_match($needle, $value);
if ($match === 1) {
return true;
@ -30,7 +30,7 @@ function get_alias_by_home_path($home_path, $aliases) {
trigger_error('Argument 2 must be array');
$home_path = "#".preg_quote($home_path)."#";
$alias_info = false;
foreach ($aliases as $alias => $info) {
foreach ((array)$aliases as $alias => $info) {
if( preg_match($home_path, $info['home']) )
{
$alias_info = $aliases[$alias];
@ -114,7 +114,7 @@ function check_access_rules_entries()
{
$entries = explode(",",$_POST['match_file_extension']);
$entries = array_unique(array_filter($entries));
foreach($entries as $key => $entry)
foreach ((array)$entries as $key => $entry)
{
$entry = trim($entry);
if(!preg_match("/^[a-z0-9]+$/i",$entry))
@ -134,7 +134,7 @@ function check_access_rules_entries()
{
$entries = explode(",",$_POST['match_client_ip']);
$entries = array_unique(array_filter($entries));
foreach($entries as $key => $entry)
foreach ((array)$entries as $key => $entry)
{
$entry = trim($entry);
if( !preg_match('#(^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$|'.
@ -169,7 +169,7 @@ function get_fastdl_settings($remote_server_id)
WHERE `remote_server_id`='".$db->realEscapeSingle($remote_server_id)."'");
if(!$result) return FALSE;
$results = array();
foreach($result as $row)
foreach ((array)$result as $row)
{
$results[$row['setting']] = $row['value'];
}
@ -182,7 +182,7 @@ function set_fastdl_settings($remote_server_id, $settings)
global $db;
if( !is_numeric($remote_server_id) ) return FALSE;
if( !is_array($settings) ) return FALSE;
foreach ( $settings as $s_key => $s_value )
foreach ((array)$settings as $s_key => $s_value )
{
$query = 'INSERT INTO `'.OGP_DB_PREFIX.'fastdl_settings` (`remote_server_id`,`setting`,`value`)
VALUES(\''.$db->realEscapeSingle($remote_server_id).'\', \''.$db->realEscapeSingle($s_key).'\', \''.$db->realEscapeSingle($s_value).'\') ON DUPLICATE KEY

View file

@ -55,7 +55,7 @@ function exec_ogp_module()
$ip_ports = $db->getHomeIpPorts($server_home['home_id']);
$is_address_assigned = false;
foreach($ip_ports as $ip_port)
foreach ((array)$ip_ports as $ip_port)
{
if($ip_port['ip'] == $ip and $ip_port['port'] == $port)
{
@ -98,7 +98,7 @@ function exec_ogp_module()
$aliases = $aliases === -1 ? array() : $aliases;
if( isset( $_POST['create'] ) )
{
if(!array_key_exists($alias , $aliases))
if(!array_key_exists($alias, (array)$aliases))
{
$home = clean_path($server_home['home_path']."/".clean_string($_POST['path']));
$alias = clean_string($_POST['alias']);