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

@ -92,12 +92,12 @@ class Crypt_XXTEA {
} else {
return PEAR::raiseError('The secret key must be a string or long integer array.');
}
if (count($k) > 4) {
if (count((array)$k) > 4) {
return PEAR::raiseError('The secret key cannot be more than 16 characters or 4 long values.');
} elseif (count($k) == 0) {
} elseif (count((array)$k) == 0) {
return PEAR::raiseError('The secret key cannot be empty.');
} elseif (count($k) < 4) {
for ($i = count($k); $i < 4; $i++) {
} elseif (count((array)$k) < 4) {
for ($i = count((array)$k); $i < 4; $i++) {
$k[$i] = 0;
}
}
@ -206,7 +206,7 @@ class Crypt_XXTEA {
* PEAR_Error on failure
*/
function _encryptArray($v) {
$n = count($v) - 1;
$n = count((array)$v) - 1;
$z = $v[$n];
$y = $v[0];
$q = floor(6 + 52 / ($n + 1));
@ -264,7 +264,7 @@ class Crypt_XXTEA {
* PEAR_Error on failure
*/
function _decryptArray($v) {
$n = count($v) - 1;
$n = count((array)$v) - 1;
$z = $v[$n];
$y = $v[0];
$q = floor(6 + 52 / ($n + 1));
@ -300,7 +300,7 @@ class Crypt_XXTEA {
* @return string the string
*/
function _long2str($v, $w) {
$len = count($v);
$len = count((array)$v);
$s = '';
for ($i = 0; $i < $len; $i++) {
$s .= pack('V', $v[$i]);

View file

@ -5,7 +5,7 @@
$arrayElements = explode(";", $tagsList);
echo "Contains ".sizeof($arrayElements)." elements<br>-----------------<br><br>";
$counter = 0;
foreach($arrayElements as $vehicle)
foreach ((array)$arrayElements as $vehicle)
{
$vehicleValues = explode(",", $vehicle);
echo"
@ -33,7 +33,7 @@
$arrayElements = explode(";", $tagsList);
echo "Contains ".sizeof($arrayElements)." elements<br>-----------------<br><br>";
$counter = 0;
foreach($arrayElements as $vehicle)
foreach ((array)$arrayElements as $vehicle)
{
$vehicleValues = explode(",", $vehicle);
echo"
@ -51,7 +51,7 @@
$tagsList=$_POST['tags_list'];
$arrayElements = explode(";", $tagsList);
$counter = 0;
foreach($arrayElements as $vehicle)
foreach ((array)$arrayElements as $vehicle)
{
$vehicleValues = explode(",", $vehicle);
$step1 = str_replace('[', '',$vehicleValues[0]);

View file

@ -103,7 +103,7 @@ function heading()
// Use parent expiration date for subusers
if(!is_null($info['users_parent']) && is_numeric($info['users_parent'])){
$parentInfo = $db->getUserById($info['users_parent']);
if(is_array($parentInfo) && array_key_exists("user_expires", $parentInfo) && $parentInfo['user_expires'] != "X"){
if(is_array($parentInfo) && array_key_exists("user_expires", (array)$parentInfo) && $parentInfo['user_expires'] != "X"){
$info['user_expires'] = $parentInfo['user_expires'];
}
}
@ -166,11 +166,11 @@ function ogpHome()
if(!empty($server_homes))
{
$servers_by_game_name = array();
foreach( $server_homes as $server_home )
foreach ((array)$server_homes as $server_home)
{
if(isset($settings['check_expiry_by']) and $settings['check_expiry_by'] == "once_logged_in")
{
if($db->check_expire_date($_SESSION['user_id'], $server_home['home_id']))
if($db->check_expire_date($_SESSION['user_id'], is_numeric($server_home['home_id']) ? (int)$server_home['home_id'] : strtotime($server_home['home_id'])))
continue;
}
$servers_by_game_name["$server_home[game_name]"][] = $server_home;
@ -178,7 +178,7 @@ function ogpHome()
ksort($servers_by_game_name);
$game_homes_list = "<ul id='submenu_0' >\n";
require_once("modules/config_games/server_config_parser.php");
foreach( $servers_by_game_name as $game_name => $server_homes )
foreach ((array)$servers_by_game_name as $game_name => $server_homes )
{
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_homes[0]['home_cfg_file']);
$mod = $server_homes[0]['mod_key'];
@ -201,7 +201,7 @@ function ogpHome()
$game_homes_list .= "<li>\n<a href='?m=gamemanager&p=game_monitor&home_cfg_id=".$server_homes[0]['home_cfg_id'].
"'><span data-icon_path='$icon_path'>$game_name</span></a>\n<ul id='submenu_1' >\n";
foreach($server_homes as $server_home)
foreach ((array)$server_homes as $server_home)
{
$button_name = htmlentities($server_home['home_name']);
if( ! preg_match("/none/i", $server_home['mod_name']) )
@ -223,7 +223,7 @@ function ogpHome()
<ul>
<?php
$menus = $db->getMenusForGroup('user');
foreach ( $menus as $menu )
foreach ((array)$menus as $menu)
{
$module = $menu['module'];
if ( !empty( $menu['subpage'] ) )
@ -261,7 +261,7 @@ function ogpHome()
$TotalSelected = false;
$menus = $db->getMenusForGroup('admin');
foreach ($menus as $key => $row) {
foreach ((array)$menus as $key => $row) {
if ( !empty( $row['subpage'] ) )
$name[$key] = $row['subpage'];
else
@ -271,7 +271,7 @@ function ogpHome()
}
array_multisort($translation, $name, SORT_DESC, $menus);
foreach ( $menus as $menu )
foreach ((array)$menus as $menu)
{
$module = $menu['module'];
if ( !empty( $menu['subpage'] ) )

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;

View file

@ -136,7 +136,7 @@ function ogpHome()
$locale_files = makefilelist("lang/", ".|..|.svn", true, "folders");
$lang_sel = "<select name='lang' onchange=\"this.form.submit();\" >\n".
"<option>-</option>\n";
for ($i=0;$i < count($locale_files);$i++)
for ($i=0;$i < count((array)$locale_files);$i++)
{
$selected = ( isset( $_GET['lang'] ) AND $_GET['lang'] != "-" AND $_GET['lang'] == $locale_files[$i] ) ? "selected='selected'" : "";
$lang_sel .= "<option $selected value='".$locale_files[$i]."' >".$locale_files[$i]."</option>\n";
@ -153,7 +153,7 @@ function ogpHome()
$menus = $db->getMenusForGroup('guest');
if(!empty($menus))
{
foreach ( $menus as $menu )
foreach ((array)$menus as $menu)
{
$module = $menu['module'];
if ( !empty( $menu['subpage'] ) )
@ -196,7 +196,7 @@ function ogpHome()
//tagged for future use...
/*
$postdata = "";
foreach($_POST as $key =>$value)
foreach ((array)$_POST as $key =>$value)
$postdata .= ",'$key': '$value'";
$postdata = substr($postdata,1);
$postdata = "{".$postdata."}";
@ -292,14 +292,14 @@ function ogpHome()
$login_attempts++;
if( $login_attempts == $settings["login_attempts_before_banned"] )
{
$banned_until = time() + (array_key_exists("login_ban_time" , $settings) && !empty($settings["login_ban_time"]) && is_numeric($settings["login_ban_time"]) ? $settings["login_ban_time"] : 300); // Five minutes or user defined setting.
$banned_until = time() + (array_key_exists("login_ban_time", (array)$settings) && !empty($settings["login_ban_time"]) && is_numeric($settings["login_ban_time"]) ? $settings["login_ban_time"] : 300); // Five minutes or user defined setting.
if( !$banlist_info )
$db->query("INSERT INTO `OGP_DB_PREFIXban_list` (`client_ip`) VALUES('$client_ip');");
$db->logger( get_lang("bad_login") . " ( Banned until " . date("r", $banned_until) . " ) [ " . get_lang("login") . ": " . sanitizeInputStr($_POST["ulogin"]) . ", " . get_lang("password") . ": ******** ]" );
$db->logger( get_lang("bad_login") . " ( Banned until " . date("r", is_numeric($banned_until) ? (int)$banned_until : strtotime($banned_until)) . " ) [ " . get_lang("login") . ": " . sanitizeInputStr($_POST["ulogin"]) . ", " . get_lang("password") . ": ******** ]" );
$db->query("UPDATE `OGP_DB_PREFIXban_list` SET logging_attempts='$login_attempts', banned_until='$banned_until' WHERE client_ip='$client_ip';");
print_failure("Banned until " . date("r",$banned_until));
print_failure("Banned until " . date("r", is_numeric($banned_until) ? (int)$banned_until : strtotime($banned_until)));
}
else
{

View file

@ -136,7 +136,7 @@ function ogpHome()
$locale_files = makefilelist("lang/", ".|..|.svn", true, "folders");
$lang_sel = "<select name='lang' onchange=\"this.form.submit();\" >\n".
"<option>-</option>\n";
for ($i=0;$i < count($locale_files);$i++)
for ($i=0;$i < count((array)$locale_files);$i++)
{
$selected = ( isset( $_GET['lang'] ) AND $_GET['lang'] != "-" AND $_GET['lang'] == $locale_files[$i] ) ? "selected='selected'" : "";
$lang_sel .= "<option $selected value='".$locale_files[$i]."' >".$locale_files[$i]."</option>\n";
@ -159,7 +159,7 @@ function ogpHome()
$menus = $db->getMenusForGroup('guest');
if(!empty($menus))
{
foreach ( $menus as $menu )
foreach ((array)$menus as $menu)
{
$module = $menu['module'];
if ( !empty( $menu['subpage'] ) )
@ -207,7 +207,7 @@ function ogpHome()
//tagged for future use...
/*
$postdata = "";
foreach($_POST as $key =>$value)
foreach ((array)$_POST as $key =>$value)
$postdata .= ",'$key': '$value'";
$postdata = substr($postdata,1);
$postdata = "{".$postdata."}";
@ -343,14 +343,14 @@ function ogpHome()
$login_attempts++;
if( $login_attempts == $settings["login_attempts_before_banned"] )
{
$banned_until = time() + (array_key_exists("login_ban_time" , $settings) && !empty($settings["login_ban_time"]) && is_numeric($settings["login_ban_time"]) ? $settings["login_ban_time"] : 300); // Five minutes or user defined setting.
$banned_until = time() + (array_key_exists("login_ban_time", (array)$settings) && !empty($settings["login_ban_time"]) && is_numeric($settings["login_ban_time"]) ? $settings["login_ban_time"] : 300); // Five minutes or user defined setting.
if( !$banlist_info )
$db->query("INSERT INTO `OGP_DB_PREFIXban_list` (`client_ip`) VALUES('$client_ip');");
$db->logger( get_lang("bad_login") . " ( Banned until " . date("r", $banned_until) . " ) [ login: $_POST[ulogin], password: ******** ]" );
$db->logger( get_lang("bad_login") . " ( Banned until " . date("r", is_numeric($banned_until) ? (int)$banned_until : strtotime($banned_until)) . " ) [ login: $_POST[ulogin], password: ******** ]" );
$db->query("UPDATE `OGP_DB_PREFIXban_list` SET logging_attempts='$login_attempts', banned_until='$banned_until' WHERE client_ip='$client_ip';");
print_failure("Banned until " . date("r",$banned_until));
print_failure("Banned until " . date("r", is_numeric($banned_until) ? (int)$banned_until : strtotime($banned_until)));
}
else
{

View file

@ -112,7 +112,7 @@ $global_comparison_lang_files = array();
$gclf_tmp = glob($COMPARISON_LANG."/*.php");
// Remove the directory from filename.
foreach ( $gclf_tmp as $tmp )
foreach ((array)$gclf_tmp as $tmp)
{
$array_tmp = explode("/",$tmp);
array_push($global_comparison_lang_files,$array_tmp[1]);
@ -120,7 +120,7 @@ foreach ( $gclf_tmp as $tmp )
$gclf_tmp = glob($COMPARISON_LANG."/modules/*.php");
foreach ( $gclf_tmp as $tmp )
foreach ((array)$gclf_tmp as $tmp)
{
$array_tmp = explode("/",$tmp);
array_push($global_comparison_lang_files,"modules/".$array_tmp[2]);
@ -129,7 +129,7 @@ foreach ( $gclf_tmp as $tmp )
$locale_files = makefilelist("./", ".|..|.svn", true, "folders");
echo "<ul id='lang_list'>";
foreach ($locale_files as $lang_name)
foreach ((array)$locale_files as $lang_name)
{
echo "<li><a href='#$lang_name'>$lang_name</a></li>\n";
}
@ -144,13 +144,13 @@ if ( isset($_SESSION['users_login']) )
{
if( !empty( $_POST ) )
{
foreach ($locale_files as $lang_name)
foreach ((array)$locale_files as $lang_name)
{
if ( $lang_name == $COMPARISON_LANG ) continue;
$lang_ok = true;
foreach ( $global_comparison_lang_files as $glf )
foreach ((array)$global_comparison_lang_files as $glf)
{
$file = $lang_name."/".$glf;
if( isset( $_POST[str_replace(".", "_", $file)] ) )
@ -158,7 +158,7 @@ if ( isset($_SESSION['users_login']) )
echo "<h2>".$lang_name."</h2>\n";
echo $file."\n Values Added.";
$add_values = '<?php '."\n";
foreach ( $_POST as $var => $value )
foreach ((array)$_POST as $var => $value )
{
if( $var != str_replace(".", "_", $file) )
$add_values .= 'define(\''.$var.'\', "'.$value.'");'."\n";
@ -175,7 +175,7 @@ if ( isset($_SESSION['users_login']) )
}
$current_url = curPageURL();
foreach ($global_comparison_lang_files as $glf)
foreach ((array)$global_comparison_lang_files as $glf)
{
$file = $COMPARISON_LANG."/".$glf;
$contents = file_get_contents($current_url.'?file='.$file);
@ -184,7 +184,7 @@ foreach ($global_comparison_lang_files as $glf)
// Check every lang.
foreach ($locale_files as $lang_name)
foreach ((array)$locale_files as $lang_name)
{
if ( $lang_name == $COMPARISON_LANG ) continue;
@ -192,7 +192,7 @@ foreach ($locale_files as $lang_name)
$lang_ok = true;
foreach ( $global_comparison_lang_files as $glf )
foreach ((array)$global_comparison_lang_files as $glf)
{
$file = $lang_name."/".$glf;
if ( !is_file($file) )
@ -224,7 +224,7 @@ foreach ($locale_files as $lang_name)
{
echo "<div class='missing_lang'><h4>Missing lang vars:</h4>\n";
echo "<br>";
foreach ( $missing_lang_vars as $var => $value )
foreach ((array)$missing_lang_vars as $var => $value )
{
echo "<label for='$var' >$var</label><br><textarea id='$var' name='$var'>".$lang[$glf][$var]."</textarea><br>\n";
}
@ -238,7 +238,7 @@ foreach ($locale_files as $lang_name)
{
echo "<div class='extra_lang'><h4>Extra lang vars:</h4>\n";
echo "<ul>";
foreach ( $extra_lang_vars as $var => $value )
foreach ((array)$extra_lang_vars as $var => $value )
{
echo "<li>$var</li>";
}

View file

@ -48,7 +48,7 @@ function exec_ogp_module()
<td class='left'>
<select onchange=".'"this.form.submit()"'." name='rserver_id'>
<option></option>\n";
foreach ( $remote_servers as $server )
foreach ((array)$remote_servers as $server)
{
$display_ip = checkDisplayPublicIP($server['display_public_ip'],$server['ip'] != $server['agent_ip'] ? $server['ip'] : $server['agent_ip']);
echo "<option value='".$server['remote_server_id']."'>".
@ -89,7 +89,7 @@ function exec_ogp_module()
if( isset( $_POST['vserver_id'] ) && !$isAdmin )
{
foreach($TS3_list as $TS3)
foreach ((array)$TS3_list as $TS3)
{
if($_POST['vserver_id'] == $TS3['vserver_id'])
{
@ -113,7 +113,7 @@ function exec_ogp_module()
{
echo "<table><tr>";
$counter = 0;
foreach( $TS3_list as $TS3 )
foreach ((array)$TS3_list as $TS3)
{
$counter++;
echo "<td><form action='' method='POST'>

View file

@ -285,7 +285,7 @@ class Config_File {
/* parse file line by line */
preg_match_all('!^.*\r?\n?!m', $contents, $match);
$lines = $match[0];
for ($i=0, $count=count($lines); $i<$count; $i++) {
for ($i=0, $count=count((array)$lines); $i<$count; $i++) {
$line = $lines[$i];
if (empty($line)) continue;

View file

@ -587,7 +587,7 @@ class Smarty
function assign($tpl_var, $value = null)
{
if (is_array($tpl_var)){
foreach ($tpl_var as $key => $val) {
foreach ((array)$tpl_var as $key => $val) {
if ($key != '') {
$this->_tpl_vars[$key] = $val;
}
@ -620,13 +620,13 @@ class Smarty
{
if (is_array($tpl_var)) {
// $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val) {
foreach ((array)$tpl_var as $_key => $_val) {
if ($_key != '') {
if(!@is_array($this->_tpl_vars[$_key])) {
settype($this->_tpl_vars[$_key],'array');
}
if($merge && is_array($_val)) {
foreach($_val as $_mkey => $_mval) {
foreach ((array)$_val as $_mkey => $_mval) {
$this->_tpl_vars[$_key][$_mkey] = $_mval;
}
} else {
@ -640,7 +640,7 @@ class Smarty
settype($this->_tpl_vars[$tpl_var],'array');
}
if($merge && is_array($value)) {
foreach($value as $_mkey => $_mval) {
foreach ((array)$value as $_mkey => $_mval) {
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
}
} else {
@ -663,7 +663,7 @@ class Smarty
settype($this->_tpl_vars[$tpl_var],'array');
}
if ($merge && is_array($value)) {
foreach($value as $_key => $_val) {
foreach ((array)$value as $_key => $_val) {
$this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
}
} else {
@ -681,7 +681,7 @@ class Smarty
function clear_assign($tpl_var)
{
if (is_array($tpl_var))
foreach ($tpl_var as $curr_var)
foreach ((array)$tpl_var as $curr_var)
unset($this->_tpl_vars[$curr_var]);
else
unset($this->_tpl_vars[$tpl_var]);
@ -813,11 +813,11 @@ class Smarty
*/
function register_resource($type, $functions)
{
if (count($functions)==4) {
if (count((array)$functions)==4) {
$this->_plugins['resource'][$type] =
array($functions, false);
} elseif (count($functions)==5) {
} elseif (count((array)$functions)==5) {
$this->_plugins['resource'][$type] =
array(array(array(&$functions[0], $functions[1])
,array(&$functions[0], $functions[2])
@ -1244,7 +1244,7 @@ class Smarty
// load filters that are marked as autoload
if (count($this->autoload_filters)) {
foreach ($this->autoload_filters as $_filter_type => $_filters) {
foreach ($_filters as $_filter) {
foreach ((array)$_filters as $_filter) {
$this->load_filter($_filter_type, $_filter);
}
}
@ -1625,7 +1625,7 @@ class Smarty
// split tpl_path by the first colon
$_resource_name_parts = explode(':', $params['resource_name'], 2);
if (count($_resource_name_parts) == 1) {
if (count((array)$_resource_name_parts) == 1) {
// no resource type given
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $_resource_name_parts[0];
@ -1688,7 +1688,7 @@ class Smarty
$this->_plugins['modifier'][$_modifier_name];
$_var = $_args[0];
foreach ($_var as $_key => $_val) {
foreach ((array)$_var as $_key => $_val) {
$_args[0] = $_val;
$_var[$_key] = call_user_func_array($_func_name, $_args);
}
@ -1911,7 +1911,7 @@ class Smarty
} else {
/* add a reference to a new set of cache_attrs */
$_cache_attrs[] = array();
return $_cache_attrs[count($_cache_attrs)-1];
return $_cache_attrs[count((array)$_cache_attrs)-1];
}

View file

@ -276,17 +276,17 @@ class Smarty_Compiler extends Smarty {
$text_blocks = preg_split("~{$ldq}.*?{$rdq}~s", $source_content);
/* loop through text blocks */
for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
for ($curr_tb = 0, $for_max = count((array)$text_blocks); $curr_tb < $for_max; $curr_tb++) {
/* match anything resembling php tags */
if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?\s*php\s*[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
/* replace tags with placeholders to prevent recursive replacements */
$sp_match[1] = array_unique($sp_match[1]);
usort($sp_match[1], '_smarty_sort_length');
for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
for ($curr_sp = 0, $for_max2 = count((array)$sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
$text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
}
/* process each one */
for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
for ($curr_sp = 0, $for_max2 = count((array)$sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
/* echo php contents */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?php echo \''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n", $text_blocks[$curr_tb]);
@ -307,7 +307,7 @@ class Smarty_Compiler extends Smarty {
/* Compile the template tags into PHP code. */
$compiled_tags = array();
for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {
for ($i = 0, $for_max = count((array)$template_tags); $i < $for_max; $i++) {
$this->_current_line_no += substr_count($text_blocks[$i], "\n");
$compiled_tags[] = $this->_compile_tag($template_tags[$i]);
$this->_current_line_no += substr_count($template_tags[$i], "\n");
@ -321,7 +321,7 @@ class Smarty_Compiler extends Smarty {
/* Reformat $text_blocks between 'strip' and '/strip' tags,
removing spaces, tabs and newlines. */
$strip = false;
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
for ($i = 0, $for_max = count((array)$compiled_tags); $i < $for_max; $i++) {
if ($compiled_tags[$i] == '{strip}') {
$compiled_tags[$i] = '';
$strip = true;
@ -353,7 +353,7 @@ class Smarty_Compiler extends Smarty {
$tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%';
/* Interleave the compiled contents and text blocks to get the final result. */
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
for ($i = 0, $for_max = count((array)$compiled_tags); $i < $for_max; $i++) {
if ($compiled_tags[$i] == '') {
// tag result empty, remove first newline from following text block
$text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]);
@ -405,7 +405,7 @@ class Smarty_Compiler extends Smarty {
if (count($this->_plugin_info)) {
$_plugins_params = "array('plugins' => array(";
foreach ($this->_plugin_info as $plugin_type => $plugins) {
foreach ($plugins as $plugin_name => $plugin_info) {
foreach ((array)$plugins as $plugin_name => $plugin_info) {
$_plugins_params .= "array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\")) . "', $plugin_info[1], ";
$_plugins_params .= $plugin_info[2] ? 'true),' : 'false),';
}
@ -560,7 +560,7 @@ class Smarty_Compiler extends Smarty {
$this->_current_line_no += substr_count($block[0], "\n");
/* the number of matched elements in the regexp in _compile_file()
determins the type of folded tag that was found */
switch (count($block)) {
switch (count((array)$block)) {
case 2: /* comment */
return '';
@ -848,9 +848,9 @@ class Smarty_Compiler extends Smarty {
list($object, $obj_comp) = explode('->', $tag_command);
$arg_list = array();
if(count($attrs)) {
if(count((array)$attrs)) {
$_assign_var = false;
foreach ($attrs as $arg_name => $arg_value) {
foreach ((array)$attrs as $arg_name => $arg_value) {
if($arg_name == 'assign') {
$_assign_var = $arg_value;
unset($attrs['assign']);
@ -947,7 +947,7 @@ class Smarty_Compiler extends Smarty {
$delayed_loading = false;
}
foreach ($attrs as $arg_name => $arg_value) {
foreach ((array)$attrs as $arg_name => $arg_value) {
if (is_bool($arg_value))
$arg_value = $arg_value ? 'true' : 'false';
$arg_list[] = "'$arg_name' => $arg_value";
@ -975,7 +975,7 @@ class Smarty_Compiler extends Smarty {
$this->_syntax_error("missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__);
}
foreach ($attrs as $arg_name => $arg_value) {
foreach ((array)$attrs as $arg_name => $arg_value) {
if ($arg_name == 'file') {
$include_file = $arg_value;
continue;
@ -1031,7 +1031,7 @@ class Smarty_Compiler extends Smarty {
$once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true';
$arg_list = array();
foreach($attrs as $arg_name => $arg_value) {
foreach ((array)$attrs as $arg_name => $arg_value) {
if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
if(is_bool($arg_value))
$arg_value = $arg_value ? 'true' : 'false';
@ -1065,7 +1065,7 @@ class Smarty_Compiler extends Smarty {
$output .= "unset(\$this->_sections[$section_name]);\n";
$section_props = "\$this->_sections[$section_name]";
foreach ($attrs as $attr_name => $attr_value) {
foreach ((array)$attrs as $attr_name => $attr_value) {
switch ($attr_name) {
case 'loop':
$output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
@ -1279,7 +1279,7 @@ class Smarty_Compiler extends Smarty {
$is_arg_stack = array();
for ($i = 0; $i < count($tokens); $i++) {
for ($i = 0; $i < count((array)$tokens); $i++) {
$token = &$tokens[$i];
@ -1384,7 +1384,7 @@ class Smarty_Compiler extends Smarty {
$new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
/* Replace the old tokens with the new ones. */
array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);
array_splice($tokens, $is_arg_start, count((array)$tokens), $new_tokens);
/* Adjust argument start so that it won't change from the
current position for the next iteration. */
@ -1439,7 +1439,7 @@ class Smarty_Compiler extends Smarty {
$_cache_attrs = null;
}
foreach ($attrs as $arg_name => $arg_value) {
foreach ((array)$attrs as $arg_name => $arg_value) {
if (is_bool($arg_value))
$arg_value = $arg_value ? 'true' : 'false';
if (is_null($arg_value))
@ -1538,7 +1538,7 @@ class Smarty_Compiler extends Smarty {
2 - expecting attribute value (not '=') */
$state = 0;
foreach ($tokens as $token) {
foreach ((array)$tokens as $token) {
switch ($state) {
case 0:
/* If the token is a valid identifier, we set attribute name
@ -1607,7 +1607,7 @@ class Smarty_Compiler extends Smarty {
*/
function _parse_vars_props(&$tokens)
{
foreach($tokens as $key => $val) {
foreach ((array)$tokens as $key => $val) {
$tokens[$key] = $this->_parse_var_props($val);
}
}
@ -1686,7 +1686,7 @@ class Smarty_Compiler extends Smarty {
if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) {
$_match = $_match[0];
$_replace = array();
foreach($_match as $_var) {
foreach ((array)$_match as $_var) {
$_replace[$_var] = '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."';
}
$var_expr = strtr($var_expr, $_replace);
@ -1711,12 +1711,12 @@ class Smarty_Compiler extends Smarty {
$_has_math = false;
$_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
if(count($_math_vars) > 1) {
if(count((array)$_math_vars) > 1) {
$_first_var = "";
$_complete_var = "";
$_output = "";
// simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
foreach($_math_vars as $_k => $_math_var) {
foreach ((array)$_math_vars as $_k => $_math_var) {
$_math_var = $_math_vars[$_k];
if(!empty($_math_var) || is_numeric($_math_var)) {
@ -1777,7 +1777,7 @@ class Smarty_Compiler extends Smarty {
}
} elseif(is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) {
// because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers
if(count($_indexes) > 0)
if(count((array)$_indexes) > 0)
{
$_var_name .= implode("", $_indexes);
$_indexes = array();
@ -1787,7 +1787,7 @@ class Smarty_Compiler extends Smarty {
$_output = "\$this->_tpl_vars['$_var_name']";
}
foreach ($_indexes as $_index) {
foreach ((array)$_indexes as $_index) {
if (substr($_index, 0, 1) == '[') {
$_index = substr($_index, 1, -1);
if (is_numeric($_index)) {
@ -1847,7 +1847,7 @@ class Smarty_Compiler extends Smarty {
$orig_vals = $match = $match[0];
$this->_parse_vars_props($match);
$replace = array();
for ($i = 0, $count = count($match); $i < $count; $i++) {
for ($i = 0, $count = count((array)$match); $i < $count; $i++) {
$replace[$orig_vals[$i]] = $match[$i];
}
return strtr($parenth_args, $replace);
@ -1909,7 +1909,7 @@ class Smarty_Compiler extends Smarty {
preg_match_all('~\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)~', '|' . $modifier_string, $_match);
list(, $_modifiers, $modifier_arg_strings) = $_match;
for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) {
for ($_i = 0, $_for_max = count((array)$_modifiers); $_i < $_for_max; $_i++) {
$_modifier_name = $_modifiers[$_i];
if($_modifier_name == 'smarty') {
@ -1949,7 +1949,7 @@ class Smarty_Compiler extends Smarty {
$_modifier_args[0] = '@' . $_modifier_args[0];
}
}
if (count($_modifier_args) > 0)
if (count((array)$_modifier_args) > 0)
$_modifier_args = ', '.implode(', ', $_modifier_args);
else
$_modifier_args = '';
@ -1996,7 +1996,7 @@ class Smarty_Compiler extends Smarty {
{
/* Extract the reference name. */
$_ref = substr($indexes[0], 1);
foreach($indexes as $_index_no=>$_index) {
foreach ((array)$indexes as $_index_no=>$_index) {
if (substr($_index, 0, 1) != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) {
$this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
}
@ -2165,7 +2165,7 @@ class Smarty_Compiler extends Smarty {
break;
}
if (isset($_max_index) && count($indexes) > $_max_index) {
if (isset($_max_index) && count((array)$indexes) > $_max_index) {
$this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
}

View file

@ -49,13 +49,13 @@ function smarty_core_create_dir_structure($params, &$smarty)
}
/* all paths use "/" only from here */
foreach ($_dir_parts as $_dir_part) {
foreach ((array)$_dir_parts as $_dir_part) {
$_new_dir .= $_dir_part;
if ($_use_open_basedir) {
// do not attempt to test or make directories outside of open_basedir
$_make_new_dir = false;
foreach ($_open_basedirs as $_open_basedir) {
foreach ((array)$_open_basedirs as $_open_basedir) {
if (substr($_new_dir, 0, strlen($_open_basedir)) == $_open_basedir) {
$_make_new_dir = true;
break;

View file

@ -30,7 +30,7 @@ function smarty_core_get_include_path(&$params, &$smarty)
$_path_array = explode(':',$_ini_include_path);
}
}
foreach ($_path_array as $_include_path) {
foreach ((array)$_path_array as $_include_path) {
if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
$params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
return true;

View file

@ -16,7 +16,7 @@
function smarty_core_load_plugins($params, &$smarty)
{
foreach ($params['plugins'] as $_plugin_info) {
foreach ((array)$params['plugins'] as $_plugin_info) {
list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
$_plugin = &$smarty->_plugins[$_type][$_name];

View file

@ -24,9 +24,9 @@ function smarty_core_load_resource_plugin($params, &$smarty)
$_plugin = &$smarty->_plugins['resource'][$params['type']];
if (isset($_plugin)) {
if (!$_plugin[1] && count($_plugin[0])) {
if (!$_plugin[1] && count((array)$_plugin[0])) {
$_plugin[1] = true;
foreach ($_plugin[0] as $_plugin_func) {
foreach ((array)$_plugin[0] as $_plugin_func) {
if (!is_callable($_plugin_func)) {
$_plugin[1] = false;
break;
@ -55,7 +55,7 @@ function smarty_core_load_resource_plugin($params, &$smarty)
*/
$_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
$_resource_funcs = array();
foreach ($_resource_ops as $_op) {
foreach ((array)$_resource_ops as $_op) {
$_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
if (!function_exists($_plugin_func)) {
$smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);

View file

@ -17,7 +17,7 @@ function smarty_core_process_cached_inserts($params, &$smarty)
$params['results'], $match);
list($cached_inserts, $insert_args) = $match;
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
for ($i = 0, $for_max = count((array)$cached_inserts); $i < $for_max; $i++) {
if ($smarty->debugging) {
$_params = array();
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');

View file

@ -38,12 +38,12 @@ function smarty_core_write_cache_file($params, &$smarty)
// this new nocache-tag will be replaced by dynamic contents in
// smarty_core_process_compiled_includes() on a cache-read
$match_count = count($match[0]);
$match_count = count((array)$match[0]);
$results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE);
$level = 0;
$j = 0;
for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) {
for ($i=0, $results_count = count((array)$results); $i < $results_count && $j < $match_count; $i++) {
if ($results[$i] == $match[0][$j]) {
// nocache tag
if ($match[1][$j]) { // closing tag

View file

@ -22,7 +22,7 @@ function smarty_core_write_compiled_include($params, &$smarty)
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
// no nocache-parts found: done
if (count($_match_source)==0) return;
if (count((array)$_match_source)==0) return;
// convert the matched php-code to functions
$_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
@ -37,7 +37,7 @@ function smarty_core_write_compiled_include($params, &$smarty)
$_include_compiled .= "<?php";
$this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
for ($_i = 0, $_for_max = count((array)$_match_source); $_i < $_for_max; $_i++) {
$_match =& $_match_source[$_i];
$source = $_match[4];
if ($this_varname == '_smarty') {
@ -56,7 +56,7 @@ function smarty_core_write_compiled_include($params, &$smarty)
if ($open_tag == '<?php ') break;
}
for ($i=0, $count = count($tokens); $i < $count; $i++) {
for ($i=0, $count = count((array)$tokens); $i < $count; $i++) {
if (is_array($tokens[$i])) {
if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
$tokens[$i] = '$' . $this_varname;

View file

@ -43,7 +43,7 @@ function smarty_block_textformat($params, $content, &$smarty)
$wrap_cut = false;
$assign = null;
foreach ($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch ($_key) {
case 'style':
case 'indent_char':
@ -75,7 +75,7 @@ function smarty_block_textformat($params, $content, &$smarty)
$_paragraphs = preg_split('![\r\n][\r\n]!',$content);
$_output = '';
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
for($_x = 0, $_y = count((array)$_paragraphs); $_x < $_y; $_x++) {
if ($_paragraphs[$_x] == '') {
continue;
}

View file

@ -91,7 +91,7 @@ function smarty_function_cycle($params, &$smarty)
}
if($advance) {
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
if ( $cycle_vars[$name]['index'] >= count((array)$cycle_array) -1 ) {
$cycle_vars[$name]['index'] = 0;
} else {
$cycle_vars[$name]['index']++;

View file

@ -72,7 +72,7 @@ function smarty_function_fetch($params, &$smarty)
$pass = $uri_parts['pass'];
}
// loop through parameters, setup headers
foreach($params as $param_key => $param_value) {
foreach ((array)$params as $param_key => $param_value) {
switch($param_key) {
case "file":
case "assign":
@ -168,7 +168,7 @@ function smarty_function_fetch($params, &$smarty)
fputs($fp, "Referer: $referer\r\n");
}
if(isset($extra_headers) && is_array($extra_headers)) {
foreach($extra_headers as $curr_header) {
foreach ((array)$extra_headers as $curr_header) {
fputs($fp, $curr_header."\r\n");
}
}

View file

@ -52,7 +52,7 @@ function smarty_function_html_checkboxes($params, &$smarty)
$extra = '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch($_key) {
case 'name':
case 'separator':
@ -103,12 +103,12 @@ function smarty_function_html_checkboxes($params, &$smarty)
if (isset($options)) {
foreach ($options as $_key=>$_val)
foreach ((array)$options as $_key=>$_val)
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} else {
foreach ($values as $_i=>$_key) {
foreach ((array)$values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
}

View file

@ -48,7 +48,7 @@ function smarty_function_html_image($params, &$smarty)
$path_prefix = '';
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch($_key) {
case 'file':
case 'height':

View file

@ -39,7 +39,7 @@ function smarty_function_html_options($params, &$smarty)
$extra = '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch($_key) {
case 'name':
$$_key = (string)$_val;
@ -75,12 +75,12 @@ function smarty_function_html_options($params, &$smarty)
if (isset($options)) {
foreach ($options as $_key=>$_val)
foreach ((array)$options as $_key=>$_val)
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
} else {
foreach ($values as $_i=>$_key) {
foreach ((array)$values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
}
@ -110,7 +110,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
function smarty_function_html_options_optgroup($key, $values, $selected) {
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
foreach ($values as $key => $value) {
foreach ((array)$values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
}
$optgroup_html .= "</optgroup>\n";

View file

@ -52,7 +52,7 @@ function smarty_function_html_radios($params, &$smarty)
$output = null;
$extra = '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch($_key) {
case 'name':
case 'separator':
@ -107,12 +107,12 @@ function smarty_function_html_radios($params, &$smarty)
if (isset($options)) {
foreach ($options as $_key=>$_val)
foreach ((array)$options as $_key=>$_val)
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
} else {
foreach ($values as $_i=>$_key) {
foreach ((array)$values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
}

View file

@ -84,7 +84,7 @@ function smarty_function_html_select_date($params, &$smarty)
$year_empty = null;
$extra_attrs = '';
foreach ($params as $_key=>$_value) {
foreach ((array)$params as $_key=>$_value) {
switch ($_key) {
case 'prefix':
case 'time':
@ -135,7 +135,7 @@ function smarty_function_html_select_date($params, &$smarty)
if (preg_match('!^-\d+$!', $time)) {
// negative timestamp, use date()
$time = date('Y-m-d', $time);
$time = date('Y-m-d', is_numeric($time) ? (int)$time : strtotime($time));
}
// If $time is not in format yyyy-mm-dd
if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {

View file

@ -46,7 +46,7 @@ function smarty_function_html_select_time($params, &$smarty)
$second_extra = null;
$meridian_extra = null;
foreach ($params as $_key=>$_value) {
foreach ((array)$params as $_key=>$_value) {
switch ($_key) {
case 'prefix':
case 'time':
@ -84,7 +84,7 @@ function smarty_function_html_select_time($params, &$smarty)
if ($display_hours) {
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
$hour_fmt = $use_24_hours ? '%H' : '%I';
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
for ($i = 0, $for_max = count((array)$hours); $i < $for_max; $i++)
$hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
@ -109,7 +109,7 @@ function smarty_function_html_select_time($params, &$smarty)
if ($display_minutes) {
$all_minutes = range(0, 59);
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
for ($i = 0, $for_max = count((array)$all_minutes); $i < $for_max; $i+= $minute_interval)
$minutes[] = sprintf('%02d', $all_minutes[$i]);
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
$html_result .= '<select name=';
@ -136,7 +136,7 @@ function smarty_function_html_select_time($params, &$smarty)
if ($display_seconds) {
$all_seconds = range(0, 59);
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
for ($i = 0, $for_max = count((array)$all_seconds); $i < $for_max; $i+= $second_interval)
$seconds[] = sprintf('%02d', $all_seconds[$i]);
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
$html_result .= '<select name=';

View file

@ -65,7 +65,7 @@ function smarty_function_html_table($params, &$smarty)
return;
}
foreach ($params as $_key=>$_value) {
foreach ((array)$params as $_key=>$_value) {
switch ($_key) {
case 'loop':
$$_key = (array)$_value;
@ -74,10 +74,10 @@ function smarty_function_html_table($params, &$smarty)
case 'cols':
if (is_array($_value) && !empty($_value)) {
$cols = $_value;
$cols_count = count($_value);
$cols_count = count((array)$_value);
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
$cols = explode(',', $_value);
$cols_count = count($cols);
$cols_count = count((array)$cols);
} elseif (!empty($_value)) {
$cols_count = (int)$_value;
} else {
@ -106,7 +106,7 @@ function smarty_function_html_table($params, &$smarty)
}
}
$loop_count = count($loop);
$loop_count = count((array)$loop);
if (empty($params['rows'])) {
/* no rows specified */
$rows = ceil($loop_count/$cols_count);
@ -165,7 +165,7 @@ function smarty_function_html_table_cycle($name, $var, $no) {
if(!is_array($var)) {
$ret = $var;
} else {
$ret = $var[$no % count($var)];
$ret = $var[$no % count((array)$var)];
}
return ($ret) ? ' '.$ret : '';

View file

@ -65,7 +65,7 @@ function smarty_function_mailto($params, &$smarty)
$search = array('%40', '%2C');
$replace = array('@', ',');
$mail_parms = array();
foreach ($params as $var=>$value) {
foreach ((array)$params as $var=>$value) {
switch ($var) {
case 'cc':
case 'bcc':
@ -88,7 +88,7 @@ function smarty_function_mailto($params, &$smarty)
}
$mail_parm_vals = '';
for ($i=0; $i<count($mail_parms); $i++) {
for ($i=0; $i<count((array)$mail_parms); $i++) {
$mail_parm_vals .= (0==$i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
}

View file

@ -61,7 +61,7 @@ function smarty_function_math($params, $template)
// match all vars in equation, make sure all are passed
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
foreach ($match[ 1 ] as $curr_var) {
foreach ((array)$match[ 1 ] as $curr_var) {
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
@ -69,7 +69,7 @@ function smarty_function_math($params, $template)
}
}
foreach ($params as $key => $val) {
foreach ((array)$params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val) == 0) {

View file

@ -22,7 +22,7 @@
function smarty_function_popup($params, &$smarty)
{
$append = '';
foreach ($params as $_key=>$_value) {
foreach ((array)$params as $_key=>$_value) {
switch ($_key) {
case 'text':
case 'trigger':

View file

@ -25,7 +25,7 @@ function smarty_modifier_count_words($string)
// count matches that contain alphanumerics
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
return count($word_count);
return count((array)$word_count);
}
/* vim: set expandtab: */

View file

@ -42,11 +42,11 @@ function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_da
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
$_win_to[] = sprintf('%\' 2d', date('j', is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp)));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
$_win_to[] = sprintf('%\' 2d', date('h', is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp)));
}
$format = str_replace($_win_from, $_win_to, $format);
}

View file

@ -30,8 +30,8 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
switch (gettype($var)) {
case 'array' :
$results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) {
$results = '<b>Array (' . count((array)$var) . ')</b>';
foreach ((array)$var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
@ -40,8 +40,8 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
break;
case 'object' :
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
foreach ($object_vars as $curr_key => $curr_val) {
$results = '<b>' . get_class($var) . ' Object (' . count((array)$object_vars) . ')</b>';
foreach ((array)$object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);

View file

@ -23,7 +23,7 @@
function smarty_modifier_regex_replace($string, $search, $replace)
{
if(is_array($search)) {
foreach($search as $idx => $s)
foreach ((array)$search as $idx => $s)
$search[$idx] = _smarty_regex_replace_check($s);
} else {
$search = _smarty_regex_replace_check($search);

View file

@ -64,7 +64,7 @@ function smarty_outputfilter_trimwhitespace($source, &$smarty)
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
$_len = strlen($search_str);
$_pos = 0;
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
for ($_i=0, $_count=count((array)$replace); $_i<$_count; $_i++)
if (($_pos=strpos($subject, $search_str, $_pos))!==false)
$subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
else

View file

@ -203,12 +203,12 @@ class TS3lib
$resultVarsSplitted = explode('|', trim($resultVars[0]));
$count = count($resultVarsSplitted);
$count = count((array)$resultVarsSplitted);
for($i=0; $i<$count; $i++)
{
$resultVarsSplitted[$i] = explode(' ', $resultVarsSplitted[$i]);
$countSub = count($resultVarsSplitted[$i]);
$countSub = count((array)$resultVarsSplitted[$i]);
for($t=0; $t<$countSub; $t++)
{
if( strpos($resultVarsSplitted[$i][$t], '=') === false )
@ -220,7 +220,7 @@ class TS3lib
}
}
//if( count($result) == 1 ) $result = $result[0];
//if( count((array)$result) == 1 ) $result = $result[0];
return $result;
}
@ -239,7 +239,7 @@ class TS3lib
if( is_array($string) )
{
foreach($string as $key => $value )
foreach ((array)$string as $key => $value )
{
if( is_array($string[$key]) )
{
@ -266,7 +266,7 @@ class TS3lib
if( is_array($string) )
{
foreach($string as $key => $value )
foreach ((array)$string as $key => $value )
{
if( is_array($string[$key]) )
{
@ -322,7 +322,7 @@ var_dump($result = $ts3->performResultless('clientmove clid=3 cid=56'));*/
/*$param = "Test String fürs escapen|ziemlich X\\X normal/anders
/*$param = "Test String frs escapen|ziemlich X\\X normal/anders
oder nicht?\nder autor denkt nichts\nziemlich sinnlos ;)";
echo $param.'

View file

@ -134,7 +134,7 @@ class TS3remote extends TS3lib
{
$vServerName = $this->escape($vServerName);
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $this->escape($props[$i][0]).'='.$this->escape($props[$i][1]);
@ -178,7 +178,7 @@ class TS3remote extends TS3lib
//$props = $this->escape($props);
//print_r($props);
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $this->escape($props[$i][0]).'='.$this->escape($props[$i][1]);
@ -370,7 +370,7 @@ class TS3remote extends TS3lib
$props = $this->escape($props);
}
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $props[$i][0].'='.$props[$i][1];
@ -387,7 +387,7 @@ class TS3remote extends TS3lib
$cid = $this->escape($cid);
$props = $this->escape($props);
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $props[$i][0].'='.$props[$i][1];
@ -417,7 +417,7 @@ class TS3remote extends TS3lib
$cid = $this->escape($cid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3];
@ -432,7 +432,7 @@ class TS3remote extends TS3lib
$cid = $this->escape($cid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1];
@ -475,7 +475,7 @@ class TS3remote extends TS3lib
$cgid = $this->escape($cgid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3];
@ -490,7 +490,7 @@ class TS3remote extends TS3lib
$cgid = $this->escape($cgid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1];
@ -555,7 +555,7 @@ class TS3remote extends TS3lib
$clid = $this->escape($clid);
$props = $this->escape($props);
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $props[$i][0].'='.$props[$i][1];
@ -582,7 +582,7 @@ class TS3remote extends TS3lib
{
$cldbid = $this->escape($cldbid);
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $props[$i][0].'='.$props[$i][1];
@ -636,7 +636,7 @@ class TS3remote extends TS3lib
public function r_clientupdate($props)
{
$countProps = count($props);
$countProps = count((array)$props);
for($i=0; $i<$countProps; $i++)
{
$props[$i] = $this->escape($props[$i][0]).'='.$this->escape($props[$i][1]);
@ -654,7 +654,7 @@ class TS3remote extends TS3lib
if( is_array($clid) )
{
$countClid = count($clid);
$countClid = count((array)$clid);
for($i=0; $i<$countClid; $i++)
{
$clid[$i] = $clid[$i][0].'='.$clid[$i][1];
@ -677,7 +677,7 @@ class TS3remote extends TS3lib
if( is_array($clid) )
{
$countClid = count($clid);
$countClid = count((array)$clid);
for($i=0; $i<$countClid; $i++)
{
$clid[$i] = $clid[$i][0].'='.$clid[$i][1];
@ -699,7 +699,7 @@ class TS3remote extends TS3lib
if( is_array($clid) )
{
$countClid = count($clid);
$countClid = count((array)$clid);
for($i=0; $i<$countClid; $i++)
{
$clid[$i] = $clid[$i][0].'='.$clid[$i][1];
@ -726,7 +726,7 @@ class TS3remote extends TS3lib
$cldbid = $this->escape($cldbid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3].' '.$perms[$i][4].'='.$perms[$i][5];
@ -741,7 +741,7 @@ class TS3remote extends TS3lib
$cldbid = $this->escape($cldbid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1];
@ -765,7 +765,7 @@ class TS3remote extends TS3lib
$cldbid = $this->escape($cldbid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3];
@ -781,7 +781,7 @@ class TS3remote extends TS3lib
$cldbid = $this->escape($cldbid);
$perms = $this->escape($perms);
$countPerms = count($perms);
$countPerms = count((array)$perms);
for($i=0; $i<$countPerms; $i++)
{
$perms[$i] = $perms[$i][0].'='.$perms[$i][1];

View file

@ -33,7 +33,7 @@ function getAssignedServerUsers()
if($ts3vservers != FALSE)
{
$users_assigned = array();
foreach($ts3vservers as $ts3vserver)
foreach ((array)$ts3vservers as $ts3vserver)
{
if($ts3vserver['user_id'] != $_SESSION['user_id'])
$users_assigned[] = $ts3vserver['user_id'];
@ -44,7 +44,7 @@ function getAssignedServerUsers()
$subusers_list = array();
if(is_array($subusers))
{
foreach($subusers as $subuser)
foreach ((array)$subusers as $subuser)
{
if(!in_array($subuser,$users_assigned))
$subusers_list[] = $db->getUserById($subuser);
@ -56,7 +56,7 @@ function getAssignedServerUsers()
if(is_array($users_assigned))
{
$subusers_assigned_list = array();
foreach($users_assigned as $user_assigned)
foreach ((array)$users_assigned as $user_assigned)
{
if(in_array($user_assigned,$subusersb))
$subusers_assigned_list[] = $db->getUserById($user_assigned);
@ -340,7 +340,7 @@ class TS3webinterface
$response = array('OK');
if( !is_array($_POST['serverprop']) ) $_POST['serverprop'] = array($_POST['serverprop']);
for($i=0; $i<count($_POST['serverprop']); $i++)
for($i=0; $i<count((array)$_POST['serverprop']); $i++)
{
if( $_POST['serverprop'][$i] == 'virtualserver_uptime' )
{
@ -730,7 +730,7 @@ class TS3webinterface
$serverGroupList = $this->server->r_servergrouplist();
$serverGroupListNames = array();
for($i=0; $i<count($serverGroupList); $i++)
for($i=0; $i<count((array)$serverGroupList); $i++)
{
$serverGroupListNames[$serverGroupList[$i]['sgid']] = $serverGroupList[$i];
}
@ -739,7 +739,7 @@ class TS3webinterface
$channelGroupList = $this->server->r_channelgrouplist();
$channelGroupListNames = array();
for($i=0; $i<count($channelGroupList); $i++)
for($i=0; $i<count((array)$channelGroupList); $i++)
{
$channelGroupListNames[$channelGroupList[$i]['cgid']] = $channelGroupList[$i];
}
@ -748,7 +748,7 @@ class TS3webinterface
$channelList = $this->server->r_channellist();
$channelListNames = array();
for($i=0; $i<count($channelList); $i++)
for($i=0; $i<count((array)$channelList); $i++)
{
$channelListNames[$channelList[$i]['cid']] = $channelList[$i];
}
@ -914,21 +914,21 @@ class TS3webinterface
$lastLevel = array();
$cidConnection = array();
$channelNum = count($channels);
$channelNum = count((array)$channels);
for($i=0; $i<$channelNum; $i++)
{
$cidConnection[$channels[$i]['cid']] = $i;
$channels[$i]['is_last_channel'] = false;
/*if( $channels[$i]['pid'] != $pidStack[count($pidStack)-1] )
/*if( $channels[$i]['pid'] != $pidStack[count((array)$pidStack)-1] )
{
if( in_array($channels[$i]['pid'], $pidStack) )
{
do
{
array_pop($pidStack);
} while( in_array($channels[$i]['pid'], $pidStack) && count($pidStack) > 1 );
} while( in_array($channels[$i]['pid'], $pidStack) && count((array)$pidStack) > 1 );
//$pidStack[] = $channels[$i]['pid'];
$channels[$i]['is_last_channel'] = true;
}
@ -937,7 +937,7 @@ class TS3webinterface
$pidStack[] = $channels[$i]['pid'];
}
}*/
//$channels[$i]['level'] = count($pidStack)-1;
//$channels[$i]['level'] = count((array)$pidStack)-1;
if( $channels[$i]['pid'] == 0 ) $channels[$i]['level'] = 0;
else $channels[$i]['level'] = $channels[$cidConnection[$channels[$i]['pid']]]['level'] + 1;
@ -949,7 +949,7 @@ class TS3webinterface
$lastLevel[$channels[$i]['level']] = $i;
}
/*$reversedCounter = count($channels)-1;
/*$reversedCounter = count((array)$channels)-1;
do
{
@ -1051,7 +1051,7 @@ class TS3webinterface
}
}
$clientNum = count($clients);
$clientNum = count((array)$clients);
for($i=0; $i<$clientNum; $i++)
{
if( $clients[$i]['client_input_hardware'] == '0' ) $clients[$i]['status_img'] = '16x16_hardware_input_muted';
@ -1090,7 +1090,7 @@ class TS3webinterface
$channels = array();
$cidConnection = array();
$channelNum = count($result);
$channelNum = count((array)$result);
for($i=0; $i<$channelNum; $i++ )
{
$cidConnection[$result[$i]['cid']] = $i;
@ -1135,14 +1135,14 @@ class TS3webinterface
$cidConnection = array();
$backupNum = count($backup);
$backupNum = count((array)$backup);
for($i=0; $i<$backupNum; $i++)
{
$tmpCreate = array();
$channelPropNum = count($backup[$i]);
foreach($backup[$i] as $key => $value)
$channelPropNum = count((array)$backup[$i]);
foreach ((array)$backup[$i] as $key => $value)
{
if( $key == 'pid' || $key == 'channel_order' || $key == 'channel_name' ) continue;
@ -1210,7 +1210,7 @@ class TS3webinterface
{
if( $add != 0 ) $timeSeconds += $add;
return date($format, $timeSeconds);
return date($format, is_numeric($timeSeconds) ? (int)$timeSeconds : strtotime($timeSeconds));
}
public function convertByteToMB($num, $prec=2)

View file

@ -63,7 +63,7 @@ function exec_ogp_module() {
$groups = [];
}
$query_groups .= " AND (";
foreach($groups as $group)
foreach ((array)$groups as $group)
$query_groups .= "group_id=".$group['group_id']." OR ";
$query_groups .= "group_id=0 OR group_id IS NULL)";
}
@ -114,7 +114,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);
{
$address_owned = $ip_port['ip'].":".$ip_port['port'];
if($address_owned == $address_at_post)
@ -273,7 +273,7 @@ function exec_ogp_module() {
if (!is_array($addons)) {
$addons = [];
}
foreach($addons as $addon)
foreach ((array)$addons as $addon)
{
?>
<option value="<?php echo $addon['addon_id']; ?>"><?php echo $addon['name']; ?></option>

View file

@ -143,7 +143,7 @@ function exec_ogp_module() {
}
echo "<option style='background:black;color:white;' value=''>".get_lang('linux_games')."</option>\n";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if ( preg_match("/linux/", $row['game_key']) )
{
@ -154,7 +154,7 @@ function exec_ogp_module() {
}
}
echo "<option style='background:black;color:white;' value=''>".get_lang('windows_games')."</option>\n";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if ( preg_match("/win/", $row['game_key']) )
{
@ -175,7 +175,7 @@ function exec_ogp_module() {
<td align="left">
<?php
$types = array( 'plugin', 'mappack', 'config' );
foreach($types as $type)
foreach ((array)$types as $type)
{
$checked = ( isset($addon_type) AND $type == $addon_type) ? 'checked' : '';
echo '<input type="radio" name="addon_type" value="'.$type.'" '.$checked.'>'.get_lang($type);
@ -195,7 +195,7 @@ function exec_ogp_module() {
if (!is_array($groups)) {
$groups = [];
}
foreach($groups as $group)
foreach ((array)$groups as $group)
{
$selected = (isset($group_id) AND $group['group_id'] == $group_id) ? 'selected=selected' : '';
echo "<option value='".$group['group_id']."' $selected>".$group['group_name']."</option>\n";
@ -241,7 +241,7 @@ function exec_ogp_module() {
<b><?php print_lang('game'); ?></b> <select name='home_cfg_id'>
<?php
echo "<option style='background:black;color:white;' value=''>".get_lang('linux_games')."</option>\n";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if ( preg_match("/linux/", $row['game_key']) )
{
@ -255,7 +255,7 @@ function exec_ogp_module() {
}
}
echo "<option style='background:black;color:white;' value=''>".get_lang('windows_games')."</option>\n";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if(isset($_GET['home_cfg_id']) AND $row['home_cfg_id'] == $_GET['home_cfg_id'])
$selected = "selected='selected'";
@ -276,7 +276,7 @@ function exec_ogp_module() {
<?php
$option = '';
foreach ($addon_types as $k) {
foreach ((array)$addon_types as $k) {
$option .= '<option';
if (isset($_GET['addon_type']) && $_GET['addon_type'] == $k) {
@ -294,7 +294,7 @@ function exec_ogp_module() {
<select name='group_id'>
<option value="0"><?php print_lang('all_groups'); ?></option>
<?php
foreach($groups as $group)
foreach ((array)$groups as $group)
{
$selected = (isset($_GET['group_id']) AND $group['group_id'] == $_GET['group_id']) ? 'selected=selected' : '';
echo "<option value='".$group['group_id']."' $selected>".$group['group_name']."</option>\n";
@ -355,12 +355,12 @@ function exec_ogp_module() {
<table class="center">
<?php
$group_names = array();
foreach($groups as $group)
foreach ((array)$groups as $group)
$group_names[$group['group_id']] = $group['group_name'];
if (isset($result) and is_array($result) and (is_array($result) ? count($result) : 0) > 0)
if (isset($result) and is_array($result) and (is_array($result) ? count((array)$result) : 0) > 0)
{
foreach($result as $row)
foreach ((array)$result as $row)
{
?>
<tr>

View file

@ -30,12 +30,12 @@ if($_SESSION['users_role'] != "admin")
$groups = [];
}
$query_groups .= " AND (";
foreach($groups as $group)
foreach ((array)$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 = is_array($addons) ? count($addons) : 0;
$addons_qty = is_array($addons) ? count((array)$addons) : 0;
if($addons and $addons_qty >= 1){
$module_buttons = array(
"<a class='monitorbutton' href='?m=addonsmanager&amp;p=user_addons&amp;home_id=".

View file

@ -42,7 +42,7 @@ function exec_ogp_module() {
$groups = [];
}
$query_groups .= " AND (";
foreach($groups as $group)
foreach ((array)$groups as $group)
$query_groups .= "group_id=".$group['group_id']." OR ";
$query_groups .= "group_id=0 OR group_id IS NULL)";
}
@ -57,7 +57,7 @@ function exec_ogp_module() {
"NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
"WHERE addon_type='plugin' ".
"AND home_cfg_id=".$home_cfg_id.$query_groups);
$plugins_qty = is_array($plugins) ? count($plugins) : 0;
$plugins_qty = is_array($plugins) ? count((array)$plugins) : 0;
if($plugins and $plugins_qty >= 1)
echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
"&amp;mod_id=".$mod_id."&amp;addon_type=plugin&amp;ip=".$ip.
@ -68,7 +68,7 @@ function exec_ogp_module() {
"NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
"WHERE addon_type='mappack' ".
"AND home_cfg_id=".$home_cfg_id.$query_groups);
$mappacks_qty = is_array($mappacks) ? count($mappacks) : 0;
$mappacks_qty = is_array($mappacks) ? count((array)$mappacks) : 0;
if($mappacks and $mappacks_qty >= 1){
echo "</td><td>";
echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
@ -80,7 +80,7 @@ function exec_ogp_module() {
"NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
"WHERE addon_type='config' ".
"AND home_cfg_id=".$home_cfg_id.$query_groups);
$configs_qty = is_array($configs) ? count($configs) : 0;
$configs_qty = is_array($configs) ? count((array)$configs) : 0;
if($configs and $configs_qty >= 1){
echo "</td><td>";
echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.

View file

@ -32,7 +32,7 @@ function exec_ogp_module()
echo "<tr>\n";
$menus = $db->getMenusForGroup('admin');
foreach ($menus as $key => $row) {
foreach ((array)$menus as $key => $row) {
if ( !empty( $row['subpage'] ) )
$name[$key] = $row['subpage'];
else
@ -44,7 +44,7 @@ function exec_ogp_module()
array_multisort($translation, $name, SORT_DESC, $menus);
$td = 0;
foreach ( $menus as $menu )
foreach ((array)$menus as $menu)
{
$module = $menu['module'];
if ( !empty( $menu['subpage'] ) )
@ -159,7 +159,7 @@ function exec_ogp_module()
$td2 = 0;
if($external_links != 0)
{
foreach ( $external_links as $external_link )
foreach ((array)$external_links as $external_link)
{
$url = $external_link['url'];
@ -185,7 +185,7 @@ function exec_ogp_module()
if ( isset( $_POST['changeOrder'] ) )
{
foreach($_POST as $key => $value)
foreach ((array)$_POST as $key => $value)
{
if( preg_match( "/^change_button/", $key ) )
{
@ -205,7 +205,7 @@ function exec_ogp_module()
$menus = $db->getMenusForGroup('user');
$pos = 0;
foreach ( $menus as $menu )
foreach ((array)$menus as $menu)
{
$module = $menu['module'];
if ( !empty( $menu['subpage'] ) )

View file

@ -31,7 +31,7 @@ function exec_ogp_module()
if(isset($_POST['unban']))
{
unset($_POST['unban']);
foreach($_POST as $name => $ip)
foreach ((array)$_POST as $name => $ip)
{
$ip = $db->real_escape_string($ip);
$db->query("DELETE FROM `OGP_DB_PREFIXban_list` WHERE client_ip = '$ip';");
@ -42,11 +42,11 @@ function exec_ogp_module()
$ban_table = '';
if($ban_list)
{
foreach($ban_list as $ban)
foreach ((array)$ban_list as $ban)
{
if($ban['logging_attempts'] >= $settings["login_attempts_before_banned"])
{
$ban_table .= "<tr><td><input type=checkbox name='".$ban_qty."' value='".$ban['client_ip']."' /></td><td>".$ban['client_ip']."</td><td>".date("r",$ban['banned_until'])."</td></tr>\n";
$ban_table .= "<tr><td><input type=checkbox name='".$ban_qty."' value='".$ban['client_ip']."' /></td><td>".$ban['client_ip']."</td><td>".date("r", is_numeric($ban['banned_until']) ? (int)$ban['banned_until'] : strtotime($ban['banned_until']))."</td></tr>\n";
$ban_qty++;
}
else

View file

@ -82,7 +82,7 @@ function exec_ogp_module() {
if( isset( $_POST['log_id'] ) ){
$db->del_logger_log($_POST['log_id']);
$newLogs = array();
foreach($logs as $log){
foreach ((array)$logs as $log){
if($log['log_id'] != $_POST['log_id']){
$newLogs[] = $log;
}
@ -97,7 +97,7 @@ function exec_ogp_module() {
if($logs)
{
foreach($logs as $log)
foreach ((array)$logs as $log)
{
$user = $db->getUserById($log['user_id']);
$when = $log['date'];
@ -126,7 +126,7 @@ function exec_ogp_module() {
"<table>\n";
$show_values = array( "users_login", "users_lang", "users_role", "users_email", "user_expires");
foreach($user as $key => $value)
foreach ((array)$user as $key => $value)
{
if( in_array( $key, $show_values ) )
echo "<tr><td>".str_replace("_", "", substr($key,5))."</td><td>$value</td></tr>\n";
@ -139,7 +139,7 @@ function exec_ogp_module() {
echo "</tbody>\n";
echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
echo "</table>\n";
$count_logs = $db->get_logger_count($search_field);
$count_logs = $db->get_logger_count((array)$search_field);
if (isset($_GET['search']) && !empty($_GET['search'])) {
$uri = '?m=administration&p=watch_logger&search='.$_GET['search'].'&limit='.$l.'&page=';

View file

@ -20,7 +20,7 @@ function topRow(){
function bottomRow($latestDay,$backupPaths){
echo '<br><div>';
$latest = customSearch($latestDay,$backupPaths);
$length = count($backupPaths);
$length = count((array)$backupPaths);
for ($i = 0; $i < $length; $i++) {
$path = explode("/",$backupPaths[$i]);
$path1 = explode("-",$path[4]);
@ -106,7 +106,7 @@ function backupNow($homeid){
echo '</form>';
echo '<div>';
echo '<textarea readonly id="backup" name="backup" rows="20" cols="30">';
foreach ($output as $line) { echo $line."\n";}
foreach ((array)$output as $line) { echo $line."\n";}
echo '</textarea>';
echo '</div></div></center>';
@ -175,7 +175,7 @@ function restoreNow($homeid, $action){
echo '</form>';
echo '<div>';
echo '<textarea readonly id="backup" name="backup" rows="20" cols="30">';
foreach ($output as $line) { echo $line."\n";}
foreach ((array)$output as $line) { echo $line."\n";}
echo '</textarea>';
echo "</div>";
echo "</div></center>";
@ -217,7 +217,7 @@ function serverINFO($serverid) { // returns serverINFO Array
return $serverINFO;
}
function customSearch($keyword, $arrayToSearch){
foreach($arrayToSearch as $key => $arrayItem){
foreach ((array)$arrayToSearch as $key => $arrayItem){
if( stristr($arrayItem, $keyword)){
return $key;
}

View file

@ -135,7 +135,7 @@ function normalize_messages($messages) {
if (empty($messages['data']) || !is_array($messages['data'])) return $out;
// The API returns newest first by default if not specifying; we request 'asc' in fetch.
foreach ($messages['data'] as $m) {
foreach ((array)$messages['data'] as $m) {
$role = $m['role'] ?? '';
if (!in_array($role, ['user', 'assistant', 'system'], true)) continue;
@ -143,14 +143,14 @@ function normalize_messages($messages) {
$all_text = [];
$refs = [];
foreach ($m['content'] as $part) {
foreach ((array)$m['content'] as $part) {
if (($part['type'] ?? '') === 'text' && !empty($part['text']['value'])) {
$all_text[] = $part['text']['value'];
// Parse annotations for citations (file_citation)
$anns = $part['text']['annotations'] ?? [];
if (is_array($anns)) {
foreach ($anns as $ann) {
foreach ((array)$anns as $ann) {
if (($ann['type'] ?? '') === 'file_citation' && !empty($ann['file_citation']['file_id'])) {
$fid = $ann['file_citation']['file_id'];
$page = null;
@ -263,7 +263,7 @@ include(__DIR__ . '/includes/menu.php');
<?php if (!empty($history) && is_array($history)): ?>
<div style="margin-top:16px; padding:10px; border:1px solid #ccc; border-radius:8px;">
<?php foreach ($history as $msg):
<?php foreach ((array)$history as $msg):
// Label mapping: user => Question, assistant => Answer, system => (optional)
$role = $msg['role'] ?? 'assistant';
if ($role === 'user') $label = 'Question';
@ -280,7 +280,7 @@ include(__DIR__ . '/includes/menu.php');
<div style="margin-top:6px; font-size:12px;">
<em>References:</em>
<ul style="margin:6px 0 0 18px; padding:0;">
<?php foreach ($refs as $r):
<?php foreach ((array)$refs as $r):
$fname = $r['filename'] ?? 'file';
$page = $r['page'] ?? 'n/a';
// If you have your own document links, replace '#' with a real URL.

View file

@ -140,7 +140,7 @@ $game_options = [];
$games_dir = __DIR__ . '/../../config_games/server_configs/';
if (is_dir($games_dir)) {
$files = scandir($games_dir);
foreach ($files as $file) {
foreach ((array)$files as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'xml' && strpos($file, '.bak') === false) {
$game_key = str_replace('.xml', '', $file);
$game_options[] = $game_key;
@ -265,7 +265,7 @@ include(__DIR__ . '/includes/menu.php');
<div id="game_filter_list_container" class="form-group" style="display:none;">
<label>Select Games</label>
<div class="game-checkboxes">
<?php foreach ($game_options as $game): ?>
<?php foreach ((array)$game_options as $game): ?>
<label>
<input type="checkbox" name="game_filter_list[]" value="<?php echo h($game); ?>">
<?php echo h($game); ?>
@ -325,7 +325,7 @@ include(__DIR__ . '/includes/menu.php');
<?php if ($coupon['game_filter_type'] === 'all_games'): ?>
All Games
<?php else: ?>
<?php echo count($games_filtered); ?> specific games
<?php echo count((array)$games_filtered); ?> specific games
<?php endif; ?>
</td>
<td>
@ -397,7 +397,7 @@ include(__DIR__ . '/includes/menu.php');
<div class="form-group" style="display:<?php echo $coupon['game_filter_type'] === 'specific_games' ? 'block' : 'none'; ?>;">
<label>Select Games</label>
<div class="game-checkboxes">
<?php foreach ($game_options as $game): ?>
<?php foreach ((array)$game_options as $game): ?>
<label>
<input type="checkbox" name="game_filter_list[]" value="<?php echo h($game); ?>"
<?php echo in_array($game, $games_filtered) ? 'checked' : ''; ?>>

View file

@ -20,7 +20,7 @@ function exec_ogp_module()
$action = $_POST['bulk_action'];
$selected = $_POST['selected_orders'];
foreach ($selected as $order_id) {
foreach ((array)$selected as $order_id) {
$order_id = $db->realEscapeSingle($order_id);
switch ($action) {
@ -41,7 +41,7 @@ function exec_ogp_module()
}
}
echo "<div class='success'><p>Bulk action completed for ".count($selected)." order(s).</p></div>";
echo "<div class='success'><p>Bulk action completed for ".count((array)$selected)." order(s).</p></div>";
}
// Get filter parameters
@ -125,7 +125,7 @@ function exec_ogp_module()
echo "<th>Actions</th>";
echo "</tr></thead><tbody>";
foreach ($orders as $order) {
foreach ((array)$orders as $order) {
$status_class = '';
switch ($order['status']) {
case 'paid': $status_class = 'label-warning'; break;
@ -191,7 +191,7 @@ function exec_ogp_module()
echo "<table class='tablesorter' style='width: auto;'>";
echo "<thead><tr><th>Status</th><th>Count</th><th>Total Value</th></tr></thead><tbody>";
foreach ($stats as $stat) {
foreach ((array)$stats as $stat) {
echo "<tr>";
echo "<td>".$stat['status']."</td>";
echo "<td>".$stat['count']."</td>";

View file

@ -40,7 +40,7 @@ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); }
</tr>
</thead>
<tbody>
<?php foreach ($files as $f): $j = json_decode(file_get_contents($f), true) ?: []; ?>
<?php foreach ((array)$files as $f): $j = json_decode(file_get_contents($f), true) ?: []; ?>
<tr>
<td><?php echo h(basename($f)); ?></td>
<td><?php echo h($j['invoice'] ?? ($j['custom'] ?? '')); ?></td>

View file

@ -14,7 +14,7 @@ $errors = [];
$availableFiles = [];
$directoryIterator = new DirectoryIterator($serverConfigDir);
foreach ($directoryIterator as $fileInfo) {
foreach ((array)$directoryIterator as $fileInfo) {
if ($fileInfo->isFile() && strtolower($fileInfo->getExtension()) === 'xml') {
$availableFiles[] = $fileInfo->getFilename();
}
@ -86,7 +86,7 @@ function billing_render_flash(array $items, string $cssClass): void {
return;
}
echo '<div class="panel ' . $cssClass . '" style="margin-bottom:12px">';
foreach ($items as $item) {
foreach ((array)$items as $item) {
echo '<div>' . $item . '</div>';
}
echo '</div>';
@ -134,7 +134,7 @@ function billing_render_flash(array $items, string $cssClass): void {
<?php if (!$availableFiles): ?>
<p style="color:#e5e7eb;">No XML files found.</p>
<?php else: ?>
<?php foreach ($availableFiles as $fileName): ?>
<?php foreach ((array)$availableFiles as $fileName): ?>
<?php $isActive = ($fileName === $selectedFile); ?>
<a href="admin_xml_editor.php?file=<?php echo urlencode($fileName); ?>" class="<?php echo $isActive ? 'active' : ''; ?>"><?php echo htmlspecialchars($fileName, ENT_QUOTES, 'UTF-8'); ?></a>
<?php endforeach; ?>

View file

@ -48,7 +48,7 @@ function col_exists($db, $table, $col){
function parse_id_list($s){
$tokens = preg_split('/\s+/', trim((string)$s));
$out = [];
foreach ($tokens as $t) {
foreach ((array)$tokens as $t) {
if ($t === '') continue;
if (preg_match('/^\d+$/', $t)) $out[] = (int)$t;
}
@ -73,7 +73,7 @@ if (isset($_POST['update_remote_servers'])) {
$enabledIds = array_map('intval', $_POST['rs'] ?? []);
$enabledSet = array_flip($enabledIds);
$allIds = fetch_all_assoc($db, "SELECT remote_server_id FROM {$table_prefix}remote_servers");
foreach ($allIds as $row) {
foreach ((array)$allIds as $row) {
$id = (int)$row['remote_server_id'];
$e = isset($enabledSet[$id]) ? 1 : 0;
$db->query("UPDATE {$table_prefix}remote_servers SET enabled={$e} WHERE remote_server_id={$id}");
@ -134,7 +134,7 @@ if (isset($_POST['update_single']) && isset($_POST['service']) && is_array($_POS
/* B2) BULK UPDATE (single button at bottom) */
if (isset($_POST['bulk_update']) && !empty($_POST['service']) && is_array($_POST['service'])) {
foreach ($_POST['service'] as $sid => $svc) {
foreach ((array)$_POST['service'] as $sid => $svc) {
update_service_row($db, $locationCol, (int)$sid, (array)$svc);
}
$flash[] = "All edited services have been updated.";
@ -153,15 +153,15 @@ $services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locat
?>
<?php if ($flash): ?>
<div class="panel" style="margin-bottom:12px"><?php foreach($flash as $m) echo "<div>".h($m)."</div>"; ?></div>
<div class="panel mb-12"><?php foreach($flash as $m) echo "<div>".h($m)."</div>"; ?></div>
<div class="panel" style="margin-bottom:12px"><?php foreach ((array)$flash as $m) echo "<div>".h($m)."</div>"; ?></div>
<div class="panel mb-12"><?php foreach ((array)$flash as $m) echo "<div>".h($m)."</div>"; ?></div>
<?php endif; ?>
<h2>Enable/Disable Server Locations (Global)</h2>
<form method="post" action="">
<input type="hidden" name="update_remote_servers" value="1">
<div style="display:flex;flex-wrap:wrap;gap:10px;">
<?php foreach ($remoteServers as $rs): ?>
<?php foreach ((array)$remoteServers as $rs): ?>
<label class="loc-label min-w-240">
<input type="checkbox" name="rs[]" value="<?php echo (int)$rs['remote_server_id']; ?>" <?php echo ((int)$rs['enabled']===1?'checked':''); ?>>
<b><?php echo h($rs['remote_server_name']); ?></b>
@ -199,7 +199,7 @@ $services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locat
</tr>
</thead>
<tbody>
<?php foreach ($services as $row): ?>
<?php foreach ((array)$services as $row): ?>
<?php
$sid = (int)$row['service_id'];
$selected = parse_id_list($row['locs'] ?? '');
@ -277,7 +277,7 @@ $services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locat
<tr>
<td colspan="8" style="border-bottom:1px solid #f0f0f0; padding:8px 6px; text-align:left;">
<div class="locs-box" data-sid="<?php echo $sid; ?>" style="display:flex; flex-wrap:wrap; gap:8px;">
<?php foreach ($remoteServers as $rs): ?>
<?php foreach ((array)$remoteServers as $rs): ?>
<?php
$rid = (int)$rs['remote_server_id'];
$isChecked = isset($selSet[$rid]);
@ -317,7 +317,7 @@ $services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locat
<form method="post" action="" style="display:flex;gap:8px;align-items:center;">
<input type="hidden" name="remove_service" value="1">
<select name="service_id_remove">
<?php foreach ($services as $s): ?>
<?php foreach ((array)$services as $s): ?>
<option value="<?php echo (int)$s['service_id']; ?>">
<?php echo h($s['service_name']); ?> (ID: <?php echo (int)$s['service_id']; ?>)
</option>

View file

@ -135,7 +135,7 @@ function normalize_messages($messages) {
if (empty($messages['data']) || !is_array($messages['data'])) return $out;
// The API returns newest first by default if not specifying; we request 'asc' in fetch.
foreach ($messages['data'] as $m) {
foreach ((array)$messages['data'] as $m) {
$role = $m['role'] ?? '';
if (!in_array($role, ['user', 'assistant', 'system'], true)) continue;
@ -143,14 +143,14 @@ function normalize_messages($messages) {
$all_text = [];
$refs = [];
foreach ($m['content'] as $part) {
foreach ((array)$m['content'] as $part) {
if (($part['type'] ?? '') === 'text' && !empty($part['text']['value'])) {
$all_text[] = $part['text']['value'];
// Parse annotations for citations (file_citation)
$anns = $part['text']['annotations'] ?? [];
if (is_array($anns)) {
foreach ($anns as $ann) {
foreach ((array)$anns as $ann) {
if (($ann['type'] ?? '') === 'file_citation' && !empty($ann['file_citation']['file_id'])) {
$fid = $ann['file_citation']['file_id'];
$page = null;
@ -263,7 +263,7 @@ include(__DIR__ . '/includes/menu.php');
<?php if (!empty($history) && is_array($history)): ?>
<div style="margin-top:16px; padding:10px; border:1px solid #ccc; border-radius:8px;">
<?php foreach ($history as $msg):
<?php foreach ((array)$history as $msg):
// Label mapping: user => Question, assistant => Answer, system => (optional)
$role = $msg['role'] ?? 'assistant';
if ($role === 'user') $label = 'Question';
@ -280,7 +280,7 @@ include(__DIR__ . '/includes/menu.php');
<div style="margin-top:6px; font-size:12px;">
<em>References:</em>
<ul style="margin:6px 0 0 18px; padding:0;">
<?php foreach ($refs as $r):
<?php foreach ((array)$refs as $r):
$fname = $r['filename'] ?? 'file';
$page = $r['page'] ?? 'n/a';
// If you have your own document links, replace '#' with a real URL.

View file

@ -76,14 +76,14 @@ create_order_log('PARSED_INPUT', [
'currency' => $currency,
'invoice_id' => $invoice_id,
'custom_id' => $custom_id,
'items_count' => $items ? count($items) : 0,
'line_invoices_count' => $line_invoices ? count($line_invoices) : 0
'items_count' => $items ? count((array)$items) : 0,
'line_invoices_count' => $line_invoices ? count((array)$line_invoices) : 0
]);
$amount_value = number_format((float)$amount_in, 2, '.', '');
if ($items) {
$sum = 0.00;
foreach ($items as $it) {
foreach ((array)$items as $it) {
$qty = isset($it['quantity']) ? (int)$it['quantity'] : 1;
$val = isset($it['unit_amount']['value']) ? (float)$it['unit_amount']['value'] : 0.00;
$sum += $qty * $val;

View file

@ -72,7 +72,7 @@ if (!$db) {
mysqli_free_result($result);
}
$cart_empty = (count($invoices) === 0);
$cart_empty = (count((array)$invoices) === 0);
}
// Handle coupon application
@ -120,9 +120,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['apply_coupon'])) {
$game_valid = true;
if ($coupon['game_filter_type'] === 'specific_games' && !empty($coupon['game_filter_list'])) {
$allowed_games = json_decode($coupon['game_filter_list'], true);
if (is_array($allowed_games) && count($allowed_games) > 0) {
if (is_array($allowed_games) && count((array)$allowed_games) > 0) {
$has_valid_game = false;
foreach ($invoices as $inv) {
foreach ((array)$invoices as $inv) {
$inv_game_key = isset($inv['game_key']) ? $inv['game_key'] : null;
if ($inv_game_key !== null && in_array($inv_game_key, $allowed_games)) {
$has_valid_game = true;
@ -256,7 +256,7 @@ $client_id = 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_
// Prepare PayPal items
$paypal_items = [];
foreach ($invoices as $inv) {
foreach ((array)$invoices as $inv) {
$game_display = !empty($inv['game_name']) ? $inv['game_name'] : 'Game Server';
$qty = max(1, intval($inv['qty']));
$paypal_items[] = [
@ -550,7 +550,7 @@ $siteBase = $protocol . $host;
</tr>
</thead>
<tbody>
<?php foreach ($invoices as $inv): ?>
<?php foreach ((array)$invoices as $inv): ?>
<tr>
<td>
<div class="game-name"><?php echo htmlspecialchars($inv['game_name'] ?? 'Game Server'); ?></div>

View file

@ -62,7 +62,7 @@ if (mysqli_num_rows($last_result) > 0) {
while ($row = mysqli_fetch_assoc($last_result)) {
echo "<tr>";
foreach ($row as $val) {
foreach ((array)$row as $val) {
echo "<td>" . htmlspecialchars($val ?? 'NULL') . "</td>";
}
echo "</tr>\n";

View file

@ -69,7 +69,7 @@ function exec_ogp_module()
$provisioned_count = 0;
$failed_count = 0;
foreach($orders as $order)
foreach ((array)$orders as $order)
{
$order_id = $order['order_id'];
$processed_orders[] = intval($order_id);
@ -137,7 +137,7 @@ function exec_ogp_module()
If you have any questions or requests, visit our website or contact us directly in our Discord Server.";
$mail = mymail($email, $subject, $message, $settings);
$rundate = date('d/M/y G:i',$now);
$rundate = date('d/M/y G:i', is_numeric($now) ? (int)$now : strtotime($now));
if (!$mail)
$db->logger( "Email FAILED - Server Renewed " . $home_id);
@ -180,7 +180,7 @@ function exec_ogp_module()
//Add IP:Port Pair to the Game Home
//need to get the IP_ID for this remote server.
$result = $db->resultQuery("SELECT ip_id FROM OGP_DB_PREFIXremote_server_ips WHERE remote_server_id=".$ip);
foreach ($result as $rs)
foreach ((array)$result as $rs)
{
$ip_id = $rs['ip_id'];
}
@ -303,7 +303,7 @@ function exec_ogp_module()
You can login to the Game Panel and click on Game Monitor to see your server. <br><br>
Thank you!<br> ";
$mail = mymail($email, $subject, $message, $settings);
$rundate = date('d/M/y G:i',$now);
$rundate = date('d/M/y G:i', is_numeric($now) ? (int)$now : strtotime($now));
if (!$mail)
$db->logger( "Email FAILED - Server Created " . $home_id);

View file

@ -62,7 +62,7 @@ $today = time();
$invoice_date = strtotime('+ 7 days'); // Create invoice 7 days before expiration
$suspend_date = $today; // Suspend immediately when overdue
$removal_date = strtotime('- 7 days'); // Remove 7 days after suspension
$rundate = date('Y-m-d H:i:s', $today);
$rundate = date('Y-m-d H:i:s', is_numeric($today) ? (int)$today : strtotime($today));
$db->logger("BILLING-CRON: Server lifecycle automation running at " . $rundate);
@ -85,7 +85,7 @@ $upcoming_expirations = $db->resultQuery("
");
if (is_array($upcoming_expirations)) {
foreach ($upcoming_expirations as $order) {
foreach ((array)$upcoming_expirations as $order) {
$user_id = $order['user_id'];
$order_id = $order['order_id'];
$home_id = $order['home_id'];
@ -158,7 +158,7 @@ $servers_to_suspend = $db->resultQuery("
");
if (is_array($servers_to_suspend)) {
foreach ($servers_to_suspend as $order) {
foreach ((array)$servers_to_suspend as $order) {
$user_id = $order['user_id'];
$home_id = $order['home_id'];
$order_id = $order['order_id'];
@ -185,7 +185,7 @@ if (is_array($servers_to_suspend)) {
$control_type = isset($server_xml->control_protocol_type) ? $server_xml->control_protocol_type : "";
$addresses = $db->getHomeIpPorts($home_id);
foreach ($addresses as $address) {
foreach ((array)$addresses as $address) {
$remote->remote_stop_server($home_id, $address['ip'], $address['port'],
$server_xml->control_protocol, $home_info['control_password'],
$control_type, $home_info['home_path']);
@ -234,7 +234,7 @@ $servers_to_delete = $db->resultQuery("
");
if (is_array($servers_to_delete)) {
foreach ($servers_to_delete as $order) {
foreach ((array)$servers_to_delete as $order) {
$user_id = $order['user_id'];
$home_id = $order['home_id'];
$order_id = $order['order_id'];
@ -305,7 +305,7 @@ if (!is_array($user_homes))
}
else
{
foreach($user_homes as $user_home)
foreach ((array)$user_homes as $user_home)
{
// Developer note:
@ -358,7 +358,7 @@ if (!is_array($user_homes))
}
else
{
foreach($user_homes as $user_home)
foreach ((array)$user_homes as $user_home)
{
$user_id = $user_home['user_id'];
$home_id = $user_home['home_id'];
@ -371,7 +371,7 @@ else
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
if(isset($server_xml->control_protocol_type))$control_type = $server_xml->control_protocol_type; else $control_type = "";
$addresses = $db->getHomeIpPorts($home_id);
foreach($addresses as $address)
foreach ((array)$addresses as $address)
{
$remote->remote_stop_server($home_id,$address['ip'],$address['port'],$server_xml->control_protocol,$home_info['control_password'],$control_type,$home_info['home_path']);
}
@ -412,7 +412,7 @@ if (!is_array($user_homes))
}
else
{
foreach($user_homes as $user_home)
foreach ((array)$user_homes as $user_home)
{
$user_id = $user_home['user_id'];
$home_id = $user_home['home_id'];

View file

@ -32,7 +32,7 @@ function getDocCategories($docsDir) {
$folders = array_diff(scandir($docsDir), ['.', '..']);
foreach ($folders as $folder) {
foreach ((array)$folders as $folder) {
$folderPath = $docsDir . '/' . $folder;
// Skip if not a directory
@ -96,7 +96,7 @@ $categories = getDocCategories($docsDir);
// Group by category
$grouped = [];
foreach ($categories as $cat) {
foreach ((array)$categories as $cat) {
$category = $cat['category'];
if (!isset($grouped[$category])) {
$grouped[$category] = [];
@ -387,20 +387,20 @@ uksort($grouped, function($a, $b) use ($categoryOrder) {
<!-- Navigation Links -->
<div class="nav-links">
<h3>Jump to Section:</h3>
<?php foreach ($grouped as $category => $docs): ?>
<?php foreach ((array)$grouped as $category => $docs): ?>
<a href="#<?php echo htmlspecialchars($category); ?>">
<?php echo htmlspecialchars($categoryLabels[$category] ?? ucfirst($category)); ?>
(<?php echo count($docs); ?>)
(<?php echo count((array)$docs); ?>)
</a>
<?php endforeach; ?>
</div>
<?php foreach ($grouped as $category => $docs): ?>
<?php foreach ((array)$grouped as $category => $docs): ?>
<div class="category-section" id="<?php echo htmlspecialchars($category); ?>">
<h2 class="category-title"><?php echo htmlspecialchars($categoryLabels[$category] ?? ucfirst($category)); ?></h2>
<div class="docs-grid">
<?php foreach ($docs as $doc): ?>
<?php foreach ((array)$docs as $doc): ?>
<a href="docs.php?action=view&doc=<?php echo urlencode($doc['folder']); ?>" class="doc-card">
<div class="doc-icon-wrapper">
<?php if (!empty($doc['icon'])): ?>

View file

@ -14,7 +14,7 @@ function billing_render_markdown($markdown)
$html = '';
$inCode = false;
$inList = false;
foreach ($lines as $line) {
foreach ((array)$lines as $line) {
$trim = trim($line);
if ($trim === '```') {
if ($inCode) {

View file

@ -11,7 +11,7 @@ function get_cart_count() {
return 0;
}
$count = 0;
foreach ($_SESSION['cart'] as $item) {
foreach ((array)$_SESSION['cart'] as $item) {
if (is_array($item) && isset($item['quantity'])) {
$count += (int) $item['quantity'];
} else {

View file

@ -48,7 +48,7 @@ $attempted[] = $localConfig;
$message = "GSP Billing module cannot find config.inc.php.\n";
$message .= "Looked in:\n";
foreach ($attempted as $path) {
foreach ((array)$attempted as $path) {
if (!$path) {
continue;
}

View file

@ -115,7 +115,7 @@ function process_payment_record(array $record) {
$processed_count = 0;
foreach ($invoices_to_process as $inv) {
foreach ((array)$invoices_to_process as $inv) {
$invoice_id = intval($inv['invoice_id']);
$order_id = intval($inv['order_id'] ?? 0);
$user_id = intval($inv['user_id']);

View file

@ -48,7 +48,7 @@ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); }
</tr>
</thead>
<tbody>
<?php foreach ($records as $r): ?>
<?php foreach ((array)$records as $r): ?>
<tr>
<td><?php echo h($r['invoice'] ?? ($r['custom'] ?? 'NO-ID')); ?></td>
<td><?php echo h(($r['currency'] ?? '') . ' ' . number_format((float)($r['amount'] ?? 0),2)); ?></td>

View file

@ -196,7 +196,7 @@ usort($invoices, function($a, $b) {
// Organize invoices by status
$invoices_by_status = [];
foreach ($invoices as $inv) {
foreach ((array)$invoices as $inv) {
$status = strtolower($inv['status'] ?? 'pending');
if (!isset($invoices_by_status[$status])) {
$invoices_by_status[$status] = [];
@ -355,11 +355,11 @@ $status_config = [
<!-- Invoices Section - Organized by Status -->
<?php if (!empty($invoices_by_status)): ?>
<?php foreach ($status_config as $status_key => $status_info): ?>
<?php foreach ((array)$status_config as $status_key => $status_info): ?>
<?php if (isset($invoices_by_status[$status_key]) && !empty($invoices_by_status[$status_key])): ?>
<div class="account-section">
<h2><?php echo htmlspecialchars($status_info['label']); ?></h2>
<?php foreach ($invoices_by_status[$status_key] as $invoice): ?>
<?php foreach ((array)$invoices_by_status[$status_key] as $invoice): ?>
<div class="invoice-item">
<div>
<div class="invoice-id">Invoice #<?php echo htmlspecialchars($invoice['invoice'] ?? $invoice['custom'] ?? 'N/A'); ?></div>

View file

@ -52,7 +52,7 @@ function exec_ogp_module()
echo "<th>Action</th>";
echo "</tr></thead><tbody>";
foreach ($orders as $order) {
foreach ((array)$orders as $order) {
echo "<tr>";
echo "<td>".$order['order_id']."</td>";
echo "<td>".$order['home_name']."</td>";
@ -75,11 +75,11 @@ function exec_ogp_module()
echo "</tbody></table>";
// Provision all button
if (count($orders) > 1) {
if (count((array)$orders) > 1) {
echo "<div style='margin-top: 20px;'>";
echo "<form method='post' action='home.php?m=billing&p=provision_servers'>";
echo "<input type='hidden' name='provision_all' value='1'>";
echo "<button type='submit' class='btn btn-primary'>Provision All My Servers (".count($orders).")</button>";
echo "<button type='submit' class='btn btn-primary'>Provision All My Servers (".count((array)$orders).")</button>";
echo "</form>";
echo "</div>";
}

View file

@ -75,7 +75,7 @@ THIS IS WHAT WE DISPLAY ON THE SHOP PAGE AT THE TOP
return;
}
foreach ($services as $key => $row) {
foreach ((array)$services as $key => $row) {
$service_ids[$key] = $row['service_id'];
$home_cfg_id[$key] = $row['home_cfg_id'];
$mod_cfg_id[$key] = $row['mod_cfg_id'];
@ -97,7 +97,7 @@ THIS IS WHAT WE DISPLAY ON THE SHOP PAGE AT THE TOP
?>
<div class="clearfix">
<?php
foreach($services as $row)
foreach ((array)$services as $row)
{
if(!isset($_REQUEST['service_id']))
{
@ -196,11 +196,11 @@ if ($row['price_monthly'] == 0.0) {
//get the out of stock into an array and see if the rsID is in that array
$available_server = false;
//loop through each of the assigned servers and see if its disabled
foreach($rsiArray as $rsi)
foreach ((array)$rsiArray as $rsi)
{
$query = "SELECT * FROM {$table_prefix}remote_servers WHERE remote_server_id = ".$rsi;
$result = $db->query($query);
foreach($result as $rs)
foreach ((array)$result as $rs)
{
$rsID =$rs['remote_server_id'];

View file

@ -182,7 +182,7 @@ if ($db && $user_id > 0) {
</ul>
</div>
<?php if (count($orders) > 0): ?>
<?php if (count((array)$orders) > 0): ?>
<h2>Your Orders</h2>
<table class="orders-table">
<thead>
@ -196,7 +196,7 @@ if ($db && $user_id > 0) {
</tr>
</thead>
<tbody>
<?php foreach ($orders as $order): ?>
<?php foreach ((array)$orders as $order): ?>
<tr>
<td>#<?php echo htmlspecialchars($order['order_id']); ?></td>
<td><?php echo htmlspecialchars($order['home_name']); ?></td>

View file

@ -75,7 +75,7 @@ function money_fmt($value, $currency) {
<?php
$currency = $details['currency'] ?? ($items[0]['unit_amount']['currency_code'] ?? '');
$grand = 0.00;
foreach ($items as $it) {
foreach ((array)$items as $it) {
$name = $it['name'] ?? '';
$sku = $it['sku'] ?? '';
$qty = isset($it['quantity']) ? (int)$it['quantity'] : 1;

View file

@ -56,7 +56,7 @@ include(__DIR__ . '/includes/menu.php');
<!-- Services container: clearfix to contain floated service cards so footer clears correctly -->
<div class="clearfix container-wide">
<?php foreach ($services as $row): ?>
<?php foreach ((array)$services as $row): ?>
<?php if (!isset($_REQUEST['service_id'])): ?>
<!-- Service listing (all) -->
<div class="float-left p-30-20">

View file

@ -105,7 +105,7 @@ while ($row = mysqli_fetch_assoc($result)) {
}
$all_present = true;
foreach ($required_columns as $col) {
foreach ((array)$required_columns as $col) {
if (in_array($col, $existing_columns)) {
echo "<p class='success'>✓ Column '$col' exists</p>";
} else {

View file

@ -39,7 +39,7 @@ function exec_ogp_module()
'admin_orders.php' => 'Admin order management'
);
foreach ($pages as $file => $desc) {
foreach ((array)$pages as $file => $desc) {
$path = "modules/billing/".$file;
if (file_exists($path)) {
echo "<div class='success'>✓ $file - $desc</div>";
@ -56,7 +56,7 @@ function exec_ogp_module()
'billing_invoices' => 'Payment records'
);
foreach ($tables as $table => $desc) {
foreach ((array)$tables as $table => $desc) {
$result = $db->query("SHOW TABLES LIKE 'OGP_DB_PREFIX".$table."'");
if ($result && $db->num_rows($result) > 0) {
echo "<div class='success'>✓ $table - $desc</div>";
@ -72,7 +72,7 @@ function exec_ogp_module()
if (!empty($stats)) {
echo "<table class='tablesorter'>";
echo "<thead><tr><th>Status</th><th>Count</th></tr></thead><tbody>";
foreach ($stats as $stat) {
foreach ((array)$stats as $stat) {
echo "<tr><td>".$stat['status']."</td><td>".$stat['count']."</td></tr>";
}
echo "</tbody></table>";

View file

@ -34,6 +34,6 @@ echo "RESPONSE:\n" . $res . "\n";
$dataDir = realpath(__DIR__ . '/../data');
$files = glob($dataDir . '/*.json');
echo "Files in data/ after run: \n";
foreach ($files as $f) echo basename($f) . "\n";
foreach ((array)$files as $f) echo basename($f) . "\n";
?>

View file

@ -99,7 +99,7 @@ if (isset($res['purchase_units'][0]['items']) && is_array($res['purchase_units']
if (!$items && $type === 'PAYMENT.CAPTURE.COMPLETED') {
$orderId = $res['supplementary_data']['related_ids']['order_id'] ?? null;
if (!$orderId && isset($res['links']) && is_array($res['links'])) {
foreach ($res['links'] as $lnk) {
foreach ((array)$res['links'] as $lnk) {
if (!empty($lnk['href']) && !empty($lnk['rel']) && stripos($lnk['href'], '/v2/checkout/orders/') !== false) {
$orderId = basename(parse_url($lnk['href'], PHP_URL_PATH));
break;
@ -157,7 +157,7 @@ if (in_array($type, ['PAYMENT.CAPTURE.COMPLETED','PAYMENT.SALE.COMPLETED'], true
}
}
if (function_exists('site_log_info')) site_log_info('webhook_event',['type'=>$type,'invoice'=>($invoice ?: 'none'),'items_count'=>count($items),'status'=>$status]);
else log_line("EVENT $type invoice=".($invoice ?: 'none')." items_count=".count($items)." status=$status");
if (function_exists('site_log_info')) site_log_info('webhook_event',['type'=>$type,'invoice'=>($invoice ?: 'none'),'items_count'=>count((array)$items),'status'=>$status]);
else log_line("EVENT $type invoice=".($invoice ?: 'none')." items_count=".count((array)$items)." status=$status");
?>

View file

@ -43,7 +43,7 @@ function exec_ogp_module()
{
if(isset($_POST['circulars_ids']) and is_array($_POST['circulars_ids']) and !empty($_POST['circulars_ids']))
{
foreach($_POST['circulars_ids'] as $circular_id)
foreach ((array)$_POST['circulars_ids'] as $circular_id)
{
remove_circular($circular_id, true);
}
@ -67,7 +67,7 @@ function exec_ogp_module()
"<th>".get_lang('users_not_read_circular')."</th>".
"<th>".get_lang('date')."</th></thead>\n";
foreach($circulars as $key => $circular)
foreach ((array)$circulars as $key => $circular)
{
$users_not_readed = get_usernames_not_read_circular($circular['circular_id']);
$users_not_readed = $users_not_readed ? $users_not_readed: "";
@ -104,7 +104,7 @@ function exec_ogp_module()
'<td><select id="select_admins" multiple>'."\n";
if(!empty($users))
{
foreach($users as $user)
foreach ((array)$users as $user)
{
if($user['users_role'] == 'admin')
echo '<option value="'.$user['user_id'].'">'.$user['users_login'].'</option>'."\n";
@ -114,7 +114,7 @@ function exec_ogp_module()
'<td><select id="select_users" multiple>'."\n";
if(!empty($users))
{
foreach($users as $user)
foreach ((array)$users as $user)
{
if($user['users_role'] == 'user')
echo '<option value="'.$user['user_id'].'">'.$user['users_login'].'</option>'."\n";
@ -125,7 +125,7 @@ function exec_ogp_module()
$groups = $db->getGroupList();
if(!empty($groups))
{
foreach($groups as $group)
foreach ((array)$groups as $group)
{
if($db->listUsersInGroup($group['group_id']))
echo '<option value="'.$group['group_id'].'">'.$group['group_name'].'</option>';
@ -136,7 +136,7 @@ function exec_ogp_module()
echo '<td><select id="select_subusers_of_users" multiple>'."\n";
if(!empty($users))
{
foreach($users as $user)
foreach ((array)$users as $user)
{
$sub_users_ids = $db->getUsersSubUsersIds($user['user_id']);
if($user['users_role'] == 'user' and $sub_users_ids)

View file

@ -33,7 +33,7 @@ function get_usernames_not_read_circular($circular_id)
if($users)
{
$user_names = array();
foreach($users as $user)
foreach ((array)$users as $user)
{
$user_info = $db->getUserById($user['user_id']);
$user_names[] = $user_info['users_login'];
@ -98,7 +98,7 @@ function send_to_user($user_id, $circular_id)
function get_user_ids($type, $ids, &$user_ids)
{
global $db;
foreach($ids as $id)
foreach ((array)$ids as $id)
{
if($type == 'admins' or $type == 'users')
{
@ -110,7 +110,7 @@ function get_user_ids($type, $ids, &$user_ids)
$group_users = $db->listUsersInGroup($id);
if($group_users and !empty($group_users))
{
foreach($group_users as $user)
foreach ((array)$group_users as $user)
{
if(!in_array($user['user_id'], $user_ids))
$user_ids[] = $user['user_id'];
@ -122,7 +122,7 @@ function get_user_ids($type, $ids, &$user_ids)
$sub_users_ids = $db->getUsersSubUsersIds($id);
if($sub_users_ids and !empty($sub_users_ids))
{
foreach($sub_users_ids as $user_id)
foreach ((array)$sub_users_ids as $user_id)
{
if(!in_array($user_id, $user_ids))
$user_ids[] = $user_id;
@ -138,13 +138,13 @@ function send_circular($data)
$circular_id = $db->resultInsertId('circular', array('subject' => $data['subject'], 'message' => $data['message']));
$user_ids = array();
unset($data['subject'], $data['message']);
foreach($data as $type => $ids)
foreach ((array)$data as $type => $ids)
{
if(is_array($ids) and !empty($ids))
get_user_ids($type, $ids, $user_ids);
}
$failed_recipients = array();
foreach($user_ids as $user_id)
foreach ((array)$user_ids as $user_id)
{
if(!send_to_user($user_id, $circular_id))
$failed_recipients[] = $user_id;

View file

@ -31,7 +31,7 @@ function exec_ogp_module()
rsort($circulars);
echo "<table id='circular_list'>\n".
"<thead><tr><th>".get_lang('status')."</th><th>".get_lang('subject')."</th><th>".get_lang('date')."</th></tr></thead><tbody>\n";
foreach($circulars as $key => $circular)
foreach ((array)$circulars as $key => $circular)
{
echo '<tr><td><i class="status_'.$circular['status'].'"></i></td><td><a href="?m=circular&p=show_circular&read_circular='.$circular['circular_id'].'">'.$circular['subject']."</a></td><td>".$circular['timestamp']."</td></tr>\n";
}
@ -39,7 +39,7 @@ function exec_ogp_module()
}
elseif(isset($_GET['read_circular']) and is_numeric($_GET['read_circular']))
{
foreach($circulars as $circular)
foreach ((array)$circulars as $circular)
if($circular['circular_id'] == $_GET['read_circular'])
break;
echo '<div id="circular_message">'.$circular['message']."</div>\n".
@ -49,7 +49,7 @@ function exec_ogp_module()
}
else
{
foreach($circulars as $key => $circular)
foreach ((array)$circulars as $key => $circular)
if($circular['status'] == "1")
unset($circulars[$key]);
sort($circulars);

View file

@ -117,9 +117,9 @@ function config_games_render_node(SimpleXMLElement $node, array $ancestors, arra
}
$attributes = $node->attributes();
if ($attributes && count($attributes) > 0) {
if ($attributes && count((array)$attributes) > 0) {
$html .= "<div class='xml-node__attributes'><strong>Attributes</strong>";
foreach ($attributes as $attrName => $attrValue) {
foreach ((array)$attributes as $attrName => $attrValue) {
$attrSafe = htmlspecialchars($attrName, ENT_QUOTES, 'UTF-8');
$valSafe = htmlspecialchars((string)$attrValue, ENT_QUOTES, 'UTF-8');
$html .= "<div class='attr-row'><span>{$attrSafe}</span><input type='text' name=\"nodes[{$safeNodeKey}][attributes][{$attrSafe}]\" value=\"{$valSafe}\" placeholder='Leave blank to remove'></div>";
@ -166,7 +166,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
return false;
}
$nodes = [];
foreach ($nodesPayload as $key => $data) {
foreach ((array)$nodesPayload as $key => $data) {
$rawPath = isset($data['path']) ? (string)$data['path'] : (string)$key;
$cleanPath = config_games_normalize_path($rawPath);
if ($cleanPath === '') {
@ -188,7 +188,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
uksort($nodes, function ($a, $b) {
return substr_count($b, '/') <=> substr_count($a, '/');
});
foreach ($nodes as $path => $nodeData) {
foreach ((array)$nodes as $path => $nodeData) {
$query = '/' . $path;
$nodeList = @$xpath->query($query);
if (!$nodeList || $nodeList->length === 0) {
@ -203,7 +203,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
continue;
}
$hasChildren = !empty($nodeData['has_children']);
if (array_key_exists('value', $nodeData)) {
if (array_key_exists('value', (array)$nodeData)) {
$normalizedValue = config_games_normalize_newlines($nodeData['value']);
while ($domNode->firstChild) {
$domNode->removeChild($domNode->firstChild);
@ -217,7 +217,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
}
}
if (isset($nodeData['attributes']) && is_array($nodeData['attributes'])) {
foreach ($nodeData['attributes'] as $attrName => $attrValue) {
foreach ((array)$nodeData['attributes'] as $attrName => $attrValue) {
$attrNameClean = preg_replace('/[^A-Za-z0-9_\\-:]/', '', (string)$attrName);
if ($attrNameClean === '') {
continue;
@ -298,7 +298,7 @@ function exec_ogp_module() {
$db->clearGameCfgs($clear_old);
foreach ( $files as $config_file )
foreach ((array)$files as $config_file)
{
$config = read_server_config($config_file);
@ -342,7 +342,7 @@ function exec_ogp_module() {
<td class='left'>\n
<select name='home_cfg_id' onchange=".'"this.form.submit()"'.">\n
<option style='background:black;color:white;' value=''>".get_lang('select_game')."</option>\n";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if ( preg_match( "/_win/", $row['game_key'] ) )
$os = "(Windows)";

View file

@ -123,7 +123,7 @@ function exec_ogp_module() {
$_SESSION['mods'][1]['mod_installer_name'] = $key_name;
}
$mods = $_SESSION['mods'];
foreach($mods as $mod)
foreach ((array)$mods as $mod)
{
$template .= "
<mod key='".$mod['mod_key']."'>
@ -139,7 +139,7 @@ function exec_ogp_module() {
$template .= "
<server_params>";
$params = $_SESSION['params'];
foreach($params as $param)
foreach ((array)$params as $param)
{
$template .= "
<param key='".$param['param_key']."' type='".$param['param_type']."'>

View file

@ -72,7 +72,7 @@ if (!function_exists('ogp_format_libxml_errors')) {
return "No additional libxml details are available.";
}
$messages = array();
foreach ($errors as $error) {
foreach ((array)$errors as $error) {
$messages[] = trim($error->message) . " (Line {$error->line}, Column {$error->column})";
}
libxml_clear_errors();

View file

@ -92,7 +92,7 @@ function exec_ogp_module() {
$template = "";
if ($mods)
{
foreach($mods as $mod)
foreach ((array)$mods as $mod)
{
$template .= " ";
$template .= $mod['mod_name'];

View file

@ -97,7 +97,7 @@ function exec_ogp_module() {
if ($params)
{
$template = "";
foreach($params as $param)
foreach ((array)$params as $param)
{
$template .= $param['param_key'];
}

View file

@ -32,7 +32,7 @@ function exec_ogp_module()
require_once 'protocol/lgsl/lgsl_protocol.php';
$lgsl_type_list = lgsl_type_list();
asort($lgsl_type_list);
foreach ($lgsl_type_list as $type => $description) {
foreach ((array)$lgsl_type_list as $type => $description) {
$queryChoices[$type] = $description;
}
$queryLabel = 'LGSL Query Name';
@ -58,7 +58,7 @@ function exec_ogp_module()
}
unset($dir);
ksort($protocols);
foreach ($protocols as $gameq => $info) {
foreach ((array)$protocols as $gameq => $info) {
$queryChoices[$gameq] = $info['name'];
}
$queryLabel = 'GameQ Query Name';
@ -95,7 +95,7 @@ CSS;
'lgsl' => 'LGSL',
'gameq' => 'GameQ',
);
foreach ($protocolOptions as $value => $label) {
foreach ((array)$protocolOptions as $value => $label) {
$safeValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$safeLabel = htmlspecialchars($label, ENT_QUOTES, 'UTF-8');
$selected = ($selectedProtocol === $value) ? "selected='selected'" : '';
@ -115,7 +115,7 @@ CSS;
$label = htmlspecialchars($queryLabel, ENT_QUOTES, 'UTF-8');
echo "<label for='query_name'>{$label}</label>";
echo "<select id='query_name' name='query_name'>";
foreach ($queryChoices as $value => $labelText) {
foreach ((array)$queryChoices as $value => $labelText) {
$safeValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$safeLabelText = htmlspecialchars($labelText, ENT_QUOTES, 'UTF-8');
echo "<option value='{$safeValue}'>{$safeLabelText}</option>";

View file

@ -35,14 +35,14 @@ function exec_ogp_module()
return 0;
}
foreach( $homes as $home )
foreach ((array)$homes as $home)
{
$home['access_rights'] = "ufpet";
$id = $home['home_id']."_".$home['ip']."_".$home['port'];
$server_homes[$id] = $home;
}
foreach($r_servers as $r_server)
foreach ((array)$r_servers as $r_server)
{
$id = $r_server['remote_server_id'];
$remote_servers[$id] = $r_server;
@ -134,7 +134,7 @@ function exec_ogp_module()
$refresh = new refreshed();
if( isset($_POST['r_server_id']) )
{
foreach($server_homes as $key => $server_home)
foreach ((array)$server_homes as $key => $server_home)
{
if($server_home['remote_server_id'] == $_POST['r_server_id'])
{
@ -265,7 +265,7 @@ function exec_ogp_module()
if ( !empty($remote_servers_offline) )
{
$offline_servers = server . " (" . offline . "):";
foreach($remote_servers_offline as $remote_server_offline)
foreach ((array)$remote_servers_offline as $remote_server_offline)
{
$offline_servers .= " " . $remote_server_offline['remote_server_name'] . ",";
}
@ -310,12 +310,12 @@ function exec_ogp_module()
</tr>
<?php
$user_jobs = "";
foreach( $jobsArray as $remote_server_id => $jobs )
foreach ((array)$jobsArray as $remote_server_id => $jobs )
{
foreach($jobs as $jobId => $job)
foreach ((array)$jobs as $jobId => $job)
{
if(isset($job['action'])){
if(array_key_exists('home_id', $job) && array_key_exists('ip', $job) && array_key_exists('port', $job) && hasValue($job['home_id']) && hasValue($job['ip']) && hasValue($job['port'])){
if(array_key_exists('home_id', (array)$job) && array_key_exists('ip', (array)$job) && array_key_exists('port', (array)$job) && hasValue($job['home_id']) && hasValue($job['ip']) && hasValue($job['port'])){
$idStr = $job['home_id']."_".$job['ip']."_".$job['port'];
}else{
$idStr = false;

View file

@ -76,7 +76,7 @@ function exec_ogp_module()
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 )

View file

@ -26,7 +26,7 @@ function reloadJobs($server_homes, $remote_servers, $getAllJobs = true)
global $db;
$remote_servers_offline = array();
$jobsArray = array();
foreach( $remote_servers as $rhost_id => $remote_server )
foreach ((array)$remote_servers as $rhost_id => $remote_server )
{
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
if($remote->status_chk() != 1)
@ -39,7 +39,7 @@ function reloadJobs($server_homes, $remote_servers, $getAllJobs = true)
$jobs = $remote->scheduler_list_tasks();
if($jobs != -1)
{
foreach($jobs as $jobId => $job)
foreach ((array)$jobs as $jobId => $job)
{
list($minute,$hour,$dayOfTheMonth,$month,$dayOfTheWeek,$command) = explode(" ", $job, 6);
if(preg_match('/'.preg_quote('wget -qO- "','/').'([^"]+)'.preg_quote('" --no-check-certificate > /dev/null 2>&1','/').'/', $command))
@ -102,11 +102,11 @@ function reloadJobs($server_homes, $remote_servers, $getAllJobs = true)
function updateCronJobTokens($old_token, $token){
global $db;
$remote_servers = $db->getRemoteServers();
foreach($remote_servers as $remote_server)
foreach ((array)$remote_servers as $remote_server)
{
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
$jobs = $remote->scheduler_list_tasks();
foreach($jobs as $job_id => $job)
foreach ((array)$jobs as $job_id => $job)
{
if(strstr($job, $old_token))
{
@ -122,11 +122,11 @@ function deleteJobsByHomeServerID($home_id){
$homeInfo = $db->getGameHome($home_id, true);
if($homeInfo){
$remote_servers = $db->getRemoteServers();
foreach($remote_servers as $remote_server)
foreach ((array)$remote_servers as $remote_server)
{
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
$jobs = $remote->scheduler_list_tasks();
foreach($jobs as $job_id => $job)
foreach ((array)$jobs as $job_id => $job)
{
if(strstr($job, "homeid=" . $home_id))
{
@ -138,7 +138,7 @@ function deleteJobsByHomeServerID($home_id){
}
}
if(is_array($jobIdsToDel) && count($jobIdsToDel) > 0){
if(is_array($jobIdsToDel) && count((array)$jobIdsToDel) > 0){
// Only make one call
$remote->scheduler_del_task(implode(",", $jobIdsToDel));
}
@ -153,7 +153,7 @@ function get_action_selector($action = false, $server_homes = false, $homeid_ip_
$server_actions[] = 'steam_auto_update';
}
$select_action = '<select name="action" style="width: 100%;">';
foreach($server_actions as $server_action)
foreach ((array)$server_actions as $server_action)
{
$selected = ($action and $action == $server_action) ? 'selected="selected"' : '';
$select_action .= '<option value="'.$server_action.'" '.$selected.'>'.get_lang($server_action).'</option>';
@ -166,7 +166,7 @@ function get_server_selector($server_homes, $homeid_ip_port = FALSE, $onchange =
$select_game = "<select style='text-overflow: ellipsis; width: 100%;' name='homeid_ip_port' $onchange_this_form_submit>\n";
if($server_homes != FALSE)
{
foreach ( $server_homes as $server_home )
foreach ((array)$server_homes as $server_home)
{
$selected = ($homeid_ip_port and ($homeid_ip_port == $server_home['home_id']."_".$server_home['ip']."_".$server_home['port'] || trim($homeid_ip_port) == trim($server_home['home_id']))) ? 'selected="selected"' : '';
$select_game .= "<option value='". $server_home['home_id'] . "_" . $server_home['ip'] .
@ -186,7 +186,7 @@ function get_remote_server_selector($r_servers, $remote_servers_offline, $remote
$onchange_this_form_submit = $onchange ? 'onchange="this.form.submit();"' : '';
$select_rserver = "<select id='r_server_id' style='width: 100%;' name='r_server_id' $onchange_this_form_submit>\n";
if($first_empty) $select_rserver .= '<option></option>';
foreach ( $r_servers as $r_server )
foreach ((array)$r_servers as $r_server)
{
$selected = ($remote_server_id and $remote_server_id == $r_server['remote_server_id']) ? 'selected="selected"' : '';
$offline = isset($remote_servers_offline[$r_server['remote_server_id']]) ? ' (' . offline . ')' : '';
@ -201,7 +201,7 @@ function checkCronInput($min, $hour, $day, $month, $dayOfWeek) {
$args = func_get_args();
foreach ($args as $k => $arg) {
foreach ((array)$args as $k => $arg) {
if (strlen($arg) == 0 || strpbrk($arg, $blacklist) || preg_match('/\\s/', $arg)) {
$returns[$k] = false;
}
@ -231,13 +231,13 @@ function updateCronJobsToNewApi()
$regex = '/'.preg_quote('action=','/').'([a-zA-Z]+)'.preg_quote('&homeid=','/').'([0-9]+)'.preg_quote('&controlpass=','/').'([^"]+)/';
$token = $db->getApiToken($_SESSION['user_id']);
$mod_key = '';
foreach($remote_servers as $remote_server)
foreach ((array)$remote_servers as $remote_server)
{
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
$jobs = $remote->scheduler_list_tasks();
if(!is_array($jobs))
continue;
foreach($jobs as $job_id => $job)
foreach ((array)$jobs as $job_id => $job)
{
if(preg_match($regex, $job, $matches))
{

View file

@ -42,7 +42,7 @@ function exec_ogp_module()
return 0;
}
foreach( $homes as $home )
foreach ((array)$homes as $home)
{
$server_homes[$home['home_id']."_".$home['ip']."_".$home['port']] = $home;
$remote_servers[$home['remote_server_id']] = array( "agent_ip" => $home['agent_ip'],
@ -224,13 +224,13 @@ You can read more on our <a href='http://wiki.iaregamer.com/doku.php?id=cron' ta
</tr>
<?php
$user_jobs = "";
foreach( $jobsArray as $remote_server_id => $jobs )
foreach ((array)$jobsArray as $remote_server_id => $jobs )
{
foreach($jobs as $jobId => $job)
foreach ((array)$jobs as $jobId => $job)
{
if(isset($job['action']))
{
if(array_key_exists('home_id', $job) && array_key_exists('ip', $job) && array_key_exists('port', $job) && hasValue($job['home_id']) && hasValue($job['ip']) && hasValue($job['port'])){
if(array_key_exists('home_id', (array)$job) && array_key_exists('ip', (array)$job) && array_key_exists('port', (array)$job) && hasValue($job['home_id']) && hasValue($job['ip']) && hasValue($job['port'])){
$uniqueStr = $job['home_id']."_".$job['ip']."_".$job['port'];
}else{
$uniqueStr = false;

Some files were not shown because too many files have changed in this diff Show more