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);
22 require_once('include/session.php');
23 require_once('include/datetime.php');
25 load_config('config');
26 load_config('system');
28 // Don't check this stuff if the function is called by the poller
29 if (App::callstack() != "poller_run") {
30 if (App::maxload_reached())
32 if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
38 if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
39 foreach ($a->hooks["cron"] as $hook)
40 if ($hook[1] == $argv[1]) {
41 logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
42 call_single_hook($a, $name, $hook, $data);
47 $last = get_config('system','last_cronhook');
49 $poll_interval = intval(get_config('system','cronhook_interval'));
54 $next = $last + ($poll_interval * 60);
56 logger('cronhook intervall not reached');
61 $a->set_baseurl(get_config('system','url'));
63 logger('cronhooks: start');
65 $d = datetime_convert();
67 if (get_config("system", "worker") AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
68 foreach ($a->hooks["cron"] as $hook) {
69 logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
70 proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
73 call_hooks('cron', $d);
75 logger('cronhooks: end');
77 set_config('system','last_cronhook', time());
82 if (array_search(__file__,get_included_files())===0){
83 cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);