From 4b94acadaae93e5e1400e76e3f6efdaf24639792 Mon Sep 17 00:00:00 2001 From: uid30988 Date: Thu, 5 Jul 2001 00:41:45 +0000 Subject: [PATCH] Correct MIME-type when viewing, add option for viewing files with unknown MIME-type as text/plain --- filemanager/inc/hook_add_def_pref.inc.php | 1 + filemanager/index.php | 12 ++++++++++++ filemanager/preferences.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/filemanager/inc/hook_add_def_pref.inc.php b/filemanager/inc/hook_add_def_pref.inc.php index ae62df7700..e24a0111f6 100755 --- a/filemanager/inc/hook_add_def_pref.inc.php +++ b/filemanager/inc/hook_add_def_pref.inc.php @@ -14,6 +14,7 @@ $pref->change ("phpwebhosting", "modifiedby_id", "True"); $pref->change ("phpwebhosting", "comment", "True"); //$pref->change ("phpwebhosting", "viewinnewwin", "False"); //$pref->change ("phpwebhosting", "viewonserver", "False"); +$pref->change ("phpwebhosting", "viewtextplain", True); //$pref->change ("phpwebhosting", "dotdot", "False"); //$pref->change ("phpwebhosting", "dotfiles", "False"); diff --git a/filemanager/index.php b/filemanager/index.php index 4f3813fdd5..c5e1b92eaf 100755 --- a/filemanager/index.php +++ b/filemanager/index.php @@ -247,6 +247,18 @@ if ($download) if ($op == "view" && $file) { + $ls_array = $phpgw->vfs->ls ($file, array (RELATIVE_ALL), False, False, True); + + if ($ls_array[0]["mime_type"]) + { + $mime_type = $ls_array[0]["mime_type"]; + } + elseif ($settings["viewtextplain"]) + { + $mime_type = "text/plain"; + } + + header('Content-type: ' . $mime_type); echo $phpgw->vfs->read ($file); $phpgw->common->phpgw_exit (); } diff --git a/filemanager/preferences.php b/filemanager/preferences.php index 5592b48c88..776f6a9906 100644 --- a/filemanager/preferences.php +++ b/filemanager/preferences.php @@ -17,7 +17,7 @@ /* To add a preference, just add it here. Key is internal name, value is displayed name */ - $other_checkboxes = array ("viewinnewwin" => "View documents in new window", "viewonserver" => "View documents on server (if available)", "dotdot" => "Show ..", "dotfiles" => "Show .files"); + $other_checkboxes = array ("viewinnewwin" => "View documents in new window", "viewonserver" => "View documents on server (if available)", "viewtextplain" => "Unknown MIME-type defaults to text/plain when viewing", "dotdot" => "Show ..", "dotfiles" => "Show .files"); if ($submit) {