ÆÄÀÏ ´Ù¿î·Îµå ÇÔ¼ö(¸ÖƼ À̾î¹Þ±â - ¼ÓµµÁ¦ÇÑ) |
|
|
![](icon/private_name/1.gif) |
12³â Àü |
function fDown($file,$name,$downview,$speed,$limit)// °æ·Î, ¿øÆÄÀϸí, ´Ù¿î/º¸ÀÓ, ´Ù¿î¼Óµµ, ¼ÓµµÁ¦ÇÑ¿©ºÎ
{
if(!file_exists($file))
die('File not exist!');
$size = filesize($file);
$name = rawurldecode($name);
if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
$UserBrowser = "Opera";
elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
$UserBrowser = "IE";
else
$UserBrowser = '';
// ºê¶ó¿ìÀú Á¤ÀÇ
$mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera')? 'application/octetstream' : 'application/octet-stream';
@ob_end_clean(); // decrease cpu usage extreme
Header('Content-Type: ' . $mime_type);
Header('Content-Disposition: $downview; filename="'.$name.'"');
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header('Accept-Ranges: bytes');
Header("Cache-control: private");
Header('Pragma: private');
// multipart-download and resume-download
if(isset($_SERVER['HTTP_RANGE']))
{
list($a, $range) = explode("=",$_SERVER['HTTP_RANGE']);
str_replace($range, "-", $range);
$size2 = $size-1;
$new_length = $size-$range;
Header("HTTP/1.1 206 Partial Content");
Header("Content-Length: $new_length");
Header("Content-Range: bytes $range$size2/$size");
} else {
$size2=$size-1;
Header("Content-Length: ".$size);
}
$chunksize = 1*(1024*$speed); // ¼ÓµµÁ¦ÇÑ°ª
$this->bytes_send = 0;
if ($file = fopen($file, 'rb'))
{
if(isset($_SERVER['HTTP_RANGE']))
fseek($file, $range);
while(!feof($file) and (connection_status()==0))
{
$buffer = fread($file, $chunksize);
print($buffer);//echo($buffer); // is also possible
flush();
$this->bytes_send += strlen($buffer);
if($limit) sleep(1); // ´Ù¿î·Îµå ¼ÓµµÁ¦ÇÑ
}
fclose($file);
} else
die('Error can not open file!!');
if(isset($new_length))
$size = $new_length;
die();
Header("Connection: close");
}
|
|
̵̧ : 686 |
̵̧
¸ñ·Ï
|
|