diff --git a/util/download-imap.php b/util/download-imap.php index 392a0e76..fd15d86e 100644 --- a/util/download-imap.php +++ b/util/download-imap.php @@ -103,7 +103,7 @@ function saveMessages($storage, $folder = '', $num = 0) { $messages = $storage->piler_batch_fetch(1, $num); - while(list($k, $v) = each($messages)) { + foreach($messages as $k => $v) { $uuid = $storage->getUniqueId($k); $tmpname = "piler-" . $username . "-" . $folder . "-" . $k . "-" . $uuid . ".eml"; diff --git a/webui/Zend/Mail/Protocol/Imap.php b/webui/Zend/Mail/Protocol/Imap.php index 7d6351ca..b10585c2 100644 --- a/webui/Zend/Mail/Protocol/Imap.php +++ b/webui/Zend/Mail/Protocol/Imap.php @@ -410,7 +410,7 @@ class Zend_Mail_Protocol_Imap $a = $this->requestAndResponse("LIST", array('""', '"*"')); - while(list($k, $v) = each($a)) { + foreach ($a as $k => $v) { if($v[1][0] == '\HasNoChildren') { array_push($folders, $v[3]); } diff --git a/webui/controller/audit/helper.php b/webui/controller/audit/helper.php index 774274ec..10b3c5af 100644 --- a/webui/controller/audit/helper.php +++ b/webui/controller/audit/helper.php @@ -99,7 +99,7 @@ class ControllerAuditHelper extends Controller { $s = preg_replace("/\s{1,}/", " ", $s); $b = explode(" ", $s); - while(list($k, $v) = each($b)) { + foreach ($b as $k => $v) { if($v == '') { continue; } if(preg_match("/(login|loginfailed|logout|view|download|search|restore|journal)$/", $v) && isset($actions[$v])) { $this->a['action'] .= "\t" . $actions[$v]; } diff --git a/webui/controller/search/helper.php b/webui/controller/search/helper.php index 70498a0c..5f225308 100644 --- a/webui/controller/search/helper.php +++ b/webui/controller/search/helper.php @@ -140,7 +140,7 @@ class ControllerSearchHelper extends Controller { $s = preg_replace("/OR/", "|", $data['search']); $b = preg_split("/\s/", $s); - while(list($k, $v) = each($b)) { + foreach ($b as $k => $v) { if($v == '') { continue; } if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v) || preg_match("/\d{1,2}\/\d{1,2}\/\d{4}/", $v)) { diff --git a/webui/model/audit/audit.php b/webui/model/audit/audit.php index f73027f8..6fa71436 100644 --- a/webui/model/audit/audit.php +++ b/webui/model/audit/audit.php @@ -43,7 +43,7 @@ class ModelAuditAudit extends Model { if(Registry::get('admin_user') == 0 && RESTRICTED_AUDITOR == 1) { $auditdomains = $session->get("auditdomains"); - while(list($k, $v) = each($auditdomains)) { + foreach($auditdomains as $k => $v) { if($q) { $q .= ","; } $q .= "?"; array_push($arr, $v); diff --git a/webui/model/google/google.php b/webui/model/google/google.php index df6ca083..d5001597 100644 --- a/webui/model/google/google.php +++ b/webui/model/google/google.php @@ -76,7 +76,7 @@ class ModelGoogleGoogle extends Model { $messages = $storage->piler_batch_fetch($from, $to); - while(list($k, $v) = each($messages)) { + foreach($messages as $k => $v) { $uuid = $storage->getUniqueId($k); $tmpname = "piler-" . $email . "-" . $k . "-" . $uuid . ".eml"; @@ -98,7 +98,7 @@ class ModelGoogleGoogle extends Model { } - syslog(LOG_INFO, "downloaded $count messages for $email"); + syslog(LOG_INFO, "downloaded $count messages for $email"); return $count; } @@ -174,5 +174,3 @@ class ModelGoogleGoogle extends Model { } - -?> diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 9e5a1de0..17e1b27d 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -199,7 +199,7 @@ class ModelHealthHealth extends Model { public function meminfo() { $m = explode("\n", file_get_contents("/proc/meminfo")); - while(list($k, $v) = each($m)) { + foreach($m as $k => $v) { $a = preg_split("/\ {1,}/", $v); if(isset($a[0]) && $a[0]) { $_m[$a[0]] = $a[1]; } } @@ -219,7 +219,7 @@ class ModelHealthHealth extends Model { $partitions = Registry::get('partitions_to_monitor'); - while(list($k, $v) = each($output)) { + foreach($output as $k => $v) { if($k > 0) { $p = preg_split("/\ {1,}/", $v); if(isset($p[5]) && in_array($p[5], $partitions) && !isset($a[$p[5]])) { diff --git a/webui/model/mail/mail.php b/webui/model/mail/mail.php index 6cbe4034..0bfafc7b 100644 --- a/webui/model/mail/mail.php +++ b/webui/model/mail/mail.php @@ -26,7 +26,7 @@ class ModelMailMail extends Model { fputs($r, "MAIL FROM: <$from>\r\n"); $l = fgets($r, 4096); - while(list($k, $v) = each($to)) { + foreach($to as $k => $v) { fputs($r, "RCPT TO: <$v>\r\n"); $l = fgets($r, 4096); } diff --git a/webui/model/search/message.php b/webui/model/search/message.php index 37f98d01..2eac00d0 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -213,7 +213,7 @@ class ModelSearchMessage extends Model { $a = explode(" ", $terms); $terms = array(); - while(list($k, $v) = each($a)) { + foreach($a as $k => $v) { if(strlen($v) >= 3 && !in_array($v, $fields)) { $v = preg_replace("/\*/", "", $v); if($v) { array_push($terms, $v); } @@ -223,7 +223,7 @@ class ModelSearchMessage extends Model { if(count($terms) <= 0) { return $s; } if($html == 0) { - while(list($k, $v) = each($terms)) { + foreach($terms as $k => $v) { $s = preg_replace("/$v/i", "$v", $s); } @@ -233,7 +233,7 @@ class ModelSearchMessage extends Model { $tokens = preg_split("/\ $token) { $pos = strpos($token, ">"); if($pos > 0) { @@ -245,7 +245,7 @@ class ModelSearchMessage extends Model { $str = substr($token, $pos+1, $len); reset($terms); - while(list($k, $v) = each($terms)) { + foreach($terms as $k => $v) { $str = preg_replace("/$v/i", "$v", $str); } diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 711d1654..db489a16 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -16,7 +16,7 @@ class ModelSearchSearch extends Model { $session = Registry::get('session'); - while(list($k,$v) = each($data)) { + foreach($data as $k => $v) { if($v) { if(is_array($v)) { $v = implode(" ", $v); } $s .= '&' . $k . '=' . $v; } } @@ -113,7 +113,7 @@ class ModelSearchSearch extends Model { $session = Registry::get('session'); $i = 0; - while(list($k, $v) = each($data['match'])) { + foreach($data['match'] as $k => $v) { if($v == "@attachment_types") { list($k, $v) = each($data['match']); $i++; @@ -199,7 +199,7 @@ class ModelSearchSearch extends Model { if(ENABLE_FOLDER_RESTRICTIONS == 1) { $s = explode(" ", $data['folders']); - while(list($k,$v) = each($s)) { + foreach($s as $k => $v) { if(in_array($v, $session->get("folders"))) { array_push($__folders, $v); } @@ -347,7 +347,7 @@ class ModelSearchSearch extends Model { $s = preg_replace("/httpX/", "http:", $s); $b = explode(" ", $s); - while(list($k, $v) = each($b)) { + foreach($b as $k => $v) { if($v == '') { continue; } if($v == 'from:') { $token = 'match'; $a['match'][] = FROM_TOKEN; continue; } @@ -441,7 +441,7 @@ class ModelSearchSearch extends Model { $offset = $page * $pagelen; $s = explode(" ", $extra_folders); - while(list($k,$v) = each($s)) { + foreach($s as $k => $v) { if(in_array($v, $session->get("extra_folders")) && is_numeric($v)) { array_push($__folders, $v); if($q) { $q .= ",?"; } @@ -649,7 +649,7 @@ class ModelSearchSearch extends Model { if(!$emails) { return $s; } - while(list($k, $v) = each($emails)) { + foreach($emails as $k => $v) { if($s) { $s .= '| ' . $this->fix_email_address_for_sphinx($v); } else { $s = $this->fix_email_address_for_sphinx($v); } } @@ -704,7 +704,7 @@ class ModelSearchSearch extends Model { $auditdomains = $session->get("auditdomains"); - while(list($k, $v) = each($auditdomains)) { + foreach($auditdomains as $k => $v) { if(validdomain($v) == 1 && !in_array($v, $a)) { $q .= ",?"; array_push($a, $v); @@ -720,7 +720,7 @@ class ModelSearchSearch extends Model { $emails = $session->get("emails"); - while(list($k, $v) = each($emails)) { + foreach($emails as $k => $v) { if(validemail($v) == 1) { $q .= ",?"; array_push($a, $v); @@ -776,7 +776,7 @@ class ModelSearchSearch extends Model { $auditdomains = $session->get("auditdomains"); - while(list($k, $v) = each($auditdomains)) { + foreach($auditdomains as $k => $v) { if(validdomain($v) == 1 && !in_array($v, $a)) { $q .= ",?"; array_push($a, $v); @@ -787,7 +787,7 @@ class ModelSearchSearch extends Model { if(Registry::get('auditor_user') == 0) { $emails = $session->get("emails"); - while(list($k, $v) = each($emails)) { + foreach($emails as $k => $v) { if(validemail($v) == 1) { $q .= ",?"; array_push($a, $v); @@ -915,7 +915,7 @@ class ModelSearchSearch extends Model { $a = explode(" ", $s); $s = ''; - while(list($k, $v) = each($a)) { + foreach($a as $k => $v) { if(substr($v, 0, 4) == 'http') { $v = preg_replace("/http(s){0,1}\:\/\//", "__URL__", $v); diff --git a/webui/model/stat/chart.php b/webui/model/stat/chart.php index e52857bc..42e8951b 100644 --- a/webui/model/stat/chart.php +++ b/webui/model/stat/chart.php @@ -69,7 +69,7 @@ class ModelStatChart extends Model { if($query->num_rows >= 15) { $i = 0; - while(list($k, $v) = each($dates)) { + foreach($dates as $k => $v) { $i++; if($i % 3) { $dates[$k] = ""; } } diff --git a/webui/model/user/import.php b/webui/model/user/import.php index 072a04da..449205a0 100644 --- a/webui/model/user/import.php +++ b/webui/model/user/import.php @@ -155,7 +155,7 @@ class ModelUserImport extends Model { /* build a list of DNs to exclude from the import */ - while (list($k, $v) = each($globals)) { + foreach($globals as $k => $v) { if(preg_match("/^reject_/", $k)) { $exclude[$v] = $v; } diff --git a/webui/system/controller.php b/webui/system/controller.php index 690e1880..1e7c6a99 100644 --- a/webui/system/controller.php +++ b/webui/system/controller.php @@ -27,7 +27,9 @@ class Controller { public function args($args = array()){ - while(list($key, $value) = each($args)) $this->data[$key] = $value; + foreach($args as $key => $value) { + $this->data[$key] = $value; + } } diff --git a/webui/system/database/mysql.php b/webui/system/database/mysql.php index f3a1895c..874bf48b 100644 --- a/webui/system/database/mysql.php +++ b/webui/system/database/mysql.php @@ -53,7 +53,7 @@ class MySQL { $R = $s->fetchAll(PDO::FETCH_ASSOC); - while(list ($k, $v) = each($R)){ + foreach($R as $k => $v) { $data[$i] = $v; $i++; } diff --git a/webui/system/database/sphinx.php b/webui/system/database/sphinx.php index f45231b8..108fedbd 100644 --- a/webui/system/database/sphinx.php +++ b/webui/system/database/sphinx.php @@ -47,7 +47,7 @@ class Sphinx { $R = $s->fetchAll(); - while(list ($k, $v) = each($R)){ + foreach($R as $k => $v) { $data[$i] = $v; $i++; } @@ -72,7 +72,7 @@ class Sphinx { $meta->execute(); $R = $meta->fetchAll(); - while(list ($k, $v) = each($R)){ + foreach($R as $k => $v) { if($v[0] == "total_found") { $query->total_found = $v[1]; } } diff --git a/webui/system/database/sqlite.php b/webui/system/database/sqlite.php index 793b1d84..9ff07dc4 100644 --- a/webui/system/database/sqlite.php +++ b/webui/system/database/sqlite.php @@ -47,7 +47,7 @@ class SQLite { $R = $s->fetchAll(); - while(list ($k, $v) = each($R)){ + foreach($R as $k => $v) { $data[$i] = $v; $i++; } diff --git a/webui/system/helper/mime.php b/webui/system/helper/mime.php index 04383b13..d50727de 100644 --- a/webui/system/helper/mime.php +++ b/webui/system/helper/mime.php @@ -255,7 +255,8 @@ class Piler_Mime_Decode { } - while(list($k, $v) = each($result)) { + foreach($result as $k => $v) { + if(strchr($v, "\n")) { $result[$k] = explode("\n", $v); } diff --git a/webui/system/language.php b/webui/system/language.php index 8dcce51c..72332080 100644 --- a/webui/system/language.php +++ b/webui/system/language.php @@ -17,7 +17,7 @@ class Language { else { $pref_langs = $this->get_preferred_languages(); - while(list($k, $v) = each($pref_langs)) { + foreach($pref_langs as $k => $v) { if(in_array($v, $langs)) { $lang = $v; define('LANG', $lang); @@ -53,7 +53,8 @@ class Language { $l = explode(";", $_SERVER['HTTP_ACCEPT_LANGUAGE']); - while(list($k, $v) = each($l)) { + foreach($l as $k => $v) { + $a = explode(",", $v); if(isset($a[0]) && substr($a[0], 0, 2) != 'q=') { diff --git a/webui/system/misc.php b/webui/system/misc.php index 5c35be15..b6192ab8 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -196,7 +196,7 @@ function first_n_characters($what, $n){ $len = 0; $a = explode(" ", $what); - while(list($k, $v) = each($a)){ + foreach($a as $k => $v) { $x .= "$v "; $len += strlen($v) + 1; if($len >= $n){ return $x . "..."; } } @@ -279,7 +279,7 @@ function my_qp_encode($s){ $res = ""; $a = explode("\n", $s); - while(list($k, $v) = each($a)){ + foreach($a as $k => $v) { $part = ""; for($i=0; $i $v) { if(!isset($arr[$k]) || $arr[$k] == '') $arr[$k] = $v; } @@ -453,7 +453,7 @@ function convert_date_string_to_ymd_by_template($date_string, $date_template) { return [$Y, $m, $d]; } - while(list($k, $v) = each($template_array)) { + foreach($template_array as $k => $v) { $$v = $date_array[$k]; } @@ -613,7 +613,7 @@ function get_ldap_attribute_names($ldap_type = '') { function htmlentities_on_array($arr = []) { - while(list($k, $v) = each($arr)) { + foreach($arr as $k => $v) { if(is_array($v)) { $arr[$k] = htmlentities_on_array($v); } else { diff --git a/webui/view/theme/default/templates/health/worker.tpl b/webui/view/theme/default/templates/health/worker.tpl index 30ef75f4..88c52a61 100644 --- a/webui/view/theme/default/templates/health/worker.tpl +++ b/webui/view/theme/default/templates/health/worker.tpl @@ -123,7 +123,7 @@ - $v) { if(!is_numeric($k)) { ?> diff --git a/webui/view/theme/default/templates/ldap/list.tpl b/webui/view/theme/default/templates/ldap/list.tpl index 55385edb..26b706bf 100644 --- a/webui/view/theme/default/templates/ldap/list.tpl +++ b/webui/view/theme/default/templates/ldap/list.tpl @@ -36,7 +36,7 @@
diff --git a/webui/view/theme/default/templates/policy/folder.tpl b/webui/view/theme/default/templates/policy/folder.tpl index 0638af31..27472638 100644 --- a/webui/view/theme/default/templates/policy/folder.tpl +++ b/webui/view/theme/default/templates/policy/folder.tpl @@ -91,7 +91,7 @@