display disk/bw quota usage in nav menu

This commit is contained in:
mlutfy 2009-03-27 03:30:23 +00:00
parent 40028613fd
commit f07c407deb
3 changed files with 40 additions and 4 deletions

View File

@ -37,7 +37,7 @@ include("head.php");
<div id="alternc-logo"><a href="http://alternc.org"><!-- img src="alternc.png" width="120" height="82" border="0" alt="AlternC" / -->AlternC</a>
<span><?php echo "$L_VERSION"; ?></span>
</div>
<h3>Menu <?php echo $mem->user["login"]; ?></h3>
<h3><?php echo _("Menu") . ' ' . $mem->user["login"]; ?></h3>
<dl id="menu-list">
<?php
$MENUPATH="/var/alternc/bureau/admin/";
@ -50,6 +50,7 @@ while (!feof ($tt)) {
}
fclose($tt);
?>
<dt id="session"><?php __("Session"); ?></dt>
<dd><a href="mem_logout.php" target="_parent"><?php __("Logout"); ?></a></dd>
</dl>

View File

@ -27,5 +27,40 @@
Purpose of file:
----------------------------------------------------------------------
*/
?>
<dd><a href="quota_show.php"><?php __("Show my quotas"); ?></a></dd>
$q=$quota->getquota();
$qlist=$quota->qlist();
reset($qlist);
echo '<dt id="#quotas">' . _("Quotas") . '</dt>';
echo '<dd><a href="quota_show.php">' . _("Show my quotas") . '</a></dd>';
if (!is_array($q)) {
// "No quotas for this account, or quotas currently unavailable
return;
}
while (list($key,$val)=each($qlist)) {
$col=3-$col;
if (($key == 'bw_web' || $key == 'web') && ($q[$key]["t"] > 0)) {
if ($key == 'web') {
$q[$key]["u"] = $q[$key]["u"] * 1024;
}
$usage_percent = (int) ($q[$key]["u"] / $q[$key]["t"] * 100);
$usage_color = ($q[$key]["u"] > $q[$key]["t"] ? '#f00' : '#0f0');
$usage_color = ((85 < $usage_percent && $usage_percent < 100) ? '#ff0' : $usage_color); // yellow if 85 < x < 100
echo "<dd>";
echo '<div><a href="quota_show.php">' . /* _($val) */ $key . ' ' . $usage_percent . '%' . ' (' . format_size($q[$key]["u"]) . ' / ' . format_size($q[$key]["t"]) . ')</a></div>';
echo "</dd>";
echo "<dd>";
echo '<div style="width: 100%; background: #fff;">';
echo '<div style="width: ' . ($usage_percent > 100 ? 100 : $usage_percent) . '%; background: ' . $usage_color . ';">&nbsp;</div>';
echo '</div>';
echo "</dd>";
}
}

View File

@ -8,5 +8,5 @@ menu_sql.php
menu_adm.php
menu_lang.php
menu_mem.php
menu_quota.php
menu_aide.php
menu_quota.php