cron.php
changeset 1227 bdac73ed481e
parent 1081 745200a9cc2a
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
    26 // Hope now that plugins are loaded :-)
    26 // Hope now that plugins are loaded :-)
    27 global $cron_tasks;
    27 global $cron_tasks;
    28 
    28 
    29 foreach ( $cron_tasks as $interval => $tasks )
    29 foreach ( $cron_tasks as $interval => $tasks )
    30 {
    30 {
    31   $interval = doubleval($interval);
    31 	$interval = doubleval($interval);
    32   $last_run = intval(getConfig("cron_lastrun_ivl_$interval"));
    32 	$last_run = intval(getConfig("cron_lastrun_ivl_$interval"));
    33   $last_run_threshold = doubleval(time()) - ( 3600.0 * $interval );
    33 	$last_run_threshold = doubleval(time()) - ( 3600.0 * $interval );
    34   if ( $last_run_threshold >= $last_run )
    34 	if ( $last_run_threshold >= $last_run )
    35   {
    35 	{
    36     foreach ( $tasks as $task )
    36 		foreach ( $tasks as $task )
    37     {
    37 		{
    38       call_user_func($task);
    38 			call_user_func($task);
    39     }
    39 		}
    40     setConfig("cron_lastrun_ivl_$interval", strval(time()));
    40 		setConfig("cron_lastrun_ivl_$interval", strval(time()));
    41   }
    41 	}
    42 }
    42 }
    43 
    43 
    44 $expiry_date = date('r', get_cron_next_run());
    44 $expiry_date = date('r', get_cron_next_run());
    45 
    45 
    46 $etag = sha1($expiry_date);
    46 $etag = sha1($expiry_date);
    47 
    47 
    48 if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) )
    48 if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) )
    49 {
    49 {
    50   if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] )
    50 	if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] )
    51   {
    51 	{
    52     header('HTTP/1.1 304 Not Modified');
    52 		header('HTTP/1.1 304 Not Modified');
    53     exit();
    53 		exit();
    54   }
    54 	}
    55 }
    55 }
    56 
    56 
    57 header("ETag: $etag");
    57 header("ETag: $etag");
    58 
    58 
    59 header('Expires: ' . $expiry_date);
    59 header('Expires: ' . $expiry_date);