4 * Description: Execute updates on pageviews, without the need of commandline php - only for use in total desperation as page loads will take forever
6 * Author: Fabio Comuni <http://kirgroup.com/profile/fabrix>
9 function poormancron_install() {
10 // check for command line php
13 $ex[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
14 $ex[1] = dirname(dirname(dirname(__file__)))."/testargs.php";
16 $out = exec(implode(" ", $ex));
18 set_config('poormancron','usecli',1);
19 logger("poormancron will use cli php");
21 set_config('poormancron','usecli',0);
22 logger("poormancron will NOT use cli php");
25 register_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook');
26 register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
27 logger("installed poormancron");
30 function poormancron_uninstall() {
31 unregister_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook');
32 unregister_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
33 logger("removed poormancron");
38 function poormancron_hook(&$a,&$b) {
40 $lastupdate = get_config('poormancron', 'lastupdate');
43 if (!$lastupdate || ($now-$lastupdate)>300) {
44 set_config('poormancron','lastupdate', $now);
45 proc_run('php',"include/poller.php");
49 function poormancron_procrun(&$a, &$arr) {
50 if (get_config('poormancron','usecli')==1) return;
52 $arr['run_cmd'] = false;
53 logger("poormancron procrun ".implode(", ",$argv));
56 logger("poormancron procrun require_once ".basename($argv[0]));
57 require_once(basename($argv[0]));
58 $funcname=str_replace(".php", "", basename($argv[0]))."_run";
60 $funcname($argv, $argc);