[PATCH] omail-admin 1.2rc1 updates for vmailmgr 0.97
Dale Woolridge <[email protected]> Sun, 11 Sep 2005 23:11:09 -0400
| Newsgroups | gmane.mail.vmailmgr |
|---|---|
| Message-ID | <[email protected]> |
--r5lq+205vWdkqwtk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
The attached patch fixes some issues in omail-admin resulting
from differences between vmailmgr 0.96.9 and 0.97:
1. aliases now have home directories (which are empty), but
omail-admin assumed this was how aliases and mailbox users
were distinguished
2. adduser3() is now used instead of adduser2() so that the
alias/user distinction is explicit
3. Resulting from (1) above, the catchall address is detected
correctly (in the default case). This should probably be fixed
to deal with changes to the vmailmgr default-username value.
In addition, this patch provides additional features:
1. a vstat() wrapper has been added to vmail.inc to support
collection of live mailbox usage statistics
2. a new parameter, config_mailbox_recursion (default 0), is
used to support the previously posted vmailmgr 0.97 patch
that adds subdirectory stats collection
3. The mailbox user list contains a new column, Size, which is
used to display the mailbox statistics collected via vstat().
Although new/seen/unseen stats are available internally, only
the sum (total mailbox size) is displayed in this column.
Warning: This can be slow (and is inefficient) with very large
numbers of mailboxes.
4. The Size column can be used to sort by mailbox size. Depending
on the config_mailbox_recursion setting, this may mean that the
sort is based on INBOX sized instead of total account disk usage.
--
-dale
--r5lq+205vWdkqwtk
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename="omail-admin-1.2rc1-vmailmgr-0.97-dw.patch"
Content-Transfer-Encoding: 8bit
--- omail-admin-1.2rc1/config.php Sun Feb 15 13:15:44 2004
+++ omail-admin/config.php Sun Sep 11 22:35:53 2005
@@ -140,8 +140,17 @@
// to allow display of domain / maildir disk usage information
// (empty by default, to activate it, replace by directory name)
//$vmailstats_directory = "/var/vmailstats";
$vmailstats_directory = "";
+
+
+// mailbox(es) size settings
+// -------------------------
+// whether to look into subdirs of dir for mailbox size
+// you can, for example use vmailstats above to keep the
+// deep/recursed mbox size and use non-recursive live
+// mbox size (to reflect INBOX size only)
+$config_mailbox_recursion = 0; // no recursion
/////////////////////////////////////////////////////////////////////////////////////////
--- omail-admin-1.2rc1/func.php Sun Feb 15 13:05:43 2004
+++ omail-admin/func.php Sat Sep 10 23:48:02 2005
@@ -249,19 +249,26 @@
function get_accounts_sort_by_name($a, $b) {
- list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible)=$a;
- list($username2, $password2, $mbox2, $alias2, $PersonalInfo2, $HardQuota2, $SoftQuota2, $SizeLimit2, $CountLimit2, $CreationTime2, $ExpiryTime2, $resp2, $Enabled2, $Visible2)=$b;
+ list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $MBoxStats, $Enabled, $Visible, $Alias)=$a;
+ list($username2, $password2, $mbox2, $alias2, $PersonalInfo2, $HardQuota2, $SoftQuota2, $SizeLimit2, $CountLimit2, $CreationTime2, $ExpiryTime2, $resp2, $MBoxStats2, $Enabled2, $Visible2, $Alias2)=$b;
return (strtolower($username) < strtolower($username2)) ? -1 : 1;
}
function get_accounts_sort_by_info($a, $b) {
- list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible)=$a;
- list($username2, $password2, $mbox2, $alias2, $PersonalInfo2, $HardQuota2, $SoftQuota2, $SizeLimit2, $CountLimit2, $CreationTime2, $ExpiryTime2, $resp2, $Enabled2, $Visible2)=$b;
+ list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $MBoxStats, $Enabled, $Visible, $Alias)=$a;
+ list($username2, $password2, $mbox2, $alias2, $PersonalInfo2, $HardQuota2, $SoftQuota2, $SizeLimit2, $CountLimit2, $CreationTime2, $ExpiryTime2, $resp2, $MBoxStats, $Enabled2, $Visible2, $Alias2)=$b;
return (strtolower($PersonalInfo) < strtolower($PersonalInfo2)) ? -1 : 1;
}
+function get_accounts_sort_by_size($a, $b) {
+
+ list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $MBoxStats, $Enabled, $Visible, $Alias)=$a;
+ list($username2, $password2, $mbox2, $alias2, $PersonalInfo2, $HardQuota2, $SoftQuota2, $SizeLimit2, $CountLimit2, $CreationTime2, $ExpiryTime2, $resp2, $MBoxStats2, $Enabled2, $Visible2, $Alias2)=$b;
+ return (($MBoxStats[1]+$MBoxStats[3]+$MBoxStats[5]) > ($MBoxStats2[1]+$MBoxStats2[3]+$MBoxStats2[5])) ? -1 : 1;
+}
+
function get_accounts($arg_action, $arg_username = "") {
@@ -300,13 +307,20 @@
// set if visible or not (for catchall or "admin" accounts like postmaster, etc...)
if ($username == "+") { $Visible = 0; } else { $Visible = 1; }
+ // check if alias
+ if (ord($data11[10]) == 49) { $Alias = 0; } else { $Alias = 1; }
// get enabled/disabled status
if (ord($data11[8]) == 49) { $Enabled = 1; } else { $Enabled = 0; }
- // findout autoresp status (only lookup for mailboxes)
+ // findout autoresp/stats status (only lookup for mailboxes)
- if ($mbox && $arg_action != 3) {
+ if ($mbox && !$Alias && $arg_action != 3) {
+ if (!isset($vm_mbox_stats[$username])) {
+ $MBoxStats = get_mbox_stats($username);
+ } else {
+ $MBoxStats = $vm_mbox_stats[$username];
+ }
if (!isset($vm_resp_status[$username])) {
$resp = load_resp_status($username);
$vm_resp_status[$username] = $resp;
@@ -315,11 +329,12 @@
}
} else {
+ $MboxStats = array(0,0,0,0,0,0); // new count/size, unseen count/size, seen count/size
$resp = 0;
}
if (($arg_action == 1) && $mb_letter && !eregi("^[$mb_letter]",$username)) {
- if ($mbox) {
+ if ($mbox && !$Alias) {
if (!(in_array($username, $readonly_accounts_list) || in_array($username, $system_accounts_list))) {
$quota_data["nb_users"]++;
}
@@ -328,7 +343,7 @@
}
if ($arg_action == 2 && $al_letter && !eregi("^[$al_letter]",$username)) {
- if (!$mbox) {
+ if (!$mbox || $Alias) {
if (!(in_array($username, $readonly_accounts_list) || in_array($username, $system_accounts_list))) {
$quota_data["nb_alias"]++;
}
@@ -336,16 +351,16 @@
continue;
}
- $list[$i] = array($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible);
+ $list[$i] = array($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $MBoxStats, $Enabled, $Visible, $Alias);
- if ($mbox && ($arg_action == 1 || $arg_action == 3)) {
+ if ($mbox && !$Alias && ($arg_action == 1 || $arg_action == 3)) {
$new_list[$j++] = $list[$i];
if (!(in_array($username, $readonly_accounts_list) || in_array($username, $system_accounts_list))) {
$quota_data["nb_users"]++;
}
}
- if (!$mbox && ($arg_action == 2 || $arg_action == 3)) {
+ if ((!$mbox || $Alias) && ($arg_action == 2 || $arg_action == 3)) {
$new_list[$j++] = $list[$i];
if (!(in_array($username, $readonly_accounts_list) || in_array($username, $system_accounts_list))) {
$quota_data["nb_alias"]++;
@@ -358,10 +373,17 @@
// try to sort on username
- if ($sort_order == "info") {
- usort($new_list, get_accounts_sort_by_info);
- } else {
- usort($new_list, get_accounts_sort_by_name);
+ switch ($sort_order) {
+ case "info":
+ usort($new_list, get_accounts_sort_by_info);
+ break;
+ case "size":
+ usort($new_list, get_accounts_sort_by_size);
+ break;
+ case "username":
+ default:
+ usort($new_list, get_accounts_sort_by_name);
+ break;
}
@@ -373,12 +395,20 @@
list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $data11)=$lookup_data;
+ // check if alias
+ if (ord($data11[10]) == 49) { $Alias = 0; } else { $Alias = 1; }
// get enabled/disabled status
if (ord($data11[8]) == 49) { $Enabled = 1; } else { $Enabled = 0; }
- if ($mbox) { $resp = load_resp_status($username); } else { $resp = 0; } // only lookup for mailboxes
+ if ($mbox && !$Alias) {
+ $MBoxStats = get_mbox_stats($username);
+ $resp = load_resp_status($username);
+ } else {
+ $MboxStats = array(0,0,0,0,0,0); // new count/size, unseen count/size, seen count/size
+ $resp = 0;
+ } // only lookup for mailboxes
- $new_list[0] = array($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, 1);
+ $new_list[0] = array($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $MBoxStats, $Enabled, 1, $Alias);
}
return $new_list;
@@ -506,6 +536,14 @@
else { return "DELETE error : " . $result[1] ; }
}
+function get_mbox_stats($arg_username) {
+ global $type, $domain, $passwd, $config_mailbox_recursion;
+
+ $return_data = vstat($domain, base64_decode($passwd), $arg_username, $config_mailbox_recursion);
+
+ return $return_data;
+}
+
function load_resp_file($arg_username) {
@@ -601,7 +639,7 @@
if ($catchallinfo[0] == "+") {
- if (!($catchallinfo[2])) {
+ if (!($catchallinfo[2]) || $catchallinfo[2] == "./users/+") {
$aliases = $catchallinfo[3];
$nb_fwd = count($aliases);
--- omail-admin-1.2rc1/htmlstuff.php Sun Feb 15 13:05:43 2004
+++ omail-admin/htmlstuff.php Sun Sep 11 21:35:48 2005
@@ -333,7 +333,7 @@
global $quota_on, $quota_data, $session, $script, $lang, $domain, $type;
include("strings.php");
- list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible)= $userinfo;
+ list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible, $Alias)= $userinfo;
// template = quotaform.temp - 23sep2k [om]
@@ -627,13 +627,15 @@
$tmp_user = $mboxlist[0];
$listtype = "account";
$templdata["title"]=$txt_user_title[$lang];
- if ($tmp_user[2]) { $mtype = "mbox"; } else { $mtype = "alias"; }
+ if ($tmp_user[2] && !$tmp_user[15]) { $mtype = "mbox"; } else { $mtype = "alias"; }
+
break;
}
$templdata["txt_email"] = $txt_email[$lang];
$templdata["txt_info"] = $txt_info[$lang];
+ $templdata["txt_size"] = $txt_size[$lang];
if ($vmailstats["active"]) {
$templdata["txt_info"] .= " / " . $txt_mailbox_size[$lang];
@@ -661,6 +663,7 @@
$templdata["url_email"] = $script . "?A=menu&form_sort=username&" . SID;
$templdata["url_info"] = $script . "?A=menu&form_sort=info&" . SID;
+ $templdata["url_size"] = $script . "?A=menu&form_sort=size&" . SID;
$templdata["url_show_mb_letter"] = $script . "?A=menu&" . SID . "&new_mb_start=1&show_mb_letter=";
$templdata["url_show_al_letter"] = $script . "?A=menu&" . SID . "&new_al_start=1&show_al_letter=";
@@ -766,14 +769,14 @@
for ($i = $loop_start; $i <= $loop_end; $i++) {
- list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible)=$mboxlist[$i];
+ list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $mboxstats, $Enabled, $Visible, $Alias)=$mboxlist[$i];
// print "$i $username<br>"; //debug
while ($username && (!$Visible || in_array($username, $system_accounts_list))) {
$hidden++;
$i++;
- list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $Enabled, $Visible)=$mboxlist[$i];
+ list($username, $password, $mbox, $alias, $PersonalInfo, $HardQuota, $SoftQuota, $SizeLimit, $CountLimit, $CreationTime, $ExpiryTime, $resp, $mboxstats, $Enabled, $Visible, $Alias)=$mboxlist[$i];
// print " $i $username<br>"; //debug
@@ -805,20 +808,26 @@
$templdata[obj][$ii]["username"] = $username;
$templdata[obj][$ii]["PersonalInfo"] = $PersonalInfo;
+ if ($arg_action != 2 && !$Alias) {
+ $templdata[obj][$ii]["size_new"] = round($mboxstats[1]/(1024*1024),3);
+ $templdata[obj][$ii]["size_unseen"] = round($mboxstats[3]/(1024*1024),3);
+ $templdata[obj][$ii]["size_seen"] = round($mboxstats[5]/(1024*1024),3);
+ $templdata[obj][$ii]["size_all"] = round(($mboxstats[1]+$mboxstats[3]+$mboxstats[5])/(1024*1024),3);
+ }
if (in_array($username, $readonly_accounts_list)) {
$templdata[obj][$ii]["PersonalInfo"] = "<I>" . $txt_system_account[$lang] . "</I>";
$templdata[obj][$ii]["colorUsername"] = "black";
}
- if ($vmailstats["active"] && $arg_action != 2) {
- if ($vmailstats[$username][size]<1024) {
+ if ($vmailstats["active"] && $arg_action != 2 && !$Alias) {
+ if ($vmailstats[$username][size]<1024) {
$templdata[obj][$ii]["PersonalInfo"] .= " (" . $vmailstats[$username][size] . " kB)";
} else {
$templdata[obj][$ii]["PersonalInfo"] .= " (" . round($vmailstats[$username][size]/1024,1) . " MB)";
}
}
$templdata[obj][$ii]["alias0"] = $alias[0];
$templdata[obj][$ii]["alias1"] = $alias[1];
--- omail-admin-1.2rc1/index.php Sun Feb 15 13:05:43 2004
+++ omail-admin/index.php Fri Sep 9 23:19:28 2005
@@ -330,6 +330,7 @@
if ($type == "domain") {
+ if ($form_sort == "size") { $sort_order = "size"; }
if ($form_sort == "info") { $sort_order = "info"; }
if ($form_sort == "username") { $sort_order = "username"; }
@@ -914,7 +915,7 @@
if (!$fwd[0] && !$fwd[1] && !$fwd[2] && !$fwd[3] && !$fwd[4] && !$fwd[5]) {
$userinfo = get_accounts(0,$U);
- if (!$userinfo[0][12]) {
+ if (!$userinfo[0][13]) {
$results .= "<br><br><b><font color=red>" . $txt_forwarding_off_warning[$lang] . "</font></b><br>";
}
} else {
--- omail-admin-1.2rc1/templates/display_account.temp Sun May 4 17:56:42 2003
+++ omail-admin/templates/display_account.temp Sat Sep 10 23:31:43 2005
@@ -2,6 +2,7 @@
<table border=0><TR><TH>N°</TH>
<TH>%txt_email%</TH>
<TH>%txt_info%</TH>
+<TH>%txt_size%</TH>
<TH>%txt_fwd% ?</TH>
%ifdef_txt_responder%
@@ -16,6 +17,7 @@
<TD><B><FONT COLOR=%colorUsername%> %username% </FONT></B> </TD>
<TD>%PersonalInfo% </TD>
+<TD>%size_all% MB</TD>
<TD>%more_alias% </TD>
%ifdef_autoresponder_status%
--- omail-admin-1.2rc1/templates/display_aliases.temp Sun May 4 17:56:42 2003
+++ omail-admin/templates/display_aliases.temp Sat Sep 10 23:30:25 2005
@@ -30,6 +30,7 @@
<table border=0><TR><TH>N°</TH>
<TH><A HREF="%url_email%">%txt_email%</A></TH>
<TH><A HREF="%url_info%">%txt_info%</A></TH>
+<TH><A HREF="%url_size%">%txt_size%</A></TH>
<TH>%txt_fwd%?</TH>
%ifdef_txt_responder%
@@ -50,6 +51,7 @@
<TD><B><FONT COLOR=%colorUsername%> %username% </FONT></B> </TD>
<TD>%PersonalInfo% </TD>
+<TD>%size_all% MB</TD>
<TD>%more_alias% </TD>
%ifdef_autoresponder_status%
--- omail-admin-1.2rc1/templates/display_mailboxes.temp Sun May 4 17:56:42 2003
+++ omail-admin/templates/display_mailboxes.temp Sat Sep 10 23:32:03 2005
@@ -30,6 +30,7 @@
<table border=0><TR><TH>N°</TH>
<TH><A HREF="%url_email%">%txt_email%</A></TH>
<TH><A HREF="%url_info%">%txt_info%</A></TH>
+<TH><A HREF="%url_size%">%txt_size%</A></TH>
<TH>%txt_fwd%?</TH>
%ifdef_txt_responder%
@@ -49,6 +50,7 @@
<TD><B><FONT COLOR=%colorUsername%> %username% </FONT></B> </TD>
<TD>%PersonalInfo% </TD>
+<TD>%size_all% MB</TD>
<TD>%more_alias% </TD>
%ifdef_autoresponder_status%
--- omail-admin-1.2rc1/templates/display_mailboxes_nolimit.temp Sun May 4 17:56:42 2003
+++ omail-admin/templates/display_mailboxes_nolimit.temp Sat Sep 10 23:32:09 2005
@@ -30,6 +30,7 @@
<table border=0><TR><TH>N°</TH>
<TH><A HREF="%url_email%">%txt_email%</A></TH>
<TH><A HREF="%url_info%">%txt_info%</A></TH>
+<TH><A HREF="%url_size%">%txt_size%</A></TH>
<TH>%txt_fwd%?</TH>
%ifdef_txt_responder%
@@ -45,6 +46,7 @@
<TD><B><FONT COLOR=%colorUsername%> %username% </FONT></B> </TD>
<TD>%PersonalInfo% </TD>
+<TD>%size_all% MB</TD>
<TD>%more_alias% </TD>
%ifdef_autoresponder_status%
--- omail-admin-1.2rc1/vmail.inc Sun May 4 17:56:42 2003
+++ omail-admin/vmail.inc Sat Sep 10 23:48:10 2005
@@ -189,8 +189,8 @@
if ($password=="") return array(1, "Empty domain password");
if ($username=="") return array(1, "Empty username");
if ($userpass=="") return array(1, "No user password supplied");
- $command=array("adduser2", $domain, $username, $password,
- $userpass, $username);
+ $command=array("adduser3", $domain, $username, $password,
+ $userpass, $username, "1");
for ($x=0; $x < sizeof($forwards); $x++)
if ($forwards[$x]!="") $command[]=$forwards[$x];
$result=vm_daemon_raw($command);
@@ -209,8 +209,8 @@
if ($domain=="") return array(1, "Empty domain");
if ($password=="") return array(1, "Empty domain password");
if ($username=="") return array(1, "Empty username");
- $command=array("adduser2", $domain, $username, $password,
- $userpass, "");
+ $command=array("adduser3", $domain, $username, $password,
+ $userpass, $username, "");
for ($x=0; $x < sizeof($forwards); $x++)
if ($forwards[$x]!="")
$command[]=$forwards[$x];
@@ -299,6 +299,16 @@
function vautoresponsestatus($domain, $password, $username){
$command = array("autoresponse", $domain, $username, $password, "status");
return vm_daemon_raw($command);
+}
+
+function vstat($domain, $password, $username, $recurse){
+ if ($recurse) {
+ $command = array("stat", $domain, $username, $password, "recurse");
+ } else {
+ $command = array("stat", $domain, $username, $password);
+ }
+ $temp = vm_daemon_raw($command);
+return array_slice(explode(chr(0),$temp[1]),1);
}
--- omail-admin-1.2rc1/scripts/vmailstats.pl Sat Feb 14 18:17:23 2004
+++ omail-admin/scripts/vmailstats.pl Thu Sep 8 23:10:15 2005
@@ -131,6 +131,7 @@
$maildir = lc($maildir);
$maildir =~ s/\:/\./g;
+ next if (!$account_cur_size && !$account_new_size && !$account_cur_nb && !$account_new_nb && !-d "$target_maildir/cur");
print OUT "$maildir\t$account_size\t$account_cur_size\t$account_new_size\t$account_cur_nb\t$account_new_nb\t\n";
}
--r5lq+205vWdkqwtk
Content-Type: text/plain; charset=us-ascii
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--r5lq+205vWdkqwtk--