• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Image Directory Informations

Danny.Domb

👽 Chevereto Freak
Here is 2 little functions to retreive the number of file, the size of and the number of sub directories in the DIR_IM (images/) directory.

Demo:
c7z20.png


ENGINE.PHP

find
Code:
<?

add AFTER
Code:
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)
{
    $return = '';
    
    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),1);
        
        $return = $size." MB";
    }
    else
    {
        $size = round($size/(1024*1024*1024),1);
        $return = $size." GB";
    }
    
    return $return;
}

CONFIG.PHP

find
Code:
$allow_over_resize = false; // true: Allows over resize images - false: Don't allow over resize.

add AFTER
Code:
$information = getDirectorySize(DIR_IM);

INDEX.PHP

find
Code:
<div id="foot"><div class="foot-d2"><?php echo APP_NAME;?>, Powered by <a href="http://chevereto.com/" target="_blank">Chevereto</a></div></div>

REPLACE WITH

Code:
<div id="foot">
    <div class="foot-d2">
        Total directory size : <?php echo sizeFormat($information['size']); ?><br />
        Number of files : <?php echo $information['count']; ?><br />
        Number of sub-directories : <?php echo $information['dircount']; ?><br />
        <?php echo APP_NAME; ?>, Powered by <a href="http://chevereto.com/" target="_blank">Chevereto</a>
    </div>
</div>
 
Back
Top