Created
November 26, 2010 09:19
-
-
Save ivuorinen/716449 to your computer and use it in GitHub Desktop.
quota.php displays your quota and how much you've used of it. freaks out if no quota set up.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Fetch the quota to temp file, grab the data and delete the file | |
system("quota -s > q.txt"); | |
$raw_quota = file("q.txt"); | |
unlink("q.txt"); | |
$raw_quota = trim( $raw_quota[3] ); | |
$raw_quota = str_replace(" ", " ", $raw_quota); | |
preg_match_all('/([0-9a-zA-Z]+)/', $raw_quota, $quota); | |
$quota = $quota[0]; | |
$used = $quota[0]; | |
$limit = $quota[1]; | |
$grace = $quota[2]; | |
?><!DOCTYPE HTML> | |
<html lang="fi-FI"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>quota</title> | |
<style type="text/css"> | |
body { font: 14px Arial, sans-serif; padding: 40px; } | |
th, td { text-align: right; } | |
</style> | |
</head> | |
<body> | |
<table width="300"> | |
<tr> | |
<th>Data</th> | |
<th>M</th> | |
<th>G</th> | |
</tr> | |
<tr> | |
<td>used</td> | |
<td><?=$used;?></td> | |
<td><?=round($used/1024, 2);?>G</td> | |
</tr> | |
<tr> | |
<td>limit</td> | |
<td><?=$limit;?></td> | |
<td><?=round($limit/1024, 2);?>G</td> | |
</tr> | |
<tr> | |
<td>grace</td> | |
<td><?=$grace;?></td> | |
<td><?=round($grace/1024, 2);?>G</td> | |
</tr> | |
<tr> | |
<td>left</td> | |
<td><?=$limit-$used;?>M</td> | |
<td><?=round(($limit-$used)/1024);?>G</td> | |
</tr> | |
<tr> | |
<td colspan="3"> | |
<div style="border: 1px solid #333;"> | |
<div style="width:<?=($used/$limit)*100;?>%; background: #000;"> </div> | |
</div> | |
</td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment