Option to check that a random profile works before returning it
This commit is contained in:
parent
c819c276f0
commit
83eb7a10e2
@ -124,6 +124,11 @@ This document assumes you're an administrator.
|
|||||||
Display the project page on your home page for logged out viewers.
|
Display the project page on your home page for logged out viewers.
|
||||||
[b]system > sellpage[/b]
|
[b]system > sellpage[/b]
|
||||||
A URL shown in the public sites list to sell your hub - display service classes, etc.
|
A URL shown in the public sites list to sell your hub - display service classes, etc.
|
||||||
|
[b]randprofile > check[/b]
|
||||||
|
When requesting a random profile, check that it actually exists first
|
||||||
|
[b]randprofile > retry[/b]
|
||||||
|
Number of times to retry getting a random profile
|
||||||
|
|
||||||
|
|
||||||
#include doc/macros/main_footer.bb;
|
#include doc/macros/main_footer.bb;
|
||||||
|
|
||||||
|
@ -581,12 +581,29 @@ function contact_remove($channel_id, $abook_id) {
|
|||||||
|
|
||||||
function random_profile() {
|
function random_profile() {
|
||||||
$randfunc = db_getfunc('rand');
|
$randfunc = db_getfunc('rand');
|
||||||
|
|
||||||
|
$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",
|
$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')
|
db_utcnow(), db_quoteinterval('30 day')
|
||||||
);
|
);
|
||||||
if($r)
|
|
||||||
|
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'];
|
return $r[0]['xchan_url'];
|
||||||
|
else
|
||||||
|
logger('Random channel turned out to be bad.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $r[0]['xchan_url'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user