if ($oid) { // Save this one in case we do a seek $_SESSION['random']['last'] = $oid; } } else { $oid = $_SESSION['random']['last']; } } // if random if ($type == 'song') { /* Base Checks passed create the song object */ $media = new Song($oid); $media->format(); } else { if ($type == 'song_preview') { $media = new Song_Preview($oid); $media->format(); } else { $type = 'video'; $media = new Video($oid); if (isset($_REQUEST['subtitle'])) { $subtitle = $media->get_subtitle_file($_REQUEST['subtitle']); } $media->format(); } } if (!User::stream_control(array(array('object_type' => $type, 'object_id' => $media->id)))) { debug_event('UI::access_denied', 'Stream control failed for user ' . $GLOBALS['user']->username . ' on ' . $media->get_stream_name(), 3); UI::access_denied(); exit; }
/** * play_url * This function takes all the song information and correctly formats a * a stream URL taking into account the downsmapling mojo and everything * else, this is the true function */ public static function play_url($oid, $additional_params = '', $player = null, $local = false) { $song = new Song_Preview($oid); $user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1'; $type = $song->type; $song_name = rawurlencode($song->get_artist_name() . " - " . $song->title . "." . $type); $url = Stream::get_base_url($local) . "type=song_preview&oid=" . $song->id . "&uid=" . $user_id . "&name=" . $song_name; return Stream_URL::format($url . $additional_params); }
/** * gc * * This function is randomly called and it cleans up the spoo */ public static function gc() { $sql = 'DELETE FROM `session` WHERE `expire` < ?'; Dba::write($sql, array(time())); // Also clean up things that use sessions as keys Query::gc(); Tmp_Playlist::gc(); Stream_Playlist::gc(); Song_Preview::gc(); return true; }