Indentation de fichiers sur les quotas

This commit is contained in:
Alan Garcia 2013-01-30 11:17:16 +00:00
parent 01e220f6ce
commit b496a01f04
2 changed files with 59 additions and 54 deletions

View File

@ -31,42 +31,42 @@ reset($qlist);
$col=1; $col=1;
if (!is_array($q)) { if (!is_array($q) || empty($q) ) {
// "No quotas for this account, or quotas currently unavailable // "No quotas for this account, or quotas currently unavailable
return; return;
} }
$first=true; $first=true;
while (list($key,$val)=each($qlist)) { while (list($key,$val)=each($qlist)) {
$col=3-$col; $col=3-$col;
// FIXME: rewrite it // FIXME: rewrite it
if (($key == 'bw_web' || $key == 'web') && (isset($q[$key]["t"]) && $q[$key]["t"] > 0)) { if (($key == 'bw_web' || $key == 'web') && (isset($q[$key]["t"]) && $q[$key]["t"] > 0)) {
if ($first) { if ($first) {
echo '<dt id="#quotas">' . _("Quotas") . '</dt>'; echo '<dt id="#quotas">' . _("Quotas") . '</dt>';
$first=false; $first=false;
} }
if ($key == 'web') { if ($key == 'web') {
$q[$key]["u"] = $q[$key]["u"] * 1024; $q[$key]["u"] = $q[$key]["u"] * 1024;
$q[$key]["t"] = $q[$key]["t"] * 1024; $q[$key]["t"] = $q[$key]["t"] * 1024;
} }
$usage_percent = (int) ($q[$key]["u"] / $q[$key]["t"] * 100); $usage_percent = (int) ($q[$key]["u"] / $q[$key]["t"] * 100);
$usage_color = ($q[$key]["u"] > $q[$key]["t"] ? '#f00' : '#0f0'); $usage_color = ($q[$key]["u"] > $q[$key]["t"] ? '#f00' : '#0f0');
$usage_color = ((85 < $usage_percent && $usage_percent < 100) ? '#ff0' : $usage_color); // yellow $usage_color = ((85 < $usage_percent && $usage_percent < 100) ? '#ff0' : $usage_color); // yellow
$url = ($key == 'bw_web' ? 'stats_show_per_month.php' : 'quota_show.php'); $url = ($key == 'bw_web' ? 'stats_show_per_month.php' : 'quota_show.php');
echo "<dd>"; echo "<dd>";
echo '<div><a href="' . $url . '">' . /* _($val) */ $key . ' ' . $usage_percent . '%' . ' (' . format_size($q[$key]["u"]) . ' / ' . format_size($q[$key]["t"]) . ')</a></div>'; 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 "<dd>"; echo "<dd>";
echo '<div style="width: 100%; background: #fff;">'; echo '<div style="width: 100%; background: #fff;">';
echo '<div style="width: ' . ($usage_percent > 100 ? 100 : $usage_percent) . '%; background: ' . $usage_color . ';">&nbsp;</div>'; echo '<div style="width: ' . ($usage_percent > 100 ? 100 : $usage_percent) . '%; background: ' . $usage_color . ';">&nbsp;</div>';
echo '</div>'; echo '</div>';
echo "</dd>"; echo "</dd>";
} }
} }
?> ?>
</div> </div>

View File

@ -36,33 +36,38 @@ include_once("head.php");
<br /> <br />
<?php <?php
$q=$quota->getquota(); $q=$quota->getquota();
if (!is_array($q)) { if (!is_array($q) || empty($q) ) {
echo "<p class=\"error\">"._("No quotas for this account, or quotas currently unavailable!")."</p>"; echo "<p class=\"error\">"._("No quotas for this account, or quotas currently unavailable!")."</p>";
} else { include_once("foot.php");
echo "<table cellspacing=\"0\" cellpadding=\"4\"><tr><th>"._("Quota")."</th><th>"._("Used")."</th><th>"._("Total")."</th></tr>"; die();
$qlist=$quota->qlist(); }
reset($qlist);
$col=1;
while (list($key,$val)=each($qlist)) {
if ( !isset($q[$key]) || !$q[$key]["t"]) continue;
$col=3-$col;
echo "<tr class=\"lst$col\">";
echo "<td>";
if ($q[$key]["u"] >= $q[$key]["t"]) echo "<font class=\"over\">";
echo _($val);
if ($q[$key]["u"] >= $q[$key]["t"]) echo "</font>";
if ($key == 'bw_web') { echo "<table cellspacing=\"0\" cellpadding=\"4\" class='tlist'>";
echo "&nbsp;</td><td align=\"center\">". format_size($q[$key]["u"]) ."&nbsp;</td><td align=\"center\">". format_size($q[$key]["t"]) ."&nbsp;</td>"; echo "<tr><th>"._("Quota")."</th><th>"._("Used")."</th><th>"._("Total")."</th></tr>";
} elseif ($key == 'web') { $qlist=$quota->qlist();
echo "&nbsp;</td><td align=\"center\">". format_size($q[$key]["u"] * 1024) . "&nbsp;</td><td align=\"center\">". format_size($q[$key]["t"] * 1024) ."&nbsp;</td>"; reset($qlist);
} else { $col=1;
echo "&nbsp;</td><td align=\"center\">".$q[$key]["u"]."&nbsp;</td><td align=\"center\">".$q[$key]["t"]."&nbsp;</td>"; while (list($key,$val)=each($qlist)) {
} if ( !isset($q[$key]) || !$q[$key]["t"]) continue;
$col=3-$col;
echo "<tr class=\"lst$col\">";
echo "<td>";
if ($q[$key]["u"] >= $q[$key]["t"]) echo "<font class=\"over\">";
echo _($val);
if ($q[$key]["u"] >= $q[$key]["t"]) echo "</font>";
if ($key == 'bw_web') {
echo "&nbsp;</td><td>". format_size($q[$key]["u"]) ."&nbsp;</td><td>". format_size($q[$key]["t"]) ."&nbsp;</td>";
} elseif ($key == 'web') {
echo "&nbsp;</td><td>". format_size($q[$key]["u"] * 1024) . "&nbsp;</td><td>". format_size($q[$key]["t"] * 1024) ."&nbsp;</td>";
} else {
echo "&nbsp;</td><td>".$q[$key]["u"]."&nbsp;</td><td>".$q[$key]["t"]."&nbsp;</td>";
}
echo "</tr>";
}
echo "</table>";
include_once("foot.php");
echo "</tr>";
}
echo "</table>";
}
?> ?>
<?php include_once("foot.php"); ?>