supajason
Member
- Messages
- 288
- Reaction score
- 2
- Points
- 18
check this out http://jason.x10hosting.com/disk.php
PHP:
<?PHP
function directory_size($directory)
{
$directorySize = 0;
if($dh = @opendir($directory))
{
while (($filename = readdir ($dh)))
{
if($filename != "." && $filename != "..")
{
if(is_file($directory."/".$filename))
{
$directorySize += filesize($directory."/".$filename);
}
if(is_dir($directory."/".$filename))
{
$directorySize += directory_size($directory."/".$filename);
}
}
}
}
@closedir($dh);
return $directorySize;
}
$directory = "/home/jasoned/";
$maxByte = 314572800;
$dirByte = directory_size($directory);
$totalSize = round(($dirByte / 1048576), 2);
$maxSize = round(($maxByte / 1048576), 2);
$per = round(($totalSize / $maxSize) * 100);
echo "Directory : ";
echo $directory;
echo "<br>";
echo "Maximum Disk Space : ";
echo $maxSize;
echo "MB";
echo "<br>";
echo "Total Size : ";
echo $totalSize;
echo "MB";
echo "<br>";
echo "Percent : ";
echo $per;
echo "%";
if ($per <= "25") {
$bg = "00FF55";
} elseif ($per <= "50") {
$bg = "FFFF00";
} elseif ($per <= "100") {
$bg = "FF0000";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
</head>
<body>
<table width="300" height="25" border="1" align="left" cellpadding="0" cellspacing="0" bordercolor="#00000">
<tr>
<td width="<?PHP echo $per; ?>%" bgcolor="#<?PHP echo $bg; ?>"> </td>
<td> </td>
</tr>
</table>
<table width="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><?PHP echo $totalSize; ?>/<?PHP echo $maxSize; ?>MB</td>
</tr>
</table>
</body>
</html>