diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-02-19 09:00:23 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-02-19 09:00:23 +0000 |
commit | 062398443b26b4f146e5d6866b452857a09759e8 (patch) | |
tree | b6dfc477c31eb39cf6e6f23582fd87826f5b68ba /download | |
parent | cbfb6bc3f38bae0a05f7fab5e7fe9569b9464d40 (diff) | |
download | ampache-062398443b26b4f146e5d6866b452857a09759e8.tar.gz ampache-062398443b26b4f146e5d6866b452857a09759e8.tar.bz2 ampache-062398443b26b4f146e5d6866b452857a09759e8.zip |
tweaked catalog drop down, added bandwidth throttling and fixed some spelling errors
Diffstat (limited to 'download')
-rw-r--r-- | download/index.php | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/download/index.php b/download/index.php index 8fe2b3b2..58b33e56 100644 --- a/download/index.php +++ b/download/index.php @@ -33,6 +33,7 @@ $browser = new Browser(); /* If we are running a demo, quick while you still can! */ if (conf('demo_mode') || !$GLOBALS['user']->has_access('25') || !$GLOBALS['user']->prefs['download']) { + debug_event('access_denied',"Download Access Denied, " . $GLOBALS['user']->username . " doesn't have sufficent rights",'3'); access_denied(); } @@ -69,13 +70,30 @@ if ($_REQUEST['action'] == 'download') { $song->format_song(); $song->format_type(); $song_name = str_replace('"'," ",$song->f_artist_full . " - " . $song->title . "." . $song->type); + + // Use Horde's Browser class to send the right headers for different browsers // Should get the mime-type from the song rather than hard-coding it. header("Content-Length: " . $song->size); $browser->downloadHeaders($song_name, $song->mime, false, $song->size); $fp = fopen($song->file, 'r'); - fpassthru($fp); + + /* We need to check and see if throttling is enabled */ + $speed = intval(conf('throttle_download')); + if ($speed > 0) { + while(!feof($fp)) { + echo fread($fp, round($speed*1024)); + flush(); + sleep(1); + } + } // if limiting + /* Otherwise just pump it out as fast as you can */ + else { + fpassthru($fp); + } // else no limit + fclose($fp); -} + +} // If they've requested a download ?> |