This functions are not suported by the dbmail daemons (to be exact the  dbmail 
daemons cannot give you the quota of a given user) but you can use them to 
calculate the quota/used space of a given user by querying the dbmail database 
directly. I have done that and it works fine. For example in conf.php of imp 
you create the imp_show_quota function:

$conf['hooks']['quota'] = 'imp_show_quota';

 if (!function_exists('imp_show_quota')) {
    function imp_show_quota ($imp) {
        $quota_html = '';
  
        $dbmail = @mysql_pconnect("localhost", "dbmail", "password") or 
die("here we die at connection");
        @mysql_select_db("dbmail",$dbmail) or die("here we die");

        $quota_usage = 0;
        $quota_limit = 0;

        $current_user = $imp['user'];

        $quota_usage_query = "select sum(messagesize) as sumup from messages 
msg,mailboxes mbox,users usr where msg.deleted_flag=0 and msg.messagesize >0 
and msg.mailbox_idnr=mbox.mailbox_idnr and mbox.owner_idnr=usr.user_idnr and 
usr.userid='$current_user'";
        if ( $quota_usage_query_res = mysql_query($quota_usage_query, $dbmail) 
) {
                $tmp_line = mysql_fetch_array($quota_usage_query_res);
                if ( empty($tmp_line['sumup']) ) $quota_usage = 0;   
                else $quota_usage = stripslashes($tmp_line['sumup']);
        }
        
        $quota_limit_query = "select maxmail_size from users where 
userid='$current_user'";
        if ( $quota_limit_query_res = mysql_query($quota_limit_query, $dbmail) 
) {
                $tmp_line = mysql_fetch_array($quota_limit_query_res); 
                $quota_limit = stripslashes($tmp_line['maxmail_size']);
        }
        
        $quota = array( 'usage' => $quota_usage , 'limit' => $quota_limit );
         
         if (is_array($quota) && $quota['limit'] != 0) {  
             $taken   = $quota['usage'] / 1024.0 / 1024.0;
             $total   = $quota['limit'] / 1024.0 / 1024.0;
             $percent = $taken * 100 / $total;
             if ($percent >= 90) {
                 $class = 'quotaalert'; 
             } elseif ($percent >= 75) {
                 $class = 'quotawarn';
             } else {
                 $class = 'quotanormal';
             }


             $quota_html = '<table width="100%" border="0" cellpadding="0" 
cellspacing="0"><tr><td class="item">'
                        . '<table border="0" cellspacing="2" cellpadding="2" 
width="100%"><tr><td align="left" class="' . $class . '">'
                        . 'User : <b>'.$current_user.'</b>' . '&nbsp; , Space 
used : '
                           . sprintf(" <b>%.2f</b> MB from <b>%.2f</b> MB total 
(%.2f%% in use) ", $taken, $total, $percent)
                           . '</td></tr></table></td></tr></table>';
        }
         if (is_array($quota) && $quota['limit'] == 0) {
             $total   = $quota['usage'] / 1024.0 / 1024.0;
         
             $quota_html = '<table width="100%" border="0" cellpadding="0" 
cellspacing="0"><tr><td class="item">'
                           . '<table border="0" cellspacing="2" cellpadding="2" 
width="100%"><tr><td align="left" class="quotanormal">'
                           . 'User : <b>'.$current_user.'</b>' . '&nbsp; , 
total size of e-mails in all folders : '
                           . sprintf(" <b>%.2f</b> MB",$total)
                           . '</td></tr></table></td></tr></table>';
         }
                 
         return $quota_html;
     }
}

-----Αρχικό Μήνυμα-----
Από: Jacques Beaudoin <[EMAIL PROTECTED]>
Θέμα: [Dbmail] imap_get_quota and imap_get_quotaroot
Ημερομηνία: Sun, 01 Jun 2003 17:13:15 -0400

Im trying  to write a script in the file config.php for  IMP webmail.

I nead to get "imap_get_quota" or "imap_get_quotaroot" to talk to
dbmail.

Is "imap_get_quota" or "imap_get_quotatroot" supported by dbmail.

Thanks
Jacques

_______________________________________________
Dbmail mailing list
Dbmail@dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


______________________________________________________________________________________
http://mobile.pathfinder.gr - Pathfinder Mobile logos & Ringtones! 
http://www.pathfinder.gr - Δωρεάν mail από τον Pathfinder!

Reply via email to