[imp] Courier IMAP and 'imp_show_quota'/today's HEAD Version.
Edwin Culp
eculp@encontacto.net
Wed, 5 Jun 2002 06:50:37 -0700
Quoting Tjeerd van der Zee <Tjeerd.vdzee@chello.nl>:
| Hi,
|
| I've modified the quota script for use with courier imap and ldap.
|
| the only thing this is being done with ldap is retreive the homedir from
| ldap.
| you change that with the function in the original script.
|
| I've had some troubles also with quota functions of courier imap.
|
| You need to compile courier imap with
|
| --enable-workarounds-for-imap-client-bugs
Tjeerd,
Thanks for the code.
I always use that. In fact, I even built the, just released, courier
mail suite, 38.2 and with --enable-workarounds-for-imap-client-bugs
out of desperation.
I think I may have found my problem after changing to your code. I
seem to have a problem reading the maildirsize because of a permissions
issue with apache2, courier and my shared virtual user uid. I'll
fix that later after a 7am meeting and let you know. I knew I was
going to have to address it but since it hadn't bitten me . . . .:-)
Again, thanks for the help,
ed
|
| otherwise c-client will fail to retreive the quota for a user.
|
| The passwords is retreived from Horde, but if you wan't, you could also get
| it from ldap since the user is known.
|
| The user gets his quota with his own username and password.
|
| It searches for the maildirsize file in the homedir, when it isn't present,
| it just skips
| the quotabar creation.
|
| With kind regards,
|
| Tjeerd van der Zee.
|
| if (!function_exists('imp_show_quota')) {
| function imp_show_quota ($imp) {
|
| $imapuser = $imp['user'];
| $splitted = split("@", $imapuser);
| $realname = @$splitted[0]; $realm = @$splitted[1];
| $imapadminpass = Auth::getCredential('password');
| $imaphost = '{localhost:143}';
|
| $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 . "
| (" . $imapuser . ")" . '</td>';
|
| $ds=ldap_connect("localhost");
| if ($ds) {
| $r=ldap_bind($ds);
| $sr=ldap_search($ds,"o=xar.nl", "mail=$imapuser");
| $info = ldap_get_entries($ds, $sr);
| for ($i=0; $i<$info["count"]; $i++) {
| @$homedir=$info[$i]["homedirectory"][0];
| }
| ldap_close($ds);
| }
|
| // check for the maildirsize file.
| $homedir = $homedir . "/Maildir/maildirsize";
| if(file_exists("$homedir")){
|
| $userprefix = 'user.';
| $mbox = imap_open($imaphost, $imapuser, $imapadminpass, OP_HALFOPEN) or
| die ("Imap host is down");
| $quota = imap_get_quota($mbox, $userprefix.$imapuser) or die ("");
| imap_close($mbox);
|
|
| if (is_array($quota) && $quota['limit'] != 0) {
| $taken = $quota['usage'] / 1024.0;
| $total = $quota['limit'] / 1024.0;
| $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=-2>Quota on /%s: %.1fMB/%.1fMB
| (%.1f%%)</font>", "Maildir", $taken, $total, $percent);
| $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>';
| } else {
| $quota_html .= '<td align="center" class="header">';
| $quota_html .= "Quota not available";
| }
| $quota_html .= '</td></tr></table></td></tr></table>';
| return $quota_html;
| }
| }
| }
|
|
|
| ----- Original Message -----
| From: "Edwin Culp" <eculp@encontacto.net>
| To: <imp@lists.horde.org>
| Sent: Wednesday, June 05, 2002 8:32 AM
| Subject: Re: [imp] Courier IMAP and 'imp_show_quota'/today's HEAD Version.
|
|
| > Quoting Edwin Culp <eculp@encontacto.net>:
| >
| > | I fixed the prevous problems and now get no errors but no quota although
| > | it works manually and the maildirsize file has been created with the
| proper
| > | values. Somehow I'm not reading the quota. I'm recompiling cclient
| right
| > | now.
| > I recompiled and reinstalled
| > imap-uw-2001a,1
| > cclient-2001a,1
| > mod_php4-4.2.1
| > restarted apache and still no quota. I don't seem to be getting anything
| > our of courier.
| >
| > ed
| >
| > |
| > | Thanks,
| > |
| > | ed
| >
| >
| >
| > -------------------------------------------------------------
| > http://insourcery.com - Mergence of Business and Technology
| > a "Griffin Plaza Partners, LLC" Company
| >
| > --
| > IMP mailing list
| > Frequently Asked Questions: http://horde.org/faq/
| > To unsubscribe, mail: imp-unsubscribe@lists.horde.org
| >
--
-------------------------------------------------------------
http://insourcery.com - Mergence of Business and Technology
a "Griffin Plaza Partners, LLC" Company