示例#1
0
function processMessages($link,$max = 3000) {
	#error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
	global $bounce_mailbox_purge_unprocessed,$bounce_mailbox_purge;
  $num = imap_num_msg($link);
	print $num . " bounces to fetch from the mailbox<br/>\n";
  print "Please do not interrupt this process<br/>";
  $report = $num . " bounces to process\n";
  if ($num > $max) {
  	print "Processing first $max bounces<br/>";
	  $report .= $num . " processing first $max bounces\n";
    $num = $max;
  }
  if (TEST) {
    print "Running in test mode, not deleting messages from mailbox<br/>";
  } else {
    print "Processed messages will be deleted from mailbox<br/>";
  }
	print prepareOutput();
	print '<script language="Javascript" type="text/javascript"> yposition = 10;document.write(progressmeter); start();</script>';
  flush();
	$nberror = 0;
#	for ($x=1;$x<150;$x++) {
  for($x=1; $x <= $num; $x++) {
	  set_time_limit(60);
  	$header = imap_fetchheader($link,$x);
    if ($x % 25 == 0)
	#    output( $x . " ". nl2br($header));
  		output($x . " done",1);
    print "\n";
    flush();
    $processed = processBounce($link,$x,$header);
    if ($processed) {
			if (!TEST && $bounce_mailbox_purge) {
        if (VERBOSE)
		      output( "Deleting message $x");
	      imap_delete($link,$x);
   		}
    } else {
			if (!TEST && $bounce_mailbox_purge_unprocessed) {
        if (VERBOSE)
	        output( "Deleting message $x");
	      imap_delete($link,$x);
   		}
		}
    flush();
  }
	flush();
  output("Closing mailbox, and purging messages");
  set_time_limit(60 * $num);
	imap_close($link);
	print '<script language="Javascript" type="text/javascript"> finish(); </script>';
  if ($num)
  	return $report;
}
示例#2
0
function processMessages($link, $max = 3000)
{
    #error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
    global $bounce_mailbox_purge_unprocessed, $bounce_mailbox_purge;
    $num = imap_num_msg($link);
    output($num . " " . $GLOBALS['I18N']->get("bounces to fetch from the mailbox") . "\n");
    output($GLOBALS['I18N']->get("Please do not interrupt this process") . "\n");
    $report = $num . " " . $GLOBALS['I18N']->get("bounces to process") . "\n";
    if ($num > $max) {
        print $GLOBALS['I18N']->get("Processing first") . " {$max} " . $GLOBALS['I18N']->get("bounces") . "<br/>";
        $report .= $num . " " . $GLOBALS['I18N']->get("processing first") . " {$max} " . $GLOBALS['I18N']->get("bounces") . "\n";
        $num = $max;
    }
    if (TEST) {
        print $GLOBALS['I18N']->get("Running in test mode, not deleting messages from mailbox") . "<br/>";
    } else {
        print $GLOBALS['I18N']->get("Processed messages will be deleted from mailbox") . "<br/>";
    }
    $nberror = 0;
    #  for ($x=1;$x<150;$x++) {
    for ($x = 1; $x <= $num; $x++) {
        set_time_limit(60);
        $header = imap_fetchheader($link, $x);
        if ($x % 25 == 0) {
            #    output( $x . " ". nl2br($header));
            output($x . " done", 1);
        }
        print "\n";
        flush();
        $processed = processBounce($link, $x, $header);
        if ($processed) {
            if (!TEST && $bounce_mailbox_purge) {
                if (VERBOSE) {
                    output($GLOBALS['I18N']->get("Deleting message") . " {$x}");
                }
                imap_delete($link, $x);
            }
        } else {
            if (!TEST && $bounce_mailbox_purge_unprocessed) {
                if (VERBOSE) {
                    output($GLOBALS['I18N']->get("Deleting message") . " {$x}");
                }
                imap_delete($link, $x);
            }
        }
        flush();
    }
    flush();
    output($GLOBALS['I18N']->get("Closing mailbox, and purging messages"));
    set_time_limit(60 * $num);
    imap_close($link);
    #  print '<script language="Javascript" type="text/javascript"> finish(); </script>';
    if ($num) {
        return $report;
    }
}