aboutsummaryrefslogtreecommitdiffstats
path: root/addon/poormancron/poormancron.php
blob: 98231727d46fcc5fe8fba27e3ac22b3c56047e32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
 * Poor Man Cron. Execute updates on pageviews
 *
 * Addon Name: poormancron
 *
 */

function poormancron_install() {

	register_hook('profile_sidebar', 'addon/poormancron/poormancron.php', 'poormancron_hook');
    register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');

	logger("installed poormancron");
}

function poormancron_uninstall() {

	unregister_hook('profile_sidebar', 'addon/poormancron/poormancron.php', 'poormancron_hook');
    unregister_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
    logger("removed poormancron");
}



function poormancron_hook($a,&$b) {
    $now = time();
    $lastupdate = get_config('poormancron', 'lastupdate');

    // 300 secs, 5 mins
    if (!$lastupdate || ($now-$lastupdate)>300) {
        set_config('poormancron','lastupdate', $now);
		$b .= "<img src='".$a->get_baseurl()."/queue_wrapper.php' width='1px' height='1px' style='display:none'>";        
        $b .= "<img src='".$a->get_baseurl()."/poller_wrapper.php' width='1px' height='1px' style='display:none'>";

    }
    
}


function poormancron_procrun($a, $args) {
	$argv = array_shift($args);
	$argc = count($argv);
	function killme(){
		// pass
	}
	require_once($argv[0]);	
}


?>