Feature #89

Demo dir size

Added by Ogi Vajarov Sedlarov 200 days ago. Updated 171 days ago.

Status:Closed Start:06/19/2008
Priority:Normal Due date:
Assigned to:- % Done:

100%

Category:Web Panel
Target version:1.1.1 Estimated time:0.20 hours

Description

I did this on my site , it's pretty easy ... and well its really nice to see that info in the admin pannel. I can post my code if you want to ?

History

Updated by Ogi Vajarov Sedlarov 200 days ago

function getDirectorySize($path)
{
  $totalsize = 0;
  $totalcount = 0;
  $dircount = 0;
  if ($handle = opendir ($path))
  {
    while (false !== ($file = readdir($handle)))
    {
      $nextpath = $path . '/' . $file;
      if ($file != '.' && $file != '..' && !is_link ($nextpath))
      {
        if (is_dir ($nextpath))
        {
          $dircount++;
          $result = getDirectorySize($nextpath);
          $totalsize += $result['size'];
          $totalcount += $result['count'];
          $dircount += $result['dircount'];
        }
        elseif (is_file ($nextpath))
        {
          $totalsize += filesize ($nextpath);
          $totalcount++;
        }
      }
    }
  }
  closedir ($handle);
  $total['size'] = $totalsize;
  $total['count'] = $totalcount;
  $total['dircount'] = $dircount;
  return $total;
}

function sizeFormat($size)
{
    if($size<1024)
    {
        return $size." bytes";
    }
    else if($size<(1024*1024))
    {
        $size=round($size/1024,1);
        return $size." KB";
    }
    else if($size<(1024*1024*1024))
    {
        $size=round($size/(1024*1024),2);
        return $size." MB";
    }
    else
    {
        $size=round($size/(1024*1024*1024),2);
        return $size." GB";
    }

} 

$path="/srv/www/htdocs/sba/demos";
$ar=getDirectorySize($path);

$theme->assign('totalsize', sizeFormat($ar['size']));
/////////////////////////////////////////////////////////////////////////////////

Updated by Erik Minekus 171 days ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Added in r86

Also available in: Atom PDF