3 require_once("boot.php");
6 function cronhooks_run(&$argv, &$argc){
14 @include(".htconfig.php");
15 require_once("include/dba.php");
16 $db = new dba($db_host, $db_user, $db_pass, $db_data);
17 unset($db_host, $db_user, $db_pass, $db_data);
20 require_once('include/session.php');
21 require_once('include/datetime.php');
23 load_config('config');
24 load_config('system');
26 // Don't check this stuff if the function is called by the poller
27 if (App::callstack() != "poller_run") {
28 if (App::maxload_reached())
30 if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
36 if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
37 foreach ($a->hooks["cron"] as $hook)
38 if ($hook[1] == $argv[1]) {
39 logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
40 call_single_hook($a, $name, $hook, $data);
45 $last = get_config('system','last_cronhook');
47 $poll_interval = intval(get_config('system','cronhook_interval'));
52 $next = $last + ($poll_interval * 60);
54 logger('cronhook intervall not reached');
59 $a->set_baseurl(get_config('system','url'));
61 logger('cronhooks: start');
63 $d = datetime_convert();
65 if (get_config("system", "worker") AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
66 foreach ($a->hooks["cron"] as $hook) {
67 logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
68 proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
71 call_hooks('cron', $d);
73 logger('cronhooks: end');
75 set_config('system','last_cronhook', time());
80 if (array_search(__file__,get_included_files())===0){
81 cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);