diff options
author | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-22 22:57:58 +0100 |
---|---|---|
committer | Stefan Parviainen <saparvia@caterva.eu> | 2014-12-22 22:57:58 +0100 |
commit | 83eb7a10e27a634dc64f093a885e9cb0d9f05eed (patch) | |
tree | 5e2860f5f04cdf56355715f9dd77cba145c7b55d | |
parent | c819c276f0bed98c2215ca0e5815ec8fb0f548c5 (diff) | |
download | volse-hubzilla-83eb7a10e27a634dc64f093a885e9cb0d9f05eed.tar.gz volse-hubzilla-83eb7a10e27a634dc64f093a885e9cb0d9f05eed.tar.bz2 volse-hubzilla-83eb7a10e27a634dc64f093a885e9cb0d9f05eed.zip |
Option to check that a random profile works before returning it
-rw-r--r-- | doc/hidden_configs.bb | 41 | ||||
-rw-r--r-- | include/Contact.php | 29 |
2 files changed, 46 insertions, 24 deletions
diff --git a/doc/hidden_configs.bb b/doc/hidden_configs.bb index 727428176..bf9705920 100644 --- a/doc/hidden_configs.bb +++ b/doc/hidden_configs.bb @@ -106,24 +106,29 @@ This document assumes you're an administrator. list of names (no spaces) [b]system > auto_follow[/b] Make the first channel of an account auto-follow channels listed here - comma separated list of webbies (member@hub addresses). - [b]system > admin_email[/b] - Specifies the administrators email for this site. This is initially set during install. - [b]system > cron_hour[/b] - Specify an hour in which to run cron_daily. By default with no config, this will run at midnight UTC. - [b]system > minimum_feedcheck_minutes[/b] - The minimum interval between polling RSS feeds. If this is lower than the cron interval, feeds will be polled with each cronjob - [b]system > blacklisted_sites[/b] - An array of specific hubs to block from this hub completely. - [b]system > ignore_imagick[/b] - Ignore imagick and use GD, even if imagick is installed on the server. Prevents some issues with PNG files in older versions of imagick. - [b]system > no_age_restriction[/b] - Do not restric registration to people over the age of 13 - [b]system > override_poll_lockfile[/b] - Ignore the lock file in the poller process to allow more than one process to run at a time. - [b]system > projecthome[/b] - Display the project page on your home page for logged out viewers. - [b]system > sellpage[/b] - A URL shown in the public sites list to sell your hub - display service classes, etc. + [b]system > admin_email[/b] + Specifies the administrators email for this site. This is initially set during install. + [b]system > cron_hour[/b] + Specify an hour in which to run cron_daily. By default with no config, this will run at midnight UTC. + [b]system > minimum_feedcheck_minutes[/b] + The minimum interval between polling RSS feeds. If this is lower than the cron interval, feeds will be polled with each cronjob + [b]system > blacklisted_sites[/b] + An array of specific hubs to block from this hub completely. + [b]system > ignore_imagick[/b] + Ignore imagick and use GD, even if imagick is installed on the server. Prevents some issues with PNG files in older versions of imagick. + [b]system > no_age_restriction[/b] + Do not restric registration to people over the age of 13 + [b]system > override_poll_lockfile[/b] + Ignore the lock file in the poller process to allow more than one process to run at a time. + [b]system > projecthome[/b] + Display the project page on your home page for logged out viewers. + [b]system > sellpage[/b] + 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; 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 ''; } - |