Someone look ovr these and tell what I am doing wrong, The download works fine and everything look good until i try to open the file and it's corrupt.
include('../config.inc.php');
ini_set('max_execution_time', 0);
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
$query = "select * from ".$prefix."search WHERE code = '$_GET[filename]'";
$result = MySQL_query($query);
$rows = MySQL_fetch_array($result);
if ($filename == ""){
echo "You must specify a filename!";
exit;
}
$domain=$HTTP_HOST;
$domain1="www.$HTTP_HOST";
$refr=getenv("HTTP_REFERER");
list($remove,$stuff)=split('//',$refr,2);
list($home,$stuff)=split('/',$stuff,2);
if ($home!=$domain AND $home!=$domain1 AND $home!=$root_url) {readfile($root_url."/download/leech.php");exit;
}else{
$filename = $rows[file_path];
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Transfer-Encoding: binary");
header("Cache-Control: private",false);
header("Content-Type: ".getMIMEtype($filename));
header("Content-Disposition: attachment; filename=".basename($filename).";" );
header("Content-Length: ".filesize($filename));
echo file_get_contents($filename);
}