diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-09-25 15:03:59 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-09-25 15:03:59 +0200 |
commit | 6705e6c987b6e4a43bbb666c33d8fc8a0ef1a0a6 (patch) | |
tree | b815871f7f031633c400a33cf5d6245282d59955 /application/libraries/Ddownload/drivers/Ddownload_nginx.php | |
parent | 50230001eb5387b6b0ff7ce906d074ef4a530d11 (diff) | |
parent | ab98249a9a087745b29e5cb258ea0b624f12f64b (diff) |
Merge branch 'working'
Diffstat (limited to 'application/libraries/Ddownload/drivers/Ddownload_nginx.php')
-rw-r--r-- | application/libraries/Ddownload/drivers/Ddownload_nginx.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/application/libraries/Ddownload/drivers/Ddownload_nginx.php b/application/libraries/Ddownload/drivers/Ddownload_nginx.php new file mode 100644 index 000000000..2410df4d4 --- /dev/null +++ b/application/libraries/Ddownload/drivers/Ddownload_nginx.php @@ -0,0 +1,29 @@ +<?php +/* + * Copyright 2013 Pierre Schmitz <pierre@archlinux.de> + * + * 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'); + } + + header('Content-disposition: inline; filename="'.$filename."\"\n"); + header('Content-Type: '.$type."\n"); + header('X-Accel-Redirect: '.$download_location.$file_path."\n"); + } + +} |