Author Topic: [1.7 / 1.7.1] Media directory size shows negative value (ACP)  (Read 24065 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
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() 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
*/
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bxbx

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [1.7 / 1.7.1] Media directory size shows negative value (ACP)
« Reply #1 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.

Offline jongerard

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: [1.7 / 1.7.1] Media directory size shows negative value (ACP)
« Reply #2 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
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!
« Last Edit: April 17, 2010, 02:25:26 AM by jongerard »