mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:51:59 +01:00
Replaced most each() calls with foreach() in preparation to support php 8
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
7aec4647a5
commit
7a66346036
@ -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";
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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]; }
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -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]])) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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", "<span class=\"mssghglght\">$v</span>", $s);
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ class ModelSearchMessage extends Model {
|
||||
$tokens = preg_split("/\</", $s);
|
||||
$s = '';
|
||||
|
||||
while(list($k, $token) = each($tokens)) {
|
||||
foreach($tokens as $k => $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", "<span class=\"mssghglght\">$v</span>", $str);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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] = ""; }
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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]; }
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class SQLite {
|
||||
|
||||
$R = $s->fetchAll();
|
||||
|
||||
while(list ($k, $v) = each($R)){
|
||||
foreach($R as $k => $v) {
|
||||
$data[$i] = $v;
|
||||
$i++;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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=') {
|
||||
|
@ -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<strlen($v); $i++){
|
||||
@ -417,7 +417,7 @@ function parse_string_to_array($s = '', $arr = array()) {
|
||||
|
||||
parse_str($s, $a);
|
||||
|
||||
while(list($k, $v) = each($a)) {
|
||||
foreach($a as $k => $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 {
|
||||
|
@ -123,7 +123,7 @@
|
||||
<tr>
|
||||
<th colspan="2"><?php print $text_message_disposition; ?></th>
|
||||
</tr>
|
||||
<?php while(list($k, $v) = each($health['counters'])) {
|
||||
<?php foreach($health['counters'] as $k => $v) {
|
||||
if(!is_numeric($k)) { ?>
|
||||
<tr>
|
||||
<td><?php $a = preg_replace("/^_piler\:/", "", $k); if(isset($$a)) { print $$a; } else { print $k; } ?></td>
|
||||
|
@ -36,7 +36,7 @@
|
||||
<label class="control-label" for="ldap_type"><?php print $text_ldap_type; ?>:</label>
|
||||
<div class="controls">
|
||||
<select name="ldap_type" id="ldap_type" onchange="Piler.fix_ldap_display();" class="span4">
|
||||
<?php while(list($k, $v) = each($ldap_types)) { ?>
|
||||
<?php foreach($ldap_types as $k => $v) { ?>
|
||||
<option value="<?php print $v; ?>"<?php if(isset($a['ldap_type']) && $a['ldap_type'] == $v) { ?> selected="selected"<?php } ?>><?php print $v; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
@ -91,7 +91,7 @@
|
||||
<div class="controls">
|
||||
<select class="ruleselect" name="folder_id">
|
||||
<option value="0">-</option>
|
||||
<?php while(list($k,$v) = each($folders)) { ?>
|
||||
<?php foreach($folders as $k => $v) { ?>
|
||||
<option value="<?php print $k; ?>"><?php print $v; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
Loading…
Reference in New Issue
Block a user