= ($limit -1)) return $r; $r2 = q("SELECT count(xlink_link) as `total`, xchan.* from xchan left join xlink on xlink_link = xchan_hash where xlink_xchan = '' and not xlink_link in ( select abook_xchan from abook where abook_channel = %d ) and not xlink_link in ( select xchan from xign where uid = %d ) and not ( xchan_flags & %d ) group by xchan_hash order by total desc limit %d, %d ", intval($uid), intval($uid), intval(XCHAN_FLAGS_HIDDEN), intval($start), intval($limit) ); if(is_array($r) && is_array($r2)) return array_merge($r,$r2); return array(); } function update_suggestions() { $a = get_app(); $dirmode = get_config('system','directory_mode'); if($dirmode === false) $dirmode = DIRECTORY_MODE_NORMAL; if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { $url = z_root() . '/sitelist'; } else { $directory = find_upstream_directory($dirmode); if($directory) { $url = $directory['url'] . '/sitelist'; } else { $url = DIRECTORY_FALLBACK_MASTER . '/sitelist'; } } if(! $url) return; $ret = z_fetch_url($url); if($ret['success']) { // We will grab fresh data once a day via the poller. Remove anything over a week old because // the targets may have changed their preferences and don't want to be suggested - and they // may have simply gone away. $r = q("delete from xlink where xlink_xchan = '' and xlink_updated < UTC_TIMESTAMP() - INTERVAL 7 DAY"); $j = json_decode($ret['body'],true); if($j && $j['success']) { foreach($j['entries'] as $host) { poco_load('',$host['url'] . '/poco'); } } } }