changed git call from https to git readonly
[atutor.git] / mods / wiki / tools / cron.d / S17anacron.php
1 <?php
2 /*
3    This part ensures that we don't get run TOO often. It implements 
4    a delay and looks up when we actually ran the last time. 
5 */
6
7 define("ANACRON_ID", "etc/anacron/last-run");
8 define("ANACRON_PAUSE", 20);  // in seconds, minimum delay between runs
9
10
11 #-- get entry
12 $data = ewiki_db::GET(ANACRON_ID);
13 if ($data && ($data["flags"] & EWIKI_DB_F_SYSTEM)) {
14    echo "[$cron]: reading in anacron timestamps\n";
15    $anacron = unserialize($data["content"]);
16 }
17 else {
18    echo "[$cron]: first run ever\n";
19    $anacron = array(
20       "last" => 0,
21       "minute" => 0,
22       "hour" => 0,
23       "day" => 0,
24       "week" => 0,
25       "month" => 0,
26    );
27 }
28
29 #-- check _PAUSE
30 if ($anacron["last"]+ANACRON_PAUSE >= time()) {
31    echo "[$cron]: oooops, we're beeing called to often, the minimum interleave is " . ANACRON_PAUSE . " seconds\n";
32    $HALT = 2;
33 }
34
35 #-- prepare state flags?
36 else {
37    // ...
38    
39    // we define this a third time here, in case it really was missed
40    // somehow (?)
41    @define("EWIKI_CRON", time());
42 }
43
44 ?>