function doError($error)
{
echo "
" . $error . "
";
echo "Click to return to the Rollofone web site";
exit(0);
}
$dir = "/storage/Audio/";
$file = "/storage/Audio/gmsoundstereo.flac";
if (!isset($_GET['sg']))
exit(0);
$id = sha1($_GET['sg']);
$fp = @fopen($dir . "list.txt","r");
if (!$fp) {
$error = "Unable to open index.";
doError($error);
exit(0);
}
$rf_name = null;
$rf_file = null;
while (!feof($fp)) {
$in = str_replace("\n","",fgets($fp));
$z = explode("::",$in);
if (count($z) != 3)
continue;
if (sha1($z[0])== $id) {
$rf_name = trim($z[1]);
$rf_file = trim($z[2]);
break;
}
}
fclose($fp);
if (!$rf_name || !$rf_file) {
doError("Sorry - No file with this id");
exit(0);
}
$file = $dir . $rf_file;
$in = filesize($file);
$fp = fopen($file,"rb");
if (!$fp) {
doError("Sorry - This file is not or no longer available");
exit(0);
}
header("Content-Disposition: Attachment;filename=".$rf_name);
header("Content-Description: File Transfer");
header("Content-Type: audio/flac");
header("Content-Transfer-Encoding: Binary");
header("Content-Length: " . filesize($file));
$out = 0;
while (!feof($fp)) {
$data = fread($fp,102400);
echo $data;
}
exit(0);
?>