function skip_mail($imap, $current_message, $note, $mail = false) { // display note, and clear process lock. global $lang, $applicationname, $email_errors, $imap, $current_message, $email_errors_address, $email_from; echo $note . "\r\n"; if ($current_message != "") { imap_setflag_full($imap, "{$current_message}", "\\Seen \\Flagged"); echo "Marked message as seen. It will be omitted on the next run.\r\n\r\n"; } if ($mail && $email_errors) { send_mail($email_errors_address, $applicationname . " - " . $lang["checkmail_mail_skipped"], $note, $email_from); } clear_process_lock("checkmail"); die; }
} if (!$staticsync_ingest) { # If not ingesting files, look for deleted files in the sync folder and archive the appropriate file from ResourceSpace. echo "Looking for deleted files..." . PHP_EOL; # For all resources with filepaths, check they still exist and archive if not. $resources_to_archive = sql_query("SELECT ref,file_path FROM resource WHERE archive=0 AND LENGTH(file_path)>0 AND file_path LIKE '%/%'"); # ***for modified syncdir directories: $syncdonemodified = hook("modifysyncdonerf"); if (!empty($syncdonemodified)) { $resources_to_archive = $syncdonemodified; } foreach ($resources_to_archive as $rf) { $fp = $syncdir . "/" . $rf["file_path"]; # ***for modified syncdir directories: if (isset($rf['syncdir']) && $rf['syncdir'] != '') { $fp = $rf['syncdir'] . $rf["file_path"]; } if (!file_exists($fp)) { echo "File no longer exists: {$rf["ref"]} ({$fp})" . PHP_EOL; # Set to archived. sql_query("UPDATE resource SET archive=2 WHERE ref='{$rf["ref"]}'"); sql_query("DELETE FROM collection_resource WHERE resource='{$rf["ref"]}'"); } } # Remove any themes that are now empty as a result of deleted files. sql_query("DELETE FROM collection WHERE theme IS NOT NULL AND LENGTH(theme) > 0 AND\n (SELECT count(*) FROM collection_resource cr WHERE cr.collection=collection.ref) = 0;"); echo "...Complete" . PHP_EOL; } sql_query("UPDATE sysvars SET value=now() WHERE name='lastsync'"); clear_process_lock("staticsync");
$ingested = false; } else { $ingested = true; } create_previews($resource['ref'], false, $resource['file_extension'], false, false, -1, $ignoremaxsize, $ingested); echo sprintf("Processed resource %d in %01.2f seconds.\n", $resource['ref'], microtime(true) - $start_time); } else { sql_query("update resource set preview_attempts=ifnull(preview_attempts,0) + 1 where ref='" . $resource['ref'] . "'"); echo sprintf("Skipped resource " . $resource['ref'] . " - maximum attempts reached or nonexistent file extension. \n"); } if ($multiprocess) { // We exit in order to avoid fork bombing. exit(0); } } } } // Test if we can create a new fork } // For each resources // We wait for all forks to exit. if ($multiprocess) { while (count($children)) { // We clean children list. reap_children(); sleep(1); } } echo sprintf("Completed in %01.2f seconds.\n", microtime(true) - $global_start_time); clear_process_lock("create_previews");
$matches, PREG_PATTERN_ORDER); return $matches[3]; } // final pass for inline files // fix replace inline images with new links if (isset($body_html)){ foreach ($refs as $ref){ echo "for resource $ref, "; foreach ($files as $file){ if (isset($file['id'])){ echo "trying to match ".$file['id']; $colpath=get_resource_path($file['ref'],false,"col",false); //print_r(get_tag("src","cid:".$file['id'],$body_html)); $body_html=str_replace("cid:".$file['id'],$colpath,$body_html); } } update_field($ref,$checkmail_body_field,$body_html); } } */ imap_close($imap); clear_process_lock("checkmail"); echo "done\r\n";