summaryrefslogtreecommitdiffstats
path: root/wp-admin
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-22 15:44:26 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-22 15:44:26 +0000
commit71c14576f335e1ad1e86b6a0b97603fcd5265a2b (patch)
tree97dd2183be0ef362d4bb838f653a8c62132cdd82 /wp-admin
parent7d2c1782f9d3aa331d37abc80bcb16b11e3e47e0 (diff)
downloadwordpress-mu-71c14576f335e1ad1e86b6a0b97603fcd5265a2b.tar.gz
wordpress-mu-71c14576f335e1ad1e86b6a0b97603fcd5265a2b.tar.xz
wordpress-mu-71c14576f335e1ad1e86b6a0b97603fcd5265a2b.zip
Move wpmu_checkAvailableSpace() to includes/mu.php and add it to upload action.
Use get_space_allowed(), props ktlee, fixes #463 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1118 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin')
-rw-r--r--wp-admin/includes/mu.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/wp-admin/includes/mu.php b/wp-admin/includes/mu.php
index 7d26ab0..7cdbdec 100644
--- a/wp-admin/includes/mu.php
+++ b/wp-admin/includes/mu.php
@@ -304,4 +304,32 @@ function refresh_user_details($id) {
return $id;
}
+/*
+ Determines if the available space defined by the admin has been exceeded by the user
+*/
+function wpmu_checkAvailableSpace() {
+ $spaceAllowed = get_space_allowed();
+
+ $dirName = trailingslashit( constant( "ABSPATH" ) . constant( "UPLOADS" ) );
+ $dir = dir($dirName);
+ $size = 0;
+
+ while($file = $dir->read()) {
+ if ($file != '.' && $file != '..') {
+ if (is_dir( $dirName . $file)) {
+ $size += get_dirsize($dirName . $file);
+ } else {
+ $size += filesize($dirName . $file);
+ }
+ }
+ }
+ $dir->close();
+ $size = $size / 1024 / 1024;
+
+ if( ($spaceAllowed - $size) <= 0 ) {
+ wp_die( __( 'Sorry, you need to delete some files before you can upload any more.' ) );
+ }
+}
+add_filter('upload_files_upload','wpmu_checkAvailableSpace');
+
?>