Don't use each() deprecated in PHP 7.2

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

@ -673,8 +673,7 @@ echo $select_param_folding->show(strval($RCI->getprop('mime_param_folding')));
<?php <?php
$plugins = $RCI->list_plugins(); $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'])); $p_check = new html_checkbox(array('name' => '_plugins_'.$p['name'], 'id' => 'cfgplugin_'.$p['name'], 'value' => $p['name']));
echo '<dt class="propname"><label>'; echo '<dt class="propname"><label>';
echo $p_check->show($p['enabled'] ? $p['name'] : 0); 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()); $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); $this->runlog->set_file(rcmail::get_instance()->config->get('log_dir').'/'.$file, $type);
} }

@ -68,7 +68,7 @@ class runlog {
$this->indent--; $this->indent--;
if ($this->run_log[$lastk]['duration'] >= $this->threshold) { if ($this->run_log[$lastk]['duration'] >= $this->threshold) {
$tag_report = ""; $tag_report = "";
foreach($this->tag_count as $tag => $count){ foreach ($this->tag_count as $tag => $count){
$tag_report .= "$tag: $count, "; $tag_report .= "$tag: $count, ";
} }
if (!empty($tag_report)) { 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) public function get($params = null, $filename = null, $skip_head = false)
{ {
if (isset($params)) { if (!empty($params)) {
while (list($key, $value) = each($params)) { foreach ($params as $key => $value) {
$this->build_params[$key] = $value; $this->build_params[$key] = $value;
} }
} }

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

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

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

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

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

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

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

@ -125,7 +125,8 @@ class rcube_message
$this->mime = new rcube_mime($this->headers->charset); $this->mime = new rcube_mime($this->headers->charset);
$this->subject = $this->headers->get('subject'); $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 // notify plugins and let them analyze this structured message object
$this->app->plugins->exec_hook('message_load', array('object' => $this)); $this->app->plugins->exec_hook('message_load', array('object' => $this));

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

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

@ -633,7 +633,7 @@ class rcube_utils
$proxy_whitelist = rcube::get_instance()->config->get('proxy_whitelist', array()); $proxy_whitelist = rcube::get_instance()->config->get('proxy_whitelist', array());
if (in_array($_SERVER['REMOTE_ADDR'], $proxy_whitelist)) { if (in_array($_SERVER['REMOTE_ADDR'], $proxy_whitelist)) {
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 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)) { if (!in_array($forwarded_ip, $proxy_whitelist)) {
return $forwarded_ip; return $forwarded_ip;
} }

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

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

@ -121,7 +121,7 @@ function rcube_identity_form($attrib)
} }
if (IDENTITIES_LEVEL == 4) { 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]['disabled'] = true;
$form['addressing']['content'][$formfield]['class'] = 'disabled'; $form['addressing']['content'][$formfield]['class'] = 'disabled';
} }

Loading…
Cancel
Save