diff --git a/util/download-imap.php b/util/download-imap.php index 392a0e7..fd15d86 100644 --- a/util/download-imap.php +++ b/util/download-imap.php @@ -103,7 +103,7 @@ $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 7d6351c..b10585c 100644 --- a/webui/Zend/Mail/Protocol/Imap.php +++ b/webui/Zend/Mail/Protocol/Imap.php @@ -410,7 +410,7 @@ $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 774274e..10b3c5a 100644 --- a/webui/controller/audit/helper.php +++ b/webui/controller/audit/helper.php @@ -99,7 +99,7 @@ $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 70498a0..5f22530 100644 --- a/webui/controller/search/helper.php +++ b/webui/controller/search/helper.php @@ -140,7 +140,7 @@ $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 f73027f..6fa7143 100644 --- a/webui/model/audit/audit.php +++ b/webui/model/audit/audit.php @@ -43,7 +43,7 @@ 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 df6ca08..d500159 100644 --- a/webui/model/google/google.php +++ b/webui/model/google/google.php @@ -76,7 +76,7 @@ $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 @@ } - syslog(LOG_INFO, "downloaded $count messages for $email"); + syslog(LOG_INFO, "downloaded $count messages for $email"); return $count; } @@ -174,5 +174,3 @@ } - -?> diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 9e5a1de..17e1b27 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -199,7 +199,7 @@ 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 @@ $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 6cbe403..0bfafc7 100644 --- a/webui/model/mail/mail.php +++ b/webui/model/mail/mail.php @@ -26,7 +26,7 @@ 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 37f98d0..2eac00d 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -213,7 +213,7 @@ $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 @@ 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 @@ $tokens = preg_split("/\ $token) { $pos = strpos($token, ">"); if($pos > 0) { @@ -245,7 +245,7 @@ $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 711d165..db489a1 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -16,7 +16,7 @@ $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 @@ $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 @@ 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 @@ $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 @@ $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 @@ 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 @@ $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 @@ $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 @@ $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 @@ 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 @@ $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 e52857b..42e8951 100644 --- a/webui/model/stat/chart.php +++ b/webui/model/stat/chart.php @@ -69,7 +69,7 @@ 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 072a04d..449205a 100644 --- a/webui/model/user/import.php +++ b/webui/model/user/import.php @@ -155,7 +155,7 @@ /* 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 690e188..1e7c6a9 100644 --- a/webui/system/controller.php +++ b/webui/system/controller.php @@ -27,7 +27,9 @@ 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 f3a1895..874bf48 100644 --- a/webui/system/database/mysql.php +++ b/webui/system/database/mysql.php @@ -53,7 +53,7 @@ $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 f45231b..108fedb 100644 --- a/webui/system/database/sphinx.php +++ b/webui/system/database/sphinx.php @@ -47,7 +47,7 @@ $R = $s->fetchAll(); - while(list ($k, $v) = each($R)){ + foreach($R as $k => $v) { $data[$i] = $v; $i++; } @@ -72,7 +72,7 @@ $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 793b1d8..9ff07dc 100644 --- a/webui/system/database/sqlite.php +++ b/webui/system/database/sqlite.php @@ -47,7 +47,7 @@ $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 04383b1..d50727d 100644 --- a/webui/system/helper/mime.php +++ b/webui/system/helper/mime.php @@ -255,7 +255,8 @@ } - 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 8dcce51..7233208 100644 --- a/webui/system/language.php +++ b/webui/system/language.php @@ -17,7 +17,7 @@ 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 @@ $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 5c35be1..b6192ab 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -196,7 +196,7 @@ $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 @@ $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 @@ 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 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 30ef75f..88c52a6 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 55385ed..26b706b 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 0638af3..2747263 100644 --- a/webui/view/theme/default/templates/policy/folder.tpl +++ b/webui/view/theme/default/templates/policy/folder.tpl @@ -91,7 +91,7 @@