# HG changeset patch # User Dan # Date 1192844373 14400 # Node ID 3dbe848431b0897b19add6b128cd136739fd8e98 # Parent e858bacb5cfa41d45f4b8dd50d7505f680d293c7 Added a cron framework. Currently tasks will not be run; will implement into templates in next commit diff -r e858bacb5cfa -r 3dbe848431b0 cron.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cron.php Fri Oct 19 21:39:33 2007 -0400 @@ -0,0 +1,54 @@ + $tasks ) +{ + $last_run_threshold = time() - ( $interval * 3600 ); + if ( $last_run_threshold >= $last_run ) + { + foreach ( $tasks as $task ) + { + @call_user_func($task); + } + } +} + +header('Pragma: no-cache'); +header('Cache-control: no-cache'); +header('Expires: Thu, 1 Jan 1970 00:00:01 GMT'); +header('Content-type: image/gif'); + +echo ENANO_GIF_SPACER; + +?> diff -r e858bacb5cfa -r 3dbe848431b0 includes/common.php --- a/includes/common.php Fri Oct 19 21:07:54 2007 -0400 +++ b/includes/common.php Fri Oct 19 21:39:33 2007 -0400 @@ -68,6 +68,9 @@ if ( file_exists( ENANO_ROOT . '/_nightly.php') ) require(ENANO_ROOT.'/_nightly.php'); +// List of scheduled tasks +$cron_tasks = array(); + // Start including files. LOTS of files. Yeah! require_once(ENANO_ROOT.'/includes/constants.php'); dc_here('Enano CMS '.$version.' (dev) - debug window
Powered by debugConsole'); diff -r e858bacb5cfa -r 3dbe848431b0 includes/functions.php --- a/includes/functions.php Fri Oct 19 21:07:54 2007 -0400 +++ b/includes/functions.php Fri Oct 19 21:39:33 2007 -0400 @@ -3168,6 +3168,20 @@ return $score; } +/** + * Registers a task that will be run every X hours. Scheduled tasks should always be scheduled at runtime - they are not stored in the DB. + * @param string Function name to call, or array(object, string method) + * @param int Interval between runs, in hours. Defaults to 24. + */ + +function register_cron_task($func, $hour_interval = 24) +{ + global $cron_tasks; + if ( !isset($cron_tasks[$hour_interval]) ) + $cron_tasks[$hour_interval] = array(); + $cron_tasks[$hour_interval][] = $func; +} + //die('
Original:  01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'
'); ?>