function processDir($dirResource, $root) { global $mysqli; while (false !== ($entry = readdir($dirResource))) { if ($entry != '.' && $entry != '..') { if (is_dir($root . '/' . $entry)) { $dirToProcess = opendir($root . '/' . $entry); processDir($dirToProcess, $root . '/' . $entry); } elseif (is_file($root . '/' . $entry)) { $filedata = stat($root . '/' . $entry); if (!fileEntryExists($root . '/' . $entry, $filedata, $mysqli)) { createFileEntry($root . '/' . $entry, $filedata, $mysqli); $mysqli->query("INSERT INTO dicom_file_queue (filename, detected_date, last_modified_date, status_id) VALUES ('" . $root . '/' . $entry . "', now(), now(), (SELECT id FROM dicom_process_status WHERE name = 'new'))"); } } } } }
function processDir($dirResource, $root, $logger) { global $mysqli; global $newfile; //echo "Processing: ".$root."\n"; while (false !== ($entry = readdir($dirResource))) { if ($entry != '.' && $entry != '..') { if (is_dir($root . '/' . $entry)) { $dirToProcess = opendir($root . '/' . $entry); processDir($dirToProcess, $root . '/' . $entry, $logger); } elseif (is_file($root . '/' . $entry)) { $filedata = stat($root . '/' . $entry); if (!fileEntryExists($root . '/' . $entry, $filedata, $mysqli)) { echo 'New file arrived: ' . $entry . "\n"; $newfile = true; createFileEntry($root . '/' . $entry, $filedata, $mysqli); $mysqli->query("INSERT INTO dicom_file_queue (filename, detected_date, last_modified_date, status_id) VALUES ('" . $root . '/' . $entry . "', now(), now(), (SELECT id FROM dicom_process_status WHERE name = 'new'))"); $logger->addLogEntry($root . '/' . $entry, 'new', basename($_SERVER['SCRIPT_FILENAME'])); } } } } }