1
1
Fork 0
friendica_2019-12_sharedHos.../addon/poormancron/poormancron.php

49 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* Poor Man Cron. Execute updates on pageviews
*
* Addon Name: poormancron
*
*/
function poormancron_install() {
2011-01-28 14:04:40 +01:00
register_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook');
register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
logger("installed poormancron");
}
function poormancron_uninstall() {
2011-01-28 14:04:40 +01:00
unregister_hook('page_end', '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);
2011-01-28 14:04:40 +01:00
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
proc_run($php_path,"include/poller.php");
}
}
2011-01-28 14:04:40 +01:00
function poormancron_procrun($a, $argv) {
logger("poormancron procrun ".implode(", ",$argv));
array_shift($argv);
$argc = count($argv);
2011-01-28 14:04:40 +01:00
logger("poormancron procrun require_once ".basename($argv[0]));
require_once(basename($argv[0]));
$funcname=str_replace(".php", "", basename($argv[0]))."_run";
$funcname($argv, $argc);
}
2011-01-28 14:04:40 +01:00
?>