TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-06-2010, 08:12 PM   #1 (permalink)
bajingo
 
skibbli's Avatar
 
Join Date: Feb 2010
Posts: 11
Thanks: 2
skibbli is on a distinguished road
Application Correcting negative filesize() bug for larger files

As you may know, PHP 5.2.13 has an issue with determining the size of a large file. The number of bytes will be displayed as a negative if the file size is too large. I've come up with a very simple fix and made a way to display the files in a list with the size as it should be seen (eg if the size is within the range of kb/mb/gb

PHP Code:
<?php
$handle
=opendir(".");
while ((
$file readdir($handle))!==false) {
if ( !
in_array($file, array(".""..""index.php")) && is_file($file) ) {
echo 
"<a href='$file'>$file</a>";
$b filesize($file);
if ( 
$b $b $b $b $b;
$kb $b 1024;
$mb $kb 1024;
$gb $mb 1024;
if ( 
$mb >= 1024 ) echo " " round($gb2) . " gb";
if ( 
$kb >= 1024 && $gb 1) echo " " round($mb2) . " mb";
if ( 
$b >= 1024 && $mb ) echo " " round($kb2) . " kb";
if ( 
$b 1024 ) echo " " $b " b";
echo 
"<br>";
}
}
closedir($handle);
?>

Last edited by skibbli : 03-22-2010 at 03:47 AM.
skibbli is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:24 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design