summaryrefslogtreecommitdiffstats
path: root/wp-content
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-08-22 16:10:10 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-08-22 16:10:10 +0000
commit589234f7fa9e0bcb1817801e700e8eafc3ea2808 (patch)
tree7dbaa8ff665daa751084fb26963233a2ac502d53 /wp-content
parent3cdac022a506c1192454ea6ea45d8009b2d5fdeb (diff)
downloadwordpress-mu-589234f7fa9e0bcb1817801e700e8eafc3ea2808.tar.gz
wordpress-mu-589234f7fa9e0bcb1817801e700e8eafc3ea2808.tar.xz
wordpress-mu-589234f7fa9e0bcb1817801e700e8eafc3ea2808.zip
Use wp_check_filetype() to figure out mimetype.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@725 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-content')
-rw-r--r--wp-content/blogs.php65
1 files changed, 61 insertions, 4 deletions
diff --git a/wp-content/blogs.php b/wp-content/blogs.php
index b2fd603..63f3f0c 100644
--- a/wp-content/blogs.php
+++ b/wp-content/blogs.php
@@ -2,6 +2,63 @@
define( "BLOGDEFINITION", true );
require_once( "../wp-config.php" );
+if ( !function_exists('wp_check_filetype') ) :
+function wp_check_filetype($filename, $mimes = null) {
+ // Accepted MIME types are set here as PCRE unless provided.
+ $mimes = is_array($mimes) ? $mimes : array (
+ 'jpg|jpeg|jpe' => 'image/jpeg',
+ 'gif' => 'image/gif',
+ 'png' => 'image/png',
+ 'bmp' => 'image/bmp',
+ 'tif|tiff' => 'image/tiff',
+ 'ico' => 'image/x-icon',
+ 'asf|asx|wax|wmv|wmx' => 'video/asf',
+ 'avi' => 'video/avi',
+ 'mov|qt' => 'video/quicktime',
+ 'mpeg|mpg|mpe' => 'video/mpeg',
+ 'txt|c|cc|h' => 'text/plain',
+ 'rtx' => 'text/richtext',
+ 'css' => 'text/css',
+ 'htm|html' => 'text/html',
+ 'mp3|mp4' => 'audio/mpeg',
+ 'ra|ram' => 'audio/x-realaudio',
+ 'wav' => 'audio/wav',
+ 'ogg' => 'audio/ogg',
+ 'mid|midi' => 'audio/midi',
+ 'wma' => 'audio/wma',
+ 'rtf' => 'application/rtf',
+ 'js' => 'application/javascript',
+ 'pdf' => 'application/pdf',
+ 'doc' => 'application/msword',
+ 'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
+ 'wri' => 'application/vnd.ms-write',
+ 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
+ 'mdb' => 'application/vnd.ms-access',
+ 'mpp' => 'application/vnd.ms-project',
+ 'swf' => 'application/x-shockwave-flash',
+ 'class' => 'application/java',
+ 'tar' => 'application/x-tar',
+ 'zip' => 'application/zip',
+ 'gz|gzip' => 'application/x-gzip',
+ 'exe' => 'application/x-msdownload'
+ );
+
+ $type = false;
+ $ext = false;
+
+ foreach ($mimes as $ext_preg => $mime_match) {
+ $ext_preg = '!\.(' . $ext_preg . ')$!i';
+ if ( preg_match($ext_preg, $filename, $ext_matches) ) {
+ $type = $mime_match;
+ $ext = $ext_matches[1];
+ break;
+ }
+ }
+
+ return compact('ext', 'type');
+}
+endif;
+
// Referrer protection
if( $_SERVER["HTTP_REFERER"] ) {
if( strpos( $_SERVER["HTTP_REFERER"], $current_blog->domain ) == false ) {
@@ -16,11 +73,11 @@ if( is_file( $file ) ) {
$lastModified = date( "D, j M Y H:i:s ", filemtime( $file ) ) . "GMT";
#$headers = apache_request_headers();
// get mime type
- $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 );
- $ext_list = array( "jpg" => "image/jpeg", "mp3" => "audio/mpeg", "mov" => "video/quicktime" );
- if( $ext_list[ $ext ] ) {
- $mimetype = $ext_list[ $ext ];
+ $mime = wp_check_filetype( $_SERVER[ 'REQUEST_URI' ] );
+ if( $mime[ 'type' ] != false ) {
+ $mimetype = $mime[ 'type' ];
} else {
+ $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 );
$mimetype = "image/$ext";
}