diff --git a/htdocs/document.php b/htdocs/document.php index 5a259898f80..b5d91d6df64 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 -if (eregi('\.doc$',$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; } -// Misc -if (eregi('\.sql$',$original_file)) { $attachment = true; } -if (eregi('\.html$',$original_file)) { $attachment = false; } // 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; } +// 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; } // 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 59f6a776bcf..3992345aaf9 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -459,7 +459,7 @@ class FormFile print ""; //print "XX".$file['name']; //$file['name'] must be utf8 print ''; 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 20a12f00071..f83fcfb6195 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; }