From 635b0717931df907ee8015a42ad0ed1fcdf967c4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 23 Sep 2013 07:47:40 +0200 Subject: Implement rangeDownload() as driver and provide sendfile implementations for Nginx and Lighttpd * The rangeDownload() function has been moved to libraries/Ddownload/drivers/Ddownload_php.php * The nginx and lighttpd drivers can be set via $config['download_driver'] Signed-off-by: Pierre Schmitz --- .../Ddownload/drivers/Ddownload_nginx.php | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 application/libraries/Ddownload/drivers/Ddownload_nginx.php (limited to 'application/libraries/Ddownload/drivers/Ddownload_nginx.php') diff --git a/application/libraries/Ddownload/drivers/Ddownload_nginx.php b/application/libraries/Ddownload/drivers/Ddownload_nginx.php new file mode 100644 index 000000000..5fb6ffa87 --- /dev/null +++ b/application/libraries/Ddownload/drivers/Ddownload_nginx.php @@ -0,0 +1,30 @@ + + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ + +class Ddownload_nginx extends Ddownload_Driver { + + public function serveFile($file, $filename, $type) + { + $CI =& get_instance(); + $upload_path = $CI->config->item('upload_path'); + $download_location = $CI->config->item('download_nginx_location'); + + if (strpos($file, $upload_path) === 0) { + $file_path = substr($file, strlen($upload_path)); + } else { + show_error('Invalid file path'); + return; + } + + header('Content-disposition: inline; filename="'.$filename."\"\n"); + header('Content-Type: '.$type."\n"); + header('X-Accel-Redirect: '.$download_location.$file_path."\n"); + } + +} -- cgit v1.2.3-24-g4f1b