mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 20:15:16 +00:00
Add a fallback or two to randprof.
This commit is contained in:
parent
f49dcc0a0c
commit
28975931b5
1 changed files with 15 additions and 2 deletions
|
@ -1,11 +1,24 @@
|
|||
<?php
|
||||
|
||||
function randprof_fallback() {
|
||||
$r = q("select channel_address from channel where channel_r_stream = 1 order by rand() limit 1");
|
||||
if($r)
|
||||
return $r[0]['channel_address'];
|
||||
return '';
|
||||
}
|
||||
|
||||
function randprof_init(&$a) {
|
||||
require_once('include/Contact.php');
|
||||
$x = random_profile();
|
||||
if($x)
|
||||
goaway(chanlink_url($x));
|
||||
// FIXME this doesn't work at the moment as a fallback
|
||||
goaway($a->get_baseurl() . '/profile');
|
||||
// Nothing there, so try a local, public channel instead
|
||||
else $x = randprof_fallback();
|
||||
if($x) {
|
||||
$goaway = (z_root() . '/channel/' . $x);
|
||||
goaway(chanlink_url($goaway));}
|
||||
|
||||
// If we STILL haven't got anything, send them to their own profile, or the front page
|
||||
|
||||
goaway($a->get_baseurl());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue