includes/functions.php
changeset 1249 81b03b3e88d0
parent 1227 bdac73ed481e
child 1251 d543689ed2eb
equal deleted inserted replaced
1248:3914c9a95879 1249:81b03b3e88d0
  2828 	if ( $size > ( 1024 * 0.9 ) )
  2828 	if ( $size > ( 1024 * 0.9 ) )
  2829 	{
  2829 	{
  2830 		return number_format($size / 1024, 1) . $lang->get('etc_unit_kilobytes_short');
  2830 		return number_format($size / 1024, 1) . $lang->get('etc_unit_kilobytes_short');
  2831 	}
  2831 	}
  2832 	return "$size " . $lang->get('etc_unit_bytes');
  2832 	return "$size " . $lang->get('etc_unit_bytes');
       
  2833 }
       
  2834 
       
  2835 /**
       
  2836  * Convert PHP's suffixes for a file size an integer.
       
  2837  * @param string
       
  2838  */
       
  2839 
       
  2840 function php_filesize_to_int($sz)
       
  2841 {
       
  2842 	$num = preg_replace('/[^0-9]/', '', $sz);
       
  2843 	$unit = preg_replace('/[^A-z]/', '', $sz);
       
  2844 	$multiplier = 1;
       
  2845 	switch(strtolower($unit))
       
  2846 	{
       
  2847 		case 'g': $multiplier = 1073741824;	break;
       
  2848 		case 'm': $multiplier = 1048576;	break;
       
  2849 		case 'k': $multiplier = 1024;		break;
       
  2850 	}
       
  2851 	return intval($num) * $multiplier;
  2833 }
  2852 }
  2834 
  2853 
  2835 /**
  2854 /**
  2836  * Injects a string into another string at the specified position.
  2855  * Injects a string into another string at the specified position.
  2837  * @param string The haystack
  2856  * @param string The haystack