aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRedMatrix <info@friendica.com>2014-12-23 11:33:11 +1100
committerRedMatrix <info@friendica.com>2014-12-23 11:33:11 +1100
commit1049adeff644eddd8a77ed29376a694e804f0604 (patch)
tree3ad11aea3578aa053435338d355f3eeb938db2fb /include
parentc85702aeb61a0d496d123c63b322b728b78ff0f7 (diff)
parentfa65d31f3fb143acc8cc273d21a43c0bbd4f0524 (diff)
downloadvolse-hubzilla-1049adeff644eddd8a77ed29376a694e804f0604.tar.gz
volse-hubzilla-1049adeff644eddd8a77ed29376a694e804f0604.tar.bz2
volse-hubzilla-1049adeff644eddd8a77ed29376a694e804f0604.zip
Merge pull request #760 from pafcu/apps
Some apps changes
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php29
1 files changed, 23 insertions, 6 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 4fd43db44..4b45a2392 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -581,12 +581,29 @@ function contact_remove($channel_id, $abook_id) {
function random_profile() {
$randfunc = db_getfunc('rand');
- $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1",
- db_utcnow(), db_quoteinterval('30 day')
- );
- if($r)
- return $r[0]['xchan_url'];
+
+ $checkrandom = get_config('randprofile','check'); // False by default
+ $retryrandom = intval(get_config('randprofile','retry'));
+ if($retryrandom === false) $retryrandom = 5;
+
+ for($i = 0; $i < $retryrandom; $i++) {
+ $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1",
+ db_utcnow(), db_quoteinterval('30 day')
+ );
+
+ if(!$r) return ''; // Couldn't get a random channel
+
+ if($checkrandom) {
+ if(z_fetch_url($r[0]['xchan_url'])['success'])
+ return $r[0]['xchan_url'];
+ else
+ logger('Random channel turned out to be bad.');
+ }
+ else {
+ return $r[0]['xchan_url'];
+ }
+
+ }
return '';
}
-