Led 17
<?php /* send_file( string $file [, int $rate ] ) param $file - Path to the file to send param $rate - Speed limit of download in kB/s */ function send_file($file, $rate = 0) { // check if the file exists if (!is_file($file)) { die('404 File Not Found'); } // get the filename, extension, and size $filename = basename($file); $file_extension = strtolower(substr(strrchr($filename, '.'), 1)); $size = filesize($file); // set the mime type based on the extension switch($file_extension) { case 'exe': $ctype = 'application/octet-stream'; break; case 'zip': $ctype = 'application/zip'; break; case 'mp3': $ctype = 'audio/mpeg'; break; case 'mpg': $ctype = 'video/mpeg'; break; case 'avi': $ctype = 'video/x-msvideo'; break; // block access to sensitive file types case 'php': case 'inc': exit; break; default: $ctype='application/force-download'; } // begin writing headers header('Cache-Control: private'); header('Content-Type: ' . $ctype); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); // open the file for reading $fp = fopen($file, 'rb'); // check if http_range was sent by client if(isset($_SERVER['HTTP_RANGE'])) { // if so, calculate the range to use $seek_range = substr($_SERVER['HTTP_RANGE'], 6); $range = explode('-', $seek_range); if($range[0] > 0){ $seek_start = intval($range[0]); } if($range[1] > 0){ $seek_end = intval($range[1]); } // seek to the requested position in the file fseek($fp, $seek_start); // set the range response headers header('HTTP/1.1 206 Partial Content'); header('Content-Length: ' . ($seek_end - $seek_start + 1)); header(sprintf('Content-Range: bytes %d-%d/%d', $seek_start, $seek_end, $size)); } else { // set default response headers header('Content-Length: ' . $size); } // set up the size of each piece of data we send $block_size = 1024; if($rate > 0) { // multiply by rate if specified $block_size *= $rate; } // prevent the script from timing out set_time_limit(0); // start sending the file while(!feof($fp)) { // output data print(fread($fp, $block_size)); flush(); if($rate > 0) { // wait one second before next block if rate is specified sleep(1); } } // close the file fclose($fp); } ?> |

You post awsome posts. Bookmarked !
I am not able to view this website correctly on opera I think there’s a downside
Good day, Fantastic site, exactly where did you come up of the facts in this summation? Im glad I observed it though, I will be checking back soon to determine what other posts you have.
Hi there, I loved studying your post. Thanks for the great info. Hoped that we can prolong our friendship by a mutual link exchange? Let me know, and nice to see you here!
Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is magnificent blog. A fantastic read. I will certainly be back.
I was suggested this blog by means of my bro. I am not sure whether or not this publish is written by means of him as no one else understand such precise about my problem. You’re wonderful! Thanks!
Usually I do not post on blogs, but I would like to say that this post extremely forced me to complete so! Thanks, really nice article.