[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_lib/ -> mimetype.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  $phpwcms['mime_types'] = array(
  24      
  25      '*'            =>    'application/octet-stream',
  26      '3dmf'        =>    'x-world/x-3dmf',
  27      '3g2'        =>    'video/3gpp2',
  28      '3gp2'        =>    'video/3gpp2',
  29      '3gp'        =>    'video/3gpp',
  30      '3gpp'        =>    'video/3gpp',
  31      'abs'        =>    'audio/x-mpeg',
  32      'aac'        =>    'audio/acc',
  33      'adts'        =>    'audio/acc',
  34      'ai'        =>    'application/postscript',
  35      'aif'        =>    'audio/x-aiff',
  36      'aifc'        =>    'audio/x-aiff',
  37      'aiff'        =>    'audio/x-aiff',
  38      'asc'        =>    'text/plain',
  39      'asf'        =>    'video/x-ms-asf',
  40      'au'        =>    'audio/basic',
  41      'avi'        =>    'video/x-msvideo',
  42      'axs'        =>    'application/x-olescript',
  43      'bcpio'        =>    'application/x-bcpio',
  44      'bin'        =>    'application/octet-stream',
  45      'bmp'        =>    'image/x-ms-bmp',
  46      'bwf'        =>    'audio/wav',
  47      'bz2'        =>    'application/x-bzip2',
  48      'c'            =>    'text/plain',
  49      'c++'        =>    'text/plain',
  50      'cal'        =>    'image/x-cals',
  51      'cc'        =>    'text/plain',
  52      'cdda'        =>    'audio/aiff',
  53      'cgm'        =>    'image/cgm',
  54      'chrt'        =>    'application/x-kchart',
  55      'cmx'        =>    'image/x-cmx',
  56      'com'        =>    'application/octet-stream',
  57      'cpio'        =>    'application/x-cpio',
  58      'cpt'        =>    'application/mac-compactpro',
  59      'csh'        =>    'application/x-csh',
  60      'csh'        =>    'application/x-csh',
  61      'css'        =>    'text/css',
  62      'dll'        =>    'application/octet-stream',
  63      'doc'        =>    'application/msword',
  64      'dot'        =>    'application/msword',
  65      'dsf'        =>    'image/x-mgx-dsf',
  66      'dvi'        =>    'application/x-dvi',
  67      'dwf'        =>    'drawing/x-dwf',
  68      'dwg'        =>    'image/x-dwg',
  69      'dxf'        =>    'image/x-dxf',
  70      'eps'        =>    'application/postscript',
  71      'es'        =>    'audio/echospeech',
  72      'evy'        =>    'application/envoy',
  73      'exe'        =>    'application/octet-stream',
  74      
  75      'f4a'        =>    'audio/mp4',
  76      'f4b'        =>    'audio/mp4',
  77      'f4p'        =>    'video/mp4',
  78      'f4v'        =>    'video/mp4',
  79      
  80      'fif'        =>    'image/fif',
  81      'flac'        =>    'audio/flac',
  82      'flv'        =>    'video/x-flv',
  83      'fm'        =>    'application/x-framemaker',
  84      'frame'        =>    'application/x-framemaker',
  85      'frm'        =>    'application/x-framemaker',
  86      'g3f'        =>    'image/g3fax',
  87      'gif'        =>    'image/gif',
  88      'gtar'        =>    'application/x-gtar',
  89      'gz'        =>    'application/x-gzip',
  90      'h'            =>    'text/plain',
  91      'hdf'        =>    'application/hdf',
  92      'hqx'        =>    'application/mac-binhex40',
  93      'htm'        =>    'text/html',
  94      'html'        =>    'text/html',
  95      'ice'        =>    'x-conference/x-cooltalk',
  96      'ief'        =>    'image/ief',
  97      'jpe'        =>    'image/jpeg',
  98      'jpeg'        =>    'image/jpeg',
  99      'jpg'        =>    'image/jpeg',
 100      'js'        =>    'text/javascript',
 101      'kar'        =>    'audio/midi',
 102      'kpr'        =>    'application/x-kpresenter',
 103      'kpt'        =>    'application/x-kpresenter',
 104      'ksp'        =>    'application/x-kspread',
 105      'kwd'        =>    'application/x-kword',
 106      'kwt'        =>    'application/x-kword',
 107      'latex'        =>    'application/x-latex',
 108      'lcc'        =>    'application/fastman',
 109      'ls'        =>    'text/javascript',
 110      'm1a'        =>    'video/mpeg',
 111      'm1s'        =>    'video/mpeg',
 112      'm1v'        =>    'video/mpeg',
 113      'm15'        =>    'video/mpeg',
 114      'm4a'        =>    'audio/x-m4a',
 115      'm4v'        =>    'video/x-m4v',
 116      'm75'        =>    'video/mpeg',
 117      'man'        =>    'application/x-troff-man',
 118      'me'        =>    'application/x-troff-me',
 119      'mid'        =>    'audio/midi',
 120      'midi'        =>    'audio/midi',
 121      'mif'        =>    'application/x-mif',
 122      'mil'        =>    'image/x-cals',
 123      'mmid'        =>    'x-music/x-midi',
 124      'mocha'        =>    'text/javascript',
 125      'mov'        =>    'video/quicktime',
 126      'movie'        =>    'video/x-sgi-movie',
 127      'mp2'        =>    'audio/mpeg',
 128      'mp2a'        =>    'audio/x-mpeg-2',
 129      'mp2v'        =>    'video/mpeg-2',
 130      'mp3'        =>    'audio/mpeg',
 131      'mp4'        =>    'video/mp4',
 132      'mpa'        =>    'audio/x-mpeg',
 133      'mpa2'        =>    'audio/x-mpeg-2',
 134      'mpe'        =>    'video/mpeg',
 135      'mpeg'        =>    'video/mpeg',
 136      'mpega'        =>    'audio/x-mpeg',
 137      'mpg'        =>    'video/mpeg',
 138      'mpg4'        =>    'video/mp4',
 139      'mpga'        =>    'audio/mpeg',
 140      'mpm'        =>    'video/mpeg',
 141      'mpv'        =>    'video/mpeg',
 142      'mpv2'        =>    'video/mpeg-2',
 143      'ms'        =>    'application/x-troff-ms',
 144      'oda'        =>    'application/oda',
 145      
 146      // Open Office
 147      'odt'        =>    'application/vnd.oasis.opendocument.text',
 148      'ott'        =>    'application/vnd.oasis.opendocument.text-template',
 149      'odg'        =>    'application/vnd.oasis.opendocument.graphics',
 150      'otg'        =>    'application/vnd.oasis.opendocument.graphics-template',
 151      'odp'        =>    'application/vnd.oasis.opendocument.presentation',
 152      'otp'        =>    'application/vnd.oasis.opendocument.presentation-template',
 153      'ods'        =>    'application/vnd.oasis.opendocument.spreadsheet',
 154      'ots'        =>    'application/vnd.oasis.opendocument.spreadsheet-template',
 155      'odc'        =>    'application/vnd.oasis.opendocument.chart',
 156      'otc'        =>    'application/vnd.oasis.opendocument.chart-template',
 157      'odi'        =>    'application/vnd.oasis.opendocument.image',
 158      'oti'        =>    'application/vnd.oasis.opendocument.image-template',
 159      'odf'        =>    'application/vnd.oasis.opendocument.formula',
 160      'otf'        =>    'application/vnd.oasis.opendocument.formula-template',
 161      'odm'        =>    'application/vnd.oasis.opendocument.text-master',
 162      'oth'        =>    'application/vnd.oasis.opendocument.text-web',
 163      
 164      // Office 2007
 165      'docx'            =>    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
 166      'docm'            =>    'application/vnd.ms-word.document.macroEnabled.12',
 167      'dotx'            =>    'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
 168      'dotm'            =>    'application/vnd.ms-word.template.macroEnabled.12',
 169      'xlsx'            =>    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
 170      'xlsm'            =>    'application/vnd.ms-excel.sheet.macroEnabled.12',
 171      'xltx'            =>    'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
 172      'xltm'            =>    'application/vnd.ms-excel.template.macroEnabled.12',
 173      'xlsb'            =>    'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
 174      'xlam'            =>    'application/vnd.ms-excel.addin.macroEnabled.12',
 175      'pptx'            =>    'application/vnd.openxmlformats-officedocument.presentationml.presentation',
 176      'pptm'            =>    'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
 177      'ppsx'            =>    'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
 178      'ppsm'            =>    'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
 179      'potx'            =>    'application/vnd.openxmlformats-officedocument.presentationml.template',
 180      'potm'            =>    'application/vnd.ms-powerpoint.template.macroEnabled.12',
 181      'ppam'            =>    'application/vnd.ms-powerpoint.addin.macroEnabled.12',
 182      'sldx'            =>    'application/vnd.openxmlformats-officedocument.presentationml.slide',
 183      'sldm'            =>    'application/vnd.ms-powerpoint.slide.macroEnabled.12',
 184      'thmx'            =>    'application/vnd.ms-officetheme',
 185      'onetoc'        =>    'application/onenote',
 186      'onetoc2'        =>    'application/onenote',
 187      'onetmp'        =>    'application/onenote',
 188      'onepkg'        =>    'application/onenote',
 189      
 190      'oga'        =>    'audio/ogg',
 191      'ogg'        =>    'audio/ogg',
 192      'ogv'        =>    'video/ogg',
 193      'ogx'        =>    'application/ogg',
 194      'pac'        =>    'application/x-ns-proxy-autoconfig',
 195      'pbm'        =>    'image/x-portable-bitmap',
 196      'pcd'        =>    'image/x-photo-cd',
 197      'pdf'        =>    'application/pdf',
 198      'pgm'        =>    'image/x-portable-graymap',
 199      'php'        =>    'text/plain',
 200      'phps'        =>    'text/plain',
 201      'pict'        =>    'image/x-pict',
 202      'pl'        =>    'text/plain',
 203      'png'        =>    'image/png',
 204      'pnm'        =>    'image/x-portable-anymap',
 205      'ppm'        =>    'image/x-portable-pixmap',
 206      'ppt'        =>    'application/mspowerpoint',
 207      'ps'        =>    'application/postscript',
 208      'qt'        =>    'video/quicktime',
 209      'ra'        =>    'application/x-pn-realaudio',
 210      'ram'        =>    'application/x-pn-realaudio',
 211      'ras'        =>    'image/x-cmu-raster',
 212      'rgb'        =>    'image/rgb',
 213      'roff'        =>    'application/x-troff',
 214      'rtf'        =>    'application/rtf',
 215      'rtx'        =>    'text/richtext',
 216      'sdv'        =>    'video/sd-video',
 217      'sea'        =>    'application/x-stuffit',
 218      'sgm'        =>    'text/sgml',
 219      'sgml'        =>    'text/sgml',
 220      'sh'        =>    'application/x-sh',
 221      'sh'        =>    'application/x-sh',
 222      'shar'        =>    'application/x-shar',
 223      'sit'        =>    'application/x-stuffit',
 224      'skp'        =>    'application/x-koan',
 225      'smf'        =>    'audio/midi',
 226      'snd'        =>    'audio/basic',
 227      'spl'        =>    'application/futuresplash',
 228      'spx'        =>    'audio/ogg',
 229      'src'        =>    'application/x-wais-source',
 230      'svf'        =>    'vector/x-svf',
 231      'swa'        =>    'audio/mp3',
 232      'swf'        =>    'application/x-shockwave-flash',
 233      't'            =>    'application/x-troff',
 234      'talk'        =>    'text/x-speech',
 235      'tar'        =>    'application/x-tar',
 236      'tcl'        =>    'application/x-tcl',
 237      'tex'        =>    'application/x-tex',
 238      'texi'        =>    'application/x-texinfo',
 239      'texinfo'    =>    'application/x-texinfo',
 240      'tgz'        =>    'application/x-gzip',
 241      'tif'        =>    'image/tiff',
 242      'tiff'        =>    'image/tiff',
 243      'tr'        =>    'application/x-troff',
 244      'txt'        =>    'text/plain',
 245      'ustar'        =>    'application/x-ustar',
 246      'uu'        =>    'application/octet-stream',
 247      'vbs'        =>    'text/vbscript',
 248      'vdo'        =>    'video/vdo',
 249      'video'        =>    'video/x-msvideo',
 250      'viv'        =>    'video/vivo',
 251      'vox'        =>    'audio/voxware',
 252      'wav'        =>    'audio/wav',
 253      'wax'        =>    'audio/x-ms-wax',
 254      'webm'        =>    'video/webm',
 255      'wi'        =>    'image/wavelet',
 256      'wm'        =>    'video/x-ms-wm',
 257      'wma'        =>    'audio/x-ms-wma',
 258      'wmv'        =>    'video/x-ms-wmv',
 259      'wp'        =>    'application/wordperfect5.1',
 260      'wsrc'        =>    'application/x-wais-source',
 261      'wvx'        =>    'video/x-ms-wvx',
 262      'xbm'        =>    'image/x-xbitmap',
 263      'xls'        =>    'application/msexcel',
 264      'xml'        =>    'text/xml',
 265      'xpm'        =>    'image/x-xpixmap',
 266      'xwd'        =>    'image/x-xwindowdump',
 267      'zip'        =>    'application/zip'
 268  
 269  );
 270  
 271  /*
 272   * Return Mime-Type of file extension
 273   *
 274   * @param string file extension
 275   * @return strin mime-type
 276   */
 277  function get_mimetype_by_extension($ext='') {
 278      
 279      if(empty($ext) || !isset($GLOBALS['phpwcms']['mime_types'][$ext])) {
 280          $ext = '*';
 281      }
 282  
 283      return $GLOBALS['phpwcms']['mime_types'][$ext];
 284  }
 285  
 286  function is_mimetype_by_extension($ext) {
 287      return empty($ext) || !isset($GLOBALS['phpwcms']['mime_types'][$ext]) ? false : true;
 288  }
 289  
 290  /**
 291   * Check a given MimeType against type/subtype format
 292   * It is mainly based to handle problemes related to mimeTypes.rdf in FireFox
 293   */
 294  function is_mimetype_format($mimetype='') {
 295      
 296      if(empty($mimetype)) {
 297          return false;
 298      }
 299      
 300      // we do not test against 'examples' type
 301      return preg_match('/^(application|audio|image|text|video|message|model|multipart)\/([a-z0-9\-\.\+]+)$/i', $mimetype);
 302  }
 303  
 304  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1