Re: Re: PHP Directory List Script Files over 2 GB
| From: | Robert M | Date: | Thu, 12 Apr 2007 23:44:12 +0000 |
| Subject: | Re: Re: PHP Directory List Script Files over 2 GB | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252807@lists.php.net to get a copy of this message | ||
I made a few changes to the script using system calls and changed the
datatype to be a string on the sprintf portion of the script
I doubt it is the most intelligent method of resolving the issue, but
it got the job done.
I do not run this on an Internet site, just a local intranet website
that I use to monitor backups with so the overhead is minimal.
Added the following at the top of the script
// SYSTEM CALLS to get information from filesystem/file
function GlobSize( $f )
{
$fsize = ls -ltr $f |awk '{print $5}';
return $fsize;
}
function GlobDate( $f )
{
$fdate = stat --printf %Y $f;
return $fdate;
}
Modified code to call the two functions above.
stat --printf %y was used to correct the date which was reporting
incorrectly as Dec 31 69 on all files larger then 2 GB
the ls command to return bytes was used to allow the Javascript to do
the correct conversion later in the script.
else$files[]=array('name'=>$f,'size'=>GlobSize($path.$f),'date'=>GlobDate($path.$f),'url'=>trim("$root/$dir/".rawurlencode($f),'/'));
then modified the the sprintf to be a string for the instead of a d
<?php while(list(,$f)=each($files))print
sprintf("_f('%s',%s,'%s','%s',%d);\n",addslashes($f['name']),$f['size'],date($date,$f['date']),addslashes($f['url']),$f['date']);?>
Thank you all for helping