By: Jon Gjengset - 3rd March - 2008
    Contact: jon@thesquareplanet.com
    Original URL: http://www.phpclasses.org/browse/package/4426.html
    
    All use permitted, but please keep this notice!
*/
#Database configuration
$db = array('host' => 'DB_TABLE', 'username' => 'DB_USERNAME', 'password' => 'DB_PASSWORD', 'database' => 'DB_DATABASE', 'table' => 'DB_TABLE');
#Lorem Ipsum for generating random strings
$lipsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam eu massa et massa ornare tempus. Curabitur sit amet nunc. Nulla tellus pede, elementum eu, bibendum et, volutpat vel, lacus. Morbi orci massa, eleifend sodales, volutpat vitae, dignissim sed, pede. Morbi urna erat, egestas vitae, malesuada a, posuere bibendum, dolor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque lacinia consectetuer ligula. Aliquam libero. Suspendisse placerat, purus non elementum bibendum, libero est pulvinar dolor, sed lacinia magna ante ac diam. Pellentesque enim dui, tincidunt non, dignissim id, adipiscing a, pede. Quisque hendrerit, dui at varius ornare, quam nunc fermentum est, sit amet sollicitudin lorem purus ut tellus. Maecenas mollis justo et neque mattis auctor. Proin tristique, lacus a auctor suscipit, elit lacus porta urna, a luctus ante nisi nec erat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam tempor augue sed erat. Phasellus nisl tortor, cursus eu, bibendum ac, pharetra ac, orci.';
#Require the class
require 'eventLogger.php';
#Create a new logger (Note the syntax for the log format, what is inside the [% %] has to be the same as the corresponding database column)
#Note that you can pass many more parameters directly here:
# function __construct( $logFormat, $maxEntries = 1000, $db = false, $dbTable = false )
$logger = new eventLogger("[%name%]|[%number%]|[%date%]");
#Set working directory
$logger->setWorkingDir('./logs');
#Set the various filters
$logger->addFilter('name', 'string');
#String is a predefined type which is the same as the regular expression: [\w\s_\-,\.:;]+
$logger->addFilter('number', 'numeric');
#Numeric is, well, numeric...
$logger->addFilter('date', '(\\d{1,2}\\-\\d{1,2})');
#Custom regular expressions are permitted as well
#There is also a type called word which only allows alphanumerical characters
#Only send text
header("Content-type: text/plain");
#Make sure that we are doing something...
if (isset($_GET['act'])) {
    switch ($_GET['act']) {
Esempio n. 2
0
}
if ($dicomConfig['FAM'] == '1') {
    // we should be able to start more processes here!
    $fam_res = fam_open();
    $dir_res = fam_monitor_directory($fam_res, $dicomConfig['biometry']['inputFolder']);
    // if we have subdirectories we need the monitor collection instead of directory
    //$dir_res = fam_monitor_collection   ( $fam_res, $dicomConfig["biometry"]["inputFolder"], 1, 'dcm');
}
echo 'Monitoring ' . $dicomConfig['biometry']['inputFolder'] . "\n\n";
if ($dicomConfig['FAM'] == '1') {
    checkExistingFiles();
}
while (true) {
    $newfile = false;
    $mysqli = connectDatabase();
    $logger = new eventLogger($mysqli);
    if ($dicomConfig['FAM'] == '1') {
        while (fam_pending($fam_res)) {
            $arr = fam_next_event($fam_res);
            // FAMCreated == 5
            if ($arr['code'] == 5) {
                echo 'New file arrived: ' . $arr['filename'] . "\n";
                $newfile = true;
                $filedata = stat($dicomConfig['biometry']['inputFolder'] . '/' . $arr['filename']);
                if (!($fileid = fileEntryExistsFAM($dicomConfig['biometry']['inputFolder'] . '/' . $arr['filename'], $filedata, $mysqli))) {
                    $fileid = createFileEntry($dicomConfig['biometry']['inputFolder'] . '/' . $arr['filename'], $filedata, $mysqli);
                }
                //var_dump("Fileid: ".$fileid);
                $mysqli->query("INSERT INTO dicom_file_queue (filename, detected_date, last_modified_date, status_id) VALUES ('" . $dicomConfig['biometry']['inputFolder'] . '/' . $arr['filename'] . "', now(), now(), (SELECT id FROM dicom_process_status WHERE name = 'new'))");
                $logger->addLogEntry($dicomConfig['biometry']['inputFolder'] . '/' . $arr['filename'], 'new', basename($_SERVER['SCRIPT_FILENAME']));
                // add log entry