This commit has been accessed 546 times via Git panel.
commit a8d0335183636f6ca8c379130cc6c474cef05a53
tree e007e554090b3762acf298ac7a9f41ce927ca020
parent 4d238ac192adbaf3b838f40ec475be789cf7088d
author Engels Antonio <engels@majcms.org> 1334942457 +0800
committer Engels Antonio <engels@majcms.org> 1334942457 +0800
Add quota usage monitor
diff --git a/folders.php b/folders.php
index 172f1b1..c456a2f 100644
--- a/folders.php
+++ b/folders.php
@@ -6,8 +6,40 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
exit;
}
-echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+$quota = imap_get_quotaroot($mbox,$folder);
+
+if (is_array($quota)) {
+
+ $quota_usage = HumanReadableFileSize($quota[usage] * 1024);
+ $quota_limit = HumanReadableFileSize($quota[limit] * 1024);
+
+ $quota_pct = ($quota[usage] / $quota[limit]) * 100;
+ $quota_pct = number_format($quota_pct,2);
+
+ if ($quota_pct > 75) {
+ $quota_bar_bgcolor = "#ffbbbb";
+ $quota_bar_border = "#ff6666";
+ $quota_bar_shadow = "3px";
+ }
+ else {
+ $quota_bar_bgcolor = "#cde2a7";
+ $quota_bar_border = "#74ae0b";
+ $quota_bar_shadow = "2px";
+ }
+ $quota_bar_max = "100";
+
+ $quota_bar_width = ($quota[usage] / $quota[limit]) * ($quota_bar_max / 100) * 100;
+ $quota_bar_width = number_format($quota_bar_width, 0);
+
+ echo "<style>";
+ echo "\r\n@-webkit-keyframes quota { 0% { width: 0; height: 11px; } }";
+ echo "\r\n@-moz-keyframes quota { 0% { width: 0; height: 11px; } }";
+ echo "\r\n.bar { height: 11px; padding: 0; margin: 0; background: $quota_bar_bgcolor; border: $quota_bar_border solid 1px; -webkit-animation-name: quota; -moz-animation-name: quota; -webkit-animation-duration: 1s; -moz-animation-duration: 1s; -webkit-animation-iteration-count: 1; -moz-animation-iteration-count: 1; -webkit-animation-timing-function: ease; -moz-animation-timing-function: ease; -moz-box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; -webkit-box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; -box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; -khtml-box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; }";
+ echo "\r\n</style>";
+}
+
+echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
@@ -83,6 +115,14 @@ echo "</table></div>";
echo "<div style=\"height: 4px;\"></div>";
+if (is_array($quota)) {
+ echo "<div class=\"folders\">";
+ echo "<table style=\"-moz-box-shadow: inset 0 0 3px #dedede; -khtml-box-shadow: inset 0 0 3px #dedede; -webkit-box-shadow: inset 0 0 3px #dedede; box-shadow: inset 0 0 3px #dedede;\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"100%\"><tr bgcolor=\"#ffffff\"><td><div class=\"bar\" style=\"width: {$quota_bar_width}px;\"></td></tr></table>";
+ echo "<font style=\"font-size: 0.75em;\">$quota_usage of $quota_limit ($quota_pct%)</font>";
+ echo "</div>";
+ echo "<div style=\"height: 4px;\"></div>";
+}
+
$get_folders = kartero_sort_folders($host,imap_list($mbox,$host,"*"));
if (is_array($get_folders)) {
tree e007e554090b3762acf298ac7a9f41ce927ca020
parent 4d238ac192adbaf3b838f40ec475be789cf7088d
author Engels Antonio <engels@majcms.org> 1334942457 +0800
committer Engels Antonio <engels@majcms.org> 1334942457 +0800
Add quota usage monitor
diff --git a/folders.php b/folders.php
index 172f1b1..c456a2f 100644
--- a/folders.php
+++ b/folders.php
@@ -6,8 +6,40 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
exit;
}
-echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+$quota = imap_get_quotaroot($mbox,$folder);
+
+if (is_array($quota)) {
+
+ $quota_usage = HumanReadableFileSize($quota[usage] * 1024);
+ $quota_limit = HumanReadableFileSize($quota[limit] * 1024);
+
+ $quota_pct = ($quota[usage] / $quota[limit]) * 100;
+ $quota_pct = number_format($quota_pct,2);
+
+ if ($quota_pct > 75) {
+ $quota_bar_bgcolor = "#ffbbbb";
+ $quota_bar_border = "#ff6666";
+ $quota_bar_shadow = "3px";
+ }
+ else {
+ $quota_bar_bgcolor = "#cde2a7";
+ $quota_bar_border = "#74ae0b";
+ $quota_bar_shadow = "2px";
+ }
+ $quota_bar_max = "100";
+
+ $quota_bar_width = ($quota[usage] / $quota[limit]) * ($quota_bar_max / 100) * 100;
+ $quota_bar_width = number_format($quota_bar_width, 0);
+
+ echo "<style>";
+ echo "\r\n@-webkit-keyframes quota { 0% { width: 0; height: 11px; } }";
+ echo "\r\n@-moz-keyframes quota { 0% { width: 0; height: 11px; } }";
+ echo "\r\n.bar { height: 11px; padding: 0; margin: 0; background: $quota_bar_bgcolor; border: $quota_bar_border solid 1px; -webkit-animation-name: quota; -moz-animation-name: quota; -webkit-animation-duration: 1s; -moz-animation-duration: 1s; -webkit-animation-iteration-count: 1; -moz-animation-iteration-count: 1; -webkit-animation-timing-function: ease; -moz-animation-timing-function: ease; -moz-box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; -webkit-box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; -box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; -khtml-box-shadow: inset 0 0 $quota_bar_shadow $quota_bar_border, 0 0 1px #777; }";
+ echo "\r\n</style>";
+}
+
+echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
@@ -83,6 +115,14 @@ echo "</table></div>";
echo "<div style=\"height: 4px;\"></div>";
+if (is_array($quota)) {
+ echo "<div class=\"folders\">";
+ echo "<table style=\"-moz-box-shadow: inset 0 0 3px #dedede; -khtml-box-shadow: inset 0 0 3px #dedede; -webkit-box-shadow: inset 0 0 3px #dedede; box-shadow: inset 0 0 3px #dedede;\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"100%\"><tr bgcolor=\"#ffffff\"><td><div class=\"bar\" style=\"width: {$quota_bar_width}px;\"></td></tr></table>";
+ echo "<font style=\"font-size: 0.75em;\">$quota_usage of $quota_limit ($quota_pct%)</font>";
+ echo "</div>";
+ echo "<div style=\"height: 4px;\"></div>";
+}
+
$get_folders = kartero_sort_folders($host,imap_list($mbox,$host,"*"));
if (is_array($get_folders)) {