Ticket #22405: 22405.4.patch
File 22405.4.patch, 4.8 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ms.php
29 29 30 30 $file_size = filesize( $file['tmp_name'] ); 31 31 if ( $space_left < $file_size ) 32 $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) / 1024) );33 if ( $file_size > ( 1024* get_site_option( 'fileupload_maxk', 1500 ) ) )32 $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) / KB_IN_BYTES ) ); 33 if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) 34 34 $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); 35 35 if ( upload_is_user_over_quota( false ) ) { 36 36 $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); … … 1104 1104 }); 1105 1105 </script> 1106 1106 <?php 1107 } 1108 No newline at end of file 1107 } -
src/wp-includes/cache.php
691 691 echo "</p>"; 692 692 echo '<ul>'; 693 693 foreach ($this->cache as $group => $cache) { 694 echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )</li>';694 echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>'; 695 695 } 696 696 echo '</ul>'; 697 697 } -
src/wp-includes/functions.php
210 210 */ 211 211 function size_format( $bytes, $decimals = 0 ) { 212 212 $quant = array( 213 // ========================= Origin ==== 214 'TB' => 1099511627776, // pow( 1024, 4) 215 'GB' => 1073741824, // pow( 1024, 3) 216 'MB' => 1048576, // pow( 1024, 2) 217 'kB' => 1024, // pow( 1024, 1) 218 'B' => 1, // pow( 1024, 0) 213 'TB' => TB_IN_BYTES, 214 'GB' => GB_IN_BYTES, 215 'MB' => MB_IN_BYTES, 216 'kB' => KB_IN_BYTES, 217 'B' => 1, 219 218 ); 220 219 221 220 foreach ( $quant as $unit => $mag ) { -
src/wp-includes/media.php
2611 2611 $size = strtolower( $size ); 2612 2612 $bytes = (int) $size; 2613 2613 if ( strpos( $size, 'k' ) !== false ) 2614 $bytes = intval( $size ) * 1024;2614 $bytes = intval( $size ) * KB_IN_BYTES; 2615 2615 elseif ( strpos( $size, 'm' ) !== false ) 2616 $bytes = intval($size) * 1024 * 1024;2616 $bytes = intval($size) * MB_IN_BYTES; 2617 2617 elseif ( strpos( $size, 'g' ) !== false ) 2618 $bytes = intval( $size ) * 1024 * 1024 * 1024;2618 $bytes = intval( $size ) * GB_IN_BYTES; 2619 2619 return $bytes; 2620 2620 } 2621 2621 -
src/wp-includes/ms-functions.php
1874 1874 if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) 1875 1875 return $upload; 1876 1876 1877 if ( strlen( $upload['bits'] ) > ( 1024* get_site_option( 'fileupload_maxk', 1500 ) ) )1877 if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) 1878 1878 return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 )); 1879 1879 1880 1880 return $upload; … … 2278 2278 $space_used = apply_filters( 'pre_get_space_used', false ); 2279 2279 if ( false === $space_used ) { 2280 2280 $upload_dir = wp_upload_dir(); 2281 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024;2281 $space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES; 2282 2282 } 2283 2283 2284 2284 return $space_used; … … 2322 2322 if ( $allowed < 0 ) { 2323 2323 $allowed = 0; 2324 2324 } 2325 $space_allowed = $allowed * 1024 * 1024;2325 $space_allowed = $allowed * MB_IN_BYTES; 2326 2326 if ( get_site_option( 'upload_space_check_disabled' ) ) 2327 2327 return $space_allowed; 2328 2328 2329 $space_used = get_space_used() * 1024 * 1024;2329 $space_used = get_space_used() * MB_IN_BYTES; 2330 2330 2331 2331 if ( ( $space_allowed - $space_used ) <= 0 ) 2332 2332 return 0; … … 2353 2353 * @return int of upload size limit in bytes 2354 2354 */ 2355 2355 function upload_size_limit_filter( $size ) { 2356 $fileupload_maxk = 1024* get_site_option( 'fileupload_maxk', 1500 );2356 $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ); 2357 2357 if ( get_site_option( 'upload_space_check_disabled' ) ) 2358 2358 return min( $size, $fileupload_maxk ); 2359 2359