A bug in latest version and some suggestions
Verfasst: Mo 06.Feb, 2006 22:40
In load.php, remove lines 18-21
Also, I've replaced the readfile function with this one:
Don't know if you are aware of it, but you can't download files bigger than 10mb in some php compilations. Along with this one I've made another change:
In load.php replace:
With:
This way you'll get the file size when downloading the file, and the download will be correctly seen with some applications as Adobe Reader when viewing some files.
Code: Alles auswählen
if ($userdata['user_id'] == 6)
{
redirect(append_sid("downloads.$phpEx"));
}Also, I've replaced the readfile function with this one:
Code: Alles auswählen
function readfile_chunked($filename,$retbytes=true) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
set_time_limit(0);
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;
}
In load.php replace:
Code: Alles auswählen
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$file_name\"");
readfile($download_dir . "" . $file_path . "/" . $file_name);Code: Alles auswählen
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Length: ".@filesize($download_dir . "" . $file_path . "/" . $file_name));
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"$file_name\"");
readfile_chunked($download_dir . "" . $file_path . "/" . $file_name);