summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes/functions.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 10:08:38 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 10:08:38 +0000
commit0637b21e512e0ee8bca53bdb479bf35f8085fe41 (patch)
treed6226dbedba232a2ae71260381030df7a1e4fde4 /wp-inst/wp-includes/functions.php
parent9f63c9fe67acd3e6c600de8e4bec6de823c6e8da (diff)
downloadwordpress-mu-0637b21e512e0ee8bca53bdb479bf35f8085fe41.tar.gz
wordpress-mu-0637b21e512e0ee8bca53bdb479bf35f8085fe41.tar.xz
wordpress-mu-0637b21e512e0ee8bca53bdb479bf35f8085fe41.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@587 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/functions.php')
-rw-r--r--wp-inst/wp-includes/functions.php63
1 files changed, 61 insertions, 2 deletions
diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php
index 73bc0a9..a8f5b5c 100644
--- a/wp-inst/wp-includes/functions.php
+++ b/wp-inst/wp-includes/functions.php
@@ -721,7 +721,7 @@ function add_query_arg() {
$base = $parts[0] . '?';
$query = $parts[1];
}
- } else if ( strstr($uri, '/') ) {
+ } else if ( !empty($protocol) || strstr($uri, '/') ) {
$base = $uri . '?';
$query = '';
} else {
@@ -986,7 +986,11 @@ function wp_upload_dir() {
function wp_upload_bits($name, $type, $bits) {
if ( empty($name) )
- return array('error' => "Empty filename");
+ return array('error' => __("Empty filename"));
+
+ $wp_filetype = wp_check_filetype($name);
+ if ( !$wp_filetype['ext'] )
+ return array('error' => __("Invalid file type"));
$upload = wp_upload_dir();
@@ -1032,6 +1036,61 @@ function wp_upload_bits($name, $type, $bits) {
return array('file' => $new_file, 'url' => $url, 'error' => false);
}
+function wp_check_filetype($filename, $mimes = null) {
+ // Accepted MIME types are set here as PCRE unless provided.
+ $mimes = is_array($mimes) ? $mimes : apply_filters('upload_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');
+}
+
function do_trackbacks($post_id) {
global $wpdb;