I have created a PHP script that calculates the amount of disk space left on a web server hard drive, although this would theortically be useless for end users, but it can be used by server admins to monitor disk space usage.
Code:
<?php
/*
PHP Disk Space Stats
Author: rm249
Site: http://www.rm249.com/
*/
?>
<html>
<head>
<title>Disk Statistics</title>
</head>
<body>
<?
$dt=disk_total_space("/");
$df=disk_free_space("/");
$total_space=round($dt/1024/1024/1024, 2);
$total_free=round($df/1024/1024/1024, 2);
$total_used=$total_space-$total_free;
$percent_free=round(($total_free/$total_space)*100, 2);
$percent_used=round(($total_used/$total_space)*100, 2);
if($percent_free < 10){
$disk_status = "<font color=\"red\"><b>WARNING: DISK SPACE LOW!</b></font>";
}else{
$disk_status = "<font color=\"green\"><b>Disk Space Okay!</b></font>";
}
?>
<table cols="2" width="500">
<tr>
<td><b>Total Disk Space:</b></td>
<td><? echo "$total_space "."GB"; ?></td>
</tr>
<tr>
<td><b>Total Free Disk Space:</b></td>
<td><? echo "$total_free "."GB"; ?></td>
</tr>
<tr>
<td><b>Total Disk Space Used:</b></td>
<td><? echo "$total_used "."GB"; ?></td>
</tr>
<tr>
<td><b>Percent Used:</b></td>
<td><? echo "$percent_used"."% Used"; ?></td>
</tr>
<tr>
<td><b>Percent Free:</b></td>
<td><? echo "$percent_free"."% Free"; ?></td>
</tr>
<tr>
<td><b>Status:</b></td>
<td><? echo $disk_status; ?></td>
</tr>
</table>
</body>
</html>