- set_config('system','cache_last_cleared', time());
- }
-
- $manual_id = 0;
- $generation = 0;
- $hub_update = false;
- $force = false;
- $restart = false;
-
- if(($argc > 1) && ($argv[1] == 'force'))
- $force = true;
-
- if(($argc > 1) && ($argv[1] == 'restart')) {
- $restart = true;
- $generation = intval($argv[2]);
- if(! $generation)
- killme();
- }
-
- if(($argc > 1) && intval($argv[1])) {
- $manual_id = intval($argv[1]);
- $force = true;
- }
-
- $interval = intval(get_config('system','poll_interval'));
- if(! $interval)
- $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
-
- $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
-
- reload_plugins();
-
- $d = datetime_convert();
-
- if(! $restart)
- proc_run('php','include/cronhooks.php');
-
- // Only poll from those with suitable relationships,
- // and which have a polling address and ignore Diaspora since
- // we are unable to match those posts with a Diaspora GUID and prevent duplicates.
-
- $abandon_sql = (($abandon_days)
- ? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days))
- : ''
- );
-
- $contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
- WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
- AND NOT `network` IN ( '%s', '%s' )
- $sql_extra
- AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
- AND `contact`.`archive` = 0
- AND `user`.`account_expired` = 0 AND `user`.`account_removed` = 0 $abandon_sql ORDER BY RAND()",
- intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND),
- dbesc(NETWORK_DIASPORA),
- dbesc(NETWORK_FACEBOOK)
- );