Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.3 KiB

  1. <?php
  2. /**
  3. * Name: Poor Man Cron
  4. * Description: Execute updates on pageviews, without the need of commandline php
  5. * Version: 1.2
  6. * Author: Fabio Comuni <http://kirgroup.com/profile/fabrix>
  7. */
  8. function poormancron_install() {
  9. register_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook');
  10. register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
  11. logger("installed poormancron");
  12. }
  13. function poormancron_uninstall() {
  14. unregister_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook');
  15. unregister_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun');
  16. logger("removed poormancron");
  17. }
  18. function poormancron_hook(&$a,&$b) {
  19. $now = time();
  20. $lastupdate = get_config('poormancron', 'lastupdate');
  21. // 300 secs, 5 mins
  22. if (!$lastupdate || ($now-$lastupdate)>300) {
  23. set_config('poormancron','lastupdate', $now);
  24. proc_run('php',"include/poller.php");
  25. }
  26. }
  27. function poormancron_procrun(&$a, $argv) {
  28. logger("poormancron procrun ".implode(", ",$argv));
  29. array_shift($argv);
  30. $argc = count($argv);
  31. logger("poormancron procrun require_once ".basename($argv[0]));
  32. require_once(basename($argv[0]));
  33. $funcname=str_replace(".php", "", basename($argv[0]))."_run";
  34. $funcname($argv, $argc);
  35. }
  36. ?>