]> git.mxchange.org Git - friendica.git/blob - include/cronhooks.php
Remove unrecommended leading backslash for fully qualified namespaces
[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                 }
17                 return;
18         }
19
20         $last = get_config('system', 'last_cronhook');
21
22         $poll_interval = intval(get_config('system', 'cronhook_interval'));
23         if (! $poll_interval) {
24                 $poll_interval = 9;
25         }
26
27         if ($last) {
28                 $next = $last + ($poll_interval * 60);
29                 if ($next > time()) {
30                         logger('cronhook intervall not reached');
31                         return;
32                 }
33         }
34
35         $a->set_baseurl(get_config('system', 'url'));
36
37         logger('cronhooks: start');
38
39         $d = datetime_convert();
40
41         if (is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
42                 foreach ($a->hooks["cron"] as $hook) {
43                         logger("Calling cronhooks for '" . $hook[1] . "'", LOGGER_DEBUG);
44                         proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
45                 }
46         }
47
48         logger('cronhooks: end');
49
50         set_config('system', 'last_cronhook', time());
51
52         return;
53 }