Don't use each() deprecated in PHP 7.2

pull/5635/head
Aleksander Machniak 7 years ago
parent f29fd706cf
commit 81f67a4de2

@ -673,8 +673,7 @@ echo $select_param_folding->show(strval($RCI->getprop('mime_param_folding')));
<?php
$plugins = $RCI->list_plugins();
foreach($plugins as $p)
{
foreach ($plugins as $p) {
$p_check = new html_checkbox(array('name' => '_plugins_'.$p['name'], 'id' => 'cfgplugin_'.$p['name'], 'value' => $p['name']));
echo '<dt class="propname"><label>';
echo $p_check->show($p['enabled'] ? $p['name'] : 0);

@ -74,7 +74,7 @@ class debug_logger extends rcube_plugin
$log_config = rcmail::get_instance()->config->get('debug_logger',array());
foreach($log_config as $type=>$file){
foreach ($log_config as $type => $file){
$this->runlog->set_file(rcmail::get_instance()->config->get('log_dir').'/'.$file, $type);
}

@ -68,7 +68,7 @@ class runlog {
$this->indent--;
if ($this->run_log[$lastk]['duration'] >= $this->threshold) {
$tag_report = "";
foreach($this->tag_count as $tag => $count){
foreach ($this->tag_count as $tag => $count){
$tag_report .= "$tag: $count, ";
}
if (!empty($tag_report)) {

@ -157,8 +157,8 @@ class enigma_mime_message extends Mail_mime
*/
public function get($params = null, $filename = null, $skip_head = false)
{
if (isset($params)) {
while (list($key, $value) = each($params)) {
if (!empty($params)) {
foreach ($params as $key => $value) {
$this->build_params[$key] = $value;
}
}

@ -689,7 +689,7 @@ class rcube_sieve_engine
if ($name == '')
$this->errors['name'] = $this->plugin->gettext('cannotbeempty');
else {
foreach($this->script as $idx => $rule)
foreach ($this->script as $idx => $rule)
if($rule['name'] == $name && $idx != $fid) {
$this->errors['name'] = $this->plugin->gettext('ruleexist');
break;

@ -1089,7 +1089,7 @@ class rcube_sieve_script
static function escape_string($str)
{
if (is_array($str) && count($str) > 1) {
foreach($str as $idx => $val)
foreach ($str as $idx => $val)
$str[$idx] = self::escape_string($val);
return '[' . implode(',', $str) . ']';

@ -64,7 +64,7 @@ class rcube_ximss_password
fclose($sock);
foreach( explode( "\0",$responseblob) as $response ) {
foreach (explode( "\0",$responseblob) as $response) {
$resp = simplexml_load_string("<xml>".$response."</xml>");
if( $resp->response[0]['id'] == 'A001' ) {

@ -194,7 +194,7 @@ class squirrelmail_usercopy extends rcube_plugin
// parse addres book file
if (filesize($abookfile)) {
foreach(file($abookfile) as $line) {
foreach (file($abookfile) as $line) {
$line = $this->convert_charset(rtrim($line), $file_charset);
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', $line);
if ($rec['name'] && $rec['email']) {

@ -537,8 +537,8 @@ class rcmail extends rcube
// we'll only handle unset host (if possible)
if (!$host && !empty($default_host)) {
if (is_array($default_host)) {
list($key, $val) = each($default_host);
$host = is_numeric($key) ? $val : $key;
$key = key($default_host);
$host = is_numeric($key) ? $default_host[$key] : $key;
}
else {
$host = $default_host;
@ -749,8 +749,8 @@ class rcmail extends rcube
// take the first entry if $host is still not set
if (empty($host)) {
list($key, $val) = each($default_host);
$host = is_numeric($key) ? $val : $key;
$key = key($default_host);
$host = is_numeric($key) ? $default_host[$key] : $key;
}
}
else if (empty($default_host)) {

@ -4241,7 +4241,7 @@ class rcube_imap extends rcube_storage
*/
protected function sort_folder_specials($folder, &$list, &$specials, &$out)
{
while (list($key, $name) = each($list)) {
foreach ($list as $key => $name) {
if ($folder === null || strpos($name, $folder.$this->delimiter) === 0) {
$out[] = $name;
unset($list[$key]);

@ -2643,7 +2643,7 @@ class rcube_imap_generic
reset($messages);
while (list($key, $headers) = each($messages)) {
foreach ($messages as $key => $headers) {
$value = null;
switch ($field) {
@ -2685,7 +2685,7 @@ class rcube_imap_generic
}
// form new array based on index
while (list($key, $val) = each($index)) {
foreach ($index as $key => $val) {
$result[$key] = $messages[$key];
}
}
@ -3630,14 +3630,12 @@ class rcube_imap_generic
$data['type'] = 'multipart';
}
else {
$data['type'] = strtolower($part_a[0]);
// encoding
$data['type'] = strtolower($part_a[0]);
$data['encoding'] = strtolower($part_a[5]);
// charset
if (is_array($part_a[2])) {
while (list($key, $val) = each($part_a[2])) {
foreach ($part_a[2] as $key => $val) {
if (strcasecmp($val, 'charset') == 0) {
$data['charset'] = $part_a[2][$key+1];
break;

@ -125,7 +125,8 @@ class rcube_message
$this->mime = new rcube_mime($this->headers->charset);
$this->subject = $this->headers->get('subject');
list(, $this->sender) = each($this->mime->decode_address_list($this->headers->from, 1));
$from = $this->mime->decode_address_list($this->headers->from, 1);
$this->sender = current($from);
// notify plugins and let them analyze this structured message object
$this->app->plugins->exec_hook('message_load', array('object' => $this));

@ -791,7 +791,7 @@ class rcube_mime
$mime_types = $mime_extensions = array();
$regex = "/([\w\+\-\.\/]+)\s+([\w\s]+)/i";
foreach((array)$lines as $line) {
foreach ((array)$lines as $line) {
// skip comments or mime types w/o any extensions
if ($line[0] == '#' || !preg_match($regex, $line, $matches))
continue;

@ -101,7 +101,7 @@ class rcube_mime_decode
$return = new stdClass;
$headers = $this->parseHeaders($headers);
while (list($key, $value) = each($headers)) {
foreach ($headers as $value) {
$header_name = strtolower($value['name']);
if (isset($return->headers[$header_name]) && !is_array($return->headers[$header_name])) {
@ -124,10 +124,8 @@ class rcube_mime_decode
$return->ctype_secondary = $regs[2];
}
if (isset($content_type['other'])) {
while (list($p_name, $p_value) = each($content_type['other'])) {
$return->ctype_parameters[$p_name] = $p_value;
}
if (!empty($content_type['other'])) {
$return->ctype_parameters = array_merge((array) $return->ctype_parameters, (array) $content_type['other']);
}
break;
@ -136,10 +134,8 @@ class rcube_mime_decode
$content_disposition = $this->parseHeaderValue($value['value']);
$return->disposition = $content_disposition['value'];
if (isset($content_disposition['other'])) {
while (list($p_name, $p_value) = each($content_disposition['other'])) {
$return->d_parameters[$p_name] = $p_value;
}
if (!empty($content_disposition['other'])) {
$return->d_parameters = array_merge((array) $return->d_parameters, (array) $content_disposition['other']);
}
break;

@ -633,7 +633,7 @@ class rcube_utils
$proxy_whitelist = rcube::get_instance()->config->get('proxy_whitelist', array());
if (in_array($_SERVER['REMOTE_ADDR'], $proxy_whitelist)) {
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
foreach(array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $forwarded_ip) {
foreach (array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $forwarded_ip) {
if (!in_array($forwarded_ip, $proxy_whitelist)) {
return $forwarded_ip;
}

@ -626,7 +626,7 @@ class rcube_vcard
$field = strtoupper($regs2[1][0]);
$enc = null;
foreach($regs2[1] as $attrid => $attr) {
foreach ($regs2[1] as $attrid => $attr) {
$attr = preg_replace('/[\s\t\n\r\0\x0B]/', '', $attr);
if ((list($key, $value) = explode('=', $attr)) && $value) {
if ($key == 'ENCODING') {
@ -752,7 +752,7 @@ class rcube_vcard
}
}
else {
foreach((array)$attrvalues as $attrvalue) {
foreach ((array)$attrvalues as $attrvalue) {
$attr .= strtoupper(";$attrname=") . self::vcard_quote($attrvalue, ',');
}
}
@ -785,7 +785,7 @@ class rcube_vcard
public static function vcard_quote($s, $sep = ';')
{
if (is_array($s)) {
foreach($s as $part) {
foreach ($s as $part) {
$r[] = self::vcard_quote($part, $sep);
}
return(implode($sep, (array)$r));

@ -656,7 +656,7 @@ function rcmail_contact_form($form, $record, $attrib = null)
if (is_array($colprop['subtypes'])) {
$values = $subtypes = array();
foreach (rcube_addressbook::get_col_values($field, $record) as $st => $vals) {
foreach((array)$vals as $value) {
foreach ((array)$vals as $value) {
$i = count($values);
$subtypes[$i] = $st;
$values[$i] = $value;

@ -121,7 +121,7 @@ function rcube_identity_form($attrib)
}
if (IDENTITIES_LEVEL == 4) {
foreach($form['addressing']['content'] as $formfield => $value){
foreach ($form['addressing']['content'] as $formfield => $value){
$form['addressing']['content'][$formfield]['disabled'] = true;
$form['addressing']['content'][$formfield]['class'] = 'disabled';
}

Loading…
Cancel
Save