<?php
### download.php ###
// sends a file to the browser to be downloaded
include("global.php");
// fixes bugs assosiated with extra slashes from rawurlencoding filenames
$play = stripslashes(rawurldecode($play));
// These lines are ESSENTIAL for the brunhilde server remain secure
// They keep a client from entering "../" to gain access to files
// outside of your web tree
if((substr_count($play, "../") > 0) || (substr_count($play, "..\\") > 0)) {
include("security.php");
}
// refuses connection if the download option has been disabled
if(isset($DOWNLOAD)) {
// gets a name for the file
$file_name_array = explode("/", $play);
$index = sizeof($file_name_array) - 1;
$file_name = $file_name_array[$index];
$file_name = trim($file_name);
// gets the size of the file
$file_size = filesize($MEDIA_DIR[$base][1].$play);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Length: $file_size");
// outputs the contents of the file to the client
readfile($MEDIA_DIR[$base][1].$play);
}
else { echo "Sorry, the download option has been disabled on this server."; }
exit;
?>