Ticket #22357: movemsuploadfunctions.diff
File movemsuploadfunctions.diff, 4.3 KB (added by wonderboymusic, 5 years ago) 


wpincludes/msfunctions.php
1922 1922 $count = $wpdb>get_var( $wpdb>prepare("SELECT COUNT(ID) as c FROM $wpdb>users WHERE spam = '0' AND deleted = '0'") ); 1923 1923 update_site_option( 'user_count', $count ); 1924 1924 } 1925 1926 /** 1927 * Returns the space used by the current blog. 1928 * 1929 * @since 3.5.0 1930 * 1931 * @return int Used space in megabytes 1932 */ 1933 function get_space_used() { 1934 // Allow for an alternative way of tracking storage space used 1935 $space_used = apply_filters( 'pre_get_space_used', false ); 1936 if ( false === $space_used ) { 1937 $upload_dir = wp_upload_dir(); 1938 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024; 1939 } 1940 1941 return $space_used; 1942 } 1943 1944 /** 1945 * Returns the upload quota for the current blog. 1946 * 1947 * @since MU 1948 * 1949 * @return int Quota in megabytes 1950 */ 1951 function get_space_allowed() { 1952 $space_allowed = get_option( 'blog_upload_space' ); 1953 1954 if ( ! is_numeric( $space_allowed ) ) 1955 $space_allowed = get_site_option( 'blog_upload_space' ); 1956 1957 if ( empty( $space_allowed )  ! is_numeric( $space_allowed ) ) 1958 $space_allowed = 50; 1959 1960 return $space_allowed; 1961 } 1962 1963 /** 1964 * Determines if there is any upload space left in the current blog's quota. 1965 * 1966 * @since 3.0.0 1967 * 1968 * @return int of upload space available in bytes 1969 */ 1970 function get_upload_space_available() { 1971 $space_allowed = get_space_allowed() * 1024 * 1024; 1972 if ( get_site_option( 'upload_space_check_disabled' ) ) 1973 return $space_allowed; 1974 1975 $space_used = get_space_used() * 1024 * 1024; 1976 1977 if ( ( $space_allowed  $space_used ) <= 0 ) 1978 return 0; 1979 1980 return $space_allowed  $space_used; 1981 } 1982 1983 /** 1984 * @since 3.0.0 1985 * 1986 * @return int of upload size limit in bytes 1987 */ 1988 function upload_size_limit_filter( $size ) { 1989 $fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 ); 1990 if ( get_site_option( 'upload_space_check_disabled' ) ) 1991 return min( $size, $fileupload_maxk ); 1992 1993 return min( $size, $fileupload_maxk, get_upload_space_available() ); 1994 } 1995 No newline at end of file 
wpadmin/includes/ms.php
290 290 } 291 291 292 292 /** 293 * @since 3.0.0294 *295 * @return int of upload size limit in bytes296 */297 function upload_size_limit_filter( $size ) {298 $fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 );299 if ( get_site_option( 'upload_space_check_disabled' ) )300 return min( $size, $fileupload_maxk );301 302 return min( $size, $fileupload_maxk, get_upload_space_available() );303 }304 /**305 * Determines if there is any upload space left in the current blog's quota.306 *307 * @since 3.0.0308 *309 * @return int of upload space available in bytes310 */311 function get_upload_space_available() {312 $space_allowed = get_space_allowed() * 1024 * 1024;313 if ( get_site_option( 'upload_space_check_disabled' ) )314 return $space_allowed;315 316 $space_used = get_space_used() * 1024 * 1024;317 318 if ( ( $space_allowed  $space_used ) <= 0 )319 return 0;320 321 return $space_allowed  $space_used;322 }323 324 /**325 293 * Check whether a blog has used its allotted upload space. 326 294 * 327 295 * @since MU … … 349 317 } 350 318 351 319 /** 352 * Returns the space used by the current blog.353 *354 * @since 3.5.0355 *356 * @return int Used space in megabytes357 */358 function get_space_used() {359 // Allow for an alternative way of tracking storage space used360 $space_used = apply_filters( 'pre_get_space_used', false );361 if ( false === $space_used ) {362 $upload_dir = wp_upload_dir();363 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024;364 }365 366 return $space_used;367 }368 369 /**370 * Returns the upload quota for the current blog.371 *372 * @since MU373 *374 * @return int Quota in megabytes375 */376 function get_space_allowed() {377 $space_allowed = get_option( 'blog_upload_space' );378 379 if ( ! is_numeric( $space_allowed ) )380 $space_allowed = get_site_option( 'blog_upload_space' );381 382 if ( empty( $space_allowed )  ! is_numeric( $space_allowed ) )383 $space_allowed = 50;384 385 return $space_allowed;386 }387 388 /**389 320 * Displays the amount of disk space used by the current blog. Not used in core. 390 321 * 391 322 * @since MU