]> git.mxchange.org Git - friendica.git/blob - include/cronhooks.php
Revert "Coding convention applied - part 1"
[friendica.git] / include / cronhooks.php
1 <?php
2
3 use \Friendica\Core\Config;
4
5 function cronhooks_run(&$argv, &$argc){
6         global $a;
7
8         require_once('include/datetime.php');
9
10         if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
11                 foreach ($a->hooks["cron"] as $hook)
12                         if ($hook[1] == $argv[1]) {
13                                 logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
14                                 call_single_hook($a, $name, $hook, $data);
15                         }
16                 return;
17         }
18
19         $last = get_config('system', 'last_cronhook');
20
21         $poll_interval = intval(get_config('system','cronhook_interval'));
22         if(! $poll_interval)
23                 $poll_interval = 9;
24
25         if($last) {
26                 $next = $last + ($poll_interval * 60);
27                 if($next > time()) {
28                         logger('cronhook intervall not reached');
29                         return;
30                 }
31         }
32
33         $a->set_baseurl(get_config('system','url'));
34
35         logger('cronhooks: start');
36
37         $d = datetime_convert();
38
39         if (is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
40                 foreach ($a->hooks["cron"] as $hook) {
41                         logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
42                         proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
43                 }
44         }
45
46         logger('cronhooks: end');
47
48         set_config('system', 'last_cronhook', time());
49
50         return;
51 }