]> git.mxchange.org Git - friendica.git/blob - include/cronhooks.php
Attachments: Better handling of preview pictures
[friendica.git] / include / cronhooks.php
1 <?php
2
3 require_once("boot.php");
4
5
6 function cronhooks_run(&$argv, &$argc){
7         global $a, $db;
8
9         if(is_null($a)) {
10                 $a = new App;
11         }
12
13         if(is_null($db)) {
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);
18         };
19
20         require_once('include/session.php');
21         require_once('include/datetime.php');
22
23         load_config('config');
24         load_config('system');
25
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())
29                         return;
30                 if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
31                         return;
32         }
33
34         $last = get_config('system','last_cronhook');
35
36         $poll_interval = intval(get_config('system','cronhook_interval'));
37         if(! $poll_interval)
38                 $poll_interval = 9;
39
40         if($last) {
41                 $next = $last + ($poll_interval * 60);
42                 if($next > time()) {
43                         logger('cronhook intervall not reached');
44                         return;
45                 }
46         }
47
48         $a->set_baseurl(get_config('system','url'));
49
50         load_hooks();
51
52         logger('cronhooks: start');
53
54         $d = datetime_convert();
55
56         call_hooks('cron', $d);
57
58         logger('cronhooks: end');
59
60         set_config('system','last_cronhook', time());
61
62         return;
63 }
64
65 if (array_search(__file__,get_included_files())===0){
66         cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);
67         killme();
68 }