<?php
$illegal = false;
if (isset($_GET['file']) && !empty($_GET['file']))
{
/* check the filevar and give the correct fileHandle */
$fh = "";
switch ($_GET['file']) {
case "mp31" : $fh = "1.mp3";
break;
case "mp32" : $fh = "2.mp3";
break;
}
/* quit or load the file */
if ($fh == "") {
$illegal = true;
} else {
$bestand = /*"http://map_naar_de_files" . $fh;*/
$len = filesize($bestand);
$newname = "soundserie_" . $fh;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
$header = "";
$type = substr($_GET['file'], 0, 3);
switch ($type) {
case "mp3" : $header = "Content-Type: audio/mp3";
break;
}
header($header);
if(strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) {
$header = "Content-Disposition: filename=".$fh.";";
} else {
$header = "Content-Disposition: attachment; filename=".$fh.";";
}
header($header);
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
readfile ($bestand);
ob_flush();
flush();
}
} else {
$illegal = true;
}
if ($illegal) {
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n";
echo "<title>downloading</title>\n";
echo "</head>\n";
echo "\n";
echo "<body>\n";
echo "File not found!\n";
echo "</body>\n";
echo "</html>\n";
}
?>