aboutsummaryrefslogtreecommitdiffstats
path: root/addon/poormancron/poormancron.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-01-28 18:50:20 -0800
committerFriendika <info@friendika.com>2011-01-28 18:50:20 -0800
commit26cc2e02fe6e075cd35a3069edbc006219f5b435 (patch)
treeb687508bd7247100ac0dd51ecf36aed9ea97d5cd /addon/poormancron/poormancron.php
parent5d77bd9489763721b8f3e4a51c8cef1181276157 (diff)
parent302acda0890a472916b759e6340ce77d9803f105 (diff)
downloadvolse-hubzilla-26cc2e02fe6e075cd35a3069edbc006219f5b435.tar.gz
volse-hubzilla-26cc2e02fe6e075cd35a3069edbc006219f5b435.tar.bz2
volse-hubzilla-26cc2e02fe6e075cd35a3069edbc006219f5b435.zip
Merge branch 'fabrixxm-master'
Conflicts: boot.php
Diffstat (limited to 'addon/poormancron/poormancron.php')
-rw-r--r--addon/poormancron/poormancron.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/addon/poormancron/poormancron.php b/addon/poormancron/poormancron.php
new file mode 100644
index 000000000..c31d2772c
--- /dev/null
+++ b/addon/poormancron/poormancron.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Poor Man Cron. Execute updates on pageviews
+ *
+ * Addon Name: poormancron
+ *
+ */
+
+function poormancron_install() {
+ 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() {
+ 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);
+ $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
+ proc_run($php_path,"include/poller.php");
+ }
+}
+
+function poormancron_procrun($a, $argv) {
+ logger("poormancron procrun ".implode(", ",$argv));
+ array_shift($argv);
+ $argc = count($argv);
+ logger("poormancron procrun require_once ".basename($argv[0]));
+ require_once(basename($argv[0]));
+ $funcname=str_replace(".php", "", basename($argv[0]))."_run";
+
+ $funcname($argv, $argc);
+}
+
+
+
+?>