Bug Maximum File Size: 1048576 = 0GB? AdminCP

Status
Not open for further replies.

McGeek

Customer
This is not really a "OMG! the whole thing doesn't work" bug... but none the less it is a bug

If you have these setting the Maximum File Size will be set to 0GB, which is incorrect.

Code:
Extension : cs
Mime-Type : text/plain
Max Extension Size : 1048576 (exactly 1MB in bytes)
Max Height : 0
Max Width : 0
Extension Group : Files
 
Fixed this as well:

dbtech/downloads/core/class_download.php, line 193

change
PHP:
	public static function convert_filesize($size, $round=2) {
		$size = floatval($size);
		
		$kb = 1 * 1024;
		$mb = $kb * 1024;
		$gb = $mb * 1024;
		
		if ($size < $mb) {
			$size = round($size / $kb, $round) . 'KB';
		} else if ($size > $mb && $size < $gb) {
			$size = round($size / $mb, $round) . 'MB';
		} else {
			$size = round($size / $gb, $round) . 'GB';
		}
		
		return $size;
	}

to (NOTE: I did not write this code, I found it on the web somewhere)
PHP:
	public static function convert_filesize($size, $round=2) {
	
	$bytes = floatval($size);
    $symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
 
    $exp = 0;
    $converted_value = 0;
    if( $bytes > 0 )
    {
      $exp = floor( log($bytes)/log(1024) );
      $converted_value = ( $bytes/pow(1024,floor($exp)) );
    }
 
    return sprintf( '%.2f '.$symbol[$exp], $converted_value );
	}
 
Last edited:
I have also added a byte calculator to the Phrase: "dbtech_downloads_extension_max_file_size"


9tllkj.jpg


Here is the code :)
HTML:
Max Extension Size
<dfn>Please enter the maximum size, in bytes, that files of this extension can be. <br />
Below is a byte calculator that will automatically calculate Kb, MB and GB to Bytes<br />
<b>Byte calculator: </b>
</dfn>
<script language="JavaScript">
  function convert(f) {
  
if (f.convertion.value == "KB")
  {
  document.cpform.maxsize.value=Math.round(f.number.value*1024*100000)/100000
  }
else if (f.convertion.value == "MB")
  {
  document.cpform.maxsize.value=Math.round(f.number.value*1048576*100000)/100000
  }
else if (f.convertion.value == "GB")
  {
   document.cpform.maxsize.value=Math.round(f.number.value*1073741824*100000)/100000
  }
else if (f.convertion.value == "BT")
  {
   document.cpform.maxsize.value=f.number.value
  }
  }
</script>
<form  style="">
<input type="text" class="bginput" name="number" value="0" style="width: 300px;" >
<select name="convertion" class="bginput" style="padding: 3px;">
  <option>BT</option>
  <option>KB</option>
  <option>MB</option>
  <option>GB</option>
</select>
<input type="button" class="button" name="calulate" value="Calulate" onclick="convert(this.form)"><br>
</form>
 
Status
Not open for further replies.

Similar threads

Legacy vBDownloads

vBulletin 3.8.x vBulletin 4.x.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
1,714
Customer rating
0.00 star(s) 0 ratings
Top