function statusnet_cron($a, $b) { $last = get_config('statusnet', 'last_poll'); $poll_interval = intval(get_config('statusnet', 'poll_interval')); if (!$poll_interval) { $poll_interval = STATUSNET_DEFAULT_POLL_INTERVAL; } if ($last) { $next = $last + $poll_interval * 60; if ($next > time()) { logger('statusnet: poll intervall not reached'); return; } } logger('statusnet: cron_start', LOGGER_DEBUG); $rand = db_getfunc('rand'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY {$rand} "); if (count($r)) { foreach ($r as $rr) { logger('statusnet: fetching for user ' . $rr['uid']); statusnet_fetchtimeline($a, $rr['uid']); } } logger('statusnet: cron_end', LOGGER_DEBUG); set_config('statusnet', 'last_poll', time()); }
function statusnet_cron($a, $b) { $last = get_config('statusnet', 'last_poll'); $poll_interval = intval(get_config('statusnet', 'poll_interval')); if (!$poll_interval) { $poll_interval = STATUSNET_DEFAULT_POLL_INTERVAL; } if ($last) { $next = $last + $poll_interval * 60; if ($next > time()) { logger('statusnet: poll intervall not reached'); return; } } logger('statusnet: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() "); if (count($r)) { foreach ($r as $rr) { logger('statusnet: fetching for user ' . $rr['uid']); statusnet_fetchtimeline($a, $rr['uid']); } } $abandon_days = intval(get_config('system', 'account_abandon_days')); if ($abandon_days < 1) { $abandon_days = 0; } $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()"); if (count($r)) { foreach ($r as $rr) { if ($abandon_days != 0) { $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit); if (!count($user)) { logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); continue; } } logger('statusnet: importing timeline from user ' . $rr['uid']); statusnet_fetchhometimeline($a, $rr["uid"], $rr["v"]); } } logger('statusnet: cron_end'); set_config('statusnet', 'last_poll', time()); }