Example #1
0
$export_queue = $pfif_conf['services'];
foreach ($export_queue as $service_name => $service) {
    $repos = $service['repository'];
    $req_params = $repos->get_request_params();
    $min_entry_date = $req_params['min_entry_date'];
    $skip = $req_params['skip'];
    $subdomain = empty($service['subdomain']) ? '' : '?subdomain=' . $service['subdomain'];
    $auth_key = empty($service['auth_key']) ? '' : '?key=' . $service['auth_key'];
    $pfif_uri = $service['post_url'] . $auth_key;
    $at_subdomain = " at subdomain {$subdomain} ";
    $p = new Pfif();
    $p->setService($service_name, $service);
    $repos->start_harvest('scheduled', 'out');
    print "\n\nExport started to " . $service['post_url'] . " at " . date("Y-m-d H:i:s") . "\n";
    $local_date = local_date($min_entry_date);
    $loaded = $p->loadFromDatabase($local_date, null, 0, $skip);
    print "Exporting original records after {$local_date}.\n";
    if ($loaded > 0) {
        // Export records
        $xml = $p->storeInXML(false, true);
        if ($xml != null) {
            $fh = fopen('cronpfif.xml', 'w');
            $charstowrite = strlen($xml);
            $written = fwrite($fh, $xml, $charstowrite);
            fclose($fh);
            $post_status = $p->postToService($xml);
            // Person and note counts are in $_SESSION['pfif_info'].
            if ($post_status == -1) {
                update_harvest_log($repos, $req_params, 'error');
                print "Export failed.\n";
            } else {