diff -Naudr omail-admin-1.2rc1/config.php omail-admin-1.2rc1-stat/config.php --- omail-admin-1.2rc1/config.php Sun Feb 15 13:15:44 2004 +++ omail-admin-1.2rc1-stat/config.php Sun Sep 18 19:07:02 2005 @@ -144,6 +144,15 @@ $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 + + ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// diff -Naudr omail-admin-1.2rc1/func.php omail-admin-1.2rc1-stat/func.php --- omail-admin-1.2rc1/func.php Sun Feb 15 13:05:43 2004 +++ omail-admin-1.2rc1-stat/func.php Sun Sep 18 19:07: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); diff -Naudr omail-admin-1.2rc1/htmlstuff.php omail-admin-1.2rc1-stat/htmlstuff.php --- omail-admin-1.2rc1/htmlstuff.php Sun Feb 15 13:05:43 2004 +++ omail-admin-1.2rc1-stat/htmlstuff.php Sun Sep 18 19:09:51 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
"; //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
"; //debug @@ -805,14 +808,20 @@ $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"] = "" . $txt_system_account[$lang] . ""; $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)"; diff -Naudr omail-admin-1.2rc1/index.php omail-admin-1.2rc1-stat/index.php --- omail-admin-1.2rc1/index.php Sun Feb 15 13:05:43 2004 +++ omail-admin-1.2rc1-stat/index.php Sun Sep 18 19:07:02 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 .= "

" . $txt_forwarding_off_warning[$lang] . "
"; } } else { diff -Naudr omail-admin-1.2rc1/scripts/vmailstats.pl omail-admin-1.2rc1-stat/scripts/vmailstats.pl --- omail-admin-1.2rc1/scripts/vmailstats.pl Sat Feb 14 18:17:23 2004 +++ omail-admin-1.2rc1-stat/scripts/vmailstats.pl Sun Sep 18 19:07:02 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"; } diff -Naudr omail-admin-1.2rc1/templates/display_account.temp omail-admin-1.2rc1-stat/templates/display_account.temp --- omail-admin-1.2rc1/templates/display_account.temp Sun May 4 17:56:42 2003 +++ omail-admin-1.2rc1-stat/templates/display_account.temp Sun Sep 18 19:07:02 2005 @@ -2,6 +2,7 @@ + %ifdef_txt_responder% @@ -16,6 +17,7 @@ + %ifdef_autoresponder_status% diff -Naudr omail-admin-1.2rc1/templates/display_aliases.temp omail-admin-1.2rc1-stat/templates/display_aliases.temp --- omail-admin-1.2rc1/templates/display_aliases.temp Sun May 4 17:56:42 2003 +++ omail-admin-1.2rc1-stat/templates/display_aliases.temp Sun Sep 18 19:07:02 2005 @@ -30,6 +30,7 @@
%txt_email% %txt_info%%txt_size% %txt_fwd% ? %username%   %PersonalInfo% %size_all% MB %more_alias% 
+ %ifdef_txt_responder% @@ -50,6 +51,7 @@ + %ifdef_autoresponder_status% diff -Naudr omail-admin-1.2rc1/templates/display_mailboxes.temp omail-admin-1.2rc1-stat/templates/display_mailboxes.temp --- omail-admin-1.2rc1/templates/display_mailboxes.temp Sun May 4 17:56:42 2003 +++ omail-admin-1.2rc1-stat/templates/display_mailboxes.temp Sun Sep 18 19:07:02 2005 @@ -30,6 +30,7 @@
%txt_email% %txt_info%%txt_size% %txt_fwd%? %username%   %PersonalInfo% %size_all% MB %more_alias% 
+ %ifdef_txt_responder% @@ -49,6 +50,7 @@ + %ifdef_autoresponder_status% diff -Naudr omail-admin-1.2rc1/templates/display_mailboxes_nolimit.temp omail-admin-1.2rc1-stat/templates/display_mailboxes_nolimit.temp --- omail-admin-1.2rc1/templates/display_mailboxes_nolimit.temp Sun May 4 17:56:42 2003 +++ omail-admin-1.2rc1-stat/templates/display_mailboxes_nolimit.temp Sun Sep 18 19:07:02 2005 @@ -30,6 +30,7 @@
%txt_email% %txt_info%%txt_size% %txt_fwd%? %username%   %PersonalInfo% %size_all% MB %more_alias% 
+ %ifdef_txt_responder% @@ -45,6 +46,7 @@ + %ifdef_autoresponder_status% diff -Naudr omail-admin-1.2rc1/vmail.inc omail-admin-1.2rc1-stat/vmail.inc --- omail-admin-1.2rc1/vmail.inc Sun May 4 17:56:42 2003 +++ omail-admin-1.2rc1-stat/vmail.inc Sun Sep 18 19:07:02 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); }
%txt_email% %txt_info%%txt_size% %txt_fwd%? %username%   %PersonalInfo% %size_all% MB %more_alias%