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:
<?php
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";
}
}
$db = mysql_connect('localhost', 'DATABASE_LOGIN', 'DATABASE_PASSWORD');
mysql_select_db('DATABASE_NAME',$db);
$sql = 'SELECT count(image_id), sum(image_size) FROM chv_images';
$req = mysql_query($sql) or die('SQL Error !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_assoc($req);
echo $data['count(image_id)'].' images uploaded for a total of '.showSize($data['sum(image_size)']);
mysql_close();
?>
<?php
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";
}
}
$db = mysql_connect('localhost', 'DATABASE_LOGIN', 'DATABASE_PASSWORD');
mysql_select_db('DATABASE_NAME',$db);
$sql = 'SELECT count(image_id), sum(image_size) FROM chv_images';
$req = mysql_query($sql) or die('SQL Error !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_assoc($req);
echo 'Total of '.$data['count(image_id)'].' images uploaded using '.showSize($data['sum(image_size)']).' of space';
mysql_close();
?>
<?php
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";
}
}
$db = mysql_connect('localhost', 'DATABASE_LOGIN', 'DATABASE_PASSWORD');
mysql_select_db('DATABASE_NAME',$db);
$sql = 'SELECT count(image_id), sum(image_size) FROM chv_images';
$req = mysql_query($sql) or die('SQL Error !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_assoc($req);
echo 'Total of <font color="red">'.$data['count(image_id)'].'</font> images uploaded using <font color="red">'.showSize($data['sum(image_size)']).'</font> of space';
mysql_close();
?>
I'd like to get more documentation about the built in pdo query stuff to make a better imagecounter
I'd love to use the pdo query BUT i didn't find any documentation about it so I dunno how to use it, as I said earlier !
<br /><p><?php echo "Hosted Images: ".number_format(total_images_uploaded()).""; ?></p>
<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>
/**
* total_images_uploaded_size
* returns the total size of images uploaded
*/
function total_images_uploaded_size() {
global $dB;
$uploaded_qry = $dB->query_fetch_single("SELECT sum(image_size) as total FROM chv_images;");
return $uploaded_qry["total"];
}
/**
* showSize
* returns the value in Gb, Mb or Kb
*/
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";
}
}
<?php echo showSize(total_images_uploaded_size()); ?>
This doesn't work for me, i used to. Once i installed AUS, however. It did no longer.
<br /><?php echo "Hosted Images: ".number_format(total_images_uploaded()).""; ?>
<br />
<?
//To calculate and count directories//GNU GPL v3 - LMPF
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)
{
$sizeStr='';
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";
}
}
$path="images/";
$ar=getDirectorySize($path);
echo "Space Used : ".sizeFormat($ar['size'])."<br>";
//print_r($ar);
?>
PHP:<br /><?php echo "Hosted Images: ".number_format(total_images_uploaded()).""; ?> <br /> <? //To calculate and count directories//GNU GPL v3 - LMPF 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) { $sizeStr=''; 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"; } } $path="images/"; $ar=getDirectorySize($path); echo "Space Used : ".sizeFormat($ar['size'])."<br>"; //print_r($ar); ?>
Even that? Because it's working for me.
Use this http://chevereto.com/community/threads/imagecounter-in-footer.961/page-2#post-14168I have 18 images uploaded on my site, but it states that 0 Images have been uploaded so far. Help :'( I used the code from the first code