diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-03-31 08:07:54 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-03-31 08:07:54 +0000 |
commit | 2f126626cbd951e97220d7c9ab1f2791f614f401 (patch) | |
tree | 739ca78b8d50c42829d45176829e2ba9e7ef39a3 /song.php | |
parent | 05a1cfe34904997715dd145af81d6d2170e120df (diff) | |
download | ampache-2f126626cbd951e97220d7c9ab1f2791f614f401.tar.gz ampache-2f126626cbd951e97220d7c9ab1f2791f614f401.tar.bz2 ampache-2f126626cbd951e97220d7c9ab1f2791f614f401.zip |
added download for size, and seriously cleaned up the /song.php file it actually is not ugly anymore.. yeah!
Diffstat (limited to 'song.php')
-rw-r--r-- | song.php | 121 |
1 files changed, 62 insertions, 59 deletions
@@ -42,7 +42,11 @@ $web_path = conf('web_path'); $song_ids = array(); $web_path = conf('web_path'); +/* We need an action and a method */ $action = scrub_in($_REQUEST['action']); +$method = scrub_in($_REQUEST['method']); + + switch ($action) { case 'play_selected': $type = scrub_in($_REQUEST['type']); @@ -56,87 +60,86 @@ switch ($action) { else { $song_ids = $_POST['song']; } - $_REQUEST['action'] = 'm3u'; + break; + case 'your_popular_songs': + $song_ids = get_popular_songs($_REQUEST['limit'], 'your', $GLOBALS['user']->id); + break; + case 'popular_songs': + $song_ids = get_popular_songs($_REQUEST['limit'], 'global'); break; case 'genre': $genre = new Genre($_REQUEST['genre']); $song_ids = $genre->get_songs(); - $_REQUEST['action'] = 'm3u'; + break; + case 'artist': + $artist = new Artist($_REQUEST['artist_id']); + $song_ids = $artist->get_song_ids(); + break; + case 'artist_random': + $artist = new Artist($_REQUEST['artist_id']); + $artist->get_count(); + $song_ids = $artist->get_random_songs(); + break; + case 'album_random': + $album = new Album($_REQUEST['album_id']); + $song_ids = $album->get_random_songs(); + break; + case 'album': + $album = new Album($_REQUEST['album_id']); + $song_ids = $album->get_song_ids(); break; case 'random_genre': $genre = new Genre($_REQUEST['genre']); $song_ids = $genre->get_random_songs(); - $_REQUEST['action'] = 'm3u'; break; case 'playlist': $playlist = new Playlist($_REQUEST['playlist_id']); $song_ids = $playlist->get_songs($_REQUEST['song']); - $_REQUEST['action'] = 'm3u'; break; case 'playlist_random': $playlist = new Playlist($_REQUEST['playlist_id']); $song_ids = $playlist->get_random_songs(); - $_REQUEST['action'] = 'm3u'; + break; + case 'random': + if($_REQUEST['genre'][0] != '-1') { + $matchlist['genre'] = $_REQUEST['genre']; + } + if($_REQUEST['catalog'] != '-1') { + $matchlist['catalog'] = $_REQUEST['catalog']; + } + /* Setup the options array */ + $options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type'],'size_limit'=>$_REQUEST['size_limit']); + $song_ids = get_random_songs($options, $matchlist); break; default: break; } // end action switch -if ($_REQUEST['album']) { - $song_ids = get_song_ids_from_album( $_REQUEST['album'] ); -} -elseif ( $_REQUEST['artist'] ) { - $artist = new Artist($_REQUEST['artist']); - $song_ids = $artist->get_song_ids(); -} -/*! - @action Random Song - @discussion takes a genre and catalog and - returns random songs based upong that -*/ -elseif ( $_REQUEST['random'] ) { - - if($_REQUEST['genre'][0] != '-1') { - $matchlist['genre'] = $_REQUEST['genre']; - } - if($_REQUEST['catalog'] != '-1') { - $matchlist['catalog'] = $_REQUEST['catalog']; - } - /* Setup the options array */ - $options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type']); - $song_ids = get_random_songs($options, $matchlist); -} - -elseif ( $_REQUEST['artist_random'] ) { - $artist = new Artist($_REQUEST['artist_random']); - $artist->get_count(); - $song_ids = $artist->get_random_songs(); -} -elseif ( $_REQUEST['album_random'] ) { - $album = new Album($_REQUEST['album_random']); - $song_ids = $album->get_random_songs(); -} -elseif ( $_REQUEST['song'] AND !is_array($_REQUEST['song'])) { - $song_ids = array(); - $song_ids[0] = $_REQUEST['song']; -} -elseif ( $_REQUEST['popular_songs'] ) { - $song_ids = get_popular_songs($_REQUEST['popular_songs'], 'global'); -} -elseif ( $_REQUEST['your_popular_songs'] ) { - $song_ids = get_popular_songs($_REQUEST['your_popular_songs'], 'your', $user->username); -} - -/* FIXME! */ -if ( !$_REQUEST['action'] or $_REQUEST['action'] == 'm3u' ) { - $stream_type = conf('playlist_type'); +/* Now that we've gathered the song information we decide what + * we should do with it, this is a sensitive time for the song id's + * they don't know where they want to go.. let's help them out + */ +switch ($method) { + case 'download': + /* Make sure they are allowed to download */ + if (!batch_ok()) { break; } + $name = "AmpacheZip-" . date("m-d-Y",time()); + $song_files = get_song_files($song_ids); + set_memory_limit($song_files[1]+32); + send_zip($name,$song_files[0]); + break; + case 'stream': + default: + $stream_type = conf('playlist_type'); - if ($user->prefs['play_type'] != "stream" AND $user->prefs['play_type'] != "downsample") { - $stream_type = $user->prefs['play_type']; - } - $stream = new Stream($stream_type,$song_ids); - $stream->start(); -} // if streaming + if ($GLOBALS['user']->prefs['play_type'] != "stream" AND $GLOBALS['user']->prefs['play_type'] != "downsample") { + $stream_type = $user->prefs['play_type']; + } + /* Start the Stream */ + $stream = new Stream($stream_type,$song_ids); + $stream->start(); + break; +} // end method switch ?> |