4images Forum & Community

4images Help / Hilfe => Bug Fixes & Patches => Topic started by: V@no on March 14, 2005, 02:38:07 AM

Title: [1.7 / 1.7.1] Media directory size shows negative value (ACP)
Post by: V@no on March 14, 2005, 02:38:07 AM
When media directory size is over 2 gigabytes it shows as negative ( -2.0 GB )
This is not a bug in 4images itself, but its limitation of intval() (http://php.net/manual/en/function.intval.php) function which can only handle numbers between -2147483648 and 2147483647

As of now, the only sollution I know is dont use that function on numbers larger then 2147483647

Open includes/functions.php
Find:
Code: [Select]
  $file_size = intval($file_size);
Replace with:
Code: [Select]
/*
  FIX NEGATIVE NUMBERS
  ORIGINAL BLOCK:
  $file_size = intval($file_size);
*/
/*
  FIX NEGATIVE NUMBERS
  START REPLACE
*/
  if ($file_size < 2147483648)
  {
    $file_size = intval($file_size);
  }
/*
  FIX NEGATIVE NUMBERS
  END REPLACE
*/
Title: Re: [1.7 / 1.7.1] Media directory size shows negative value (ACP)
Post by: bxbx on March 03, 2006, 05:38:28 PM
For PHP versions 4 through 4.2.0, if you replace:

Code: [Select]
$file_size = intval($file_size);
with:

Code: [Select]
$file_size = floatval($file_size);
it will give you the correct size.

I have not tested with all versions of PHP but you could also replace:

Code: [Select]
$file_size = intval($file_size);
with a float typecast:

Code: [Select]
$file_size = (float)($file_size);
and get the correct result.

I have tested both methods and they both return the proper size.
Title: Re: [1.7 / 1.7.1] Media directory size shows negative value (ACP)
Post by: jongerard on April 16, 2010, 04:26:38 AM
For PHP versions 4 through 4.2.0, if you replace:
Code: [Select]
$file_size = intval($file_size);with:
Code: [Select]
$file_size = floatval($file_size);it will give you the correct size.
Chicago Show (http://chicago.nyctourist.com/chicago-entertainment.php)
I have not tested with all versions of PHP but you could also replace:
Code: [Select]
$file_size = intval($file_size);with a float typecast:
Code: [Select]
$file_size = (float)($file_size);and get the correct result.
I have tested both methods and they both return the proper size.
Excellent and thank you for all of your effort!