[imp] INBOX blank after setting quota hook

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Fri Feb 28 22:02:43 PST 2003


Hi!

--On Freitag, 28. Februar 2003 15:42 -0500 Robert Kubarych 
<rkubarych at bergen.edu> wrote:

> Hello,
>
>
>
> I'm using the following components:
>
>
>
> horde 2.2.1
>
> imp 3.2
>
> turba 1.1
>
> php-4.2.2
>
> cyrus  imap 2.1.12
>
> imap-2001a version of the c-client (I also tried the imap-2002b
> version).
>
>
>
> When I change IMP's conf.php quota hook to imp_show_quota and comment
> out the courier lines in the funciton I get nothing below the menu-bar.

You have the UW-imapd and not Courier. So you can't use that code.

> I saw that someone posted what appears to be the same problem at one
> point, but never saw a resolution posted.  I'm guessing I need to make
> some changes to the imp_show_quota function example in
> imp/config/conf.php.  I've tried to create a driver program from the
> function example so I can make any adjustments, but I don't have PHP
> experience and I'm not making much progress there yet.  If my problem is
> the function I thought someone might have already written a working
> function that would work with my combination of versions.
>
>
>
> Thanks in advance for any help.
>
>
>
> Rob
>
>
>
> Robert K. Kubarych
>
> (201) 612-5591

My quota code for use with UW-imapd is following (not totally self made, 
one time found the main part here in the list):

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

if (!function_exists('imp_show_quota')) {
   function imp_show_quota ($imp) {
        $imap_admin = $imp['user'];
        $passwd_array = posix_getpwnam($imap_admin);
        $homedir = split("/", $passwd_array['dir']);
        $realname = split(",", $passwd_array['gecos']);

        $quota_html = '<table width="100%" border="0" cellpadding="0" 
cellspacing="0"><tr><td class="item"><table border="0" cellspacing="0" 
cellpadding="0" width="100%"><tr>';
        $quota_html .= '<td align="left" class="header">Login: ' . 
$realname[0] . " (" . $imap_admin . ")" . '</td>';

        $junk = exec("sudo /usr/bin/quota -u $imap_admin | grep /dev/hda9",
                     $quota_data,$return_code);
        if ($return_code == 0 && count($quota_data) == 1) {
           $splitted = split("[[:blank:]]+", trim($quota_data[0]));
           $taken = $splitted[1] / 1000 ; $total = $splitted[2] / 1000 ;
           $percent = $taken * 100 / $total ;
           if ($percent >= 90) {
               $color = '#FF0000';
           } elseif ($percent >= 80) {
               $color = '#FCE30D';
           } else {
               $color = '#339933';
           }
           $quota_html .= '<td align="center" class="header">';
           $quota_html .= sprintf("<font size=-3>Quota in %s: %.1fMB von 
%.1fMB (%.1f%%)</font>", $homedir[1], $taken, $total, $percent);
        } else {
            $quota_html .= '<td align="center" class="header">';
            $quota_html .= "Quota nicht verf&uuml;gbar";
        }
        $quota_html .= '</td><td width="30" class="header" 
align="right"><font size="-3">0%</font></td><td width="200" 
class="header">';
        $quota_html .= '<table width="100%"><tr><td bgcolor="#ccccff"><div 
style="height:6px; width:'. sprintf("%.1f%%", $percent). '; font-size:3px; 
background-color:'.$color.'">';
        $quota_html .= '</div></td></tr></table></td><td width="30" 
class="header" align="left"><font 
size="-3">100%</font></td></tr></table></td></tr></table><br>';
        return $quota_html;
    }
}


That runs fine with me, no problems at all.

Alexander



More information about the imp mailing list