AlternC/bureau/admin/menu_quota.php

81 lines
2.6 KiB
PHP
Raw Normal View History

<?php
/*
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright (C) 2000-2012 by the AlternC Development Team.
https://alternc.org/
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
*/
2009-09-08 05:29:38 +00:00
?>
2013-01-30 15:27:43 +00:00
<div class="menu-box menu-quota">
<a href="quota_show.php">
<div class="menu-title">
<img src="images/quota.png" alt="<?php __("Show my quotas"); ?>" />&nbsp;<?php __("Show my quotas"); ?>
</div>
</a>
<?php
$q=$quota->getquota();
2013-01-30 15:27:43 +00:00
$qlist=$quota->qlist();
reset($qlist);
$col=1;
2013-01-30 15:27:43 +00:00
if (!is_array($q) || empty($q) ) {
// "No quotas for this account, or quotas currently unavailable
return;
}
2013-01-30 15:27:43 +00:00
$first=true;
while (list($key,$val)=each($qlist)) {
$col=3-$col;
2013-01-30 15:27:43 +00:00
// FIXME: rewrite it
if (($key == 'bw_web' || $key == 'web') && (isset($q[$key]["t"]) && $q[$key]["t"] > 0)) {
/*
// Quite useless, so i commented it out
if ($first) {
echo '<dt id="#quotas">' . _("Quotas") . '</dt>';
$first=false;
}
*/
2009-09-08 05:29:38 +00:00
2013-01-30 15:27:43 +00:00
if ($key == 'web') {
$q[$key]["u"] = $q[$key]["u"] * 1024;
$q[$key]["t"] = $q[$key]["t"] * 1024;
}
2013-01-30 15:27:43 +00:00
$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
2013-01-30 15:27:43 +00:00
$url = ($key == 'bw_web' ? 'stats_show_per_month.php' : 'quota_show.php');
2013-01-30 15:27:43 +00:00
echo "<dd>";
echo '<div><a href="' . $url . '">' . /* _($val) */ $key . ' ' . $usage_percent . '%' . ' (' . format_size($q[$key]["u"]) . ' / ' . format_size($q[$key]["t"]) . ')</a></div>';
echo "</dd>";
echo "<dd>";
echo '<div class="progress-bar">';
echo '<div style="width: ' . ($usage_percent > 100 ? 100 : $usage_percent) . '%; background: ' . $usage_color . ';">&nbsp;</div>';
echo '</div>';
echo "</dd>";
}
2013-01-30 11:17:16 +00:00
}
2013-01-30 15:27:43 +00:00
?>
<div style="height: 5px;">&nbsp;</div>
2009-09-08 05:29:38 +00:00
</div>