} if (in_array('-clearlock', $argv)) { if (is_process_lock("create_previews")) { clear_process_lock("create_previews"); } $validargs = true; } if (!$validargs) { exit("Unknown argv: " . $argv[1]); } } # Check for a process lock if (is_process_lock("create_previews")) { exit("Process lock is in place. Deferring."); } set_process_lock("create_previews"); if (function_exists("pcntl_signal")) { $multiprocess = true; } else { $multiprocess = false; } // We store the start date. $global_start_time = microtime(true); // We define the number of threads. $max_forks = 3; $lock_directory = '.'; // We create an array to store children pids. $children = array(); /** * This function clean up the list of children pids. * This allow to detect the freeing of a thread slot.
if (in_array($argv[1], array('--clearlock', '-clearlock', '-c', '--c'))) { if (is_process_lock("staticsync")) { clear_process_lock("staticsync"); } } else { exit("Unknown argv: " . $argv[1]); } } } # Check for a process lock if (is_process_lock("staticsync")) { echo 'Process lock is in place. Deferring.' . PHP_EOL; echo 'To clear the lock after a failed run use --clearlock flag.' . PHP_EOL; exit; } set_process_lock("staticsync"); echo "Preloading data... "; $count = 0; $done = sql_array("SELECT file_path value FROM resource WHERE LENGTH(file_path)>0 AND file_path LIKE '%/%'"); $done = array_flip($done); # Load all modification times into an array for speed $modtimes = array(); $resource_modified_times = sql_query("SELECT file_modified, file_path FROM resource WHERE archive=0 AND LENGTH(file_path) > 0"); foreach ($resource_modified_times as $rmd) { $modtimes[$rmd["file_path"]] = $rmd["file_modified"]; } $lastsync = sql_value("SELECT value FROM sysvars WHERE name='lastsync'", ""); $lastsync = strlen($lastsync) > 0 ? strtotime($lastsync) : ''; echo "done." . PHP_EOL; echo "Looking for changes..." . PHP_EOL; # Pre-load the category tree, if configured.
else { exit("Unknown argv: " . $argv[1]); } } # Check for a process lock # This script checks one e-mail at a time. if (is_process_lock("checkmail")) { if ($email_errors){ send_mail($email_errors_address,$applicationname."- Checkmail blocked by process lock","Your IMAP account will not be checked until you clear this. An error may have caused this. Run the process manually with the -c switch to clear the lock and check for any errors.",$email_from); } exit("Process lock is in place. Deferring\r\n"); } set_process_lock("checkmail"); // manually include plugin config since authenticate isn't being run $config = sql_value("select config value from plugins where name='checkmail'",""); include_plugin_config("checkmail",$config); $temp_dir=$storagedir."/tmp/checkmail_in"; if (!is_dir($temp_dir)){mkdir($temp_dir,0777);} $delete=false; // set to true only after all files are transferred $build_collection=false; $collection="";