Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.9 KiB

  1. <?php
  2. if(!function_exists('mime_content_type')) {
  3. function mime_content_type($filename) {
  4. $mime_types = array(
  5. 'txt' => 'text/plain',
  6. 'htm' => 'text/html',
  7. 'html' => 'text/html',
  8. 'php' => 'text/html',
  9. 'css' => 'text/css',
  10. 'js' => 'application/javascript',
  11. 'json' => 'application/json',
  12. 'xml' => 'application/xml',
  13. 'swf' => 'application/x-shockwave-flash',
  14. 'flv' => 'video/x-flv',
  15. // images
  16. 'png' => 'image/png',
  17. 'jpe' => 'image/jpeg',
  18. 'jpeg' => 'image/jpeg',
  19. 'jpg' => 'image/jpeg',
  20. 'gif' => 'image/gif',
  21. 'bmp' => 'image/bmp',
  22. 'ico' => 'image/vnd.microsoft.icon',
  23. 'tiff' => 'image/tiff',
  24. 'tif' => 'image/tiff',
  25. 'svg' => 'image/svg+xml',
  26. 'svgz' => 'image/svg+xml',
  27. // archives
  28. 'zip' => 'application/zip',
  29. 'rar' => 'application/x-rar-compressed',
  30. 'exe' => 'application/x-msdownload',
  31. 'msi' => 'application/x-msdownload',
  32. 'cab' => 'application/vnd.ms-cab-compressed',
  33. // audio/video
  34. 'mp3' => 'audio/mpeg',
  35. 'qt' => 'video/quicktime',
  36. 'mov' => 'video/quicktime',
  37. 'ogg' => 'application/ogg',
  38. // adobe
  39. 'pdf' => 'application/pdf',
  40. 'psd' => 'image/vnd.adobe.photoshop',
  41. 'ai' => 'application/postscript',
  42. 'eps' => 'application/postscript',
  43. 'ps' => 'application/postscript',
  44. // ms office
  45. 'doc' => 'application/msword',
  46. 'rtf' => 'application/rtf',
  47. 'xls' => 'application/vnd.ms-excel',
  48. 'ppt' => 'application/vnd.ms-powerpoint',
  49. // open office
  50. 'odt' => 'application/vnd.oasis.opendocument.text',
  51. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  52. );
  53. if(strpos($filename,'.') !== false) {
  54. $ext = strtolower(array_pop(explode('.',$filename)));
  55. if (array_key_exists($ext, $mime_types)) {
  56. return $mime_types[$ext];
  57. }
  58. }
  59. elseif (function_exists('finfo_open')) {
  60. $finfo = finfo_open(FILEINFO_MIME);
  61. $mimetype = finfo_file($finfo, $filename);
  62. finfo_close($finfo);
  63. return $mimetype;
  64. }
  65. else {
  66. return 'application/octet-stream';
  67. }
  68. }}