Disk usage map for %s", $root); //----- Print entries in Info table printf("\n"); printf("\n"); printf("\n"); printf("
Disk Usage Map info.
\n"); printf("\n"); $res = $file_db->query('SELECT * FROM Info'); foreach($res AS $row){ printf(" \n", $row['key'], $row['val']); } printf("
%s=%s
\n"); printf("
"); print("

\n"); //----- Print biggest users printf("\n"); printf("\n"); $res = $file_db->query('SELECT * FROM Users ORDER BY tot_size DESC LIMIT 20'); foreach($res AS $row){ $size = size_readable($row['tot_size']); printf(" \n", $size, $row['owner']); } printf("
Top Users
%s%s
\n"); print("

\n"); //----- Print biggest directories printf("\n"); printf("\n"); $res = $file_db->query('SELECT * FROM Dirs ORDER BY size DESC LIMIT 20'); foreach($res AS $row){ $size = size_readable($row['size']); printf(" \n", $size, $row['fullpath']); } printf("
Biggest Directories
%s%s
\n"); print("

\n"); //----- Print biggest files printf("\n"); printf("\n"); $res = $file_db->query('SELECT * FROM Files ORDER BY size DESC LIMIT 20'); foreach($res AS $row){ $size = size_readable($row['size']); printf(" \n", $size, $row['fullpath']); } printf("
Biggest Files
%s%s
\n"); ?> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> // Subroutines //---------------------- // simple_query //---------------------- function simple_query($db, $query) { $sth = $db->prepare($query); $sth->execute(); return $sth->fetchColumn(); } /** * Return human readable sizes * * @author Aidan Lister * @version 1.3.0 * @link http://aidanlister.com/2004/04/human-readable-file-sizes/ * @param int $size size in bytes * @param string $max maximum unit * @param string $system 'si' for SI, 'bi' for binary prefixes * @param string $retstring return string format */ function size_readable($size, $max = null, $system = 'si', $retstring = '%01.2f %s') { // Pick units $systems['si']['prefix'] = array('B', 'K', 'MB', 'GB', 'TB', 'PB'); $systems['si']['size'] = 1000; $systems['bi']['prefix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'); $systems['bi']['size'] = 1024; $sys = isset($systems[$system]) ? $systems[$system] : $systems['si']; // Max unit to display $depth = count($sys['prefix']) - 1; if ($max && false !== $d = array_search($max, $sys['prefix'])) { $depth = $d; } // Loop $i = 0; while ($size >= $sys['size'] && $i < $depth) { $size /= $sys['size']; $i++; } return sprintf($retstring, $size, $sys['prefix'][$i]); } ?>