• 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.

Imagecounter in Footer

Avast

👽 Chevereto Freak
To show how many Images were uploaded use the following code in your footer.php:

PHP:
<div id="foot">
    <div id="in-foot">
        <div id="foot-content">
            <ul>
                <?php show_page_links('<li>'); ?>
                <?php if(is_logged_user() || is_admin()) :?><li><a rel="logout"><?php show_lang_txt('txt_logout'); ?></a></li><?php endif; ?>
            </ul>
            <br /><p><?php echo "Hosted Images: ".number_format(total_images_uploaded()).""; ?></p>
            <p>(C) 2012 <a href="http://chevereto.com/" target="_blank" title="Chevereto Image Upload Script" id="c_chevereto">Chevereto</a></p>
        </div>




Everything below is for older Versions than 2.1.0

If you want an imagecounter like me:

myBWz.jpg


you have to edit your footer.php

Code:
<span style="position: absolute; right: 0; top: 50px; margin-right: 25px"><?php
// Add number of uploaded images. smed79
// $files to liste *.* in "./images" ex: (.jpg, .png, etc...)
$files = glob("images/*.*");
// Variable $compteur counting files lister ($files) in "./images"
$compteur = count($files);
echo "There are <font color=#FF0000>$compteur</font>";
if ($compteur > 1) { echo " images uploaded so far"; }
else { echo " images uploaded so far"; }
?></span>

in your style.css ( /Paefowl/style.css)

edit:
Code:
    #in-foot {
        clear: both;
        padding: 25px;
        overflow: auto;
        [b]position: relative;[/b]
    }



Thanks to:smed79 and Rodolfo


EDIT://

This counter works in chevereto v. 2.0.0 - 2.0.11
 
Please notice that since 2.0.3 the path is:
Code:
__CHV_PATH_THUMBS__
 
An easier way of doing it is to add the following code below the copyright notice in footer.php:

<?php
$files = glob("images/*.*");
$counter = count($files);
echo "<b>$counter</b></font>";
if ($counter > 1) { echo " images"; }
else { echo " images"; }
?>

This counts how many files are in the /images/ folder and returns the value 'xxx Images'. You can change where it says " images" to any text you like.
 
why not use short code like
Code:
<span style="position: absolute; right: 0; top: 40px; margin-right: 28px">There are <font color=#FF9900><b><?php echo count(glob(__CHV_PATH_THUMBS__."*",GLOB_NOSORT)); ?></b></font> images uploaded so far</span>

?? that code above gives you the same results and is less complicate :)
 
tonemapped said:
An easier way of doing it is to add the following code below the copyright notice in footer.php:

<?php
$files = glob("images/*.*");
$counter = count($files);
echo "<b>$counter</b></font>";
if ($counter > 1) { echo " images"; }
else { echo " images"; }
?>

This counts how many files are in the /images/ folder and returns the value 'xxx Images'. You can change where it says " images" to any text you like.

Awesome, that works like a charm!
 
Is it possible to add the amount of data in MB/GB ?

EDIT: well i found out myself, not the best code in the world but works

Code:
<?php
    
        function filesize_r($path){
        if(!file_exists($path)) return 0;
        if(is_file($path)) return filesize($path);
        $ret = 0;
        foreach(glob($path."/*.*") as $fn)
        $ret += filesize_r($fn);
        return $ret;
        }
        
        function showSize($size_in_bytes) {
        $value = 0;        
        if ($size_in_bytes >= 1073741824) {
            $value = round($size_in_bytes/1073741824*10)/10;
            return  ($round) ? round($value) . 'Gb' : "{$value} GB";
        } else if ($size_in_bytes >= 1048576) {
            $value = round($size_in_bytes/1048576*10)/10;
            return  ($round) ? round($value) . 'Mb' : "{$value} MB";
        } else if ($size_in_bytes >= 1024) {
            $value = round($size_in_bytes/1024*10)/10;
            return  ($round) ? round($value) . 'Kb' : "{$value} KB";
        } else {
            return "$size_in_bytes bytes";
        }
        }
    
    $path = "i";
    $total_size = filesize_r($path);
    echo " for a total of <b>".showSize($total_size)."</b>";
     
 ?>
 
Where are you placing this code?

In the footer?



bubbl3 said:
Is it possible to add the amount of data in MB/GB ?

EDIT: well i found out myself, not the best code in the world but works

Code:
<?php
    
        function filesize_r($path){
        if(!file_exists($path)) return 0;
        if(is_file($path)) return filesize($path);
        $ret = 0;
        foreach(glob($path."/*.*") as $fn)
        $ret += filesize_r($fn);
        return $ret;
        }
        
        function showSize($size_in_bytes) {
        $value = 0;        
        if ($size_in_bytes >= 1073741824) {
            $value = round($size_in_bytes/1073741824*10)/10;
            return  ($round) ? round($value) . 'Gb' : "{$value} GB";
        } else if ($size_in_bytes >= 1048576) {
            $value = round($size_in_bytes/1048576*10)/10;
            return  ($round) ? round($value) . 'Mb' : "{$value} MB";
        } else if ($size_in_bytes >= 1024) {
            $value = round($size_in_bytes/1024*10)/10;
            return  ($round) ? round($value) . 'Kb' : "{$value} KB";
        } else {
            return "$size_in_bytes bytes";
        }
        }
    
    $path = "i";
    $total_size = filesize_r($path);
    echo " for a total of <b>".showSize($total_size)."</b>";
     
 ?>
 
wethead said:
Where are you placing this code?

In the footer?

Yes, this is the complete code to have something like this: 198319 images uploaded for a total of 1.7 GB

Code:
<?php
    
    $files = glob("i/*.*");
    $counter = count($files);
    echo "<b>19$counter</b></font>";
    if ($counter > 1) { echo " images uploaded"; }
    else { echo " images"; }

    function filesize_r($path){
        if(!file_exists($path)) return 0;
        if(is_file($path)) return filesize($path);
        $ret = 0;
        foreach(glob($path."/*.*") as $fn)
        $ret += filesize_r($fn);
        return $ret;
    }
        
    function showSize($size_in_bytes) {
        $value = 0;        
        if ($size_in_bytes >= 1073741824) {
            $value = round($size_in_bytes/1073741824*10)/10;
            return  ($round) ? round($value) . 'Gb' : "{$value} GB";
        } else if ($size_in_bytes >= 1048576) {
            $value = round($size_in_bytes/1048576*10)/10;
            return  ($round) ? round($value) . 'Mb' : "{$value} MB";
        } else if ($size_in_bytes >= 1024) {
            $value = round($size_in_bytes/1024*10)/10;
            return  ($round) ? round($value) . 'Kb' : "{$value} KB";
        } else {
            return "$size_in_bytes bytes";
        }
    }
    
    $path = "i";
    $total_size = filesize_r($path);
    echo " for a total of <b>".showSize($total_size)."</b>";
     
 ?>

Totally unrefined, feel free to fix it.
 
You could use a mysql query ; select count(image_id) from chv_images for example.

Same for the total size used.
 
Back
Top