Example #1
0
function processbounces_shutdown()
{
    global $report, $process_id;
    releaseLock($process_id);
    # $report .= "Connection status:".connection_status();
    finishBounceProcessing('info', $report);
}
Example #2
0
function processTestEmails_shutdown()
{
    global $report, $process_id;
    releaseLock($process_id);
    # $report .= "Connection status:".connection_status();
    finish('info', $report);
    if (!$GLOBALS["commandline"]) {
        include_once dirname(__FILE__) . '/footer.inc';
    }
}
Example #3
0
function finish ($flag = "info",$message = "finished") {
	global $nothingtodo,$failreport,$mailreport,$process_id;
  if ($flag == "error") {
    $subject = "Rss Errors";
  } else {
    $subject = "Rss Results";
  }
  releaseLock($process_id);
  if (!TEST && !$nothingtodo) {
  	if ($mailreport)
      sendReport($subject,$mailreport);
    if ($failreport)
	    sendReport("Rss Failure report",$failreport);
  }
}
function finish($flag = "info", $message = 'finished')
{
    global $nothingtodo, $failreport, $mailreport, $process_id;
    if ($flag == 'error') {
        $subject = $GLOBALS['I18N']->get('Rss Errors');
    } else {
        $subject = $GLOBALS['I18N']->get('Rss Results');
    }
    releaseLock($process_id);
    if (!TEST && !$nothingtodo) {
        if ($mailreport) {
            sendReport($subject, $mailreport);
        }
        if ($failreport) {
            sendReport($GLOBALS['I18N']->get('Rss Failure report'), $failreport);
        }
    }
}
Example #5
0
function my_shutdown () {
	global $script_stage,$reload;
	output( "Script status: ".connection_status(),0); # with PHP 4.2.1 buggy. http://bugs.php.net/bug.php?id=17774
	output( "Script stage: ".$script_stage,0);
  global $report,$send_process_id,$tables,$nothingtodo,$invalid,$notsent,$sent,$unconfirmed;
  $some = $sent || $invalid || $notsent;
	if (!$some) {
		output("Finished, Nothing to do",0);
		$nothingtodo = 1;
	}

	if ($script_stage == 6)
		output("Finished, All done",0);
	else
		output("Finished, Processing was interrupted, reload required");

	output(sprintf('%d messages sent and %d messages skipped',$sent,$notsent),$sent);
	if ($invalid)
		output(sprintf('%d invalid emails',$invalid));
	if ($unconfirmed)
		output(sprintf('%d emails unconfirmed (not sent)',$unconfirmed));

  releaseLock($send_process_id);

  finish("info",$report);
	if ($script_stage < 5) {
		output ("Warning: script never reached stage 5\nIt is likely that the selection process is too slow. You either need a new webserver or a new ISP!\n");
	} elseif( $script_stage == 5)	{
		# if the script timed out in stage 5, reload the page to continue with the rest
    $reload++;
		printf( '<script language="Javascript" type="text/javascript">
 			var query = window.location.search;
			query = query.replace(/&reload=\d+/,"");
			query = query.replace(/&lastsent=\d+/,"");
			query = query.replace(/&lastskipped=\d+/,"");
			document.location = document.location.pathname + query + "&reload=%d&lastsent=%d&lastskipped=%d";
     </script>',$reload,$sent,$notsent);
	#	print '<script language="Javascript" type="text/javascript">alert(document.location)</script>';
	}
}
Example #6
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['file']) || empty($params['source'])) {
        echo <<<EOT
Usage: {$argv['0']} --file=... --source=... [...]

Parameters:

--file              The file or wildcard pattern of files of records
--source            Source ID
--verbose           Enable verbose output
--config.section.name=value
                   Set configuration directive to given value overriding any
                   setting in recordmanager.ini
--lockfile=file    Use a lock file to avoid executing the command multiple times in
                   parallel (useful when running from crontab)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $manager->loadFromFile($params['source'], $params['file']);
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
function my_shutdown()
{
    global $script_stage, $reload;
    #  output( "Script status: ".connection_status(),0); # with PHP 4.2.1 buggy. http://bugs.php.net/bug.php?id=17774
    output($GLOBALS['I18N']->get('Script stage') . ': ' . $script_stage, 0);
    global $report, $send_process_id, $tables, $nothingtodo, $invalid, $processed, $failed_sent, $notsent, $sent, $unconfirmed, $num_per_batch, $batch_period, $num_users;
    $some = $processed;
    #$sent;# || $invalid || $notsent;
    if (!$some) {
        output($GLOBALS['I18N']->get('Finished, Nothing to do'), 0);
        $nothingtodo = 1;
    }
    $totaltime = $GLOBALS['processqueue_timer']->elapsed(1);
    $msgperhour = 3600 / $totaltime * $sent;
    if ($sent) {
        output(sprintf('%d %s %01.2f %s (%d %s)', $sent, $GLOBALS['I18N']->get('messages sent in'), $totaltime, $GLOBALS['I18N']->get('seconds'), $msgperhour, $GLOBALS['I18N']->get('msgs/hr')), $sent);
    }
    if ($invalid) {
        output(sprintf('%d %s', $invalid, $GLOBALS['I18N']->get('invalid emails')));
    }
    if ($failed_sent) {
        output(sprintf('%d %s', $failed_sent, $GLOBALS['I18N']->get('emails failed (will retry later)')));
    }
    if ($unconfirmed) {
        output(sprintf('%d %s', $unconfirmed, $GLOBALS['I18N']->get('emails unconfirmed (not sent)')));
    }
    releaseLock($send_process_id);
    finish("info", $report);
    if ($script_stage < 5 && !$nothingtodo) {
        output($GLOBALS['I18N']->get('Warning: script never reached stage 5') . "\n" . $GLOBALS['I18N']->get('This may be caused by a too slow or too busy server') . " \n");
    } elseif ($script_stage == 5 && (!$nothingtodo || $GLOBALS["wait"])) {
        # if the script timed out in stage 5, reload the page to continue with the rest
        $reload++;
        if (!$GLOBALS["commandline"] && $num_per_batch && $batch_period) {
            if ($sent + 10 < $GLOBALS["original_num_per_batch"] && !$GLOBALS["wait"]) {
                output($GLOBALS['I18N']->get('Less than batch size were sent, so reloading imminently'));
                $delaytime = 10000;
            } else {
                output(sprintf($GLOBALS['I18N']->get('Waiting for %d seconds before reloading'), $batch_period));
                $delaytime = $batch_period * 1000;
            }
            //output("Do not reload this page yourself, because the next batch would fail");
            printf('<script language="Javascript" type="text/javascript">
        function reload() {
          var query = window.location.search;
          query = query.replace(/&reload=\\d+/,"");
          query = query.replace(/&lastsent=\\d+/,"");
          query = query.replace(/&lastskipped=\\d+/,"");
          document.location = document.location.pathname + query + "&reload=%d&lastsent=%d&lastskipped=%d";
        }
        setTimeout("reload()",%d);
      </script>', $reload, $sent, $notsent, $delaytime);
        } else {
            printf('<script language="Javascript" type="text/javascript">
        var query = window.location.search;
        query = query.replace(/&reload=\\d+/,"");
        query = query.replace(/&lastsent=\\d+/,"");
        query = query.replace(/&lastskipped=\\d+/,"");
        document.location = document.location.pathname + query + "&reload=%d&lastsent=%d&lastskipped=%d";
      </script>', $reload, $sent, $notsent);
            output($GLOBALS['I18N']->get($processed < $num_users ? 'Reload required' : ''));
        }
        #  print '<script language="Javascript" type="text/javascript">alert(document.location)</script>';
    } elseif ($script_stage == 6 || $nothingtodo) {
        output($GLOBALS['I18N']->get('Finished, All done'), 0);
    } else {
        output($GLOBALS['I18N']->get('Script finished, but not all messages have been sent yet.'));
    }
    if (!$GLOBALS['commandline']) {
        include_once "footer.inc";
    }
    exit;
}
Example #8
0
function my_shutdown()
{
    global $script_stage, $reload;
    #  processQueueOutput( "Script status: ".connection_status(),0); # with PHP 4.2.1 buggy. http://bugs.php.net/bug.php?id=17774
    processQueueOutput(s('Script stage') . ': ' . $script_stage, 0, 'progress');
    global $counters, $report, $send_process_id, $tables, $nothingtodo, $processed, $notsent, $unconfirmed, $batch_period;
    $some = $processed;
    $delaytime = 0;
    if (!$some) {
        processQueueOutput($GLOBALS['I18N']->get('Finished, Nothing to do'), 0, 'progress');
        $nothingtodo = 1;
    }
    $totaltime = $GLOBALS['processqueue_timer']->elapsed(1);
    if ($totaltime > 0) {
        $msgperhour = 3600 / $totaltime * $counters['sent'];
    } else {
        $msgperhour = s('Calculating');
    }
    if ($counters['sent']) {
        processQueueOutput(sprintf('%d %s %01.2f %s (%d %s)', $counters['sent'], $GLOBALS['I18N']->get('messages sent in'), $totaltime, $GLOBALS['I18N']->get('seconds'), $msgperhour, $GLOBALS['I18N']->get('msgs/hr')), $counters['sent'], 'progress');
    }
    if ($counters['invalid']) {
        processQueueOutput(s('%d invalid email addresses', $counters['invalid']), 1, 'progress');
    }
    if ($counters['failed_sent']) {
        processQueueOutput(s('%d failed (will retry later)', $counters['failed_sent']), 1, 'progress');
        foreach ($counters as $label => $value) {
            #  processQueueOutput(sprintf('%d %s',$value,$GLOBALS['I18N']->get($label)),1,'progress');
            cl_output(sprintf('%d %s', $value, $GLOBALS['I18N']->get($label)));
        }
    }
    if ($unconfirmed) {
        processQueueOutput(sprintf($GLOBALS['I18N']->get('%d emails unconfirmed (not sent)'), $unconfirmed), 1, 'progress');
    }
    foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
        $plugin->processSendStats($counters['sent'], $counters['invalid'], $counters['failed_sent'], $unconfirmed, $counters);
    }
    flushClickTrackCache();
    releaseLock($send_process_id);
    finish('info', $report, $script_stage);
    if ($script_stage < 5 && !$nothingtodo) {
        processQueueOutput($GLOBALS['I18N']->get('Warning: script never reached stage 5') . "\n" . $GLOBALS['I18N']->get('This may be caused by a too slow or too busy server') . " \n");
    } elseif ($script_stage == 5 && (!$nothingtodo || isset($GLOBALS['wait']))) {
        # if the script timed out in stage 5, reload the page to continue with the rest
        ++$reload;
        if (!$GLOBALS['commandline'] && $counters['num_per_batch'] && $batch_period) {
            if ($counters['sent'] + 10 < $GLOBALS['original_num_per_batch']) {
                processQueueOutput($GLOBALS['I18N']->get('Less than batch size were sent, so reloading imminently'), 1, 'progress');
                $counters['delaysend'] = 10;
            } else {
                $counters['delaysend'] = (int) ($batch_period - $totaltime);
                $delaytime = 30;
                ## actually with the iframe we can reload fairly quickly
                processQueueOutput(s('Waiting for %d seconds before reloading', $delaytime), 1, 'progress');
            }
        }
        $counters['delaysend'] = (int) ($batch_period - $totaltime);
        if (empty($GLOBALS['inRemoteCall']) && empty($GLOBALS['commandline'])) {
            sleep($delaytime);
            printf('<script type="text/javascript">
          document.location = "./?page=pageaction&action=processqueue&ajaxed=true&reload=%d&lastsent=%d&lastskipped=%d%s";
        </script></body></html>', $reload, $counters['sent'], $notsent, addCsrfGetToken());
        }
    } elseif ($script_stage == 6 || $nothingtodo) {
        foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
            $plugin->messageQueueFinished();
        }
        processQueueOutput($GLOBALS['I18N']->get('Finished, All done'), 0);
        print '<script type="text/javascript">
      var parentJQuery = window.parent.jQuery;
      window.parent.allDone("' . s('All done') . '");
      </script>';
    } else {
        processQueueOutput(s('Script finished, but not all messages have been sent yet.'));
    }
    if (!empty($GLOBALS['inRemoteCall'])) {
        ob_end_clean();
        print outputCounters();
        @ob_start();
    }
    if (empty($GLOBALS['inRemoteCall']) && empty($GLOBALS['commandline']) && empty($_GET['ajaxed'])) {
        return;
    } elseif (!empty($GLOBALS['inRemoteCall']) || !empty($GLOBALS['commandline'])) {
        @ob_end_clean();
    }
    exit;
}
Example #9
0
function my_shutdown()
{
    global $script_stage, $reload;
    #  output( "Script status: ".connection_status(),0); # with PHP 4.2.1 buggy. http://bugs.php.net/bug.php?id=17774
    output($GLOBALS['I18N']->get('Script stage') . ': ' . $script_stage, 0, 'progress');
    global $counters, $report, $send_process_id, $tables, $nothingtodo, $invalid, $processed, $failed_sent, $notsent, $sent, $unconfirmed, $num_per_batch, $batch_period, $counters;
    $some = $processed;
    #$sent;# || $invalid || $notsent;
    if (!$some) {
        output($GLOBALS['I18N']->get('Finished, Nothing to do'), 0, 'progress');
        $nothingtodo = 1;
    }
    $totaltime = $GLOBALS['processqueue_timer']->elapsed(1);
    if ($totaltime > 0) {
        $msgperhour = 3600 / $totaltime * $sent;
    } else {
        $msgperhour = s('Calculating');
    }
    if ($sent) {
        output(sprintf('%d %s %01.2f %s (%d %s)', $sent, $GLOBALS['I18N']->get('messages sent in'), $totaltime, $GLOBALS['I18N']->get('seconds'), $msgperhour, $GLOBALS['I18N']->get('msgs/hr')), $sent, 'progress');
    }
    if ($invalid) {
        output(s('%d invalid email addresses', $invalid), 1, 'progress');
    }
    if ($failed_sent) {
        output(s('%d failed (will retry later)', $failed_sent), 1, 'progress');
        foreach ($counters as $label => $value) {
            #  output(sprintf('%d %s',$value,$GLOBALS['I18N']->get($label)),1,'progress');
            cl_output(sprintf('%d %s', $value, $GLOBALS['I18N']->get($label)));
        }
    }
    if ($unconfirmed) {
        output(sprintf($GLOBALS['I18N']->get('%d emails unconfirmed (not sent)'), $unconfirmed), 1, 'progress');
    }
    foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
        $plugin->processSendStats($sent, $invalid, $failed_sent, $unconfirmed, $counters);
    }
    flushClickTrackCache();
    releaseLock($send_process_id);
    finish("info", $report, $script_stage);
    if ($script_stage < 5 && !$nothingtodo) {
        output($GLOBALS['I18N']->get('Warning: script never reached stage 5') . "\n" . $GLOBALS['I18N']->get('This may be caused by a too slow or too busy server') . " \n");
    } elseif ($script_stage == 5 && (!$nothingtodo || isset($GLOBALS["wait"]))) {
        # if the script timed out in stage 5, reload the page to continue with the rest
        $reload++;
        if (!$GLOBALS["commandline"] && $num_per_batch && $batch_period) {
            if ($sent + 10 < $GLOBALS["original_num_per_batch"]) {
                output($GLOBALS['I18N']->get('Less than batch size were sent, so reloading imminently'), 1, 'progress');
                $delaytime = 10;
            } else {
                // we should actually want batch perion minus time already spent.
                // might be nice to calculate that at some point
                output(sprintf($GLOBALS['I18N']->get('Waiting for %d seconds before reloading'), $batch_period), 1, 'progress');
                $delaytime = $batch_period;
            }
            sleep($delaytime);
            printf('<script type="text/javascript">
        document.location = "./?page=pageaction&action=processqueue&ajaxed=true&reload=%d&lastsent=%d&lastskipped=%d";
      </script>', $reload, $sent, $notsent);
        } else {
            printf('<script type="text/javascript">
        document.location = "./?page=pageaction&action=processqueue&ajaxed=true&reload=%d&lastsent=%d&lastskipped=%d";
      </script>', $reload, $sent, $notsent);
        }
    } elseif ($script_stage == 6 || $nothingtodo) {
        foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
            $plugin->messageQueueFinished();
        }
        output($GLOBALS['I18N']->get('Finished, All done'), 0);
        print '<script type="text/javascript">
      var parentJQuery = window.parent.jQuery;
      window.parent.allDone("' . s('All done') . '");
      </script>';
    } else {
        output(s('Script finished, but not all messages have been sent yet.'));
    }
    if (empty($GLOBALS['commandline']) && empty($_GET['ajaxed'])) {
        include_once "footer.inc";
    } elseif (!empty($GLOBALS['commandline'])) {
        @ob_end_clean();
    }
    exit;
}
Example #10
0
#!/usr/bin/php
<?php 
define("SQUID_ROOT", dirname(__FILE__));
require_once SQUID_ROOT . "/common.php";
// clean up all of the iptables chains we administer
getLock();
iptablesUpdate();
releaseLock();
Example #11
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['func']) || !is_string($params['func'])) {
        echo <<<EOT
Usage: {$argv['0']} --func=... [...]

Parameters:

--func             renormalize|deduplicate|updatesolr|dump|dumpsolr|markdeleted
                   |deletesource|deletesolr|optimizesolr|count|checkdedup|comparesolr
                   |purgedeleted|markdedup
--source           Source ID to process (separate multiple sources with commas)
--all              Process all records regardless of their state (deduplicate,
                   markdedup)
                   or date (updatesolr)
--from             Override the date from which to run the update (updatesolr)
--single           Process only the given record id (deduplicate, updatesolr, dump)
--nocommit         Don't ask Solr to commit the changes (updatesolr)
--field            Field to analyze (count)
--force            Force deletesource to proceed even if deduplication is enabled for
                   the source
--verbose          Enable verbose output for debugging
--config.section.name=value
                   Set configuration directive to given value overriding any setting
                   in recordmanager.ini
--lockfile=file    Use a lock file to avoid executing the command multiple times in
                   parallel (useful when running from crontab)
--comparelog       Record comparison output file. N.B. The file will be overwritten
                   (comparesolr)
--dumpprefix       File name prefix to use when dumping records (dumpsolr). Default
                   is "dumpsolr".
--mapped           If set, use values only after any mapping files are processed when
                   counting records (count)
--daystokeep=days  How many last days to keep when purging deleted records
                   (purgedeleted)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $sources = isset($params['source']) ? $params['source'] : '';
        $single = isset($params['single']) ? $params['single'] : '';
        $noCommit = isset($params['nocommit']) ? $params['nocommit'] : false;
        // Solr update, compare and dump can handle multiple sources at once
        if ($params['func'] == 'updatesolr' || $params['func'] == 'dumpsolr') {
            $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null);
            $dumpPrefix = $params['func'] == 'dumpsolr' ? isset($params['dumpprefix']) ? $params['dumpprefix'] : 'dumpsolr' : '';
            $manager->updateSolrIndex($date, $sources, $single, $noCommit, '', $dumpPrefix);
        } elseif ($params['func'] == 'comparesolr') {
            $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null);
            $manager->updateSolrIndex($date, $sources, $single, $noCommit, isset($params['comparelog']) ? $params['comparelog'] : '-');
        } else {
            foreach (explode(',', $sources) as $source) {
                switch ($params['func']) {
                    case 'renormalize':
                        $manager->renormalize($source, $single);
                        break;
                    case 'deduplicate':
                    case 'markdedup':
                        $manager->deduplicate($source, isset($params['all']) ? true : false, $single, $params['func'] == 'markdedup');
                        break;
                    case 'dump':
                        $manager->dumpRecord($single);
                        break;
                    case 'deletesource':
                        $manager->deleteRecords($source, isset($params['force']) ? $params['force'] : false);
                        break;
                    case 'markdeleted':
                        $manager->markDeleted($source);
                        break;
                    case 'deletesolr':
                        $manager->deleteSolrRecords($source);
                        break;
                    case 'optimizesolr':
                        $manager->optimizeSolr();
                        break;
                    case 'count':
                        $manager->countValues($source, isset($params['field']) ? $params['field'] : null, isset($params['mapped']) ? $params['mapped'] : false);
                        break;
                    case 'checkdedup':
                        $manager->checkDedupRecords();
                        break;
                    case 'purgedeleted':
                        if (!isset($params['force']) || !$params['force']) {
                            echo <<<EOT
Purging of deleted records means that any further Solr updates don't include
deletions. Use the --force parameter to indicate that this is ok. No records
have been purged.

EOT;
                            exit(1);
                        }
                        $manager->purgeDeletedRecords(isset($params['daystokeep']) ? intval($params['daystokeep']) : 0);
                        break;
                    default:
                        echo 'Unknown func: ' . $params['func'] . "\n";
                        exit(1);
                }
            }
        }
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
Example #12
0
          firstclick = COALESCE(LEAST(firstclick, "%s"), "%s"),
          latestclick = COALESCE(GREATEST(latestclick, "%s"), "%s")
          where forwardid = %d and messageid = %d', $GLOBALS['tables']['linktrack_ml'], $count, $updateFormatClicked, $row['firstclick'], $row['firstclick'], $row['latestclick'], $row['latestclick'], $fwdid, $messageid));
            Sql_Query(sprintf('insert into %s 
          set forwardid = %d, messageid = %d, userid = %d,
          firstclick = "%s", latestclick = "%s", 
          clicked = %d %s
          ON DUPLICATE KEY UPDATE clicked = clicked + %d %s', $GLOBALS['tables']['linktrack_uml_click'], $fwdid, $messageid, $userid, $row['firstclick'], $row['latestclick'], $count, $setFormatClicked, $count, $updateFormatClicked));
        }
    }
    ++$c;
    if ($c % 100 == 0) {
        print ". \n";
        flushbuffer();
    }
    if ($c % 1000 == 0) {
        output("{$c}/{$total}<br/> ");
        flushbuffer();
    }
    flush();
    Sql_Query(sprintf('delete from %s where linkid = %d', $GLOBALS['tables']['linktrack'], $row['linkid']));
}
set_time_limit(6000);
output($GLOBALS['I18N']->get('Optimizing table to recover space') . '.<br/>');
Sql_Query(sprintf('optimize table %s', $GLOBALS['tables']['linktrack']));
output($GLOBALS['I18N']->get('Finished') . '.<br/>');
if (!$GLOBALS['commandline']) {
    print PageLink2('convertstats', $GLOBALS['I18N']->get('Convert some more'));
}
releaseLock($process_id);
return;
Example #13
0
function my_shutdown() {
	global $report,$process_id;
  releaseLock($process_id);
 # $report .= "Connection status:".connection_status();
  finish("info",$report);
}
Example #14
0
/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['source']) || !is_string($params['source'])) {
        echo <<<EOT
Usage: {$argv['0']} --source=... [...]

Parameters:

--source            Repository id ('*' for all, separate multiple sources
                    with commas)
--exclude           Repository id's to exclude when using '*' for source
                    (separate multiple sources with commas)
--from              Override harvesting start date
--until             Override harvesting end date
--all               Harvest from beginning (overrides --from)
--verbose           Enable verbose output
--override          Override initial resumption token
                    (e.g. to resume failed connection)
--reharvest[=date]  This is a full reharvest, delete all records that were not
                    received during the harvesting (or were modified before [date]).
                    Implies --all.
--config.section.name=value
                    Set configuration directive to given value overriding any
                    setting in recordmanager.ini
--lockfile=file     Use a lock file to avoid executing the command multiple times in
                    parallel (useful when running from crontab)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $from = isset($params['from']) ? $params['from'] : null;
        if (isset($params['all']) || isset($params['reharvest'])) {
            $from = '-';
        }
        foreach (explode(',', $params['source']) as $source) {
            $manager->harvest($source, $from, isset($params['until']) ? $params['until'] : null, isset($params['override']) ? urldecode($params['override']) : '', isset($params['exclude']) ? $params['exclude'] : null, isset($params['reharvest']) ? $params['reharvest'] : '');
        }
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
Example #15
0
Zend_Session::start();
$logger = Zend_Log::factory(array(array('writerName' => 'Stream', 'writerParams' => array('stream' => LOGS_PATH . '/testing.log'), 'filterName' => 'Priority', 'filterParams' => array('priority' => Zend_Log::DEBUG))));
Zend_Registry::set('logger', $logger);
// get the config properties
$configGlobal = new Zend_Config_Ini(APPLICATION_CONFIG, 'global', true);
$configGlobal->environment = 'testing';
Zend_Registry::set('configGlobal', $configGlobal);
$config = new Zend_Config_Ini(APPLICATION_CONFIG, 'testing');
Zend_Registry::set('config', $config);
// get database type
// for now only supporting MySQL, PostgreSQL, and SQLite
// get the database type from the existing config files
$testConfigDir = BASE_PATH . '/tests/configs/';
$dbTypes = getSqlDbTypes($testConfigDir);
foreach ($dbTypes as $dbType) {
    try {
        echo 'Dropping and installing tables for database type: ' . $dbType . PHP_EOL;
        $dbAdapter = loadDbAdapter($testConfigDir, $dbType);
        dropTables($dbAdapter, $dbType);
        require_once BASE_PATH . '/core/controllers/components/UtilityComponent.php';
        $utilityComponent = new UtilityComponent();
        installCore($dbAdapter, $dbType, $utilityComponent);
        createDefaultAssetstore();
        installModules($utilityComponent);
        releaseLock($dbType);
    } catch (Zend_Exception $ze) {
        echo $ze->getMessage();
        exit(1);
    }
}
exit(0);