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

@ -961,7 +961,7 @@ class PHPMailer
if ($useimap and function_exists('imap_rfc822_parse_adrlist')) {
//Use this built-in parser if it's available
$list = imap_rfc822_parse_adrlist($addrstr, '');
foreach ($list as $address) {
foreach ((array)$list as $address) {
if ($address->host != '.SYNTAX-ERROR.') {
if ($this->validateAddress($address->mailbox . '@' . $address->host)) {
$addresses[] = array(
@ -974,7 +974,7 @@ class PHPMailer
} else {
//Use this simpler parser
$list = explode(',', $addrstr);
foreach ($list as $address) {
foreach ((array)$list as $address) {
$address = trim($address);
//Is there a separate name part?
if (strpos($address, '<') === false) {
@ -1491,8 +1491,8 @@ class PHPMailer
ini_set('sendmail_from', $this->Sender);
}
$result = false;
if ($this->SingleTo and count($toArr) > 1) {
foreach ($toArr as $toAddr) {
if ($this->SingleTo and count((array)$toArr) > 1) {
foreach ((array)$toArr as $toAddr) {
$result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
$this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
@ -1552,7 +1552,7 @@ class PHPMailer
// Attempt to send to all recipients
foreach (array($this->to, $this->cc, $this->bcc) as $togroup) {
foreach ($togroup as $to) {
foreach ((array)$togroup as $to) {
if (!$this->smtp->recipient($to[0])) {
$error = $this->smtp->getError();
$bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']);
@ -1565,7 +1565,7 @@ class PHPMailer
}
// Only send the DATA command if we have viable recipients
if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
if ((count($this->all_recipients) > count((array)$bad_rcpt)) and !$this->smtp->data($header . $body)) {
throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
}
if ($this->SMTPKeepAlive) {
@ -1575,9 +1575,9 @@ class PHPMailer
$this->smtp->close();
}
//Create error message for any bad addresses
if (count($bad_rcpt) > 0) {
if (count((array)$bad_rcpt) > 0) {
$errstr = '';
foreach ($bad_rcpt as $bad) {
foreach ((array)$bad_rcpt as $bad) {
$errstr .= $bad['to'] . ': ' . $bad['error'];
}
throw new phpmailerException(
@ -1620,7 +1620,7 @@ class PHPMailer
$hosts = explode(';', $this->Host);
$lastexception = null;
foreach ($hosts as $hostentry) {
foreach ((array)$hosts as $hostentry) {
$hostinfo = array();
if (!preg_match(
'/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/',
@ -1823,7 +1823,7 @@ class PHPMailer
public function addrAppend($type, $addr)
{
$addresses = array();
foreach ($addr as $address) {
foreach ((array)$addr as $address) {
$addresses[] = $this->addrFormat($address);
}
return $type . ': ' . implode(', ', $addresses) . $this->LE;
@ -1881,11 +1881,11 @@ class PHPMailer
$lines = explode($this->LE, $message);
//Message will be rebuilt in here
$message = '';
foreach ($lines as $line) {
foreach ((array)$lines as $line) {
$words = explode(' ', $line);
$buf = '';
$firstword = true;
foreach ($words as $word) {
foreach ((array)$words as $word) {
if ($qp_mode and (strlen($word) > $length)) {
$space_left = $length - strlen($buf) - $crlflen;
if (!$firstword) {
@ -2592,7 +2592,7 @@ class PHPMailer
$type = $attachment[4];
$disposition = $attachment[6];
$cid = $attachment[7];
if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) {
if ($disposition == 'inline' && array_key_exists($cid, (array)$cidUniq)) {
continue;
}
$cidUniq[$cid] = true;
@ -3150,7 +3150,7 @@ class PHPMailer
public function clearQueuedAddresses($kind)
{
$RecipientsQueue = $this->RecipientsQueue;
foreach ($RecipientsQueue as $address => $params) {
foreach ((array)$RecipientsQueue as $address => $params) {
if ($params[0] == $kind) {
unset($this->RecipientsQueue[$address]);
}
@ -3289,7 +3289,7 @@ class PHPMailer
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', (array)$_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} elseif (function_exists('gethostname') && gethostname() !== false) {
$result = gethostname();
@ -3400,12 +3400,12 @@ class PHPMailer
public function msgHTML($message, $basedir = '', $advanced = false)
{
preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
if (array_key_exists(2, $images)) {
if (array_key_exists(2, (array)$images)) {
if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
// Ensure $basedir has a trailing /
$basedir .= '/';
}
foreach ($images[2] as $imgindex => $url) {
foreach ((array)$images[2] as $imgindex => $url) {
// Convert data URIs into embedded images
if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) {
$data = substr($url, strpos($url, ','));
@ -3652,16 +3652,16 @@ class PHPMailer
$ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
$pathinfo = array();
if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
if (array_key_exists(1, $pathinfo)) {
if (array_key_exists(1, (array)$pathinfo)) {
$ret['dirname'] = $pathinfo[1];
}
if (array_key_exists(2, $pathinfo)) {
if (array_key_exists(2, (array)$pathinfo)) {
$ret['basename'] = $pathinfo[2];
}
if (array_key_exists(5, $pathinfo)) {
if (array_key_exists(5, (array)$pathinfo)) {
$ret['extension'] = $pathinfo[5];
}
if (array_key_exists(3, $pathinfo)) {
if (array_key_exists(3, (array)$pathinfo)) {
$ret['filename'] = $pathinfo[3];
}
}
@ -3827,7 +3827,7 @@ class PHPMailer
{
$signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader);
$lines = explode("\r\n", $signHeader);
foreach ($lines as $key => $line) {
foreach ((array)$lines as $key => $line) {
list($heading, $value) = explode(':', $line, 2);
$heading = strtolower($heading);
$value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces
@ -3878,7 +3878,7 @@ class PHPMailer
$to_header = '';
$date_header = '';
$current = '';
foreach ($headers as $header) {
foreach ((array)$headers as $header) {
if (strpos($header, 'From:') === 0) {
$from_header = $header;
$current = 'from_header';

View file

@ -104,7 +104,7 @@ class PHPMailerOAuth extends PHPMailer
$hosts = explode(';', $this->Host);
$lastexception = null;
foreach ($hosts as $hostentry) {
foreach ((array)$hosts as $hostentry) {
$hostinfo = array();
if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
// Not a valid host entry

View file

@ -669,7 +669,7 @@ class SMTP
$in_headers = true;
}
foreach ($lines as $line) {
foreach ((array)$lines as $line) {
$lines_out = array();
if ($in_headers and $line == '') {
$in_headers = false;
@ -700,7 +700,7 @@ class SMTP
$lines_out[] = $line;
//Send the lines to the server
foreach ($lines_out as $line_out) {
foreach ((array)$lines_out as $line_out) {
//RFC2821 section 4.5.2
if (!empty($line_out) and $line_out[0] == '.') {
$line_out = '.' . $line_out;
@ -768,7 +768,7 @@ class SMTP
$this->server_caps = array();
$lines = explode("\n", $this->helo_rply);
foreach ($lines as $n => $s) {
foreach ((array)$lines as $n => $s) {
//First 4 chars contain response code followed by - or space
$s = trim(substr($s, 4));
if (empty($s)) {
@ -895,7 +895,7 @@ class SMTP
$matches = array();
if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) {
$code = $matches[1];
$code_ex = (count($matches) > 2 ? $matches[2] : null);
$code_ex = (count((array)$matches) > 2 ? $matches[2] : null);
// Cut off error code from each response line
$detail = preg_replace(
"/{$code}[ -]" .

View file

@ -202,7 +202,7 @@ function get_start_cmd($user_info,$remote,$server_xml,$home_info,$mod_id,$ip,$po
{
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;
@ -237,7 +237,7 @@ function get_start_cmd($user_info,$remote,$server_xml,$home_info,$mod_id,$ip,$po
$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'];
@ -327,7 +327,7 @@ function test_rsync_response($address)
function get_faster_rsync($rsync_sites)
{
$faster = "NONE";
foreach($rsync_sites as $site)
foreach ((array)$rsync_sites as $site)
{
list($url,$name) = explode('|', $site);
$current_time = test_rsync_response($url);
@ -446,7 +446,7 @@ function ipv6_compress($ip)
if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) {
$max = 0;
$pos = null;
foreach ($matches[0] as $match) {
foreach ((array)$matches[0] as $match) {
if (strlen($match[0]) > $max) {
$max = strlen($match[0]);
$pos = $match[1];
@ -481,7 +481,7 @@ function is_authorized()
$authorized_hosts['address']['ipv6'][] = $ip;
$remote_servers = $db->getRemoteServers();
foreach($remote_servers as $remote_server)
foreach ((array)$remote_servers as $remote_server)
{
$ip = getHostByName($remote_server['agent_ip']);
if(is_valid_ipv4($ip) and !in_array($ip, $authorized_hosts['address']['ipv4']))
@ -495,7 +495,7 @@ function is_authorized()
{
$hosts_list = file_get_contents($api_hosts_file);
$hosts = preg_split("/[\r\n]+/", $hosts_list);
foreach($hosts as $host)
foreach ((array)$hosts as $host)
{
$host = trim($host);
@ -561,7 +561,7 @@ function is_authorized()
{
$fwd_hosts_list = file_get_contents($api_fwd_hosts_file);
$fwd_hosts = preg_split("/[\r\n]+/", $fwd_hosts_list);
foreach($fwd_hosts as $fwd_host)
foreach ((array)$fwd_hosts as $fwd_host)
{
$fwd_host = trim($fwd_host);

View file

@ -35,7 +35,7 @@ abstract class OGPDatabase {
public function generateMySQLInClause($arrayOfInputs){
$inClause = "IN ('";
for($i = 0; $i < count($arrayOfInputs); $i++){
for($i = 0; $i < count((array)$arrayOfInputs); $i++){
if($i == 0){
$inClause .= $this->realEscapeSingle($arrayOfInputs[$i]);
}else{

View file

@ -138,7 +138,7 @@ class OGPDatabaseMySQL extends OGPDatabase
if ( !$this->link ) return FALSE;
if ( !is_array($settings) ) return FALSE;
foreach ( $settings as $s_key => $s_value )
foreach ((array)$settings as $s_key => $s_value )
{
$query = sprintf('INSERT INTO `%1$ssettings` (`setting`,`value`)
VALUES(\'%2$s\', \'%3$s\') ON DUPLICATE KEY
@ -289,7 +289,7 @@ class OGPDatabaseMySQL extends OGPDatabase
return $results;
}
public function get_user_count($search_field) {
public function get_user_count((array)$search_field) {
$search_field = $this->realEscapeSingle($search_field);
$sql = "SELECT COUNT(1) AS total FROM ".$this->table_prefix."users ";
@ -310,7 +310,7 @@ class OGPDatabaseMySQL extends OGPDatabase
return $this->listQuery($query);
}
public function get_group_count($search_field){
public function get_group_count((array)$search_field){
$search_field = $this->realEscapeSingle($search_field);
$sql = "SELECT COUNT(1) AS total FROM ".$this->table_prefix."user_group_info ";
@ -436,7 +436,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$widgets = $this->resultQuery("SELECT * FROM `".$this->table_prefix."widgets`");
$query = "INSERT INTO `".$this->table_prefix."widgets_users` (`user_id`, `widget_id`, `column_id`, `sort_no`, `collapsed`, `title`) VALUES";
foreach($widgets as $widget){
foreach ((array)$widgets as $widget){
$query .= "(" . $user_id . ", " . $widget['id'] . ", " . $widget['column_id'] . ", " . $widget['sort_no'] . ", " . $widget['collapsed'] . ", '" . $widget['title'] . "'),";
}
$query = substr($query, 0, -1);
@ -451,7 +451,7 @@ class OGPDatabaseMySQL extends OGPDatabase
public function editUser($fields,$user_id){
$query = "UPDATE `".$this->table_prefix."users` SET ";
foreach($fields as $key => $value)
foreach ((array)$fields as $key => $value)
{
if($value == "")
$query .= "`$key`=DEFAULT,";
@ -529,7 +529,7 @@ class OGPDatabaseMySQL extends OGPDatabase
"DELETE FROM `%suser_group_homes` WHERE `group_id` = %d",
"DELETE FROM `%suser_group_remote_servers` WHERE `group_id` = %d" );
foreach ($queries as $query_template)
foreach ((array)$queries as $query_template)
{
$query = sprintf($query_template,
$this->table_prefix,
@ -619,11 +619,11 @@ class OGPDatabaseMySQL extends OGPDatabase
$results = $this->listQuery($query);
if($results !== false){
foreach($results as $result){
foreach ((array)$results as $result){
$ids[] = $result['user_id'];
}
if(is_array($ids) && count($ids) > 0){
if(is_array($ids) && count((array)$ids) > 0){
return $ids;
}
}
@ -668,7 +668,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$subusers = $this->getUsersSubUsersIds($user_id);
if( $subusers !== false )
{
foreach ($subusers as $subuser) {
foreach ((array)$subusers as $subuser) {
$this->delUser($subuser);
}
}
@ -909,7 +909,7 @@ class OGPDatabaseMySQL extends OGPDatabase
}
}
if(isset($delVals) && is_array($delVals) && count($delVals) > 0){
if(isset($delVals) && is_array($delVals) && count((array)$delVals) > 0){
// Delete the invalid mods
$query = sprintf('DELETE FROM `%1$sconfig_mods` WHERE `home_cfg_id` = \'%2$s\' AND mod_key NOT %3$s;',
$this->table_prefix,
@ -962,14 +962,14 @@ class OGPDatabaseMySQL extends OGPDatabase
if(isset($oldModStructure) && is_array($oldModStructure) && isset($currentStructure) && is_array($currentStructure)){
foreach($oldModStructure as $oldEntry){
foreach ((array)$oldModStructure as $oldEntry){
$oldModId = $oldEntry["mod_cfg_id"];
$oldCFGId = $oldEntry["home_cfg_id"];
$oldHomeId = $oldEntry["home_id"];
$match = 0;
$cfgMatch = 0;
foreach($currentStructure as $newEntry){
foreach ((array)$currentStructure as $newEntry){
if($newEntry["game_key"] == $oldEntry["game_key"]){
// Update server home home_cfg_id
$cfgMatch++;
@ -1080,7 +1080,7 @@ class OGPDatabaseMySQL extends OGPDatabase
}
// Remove mods that have been renamed or deleted.
if(count($validMods) > 0){
if(count((array)$validMods) > 0){
$this->removeInvalidModCfgIDs($config_id, $validMods);
}
@ -1119,7 +1119,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$queries = array("DELETE FROM `%sconfig_mods` WHERE `home_cfg_id` = %d",
"DELETE FROM `%sconfig_homes` WHERE `home_cfg_id` = %d");
foreach ( $queries as $query )
foreach ((array)$queries as $query)
{
$query = sprintf($query,$this->table_prefix,$home_cfg_id);
++$this->queries_;
@ -1187,7 +1187,7 @@ class OGPDatabaseMySQL extends OGPDatabase
if ( !$this->link ) return FALSE;
$keys = "";
$values = "";
foreach($fields as $key => $val)
foreach ((array)$fields as $key => $val)
{
$keys .= "`$key`,";
$values .= "'".$this->realEscapeSingle($val)."',";
@ -1316,7 +1316,7 @@ class OGPDatabaseMySQL extends OGPDatabase
(SELECT home_id FROM `%1$sserver_homes` WHERE remote_server_id = %2$d);',
"DELETE FROM `%sserver_homes` WHERE remote_server_id = %d;");
foreach ( $queries as $query )
foreach ((array)$queries as $query)
{
$query = sprintf($query,$this->table_prefix,$remote_server_id);
++$this->queries_;
@ -1354,7 +1354,7 @@ class OGPDatabaseMySQL extends OGPDatabase
(SELECT ip FROM `%1$sremote_server_ips` WHERE ip_id = %3$d);',
"UPDATE `%sremote_server_ips` SET ip='%s' WHERE ip_id = %d;");
foreach ( $queries as $query )
foreach ((array)$queries as $query)
{
$query = sprintf($query,$this->table_prefix,$ip,$ip_id);
++$this->queries_;
@ -1382,7 +1382,7 @@ class OGPDatabaseMySQL extends OGPDatabase
(SELECT ip FROM `%1$sremote_server_ips` WHERE ip_id = %2$d);',
"DELETE FROM `%sremote_server_ips` WHERE ip_id = %d;");
foreach ( $queries as $query )
foreach ((array)$queries as $query)
{
$query = sprintf($query,$this->table_prefix,$ip_id);
++$this->queries_;
@ -1610,12 +1610,12 @@ class OGPDatabaseMySQL extends OGPDatabase
{
$user_expiration_dates = $this->listQuery($query2);
$user_group_expiration_dates = $this->listQuery($query3);
foreach($servers as $key => $server)
foreach ((array)$servers as $key => $server)
{
$servers[$key]['access_rights'] = $this->getFullAccessRightsString();
if($user_expiration_dates)
{
foreach($user_expiration_dates as $user_expiration_date)
foreach ((array)$user_expiration_dates as $user_expiration_date)
{
if($server['home_id'] == $user_expiration_date['home_id'])
$servers[$key]['user_expiration_date'] = $user_expiration_date['user_expiration_date'];
@ -1623,7 +1623,7 @@ class OGPDatabaseMySQL extends OGPDatabase
}
if($user_group_expiration_dates)
{
foreach($user_group_expiration_dates as $user_group_expiration_date)
foreach ((array)$user_group_expiration_dates as $user_group_expiration_date)
{
if($server['home_id'] == $user_group_expiration_date['home_id'])
$servers[$key]['user_group_expiration_date'] = $user_group_expiration_date['user_group_expiration_date'];
@ -1989,12 +1989,12 @@ class OGPDatabaseMySQL extends OGPDatabase
{
$user_expiration_dates = $this->listQuery($query2);
$user_group_expiration_dates = $this->listQuery($query3);
foreach($servers as $key => $server)
foreach ((array)$servers as $key => $server)
{
$servers[$key]['access_rights'] = $this->getFullAccessRightsString();
if($user_expiration_dates)
{
foreach($user_expiration_dates as $user_expiration_date)
foreach ((array)$user_expiration_dates as $user_expiration_date)
{
if($server['home_id'] == $user_expiration_date['home_id'])
$servers[$key]['user_expiration_date'] = $user_expiration_date['user_expiration_date'];
@ -2002,7 +2002,7 @@ class OGPDatabaseMySQL extends OGPDatabase
}
if($user_group_expiration_dates)
{
foreach($user_group_expiration_dates as $user_group_expiration_date)
foreach ((array)$user_group_expiration_dates as $user_group_expiration_date)
{
if($server['home_id'] == $user_group_expiration_date['home_id'])
$servers[$key]['user_group_expiration_date'] = $user_group_expiration_date['user_group_expiration_date'];
@ -2725,7 +2725,7 @@ class OGPDatabaseMySQL extends OGPDatabase
(SELECT ip_id, port FROM `%shome_ip_ports` WHERE `home_id` = %d);',
"DELETE FROM `%shome_ip_ports` WHERE `home_id` = %d;");
foreach ( $queries as $query )
foreach ((array)$queries as $query)
{
$query = sprintf($query,$this->table_prefix,$home_id);
++$this->queries_;
@ -3016,7 +3016,7 @@ class OGPDatabaseMySQL extends OGPDatabase
{
$gid = array();
$currentGroups = $this->getUsersGroups($user_id);
foreach($currentGroups as $group){
foreach ((array)$currentGroups as $group){
$gid[] = $group["group_id"];
}
@ -3028,7 +3028,7 @@ class OGPDatabaseMySQL extends OGPDatabase
WHERE `user_id` = %3$d
)';
if(count($gid)){
if(count((array)$gid)){
$template .= ' OR `home_id` IN
(
@ -3371,7 +3371,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$result = $this->listQuery($query);
$position = 0;
foreach($result as $maching_mod )
foreach ((array)$result as $maching_mod)
{
if ( $maching_mod['home_id'] < $home_id )
$position = $position + 2;
@ -3392,7 +3392,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$this->query("INSERT INTO OGP_DB_PREFIXlogger (date, user_id, ip, message) VALUE (FROM_UNIXTIME(UNIX_TIMESTAMP(), '%d-%m-%Y %H:%i:%s'), $user_id, '$client_ip', '$message');");
}
public function get_logger_count($search_field) {
public function get_logger_count((array)$search_field) {
$search_field = $this->realEscapeSingle($search_field);
$sql = "SELECT COUNT(1) AS total FROM ".$this->table_prefix."logger ";
@ -3461,7 +3461,7 @@ class OGPDatabaseMySQL extends OGPDatabase
if($ranges != FALSE)
{
$used_range_ports = array();
foreach($ranges as $range)
foreach ((array)$ranges as $range)
{
for($port = $range['start_port']; $port >= $range['start_port'] and $port <= $range['end_port']; $port++)
{
@ -3475,7 +3475,7 @@ class OGPDatabaseMySQL extends OGPDatabase
{
$range_ports[] = $port;
}
foreach($range_ports as $range_port)
foreach ((array)$range_ports as $range_port)
{
if(in_array($range_port,$used_range_ports))
return 2;
@ -3526,7 +3526,7 @@ class OGPDatabaseMySQL extends OGPDatabase
if($ranges != FALSE)
{
$used_range_ports = array();
foreach($ranges as $range)
foreach ((array)$ranges as $range)
{
if($range['range_id'] == $range_id)
continue;
@ -3543,7 +3543,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$range_ports[] = $port;
}
foreach($range_ports as $range_port)
foreach ((array)$range_ports as $range_port)
{
if(in_array($range_port,$used_range_ports))
return 2;
@ -3583,7 +3583,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$used_ports = array();
if(!empty($home_used_ports))
{
foreach($home_used_ports as $home_used_port)
foreach ((array)$home_used_ports as $home_used_port)
{
$used_ports[] = $home_used_port['port'];
}
@ -3730,7 +3730,7 @@ class OGPDatabaseMySQL extends OGPDatabase
}
public function check_expire_date($user_id, $home_id, $types = array('user', 'user_group', 'server')) {
foreach($types as $type)
foreach ((array)$types as $type)
{
switch ($type) {
case 'user':
@ -3793,7 +3793,7 @@ class OGPDatabaseMySQL extends OGPDatabase
$assigned = $this->getHomeIpPorts($home_id);
if( !empty($assigned) )
{
foreach($assigned as $address)
foreach ((array)$assigned as $address)
{
if($remote->rfile_exists( "startups/".$address['ip']."-".$address['port'] ) === 1)
{
@ -3919,9 +3919,9 @@ class OGPDatabaseMySQL extends OGPDatabase
}
public function saveGameServerOrder($order){
if(is_array($order) && count($order)){
if(is_array($order) && count((array)$order)){
$sql = "";
foreach($order as $homeOrder){
foreach ((array)$order as $homeOrder){
if(is_numeric($homeOrder["home_id"]) && is_numeric($homeOrder["order"])){
$sql .= sprintf("UPDATE %sserver_homes SET home_user_order='%d'
WHERE home_id = '%d';",

View file

@ -222,7 +222,7 @@ function create_home_selector($module, $subpage, $server_homes) {
}
else
{
foreach ($server_homes as $key => $row) {
foreach ((array)$server_homes as $key => $row) {
$home_name[$key] = $row['home_name'];
$home_id[$key] = $row['home_id'];
$mod_id[$key] = $row['home_id'];
@ -237,7 +237,7 @@ function create_home_selector($module, $subpage, $server_homes) {
if( $subpage ) echo "<input type='hidden' name='p' value='".$subpage."' />\n";
echo "<select onchange=".'"this.form.submit()"'." name='home_id'>\n";
echo "<option></option>\n";
foreach ( $server_homes as $server_home )
foreach ((array)$server_homes as $server_home)
{
if( isset( $_GET['home_id'] ) and $_GET['home_id'] == $server_home['home_id'] )
$selected = 'selected="selected"';
@ -263,14 +263,14 @@ function create_home_selector_address($module, $subpage, $server_homes, $extra_i
if( $subpage ) echo "<input type='hidden' name='p' value='".$subpage."' />\n";
if($extra_inputs)
{
foreach($extra_inputs as $input)
foreach ((array)$extra_inputs as $input)
{
echo "<input type='$input[type]' name='$input[name]' value='$input[value]' />\n";
}
}
echo "<select onchange=\"this.form.submit();\" name='home_id-mod_id-ip-port'>\n";
echo "<option></option>\n";
foreach ($server_homes as $key => $row) {
foreach ((array)$server_homes as $key => $row) {
if( !isset($row['ip']) or !isset($row['mod_id']) )
{
unset($server_homes[$key]);
@ -284,7 +284,7 @@ function create_home_selector_address($module, $subpage, $server_homes, $extra_i
}
array_multisort($home_name, $ip, $port, $mod_id,
$home_id, SORT_DESC, $server_homes);
foreach ( $server_homes as $server_home )
foreach ((array)$server_homes as $server_home)
{
$display_ip = checkDisplayPublicIP($server_home['display_public_ip'],$server_home['ip'] != $server_home['agent_ip'] ? $server_home['ip'] : $server_home['agent_ip']);
@ -314,7 +314,7 @@ function create_home_selector_game_type($module, $subpage, $server_homes) {
"<option>".get_lang('game_type')."</option>\n";
$servers_by_game_name = array();
foreach( $server_homes as $server_home )
foreach ((array)$server_homes as $server_home)
{
if( !isset($server_home['ip']) or !isset($server_home['mod_id']) )
continue;
@ -322,7 +322,7 @@ function create_home_selector_game_type($module, $subpage, $server_homes) {
}
ksort($servers_by_game_name);
foreach( $servers_by_game_name as $game_name => $home_cfg_id )
foreach ((array)$servers_by_game_name as $game_name => $home_cfg_id )
{
$selected = (isset($_GET['home_cfg_id']) and $_GET['home_cfg_id'] == $home_cfg_id) ? 'selected="selected"' : "";
echo "<option value='". $home_cfg_id . "' $selected >" . $game_name . "</option>\n";
@ -395,7 +395,7 @@ function mymail($email_address, $subject, $message, $panel_settings, $user_to_pa
{
$mail->AddAddress($panel_email);
$user_to_panel = is_bool($user_to_panel) ? "" : $user_to_panel; // True boolean or user name string
foreach ( $email_addresses as $address )
foreach ((array)$email_addresses as $address)
{
$mail->SetFrom($address,$user_to_panel);
$mail->AddReplyTo($address,$user_to_panel);
@ -403,7 +403,7 @@ function mymail($email_address, $subject, $message, $panel_settings, $user_to_pa
}
else // panel to user
{
foreach ( $email_addresses as $address )
foreach ((array)$email_addresses as $address)
{
$mail->AddAddress($address);
}
@ -541,7 +541,7 @@ function clean_server_param_value($value, $cli_allow_chars) {
}
$find = array();
$repl = array();
foreach($escape_chars as $char)
foreach ((array)$escape_chars as $char)
{
$find[] = '%'.preg_quote($char).'%';
$char = $char == '\\' ? preg_quote('\\\\') : $char;
@ -563,12 +563,12 @@ function array_orderby()
{
$args = func_get_args();
$data = array_shift($args);
foreach ($args as $n => $field)
foreach ((array)$args as $n => $field)
{
if (is_string($field))
{
$tmp = array();
foreach ($data as $key => $row)
foreach ((array)$data as $key => $row)
$tmp[$key] = $row[$field];
$args[$n] = $tmp;
}
@ -613,7 +613,7 @@ function get_game_selector($os, $game_cfgs, $home_cfg_id = FALSE)
}
$selector = "";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if ( preg_match($os_match, $row['game_key'], $matches) )
{
@ -715,7 +715,7 @@ function isValidIP($ip){
function isPrivateIp($ip){
if(is_array($ip)) {
$ret=false;
foreach($ip as $i)
foreach ((array)$ip as $i)
$ret=$ret or isPrivateIp($i);
return $ret;
}
@ -798,7 +798,7 @@ function checkDisplayPublicIP($display_public_ip,$internal_ip){
if(filter_var($display_public_ip, FILTER_VALIDATE_IP)){
return $display_public_ip;
}else{
if(!array_key_exists($display_public_ip, $_SESSION['gethostbyname_cache'])){
if(!array_key_exists($display_public_ip, (array)$_SESSION['gethostbyname_cache'])){
$_SESSION['gethostbyname_cache'][$display_public_ip] = array();
$dns_check = dns_get_record($display_public_ip, DNS_A);
$ipcheck = isset($dns_check[0]['ip']) ? $dns_check[0]['ip'] : $internal_ip;
@ -851,7 +851,7 @@ function preg_replace_nth($pattern, $replacement, $subject, $nth=1) {
// https://stackoverflow.com/questions/12559878/multidimensional-array-find-item-and-move-to-the-top
function customShift($array, $keyToMoveOn, $valueToMoveOn){
foreach($array as $key => $val){
foreach ((array)$array as $key => $val){
if($val[$keyToMoveOn] == $valueToMoveOn){
unset($array[$key]);
array_unshift($array, $val);
@ -878,7 +878,7 @@ function getURLParam($param, $url){
function utf8ize($d, $htmlEntities = true) {
if (is_array($d)) {
foreach ($d as $k => $v) {
foreach ((array)$d as $k => $v) {
$d[$k] = utf8ize($v, $htmlEntities);
}
} else if (is_string ($d)) {
@ -939,7 +939,7 @@ function updateAllPanelModules(){
$modules = $db->getInstalledModules();
// update module manager first
foreach ( $modules as $row )
foreach ((array)$modules as $row)
{
if($row['folder'] == 'modulemanager')
{
@ -948,7 +948,7 @@ function updateAllPanelModules(){
}
}
foreach ( $modules as $row )
foreach ((array)$modules as $row)
{
if($row['folder'] == 'modulemanager')//already updated
continue;
@ -1034,7 +1034,7 @@ function getQueryPortOverridesForGame($protocol, $ip, $port, $defaultQueryPort){
function removeInvalidFileNameCharacters($string){
global $settings;
$pattern = '/[\^\$\*\+\?\(\)\[\{\\\|\]!@#%&=~`,\'<>"}\s]/i';
if(is_array($settings) && array_key_exists("regex_invalid_file_name_chars", $settings) && !empty($settings["regex_invalid_file_name_chars"])){
if(is_array($settings) && array_key_exists("regex_invalid_file_name_chars", (array)$settings) && !empty($settings["regex_invalid_file_name_chars"])){
$pattern = $settings["regex_invalid_file_name_chars"];
}
$string = preg_replace($pattern, '', $string);
@ -1060,8 +1060,8 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
$dbsToDelete = $modDb->getMysqlDBsbyHomeId($home_id);
if(is_array($dbsToDelete) && count($dbsToDelete)){
foreach($dbsToDelete as $dbToDel){
if(is_array($dbsToDelete) && count((array)$dbsToDelete)){
foreach ((array)$dbsToDelete as $dbToDel){
$mysql_db = $dbToDel;
if($mysql_db['remote_server_id'] != "0")
{
@ -1084,7 +1084,7 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
{
$queries = array("DROP DATABASE ".$mysql_db['db_name'].";",
"DROP USER '".$mysql_db['db_user']."'@'%';");
foreach( $queries as $query )
foreach ((array)$queries as $query)
{
@$return = mysqli_query($link, $query);
if(!$return)
@ -1102,7 +1102,7 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
{
$queries = array("DROP DATABASE ".$mysql_db['db_name'].";",
"DROP USER '".$mysql_db['db_user']."'@'%';");
foreach( $queries as $query )
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
@ -1120,7 +1120,7 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
}
}
if($dbDeletedCount == count($dbsToDelete)){
if($dbDeletedCount == count((array)$dbsToDelete)){
return true;
}else if($dbDeletedCount > 0){
return 'partial';

View file

@ -122,7 +122,7 @@ function isPortValid($port)
function cleanFilenames($file_array)
{
$retval = array();
foreach($file_array as $file_name)
foreach ((array)$file_array as $file_name)
{
if($file_name === "." && $file_name === "..")
continue;
@ -140,7 +140,7 @@ function clean_id_string($id_string)
function get_first_existing_file($paths, $referrer = "", $agent = "")
{
foreach ($paths as $path)
foreach ((array)$paths as $path)
{
if(preg_match("/^http/", $path))
{
@ -275,7 +275,7 @@ function updateGameConfigsPostInstall($clear_old = false){
$db->clearGameCfgs($clear_old);
$counter = 0;
foreach ( $files as $config_file )
foreach ((array)$files as $config_file)
{
$config = read_server_config($config_file);
if ( !$db->addGameCfg($config) )
@ -285,7 +285,7 @@ function updateGameConfigsPostInstall($clear_old = false){
}
}
if($counter == count($files)){
if($counter == count((array)$files)){
return false;
}
@ -321,7 +321,7 @@ function recursiveDelete($str) {
if($folder != ".." && $folder != "."){
$scan = glob($str . '/{,.}*', GLOB_BRACE);
if(isset($scan) && is_array($scan)){
foreach($scan as $index=>$path) {
foreach ((array)$scan as $index=>$path) {
recursiveDelete($path);
}
}
@ -391,7 +391,7 @@ function removeOldGameConfigs(){ // Wrote this function in-case we rename config
'modules/config_games/server_configs/bukkit_win64.xml',
);
foreach($oldConfigsToRemove as $config){
foreach ((array)$oldConfigsToRemove as $config){
recursiveDelete($config);
}
}
@ -402,7 +402,7 @@ function removeOldPanelFiles(){ // Should run post panel update to remove old fi
'protocol/GameQ/gameq'
);
foreach($oldFiles as $file){
foreach ((array)$oldFiles as $file){
recursiveDelete($file);
}
}
@ -424,7 +424,7 @@ function runPostUpdateOperations(){
removeOldPanelFiles();
}
if(!array_key_exists("users_api_key", $_SESSION)){
if(!array_key_exists("users_api_key", (array)$_SESSION)){
$_SESSION['users_api_key'] = $db->getApiToken($_SESSION['user_id']);
}
}
@ -480,13 +480,13 @@ function getOGPLangConstantsJSON(){
$finalConsts = array();
$consts = get_defined_constants(true);
foreach($consts["user"] as $key => $value){
foreach ((array)$consts["user"] as $key => $value){
if(startsWith($key, $OGPLangPre)){
$finalConsts[$key] = $value;
}
}
if(count($finalConsts) > 0){
if(count((array)$finalConsts) > 0){
return json_encode(utf8ize($finalConsts));
}

View file

@ -49,7 +49,7 @@ function create_drop_box_from_array_rsync($input_array, $listname, $current_valu
{
$count = 1;
$retval = "<select id=\"$listname\" name=\"$listname\">\n";
foreach($input_array as $key => $value)
foreach ((array)$input_array as $key => $value)
{
$value = trim($value);
list($rsync_site,$location) = explode("|", $value);
@ -84,7 +84,7 @@ function create_drop_box_from_array_rsync($input_array, $listname, $current_valu
function create_drop_box_from_array($input_array,$listname,$current_value = "", $use_only_values = true)
{
$retval = "<select id=\"$listname\" name=\"$listname\" style=\"max-width:330px;\">\n";
foreach($input_array as $key => $value)
foreach ((array)$input_array as $key => $value)
{
// Make sure we don't allow HTML or script
$key = trim(strip_tags($key));
@ -120,7 +120,7 @@ function create_drop_box_from_passwd($input_array,$listname)
{
$retval = "<select name=\"$listname\">\n";
foreach($input_array as $line)
foreach ((array)$input_array as $line)
{
$line = trim($line);
if ( empty($line) ) continue;
@ -134,7 +134,7 @@ function create_drop_box_from_passwd($input_array,$listname)
function get_user_uid_gid_from_passwd($input_array,$name)
{
foreach($input_array as $line)
foreach ((array)$input_array as $line)
{
$line = trim($line);
if ( empty($line) ) continue;

View file

@ -65,7 +65,7 @@ function ipv4_in_range($ip, $range) {
// $netmask is a CIDR size block
// fix the range argument
$x = explode('.', $range);
while(count($x)<4) $x[] = '0';
while(count((array)$x)<4) $x[] = '0';
list($a,$b,$c,$d) = $x;
$range = sprintf("%u.%u.%u.%u", empty($a)?'0':$a, empty($b)?'0':$b,empty($c)?'0':$c,empty($d)?'0':$d);
$range_dec = ip2long($range);
@ -107,7 +107,7 @@ function ip2long6($ip) {
$ip = explode(':', $ip);
$r_ip = '';
foreach ($ip as $v) {
foreach ((array)$ip as $v) {
$r_ip .= str_pad(base_convert($v, 16, 2), 16, 0, STR_PAD_LEFT);
}
@ -128,13 +128,13 @@ function get_ipv6_full($ip)
// Pad out the shorthand entries.
$main_ip_pieces = explode(":", $main_ip_piece);
foreach($main_ip_pieces as $key=>$val) {
foreach ((array)$main_ip_pieces as $key=>$val) {
$main_ip_pieces[$key] = str_pad($main_ip_pieces[$key], 4, "0", STR_PAD_LEFT);
}
// Check to see if the last IP block (part after ::) is set
$last_piece = "";
$size = count($main_ip_pieces);
$size = count((array)$main_ip_pieces);
if (trim($last_ip_piece) != "") {
$last_piece = str_pad($last_ip_piece, 4, "0", STR_PAD_LEFT);
@ -175,7 +175,7 @@ function ipv6_in_range($ip, $range_ip)
// Pad out the shorthand entries.
$main_ip_pieces = explode(":", $main_ip_piece);
foreach($main_ip_pieces as $key=>$val) {
foreach ((array)$main_ip_pieces as $key=>$val) {
$main_ip_pieces[$key] = str_pad($main_ip_pieces[$key], 4, "0", STR_PAD_LEFT);
}
@ -185,7 +185,7 @@ function ipv6_in_range($ip, $range_ip)
// Check to see if the last IP block (part after ::) is set
$last_piece = "";
$size = count($main_ip_pieces);
$size = count((array)$main_ip_pieces);
if (trim($last_ip_piece) != "") {
$last_piece = str_pad($last_ip_piece, 4, "0", STR_PAD_LEFT);

View file

@ -71,14 +71,14 @@ function ogpLang()
$modules = preg_grep("/.*/",get_included_files());
foreach ($lang_modules as $lang_module)
foreach ((array)$lang_modules as $lang_module)
{
$lang_file = LANG_DIR."/modules/".$lang_module.".php";
if ( is_file($lang_file) )
array_push($files,$lang_file);
}
foreach ($files as $file_name)
foreach ((array)$files as $file_name)
{
// Load the actual language files.
include_once($file_name);

View file

@ -97,7 +97,7 @@ class OGPRemoteLibrary
$params_array = array();
$args = func_get_args();
foreach ($args as $arg)
foreach ((array)$args as $arg)
{
array_push($params_array,$this->encryptParam($arg));
}
@ -193,7 +193,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line)."\n";
}
@ -246,7 +246,7 @@ class OGPRemoteLibrary
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line);
}
@ -685,7 +685,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line);
}
@ -781,7 +781,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line)."\n";
}
@ -804,7 +804,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line);
}
@ -827,7 +827,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line);
}
@ -849,7 +849,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line);
}
@ -870,7 +870,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$decoded_line = base64_decode($line);
if(!preg_match("/^[\s|\t]*$/", $decoded_line))
@ -930,7 +930,7 @@ class OGPRemoteLibrary
$this->add_enc_chk($args);
$request = xmlrpc_encode_request("fastdl_get_aliases",$args);
$response = $this->sendRequest($request);
if(!is_array($response) or count($response) == 0)
if(!is_array($response) or count((array)$response) == 0)
return -1;
return $response;
}
@ -948,7 +948,7 @@ class OGPRemoteLibrary
if(is_array($aliases))
{
$params_array = array();
foreach($aliases as $alias)
foreach ((array)$aliases as $alias)
{
$params_array[] = $this->encryptParam($alias);
}
@ -1002,7 +1002,7 @@ class OGPRemoteLibrary
else
{
$data = array();
foreach ($response as $id => $task)
foreach ((array)$response as $id => $task)
{
$task = trim(base64_decode($task));
$data[$id] = $task;
@ -1072,7 +1072,7 @@ class OGPRemoteLibrary
if (is_array($response) and !empty($response))
{
$data = array();
foreach ($response as $key => $value)
foreach ((array)$response as $key => $value)
{
$data[$key] = base64_decode($value);
}
@ -1084,7 +1084,7 @@ class OGPRemoteLibrary
if ( $retval > 0 )
{
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
$data .= base64_decode($line);
}
@ -1205,7 +1205,7 @@ class OGPRemoteLibrary
{
list($retval, $data_tmp) = explode(";", $response);
$lines = explode('\n',$data_tmp);
foreach ($lines as $line)
foreach ((array)$lines as $line)
{
@list($string_name, $mod_title) = explode(':', base64_decode($line), 2);
if($string_name != "" and $mod_title != "")

View file

@ -123,7 +123,7 @@ class OGPView {
// Set some useful variables
$javascript .= '<script type="text/javascript">';
if(array_key_exists("users_api_key", $_SESSION) && !empty($_SESSION['users_api_key'])){
if(array_key_exists("users_api_key", (array)$_SESSION) && !empty($_SESSION['users_api_key'])){
$javascript .= 'var userAPIKey = "' . $_SESSION['users_api_key'] . '";';
}
$javascript .= '</script>' . "\n";
@ -151,7 +151,7 @@ class OGPView {
MODULES . "{$_GET['m']}/{$_GET['m']}.css"
);
foreach($fc as $file_check){
foreach ((array)$fc as $file_check){
if(is_readable($file_check)){
$stylesheet .= "<link rel=\"stylesheet\" href=\"${file_check}\">\n";
break;
@ -163,7 +163,7 @@ class OGPView {
$path . MODULES . "{$_GET['m']}/{$_GET['m']}.js"
);
foreach($fc as $file_check){
foreach ((array)$fc as $file_check){
if(is_readable($file_check)){
$javascript .= "<script type=\"text/javascript\" src=\"${file_check}\"></script>\n";
break;