my script is little diferent, it suppor resume for getright, download accelerator, and others download managers.
It´s work fine with php as apache module.
i have a problem, header("HTTP/1.1 206 Partial Content"); doesnt work as cgi module and i dont know why, does anyobody know how can i make it?
php say
[Wed Jan 29 11:07:18 2003] [error] [client 200.43.42.120] malformed header
from script. Bad header=HTTP/1.1 206 Partial content:
/usr/local/php/bin//php
thanks
<?
header("HTTP/1.1 206 Partial Content");
$filename="file.zip";
if ($HTTP_RANGE){
$pos=strpos ($HTTP_RANGE, "bytes=");
$pos2=strpos($HTTP_RANGE,"-");
$bytes=substr ($HTTP_RANGE, $pos+strlen("bytes="),$pos2-($pos+strlen("bytes=")));
$ultimobyte=substr($HTTP_RANGE,$pos2+1,strlen($HTTP_RANGE));
}else{
$bytes=0;
}
settype ($bytes, "integer");
settype ($ultimobyte,"integer");
if ($ultimobyte!=0) {
$hasta=$ultimobyte;
}else{
$hasta=filesize($filename)-1;
}
$largo=$hasta-$bytes+1;
$ttotal=filesize($filename);
error_reporting(0);
header("Last-Modified: " . gmdate("D, d M Y H:i:s T", filemtime($filename)));
header("Accept-Ranges: bytes");
header("Content-Length: " . $largo);
header("Content-Disposition:attachment; filename="."file.zip");
header("Content-Range: bytes ".$bytes."-".$hasta."/".$ttotal);
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Transfer-Encoding: binary");
header("Pragma:no-cache");
header("Expires:0");
set_time_limit(0);
$fp = fopen($filename,'rb');
if (!$fp) {
echo "error de apertura";
exit();
}
rewind ($fp);
fseek ($fp, $bytes);
echo fread ($fp, $largo);
header("Connection: close");
exit();