summaryrefslogtreecommitdiffstats
path: root/wp-admin/includes/mu.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-26 15:16:08 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-26 15:16:08 +0000
commitb6993d5766a5630574951bf4e62c7e55ae92c090 (patch)
tree4a854c8e2a452a506f3bf1e7bfb69826cceee65b /wp-admin/includes/mu.php
parent5c276aac16e4d4c7ba2d711dfa20c15f83d8f331 (diff)
downloadwordpress-mu-b6993d5766a5630574951bf4e62c7e55ae92c090.tar.gz
wordpress-mu-b6993d5766a5630574951bf4e62c7e55ae92c090.tar.xz
wordpress-mu-b6993d5766a5630574951bf4e62c7e55ae92c090.zip
Added (back in?) "wp_handle_upload_prefilter" filter to filter uploads before they go in blog's directory, fixes #478
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1133 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/includes/mu.php')
-rw-r--r--wp-admin/includes/mu.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/wp-admin/includes/mu.php b/wp-admin/includes/mu.php
index cbf5c9d..90d0343 100644
--- a/wp-admin/includes/mu.php
+++ b/wp-admin/includes/mu.php
@@ -1,5 +1,29 @@
<?php
+function check_upload_size( $file ) {
+
+ if( $file[ 'error' ] != '0' ) // there's already an error
+ return $file;
+
+ $space_allowed = 1048576*get_space_allowed();
+ $space_used = get_dirsize( constant( "ABSPATH" ) . constant( "UPLOADS" ) );
+ $space_left = $space_allowed - $space_used;
+ $file_size = filesize( $file[ 'tmp_name' ]);
+ if( $space_left < $file_size )
+ $file[ 'error' ] = sprintf( __( 'Not enough space to upload. %1$sKb needed.' ), number_format( ($file_size - $space_left) /1024 ) );
+ if( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
+ $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s Kb in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
+ if( upload_is_user_over_quota( false ) ) {
+ $file['error'] = __('You have used your space quota. Please delete files before uploading.');
+ }
+ if( $file[ 'error' ] != '0' )
+ wp_die( $file[ 'error' ] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
+
+ return $file;
+
+}
+add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
+
function wpmu_delete_blog($blog_id, $drop = false) {
global $wpdb, $wpmuBaseTablePrefix;