]> git.mxchange.org Git - friendica.git/blob - addon/poormancron/poormancron.php
first try of 'poormancron' whith 'proc_run' hook
[friendica.git] / addon / poormancron / poormancron.php
1 <?php
2 /**
3  * Poor Man Cron. Execute updates on pageviews
4  *
5  * Addon Name: poormancron
6  *
7  */
8
9 function poormancron_install() {
10
11         register_hook('profile_sidebar', 'addon/poormancron/poormancron.php', 'poormancron_hook');
12     register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
13
14         logger("installed poormancron");
15 }
16
17 function poormancron_uninstall() {
18
19         unregister_hook('profile_sidebar', 'addon/poormancron/poormancron.php', 'poormancron_hook');
20     unregister_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
21     logger("removed poormancron");
22 }
23
24
25
26 function poormancron_hook($a,&$b) {
27     $now = time();
28     $lastupdate = get_config('poormancron', 'lastupdate');
29
30     // 300 secs, 5 mins
31     if (!$lastupdate || ($now-$lastupdate)>300) {
32         set_config('poormancron','lastupdate', $now);
33                 $b .= "<img src='".$a->get_baseurl()."/queue_wrapper.php' width='1px' height='1px' style='display:none'>";        
34         $b .= "<img src='".$a->get_baseurl()."/poller_wrapper.php' width='1px' height='1px' style='display:none'>";
35
36     }
37     
38 }
39
40
41 function poormancron_procrun($a, $args) {
42         $argv = array_shift($args);
43         $argc = count($argv);
44         function killme(){
45                 // pass
46         }
47         require_once($argv[0]); 
48 }
49
50
51 ?>