diff --git a/htdocs/document.php b/htdocs/document.php index 5a259898f805c57e2a40030a8fe71642c685a269..b5d91d6df646b58321c2187a0f77e021e4e7d30e 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -70,28 +70,40 @@ function llxHeader() { } $type = 'application/octet-stream'; if (! empty($_GET["type"])) $type=$_GET["type"]; else $type=dol_mimetype($original_file); +//print 'X'.$type.'-'.$original_file;exit; // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; -// Documents +// Text files +if (eregi('\.txt$',$original_file)) { $attachment = false; } +if (eregi('\.csv$',$original_file)) { $attachment = true; } +if (eregi('\.tsv$',$original_file)) { $attachment = true; } +// Documents MS office if (eregi('\.doc$',$original_file)) { $attachment = true; } +if (eregi('\.dot$',$original_file)) { $attachment = true; } +if (eregi('\.mdb$',$original_file)) { $attachment = true; } if (eregi('\.ppt$',$original_file)) { $attachment = true; } if (eregi('\.xls$',$original_file)) { $attachment = true; } -if (eregi('\.pdf$',$original_file)) { $attachment = true; } +// Documents Open office +if (eregi('\.odp$',$original_file)) { $attachment = true; } +if (eregi('\.ods$',$original_file)) { $attachment = true; } +if (eregi('\.odt$',$original_file)) { $attachment = true; } // Misc +if (eregi('\.(html|htm)$',$original_file)) { $attachment = false; } +if (eregi('\.pdf$',$original_file)) { $attachment = true; } if (eregi('\.sql$',$original_file)) { $attachment = true; } -if (eregi('\.html$',$original_file)) { $attachment = false; } -// Text files -if (eregi('\.csv$',$original_file)) { $attachment = true; } -if (eregi('\.tsv$',$original_file)) { $attachment = true; } // Images if (eregi('\.jpg$',$original_file)) { $attachment = true; } +if (eregi('\.jpeg$',$original_file)) { $attachment = true; } if (eregi('\.png$',$original_file)) { $attachment = true; } +if (eregi('\.gif$',$original_file)) { $attachment = true; } +if (eregi('\.bmp$',$original_file)) { $attachment = true; } if (eregi('\.tiff$',$original_file)) { $attachment = true; } // Calendar if (eregi('\.vcs$',$original_file)) { $attachment = true; } if (eregi('\.ics$',$original_file)) { $attachment = true; } if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; +//print "XX".$attachment;exit; // Suppression de la chaine de caractere ../ dans $original_file $original_file = str_replace("../","/", $original_file); diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index 59f6a776bcf5e97f91704a1bbfd7c91ab4611c0e..3992345aaf940e57ee120ab6922f31a3443b289e 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -459,7 +459,7 @@ class FormFile print "<tr $bc[$var]><td>"; //print "XX".$file['name']; //$file['name'] must be utf8 print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; - if ($forcedownload) print '&type=application/binary'; + //if ($forcedownload) print '&type=application/binary'; print '&file='.urlencode($relativepath.$file['name']).'">'; print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' '; print dol_trunc($file['name'],$maxlength,'middle'); diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index 20a12f00071f528eef1ebd0172a8e5ae12778ee6..f83fcfb6195770f2e078dda5474cbb5fb716f6f6 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -168,24 +168,42 @@ function dol_compare_file($a, $b) function dol_mimetype($file) { $mime='application/octet-stream'; + // Text files if (eregi('\.txt',$file)) $mime='text/plain'; - if (eregi('\.sql$',$file)) $mime='text/plain'; - if (eregi('\.(html|htm)$',$file)) $mime='text/html'; if (eregi('\.csv$',$file)) $mime='text/csv'; if (eregi('\.tsv$',$file)) $mime='text/tab-separated-values'; + // MS office + if (eregi('\.mdb$',$file)) $mime='application/msaccess'; + if (eregi('\.doc$',$file)) $mime='application/msword'; + if (eregi('\.dot$',$file)) $mime='application/msword'; + if (eregi('\.xls$',$file)) $mime='application/vnd.ms-excel'; + if (eregi('\.ppt$',$file)) $mime='application/vnd.ms-powerpoint'; + // Open office + if (eregi('\.odp$',$file)) $mime='application/vnd.oasis.opendocument.presentation'; + if (eregi('\.ods$',$file)) $mime='application/vnd.oasis.opendocument.spreadsheet'; + if (eregi('\.odt$',$file)) $mime='application/vnd.oasis.opendocument.text'; + // Mix + if (eregi('\.(html|htm)$',$file)) $mime='text/html'; if (eregi('\.pdf$',$file)) $mime='application/pdf'; - if (eregi('\.xls$',$file)) $mime='application/x-msexcel'; + if (eregi('\.sql$',$file)) $mime='text/plain'; + if (eregi('\.(sh|ksh|bash)$',$file)) $mime='text/plain'; + // Images if (eregi('\.jpg$',$file)) $mime='image/jpeg'; if (eregi('\.jpeg$',$file)) $mime='image/jpeg'; if (eregi('\.png$',$file)) $mime='image/png'; if (eregi('\.gif$',$file)) $mime='image/gif'; if (eregi('\.bmp$',$file)) $mime='image/bmp'; if (eregi('\.tiff$',$file)) $mime='image/tiff'; + // Calendar if (eregi('\.vcs$',$file)) $mime='text/calendar'; if (eregi('\.ics$',$file)) $mime='text/calendar'; + // Other if (eregi('\.torrent$',$file)) $mime='application/x-bittorrent'; + // Audio if (eregi('\.(mp3|ogg|au)$',$file)) $mime='audio'; + // Video if (eregi('\.(avi|mvw|divx|xvid)$',$file)) $mime='video'; + // Archive if (eregi('\.(zip|rar|gz|tgz|z|cab|bz2)$',$file)) $mime='archive'; return $mime; }