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;
}
Exemple #2
0
{
}
if (!function_exists('imap_open')) {
    Error($GLOBALS['I18N']->get('IMAP is not included in your PHP installation, cannot continue') . '<br/>' . $GLOBALS['I18N']->get('Check out') . ' <a href="http://www.php.net/manual/en/ref.imap.php">http://www.php.net/manual/en/ref.imap.php</a>');
    return;
}
//print '<script language="Javascript" src="js/progressbar.js" type="text/javascript"></script>';
flush();
$outputdone = 0;
# lets not do this unless we do some locking first
register_shutdown_function('processTestEmails_shutdown');
$abort = ignore_user_abort(1);
$process_id = getPageLock();
if (!empty($_REQUEST['email'])) {
    $mailToFind = $_REQUEST['email'];
    print prepareOutput();
    switch ($test_protocol) {
        case "pop":
            $link = openPop($test_mailbox_host, $test_mailbox_user, $test_mailbox_password);
            break;
        case "mbox":
            $link = openMbox($test_mailbox);
            break;
        default:
            Error($GLOBALS['I18N']->get("test_protocol not supported"));
            return;
    }
    if (isset($link)) {
        $mailIndex = findEmailForUser($link, $mailToFind);
        if (!is_null($mailIndex)) {
            $body = imap_body($link, $mailIndex);
function prepareOutput($dirContent, $level = 0)
{
    $result = '';
    if ($level > SHOW_LEVELS) {
        // Don't show more than SHOW_LEVELS levels
        return '';
    }
    // Process files
    if (isset($dirContent['FILES']) && $dirContent['FILES']) {
        ksort($dirContent['FILES']);
        // Sort files
        foreach ($dirContent['FILES'] as $key => $val) {
            $result .= formatOutput($key, $val, $level);
        }
    } else {
        if (SHOW_EMPTY) {
            // Add 'empty' string if dir is empty
            $result .= str_repeat(LEVEL_CHAR, $level) . ' ' . EMPTY_SIGN . NEW_REC;
        }
    }
    // Process dirs
    if (isset($dirContent['DIRS']) && $dirContent['DIRS']) {
        ksort($dirContent['DIRS']);
        // Sort dirs
        foreach ($dirContent['DIRS'] as $key => $val) {
            $result .= formatOutput($key, $val['SIZE'], $level);
            $result .= prepareOutput($val, $level + 1);
        }
    }
    return $result;
}