diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-12-02 22:03:22 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-12-02 22:03:22 +0100 |
commit | ecebf3a8627f527cbd184b7907dd91f65764617b (patch) | |
tree | b8cc9e688deccab5f9b3a78258f666ecc624c4c5 /lib | |
parent | 02a002e903ab4b1afa2e1c3d7c2b3e44d77783fa (diff) | |
download | rpg-ecebf3a8627f527cbd184b7907dd91f65764617b.tar.gz rpg-ecebf3a8627f527cbd184b7907dd91f65764617b.tar.bz2 |
Make content-disposition configurable in mime.conf FS#1541
With this patch it is possible to define if a file should be served as download
or be displayed inside the browser (if supported) by configuring it in
conf/mime.conf
Mimetypes that should be served with a "Content-Disposition: attachment" header
need to be prefixed with a exclamation mark. All others will be served inline.
This will also fix a Problem with Flash 10.
darcs-hash:20081202210322-7ad00-6e7ef30aff9322cd135311be77809187da121f3b.gz
Diffstat (limited to 'lib')
-rw-r--r-- | lib/exe/fetch.php | 28 | ||||
-rw-r--r-- | lib/exe/xmlrpc.php | 2 |
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index becb60b64..dd4da459c 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -25,10 +25,11 @@ $CACHE = calc_cache($_REQUEST['cache']); $WIDTH = (int) $_REQUEST['w']; $HEIGHT = (int) $_REQUEST['h']; - list($EXT,$MIME) = mimetype($MEDIA); + list($EXT,$MIME,$DL) = mimetype($MEDIA); if($EXT === false){ $EXT = 'unknown'; $MIME = 'application/octet-stream'; + $DL = true; } //media to local file @@ -78,17 +79,18 @@ } // finally send the file to the client - $data = array('file' => $FILE, - 'mime' => $MIME, - 'cache' => $CACHE, - 'orig' => $ORIG, - 'ext' => $EXT, - 'width' => $WIDTH, - 'height' => $HEIGHT); + $data = array('file' => $FILE, + 'mime' => $MIME, + 'download' => $DL, + 'cache' => $CACHE, + 'orig' => $ORIG, + 'ext' => $EXT, + 'width' => $WIDTH, + 'height' => $HEIGHT); $evt = new Doku_Event('MEDIA_SENDFILE', $data); if ($evt->advise_before()) { - sendFile($data['file'],$data['mime'],$data['cache']); + sendFile($data['file'],$data['mime'],$data['download'],$data['cache']); } /* ------------------------------------------------------------------------ */ @@ -99,7 +101,7 @@ * @author Andreas Gohr <andi@splitbrain.org> * @author Ben Coburn <btcoburn@silicodon.net> */ -function sendFile($file,$mime,$cache){ +function sendFile($file,$mime,$dl,$cache){ global $conf; $fmtime = @filemtime($file); // send headers @@ -126,9 +128,11 @@ function sendFile($file,$mime,$cache){ http_conditionalRequest($fmtime); - //application mime type is downloadable - if(substr($mime,0,11) == 'application'){ + //download or display? + if($dl){ header('Content-Disposition: attachment; filename="'.basename($file).'";'); + }else{ + header('Content-Disposition: inline; filename="'.basename($file).'";'); } //use x-sendfile header to pass the delivery to compatible webservers diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index c2805cb01..97e473d7e 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -452,7 +452,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { io_saveFile($ftmp, $buff); // get filename - list($iext, $imime) = mimetype($id); + list($iext, $imime,$dl) = mimetype($id); $id = cleanID($id); $fn = mediaFN($id); |