+ $r2 = q("SELECT gcontact.* from gcontact
+ left join glink on glink.gcid = gcontact.id
+ where glink.uid = 0 and glink.cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d)
+ and not gcontact.id in ( select gcid from gcign where uid = %d )
+ order by rand() limit %d, %d ",
+ intval($uid),
+ intval($uid),
+ intval($start),
+ intval($limit)
+ );
+
+
+ return array_merge($r,$r2);
+
+}
+
+function update_suggestions() {
+
+ $a = get_app();
+
+ $done = array();
+
+ poco_load(0,0,$a->get_baseurl() . '/poco');
+
+ $done[] = $a->get_baseurl() . '/poco';
+
+ if(strlen(get_config('system','directory_submit_url'))) {
+ $x = fetch_url('http://dir.friendica.com/pubsites');
+ if($x) {
+ $j = json_decode($x);
+ if($j->entries) {
+ foreach($j->entries as $entry) {
+ $url = $entry->url . '/poco';
+ if(! in_array($url,$done))
+ poco_load(0,0,$entry->url . '/poco');
+ }
+ }
+ }
+ }
+
+ $r = q("select distinct(poco) as poco from contact where network = '%s'",
+ dbesc(NETWORK_DFRN)
+ );
+
+ if(count($r)) {
+ foreach($r as $rr) {
+ $base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
+ if(! in_array($base,$done))
+ poco_load(0,0,$base);
+ }
+ }