[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** Wrapper to extend the actual mimetype class below. */ 4 class MailAttachmentMIME extends mimetype { 5 /** 6 * Detect the MIME type based on extension in the filename. 7 * @return MIME type text. 8 */ 9 static function detect($filename) { 10 $mime = new mimetype(); 11 return $mime->getType($filename); 12 } 13 } 14 15 /** 16 Copyright (C) 2002 Jason Sheets <[email protected]>. 17 All rights reserved. 18 19 THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 Redistribution and use in source and binary forms, with or without 21 modification, are permitted provided that the following conditions 22 are met: 23 24 1. Redistributions of source code must retain the above copyright 25 notice, this list of conditions and the following disclaimer. 26 27 2. Redistributions in binary form must reproduce the above copyright 28 notice, this list of conditions and the following disclaimer in the 29 documentation and/or other materials provided with the distribution. 30 31 3. Neither the name of the project nor the names of its contributors 32 may be used to endorse or promote products derived from this software 33 without specific prior written permission. 34 35 THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 36 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 38 ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 39 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 40 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 41 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 42 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 43 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 44 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 45 SUCH DAMAGE. 46 **/ 47 48 /** 49 Name: PHP MimeType Class 50 51 Version: 1.0 52 Date Released: 10/20/02 53 54 Description: This class allows a PHP script to determine the mime type 55 a file based on the file extension. This class is handy for PHP versions 56 without the benefit of other tools to determine the mime type. The class 57 defaults to octet-stream so if the file type is not recognized the user 58 is presented with a file download prompt. 59 60 NOTES: The mime types for this version are based on Apache 1.3.27 61 mime types may change or need to be added in the future, the mime types 62 are stored in an array so that an awk or other script can automatically 63 generate the code to make the array. 64 65 Usage: 66 67 First an instance of the mimetype class must be created, then the 68 getType method should be called with the filename. It will return 69 the mime type, an example follows. 70 71 Example: 72 73 $mimetype = new mimetype(); 74 print $mimetype->getType('acrobat.pdf'); 75 76 Author: Jason Sheets <[email protected]> 77 78 License: This script is distributed under the BSD License, you are free 79 to use, or modify it however you like. If you find this script useful please 80 e-mail me. 81 **/ 82 83 class mimetype { 84 function getType($filename) { 85 // get base name of the filename provided by user 86 $filename = basename($filename); 87 88 // break file into parts seperated by . 89 $filename = explode('.', $filename); 90 91 // take the last part of the file to get the file extension 92 $filename = $filename[count($filename)-1]; 93 94 // find mime type 95 return $this->privFindType($filename); 96 } 97 98 function privFindType($ext) { 99 // create mimetypes array 100 $mimetypes = $this->privBuildMimeArray(); 101 102 // return mime type for extension 103 if (isset($mimetypes[$ext])) { 104 return $mimetypes[$ext]; 105 // if the extension wasn't found return octet-stream 106 } else { 107 return 'application/octet-stream'; 108 } 109 110 } 111 112 function privBuildMimeArray() { 113 return array( 114 "ez" => "application/andrew-inset", 115 "hqx" => "application/mac-binhex40", 116 "cpt" => "application/mac-compactpro", 117 "doc" => "application/msword", 118 "bin" => "application/octet-stream", 119 "dms" => "application/octet-stream", 120 "lha" => "application/octet-stream", 121 "lzh" => "application/octet-stream", 122 "exe" => "application/octet-stream", 123 "class" => "application/octet-stream", 124 "so" => "application/octet-stream", 125 "dll" => "application/octet-stream", 126 "oda" => "application/oda", 127 "pdf" => "application/pdf", 128 "ai" => "application/postscript", 129 "eps" => "application/postscript", 130 "ps" => "application/postscript", 131 "smi" => "application/smil", 132 "smil" => "application/smil", 133 "wbxml" => "application/vnd.wap.wbxml", 134 "wmlc" => "application/vnd.wap.wmlc", 135 "wmlsc" => "application/vnd.wap.wmlscriptc", 136 "bcpio" => "application/x-bcpio", 137 "vcd" => "application/x-cdlink", 138 "pgn" => "application/x-chess-pgn", 139 "cpio" => "application/x-cpio", 140 "csh" => "application/x-csh", 141 "dcr" => "application/x-director", 142 "dir" => "application/x-director", 143 "dxr" => "application/x-director", 144 "dvi" => "application/x-dvi", 145 "spl" => "application/x-futuresplash", 146 "gtar" => "application/x-gtar", 147 "hdf" => "application/x-hdf", 148 "js" => "application/x-javascript", 149 "skp" => "application/x-koan", 150 "skd" => "application/x-koan", 151 "skt" => "application/x-koan", 152 "skm" => "application/x-koan", 153 "latex" => "application/x-latex", 154 "nc" => "application/x-netcdf", 155 "cdf" => "application/x-netcdf", 156 "sh" => "application/x-sh", 157 "shar" => "application/x-shar", 158 "swf" => "application/x-shockwave-flash", 159 "sit" => "application/x-stuffit", 160 "sv4cpio" => "application/x-sv4cpio", 161 "sv4crc" => "application/x-sv4crc", 162 "tar" => "application/x-tar", 163 "tcl" => "application/x-tcl", 164 "tex" => "application/x-tex", 165 "texinfo" => "application/x-texinfo", 166 "texi" => "application/x-texinfo", 167 "t" => "application/x-troff", 168 "tr" => "application/x-troff", 169 "roff" => "application/x-troff", 170 "man" => "application/x-troff-man", 171 "me" => "application/x-troff-me", 172 "ms" => "application/x-troff-ms", 173 "ustar" => "application/x-ustar", 174 "src" => "application/x-wais-source", 175 "xhtml" => "application/xhtml+xml", 176 "xht" => "application/xhtml+xml", 177 "zip" => "application/zip", 178 "au" => "audio/basic", 179 "snd" => "audio/basic", 180 "mid" => "audio/midi", 181 "midi" => "audio/midi", 182 "kar" => "audio/midi", 183 "mpga" => "audio/mpeg", 184 "mp2" => "audio/mpeg", 185 "mp3" => "audio/mpeg", 186 "aif" => "audio/x-aiff", 187 "aiff" => "audio/x-aiff", 188 "aifc" => "audio/x-aiff", 189 "m3u" => "audio/x-mpegurl", 190 "ram" => "audio/x-pn-realaudio", 191 "rm" => "audio/x-pn-realaudio", 192 "rpm" => "audio/x-pn-realaudio-plugin", 193 "ra" => "audio/x-realaudio", 194 "wav" => "audio/x-wav", 195 "pdb" => "chemical/x-pdb", 196 "xyz" => "chemical/x-xyz", 197 "bmp" => "image/bmp", 198 "gif" => "image/gif", 199 "ief" => "image/ief", 200 "jpeg" => "image/jpeg", 201 "jpg" => "image/jpeg", 202 "jpe" => "image/jpeg", 203 "png" => "image/png", 204 "tiff" => "image/tiff", 205 "tif" => "image/tif", 206 "djvu" => "image/vnd.djvu", 207 "djv" => "image/vnd.djvu", 208 "wbmp" => "image/vnd.wap.wbmp", 209 "ras" => "image/x-cmu-raster", 210 "pnm" => "image/x-portable-anymap", 211 "pbm" => "image/x-portable-bitmap", 212 "pgm" => "image/x-portable-graymap", 213 "ppm" => "image/x-portable-pixmap", 214 "rgb" => "image/x-rgb", 215 "xbm" => "image/x-xbitmap", 216 "xpm" => "image/x-xpixmap", 217 "xwd" => "image/x-windowdump", 218 "igs" => "model/iges", 219 "iges" => "model/iges", 220 "msh" => "model/mesh", 221 "mesh" => "model/mesh", 222 "silo" => "model/mesh", 223 "wrl" => "model/vrml", 224 "vrml" => "model/vrml", 225 "css" => "text/css", 226 "html" => "text/html", 227 "htm" => "text/html", 228 "asc" => "text/plain", 229 "txt" => "text/plain", 230 "rtx" => "text/richtext", 231 "rtf" => "text/rtf", 232 "sgml" => "text/sgml", 233 "sgm" => "text/sgml", 234 "tsv" => "text/tab-seperated-values", 235 "wml" => "text/vnd.wap.wml", 236 "wmls" => "text/vnd.wap.wmlscript", 237 "etx" => "text/x-setext", 238 "xml" => "text/xml", 239 "xsl" => "text/xml", 240 "mpeg" => "video/mpeg", 241 "mpg" => "video/mpeg", 242 "mpe" => "video/mpeg", 243 "qt" => "video/quicktime", 244 "mov" => "video/quicktime", 245 "mxu" => "video/vnd.mpegurl", 246 "avi" => "video/x-msvideo", 247 "movie" => "video/x-sgi-movie", 248 "ice" => "x-conference-xcooltalk" 249 ); 250 } 251 } 252 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |