[imp] Cyrus Quota's in IMP...
Chris Bowlby
excalibur@hub.org
Tue Nov 19 17:41:58 2002
On Tue, 19 Nov 2002, Paul M Fleming wrote:
Ok, with this in place do I need to disable the quota => (...) part? How
do I get this hook in place so that imp will pick it up?
> Until PHP IMAP supports getquotaroot or fsock w/ ssl = Here is a
> solution using raw sockets in clear text. The alternative is to login as
> an admin in the quota function..
>
>
> $conf['hooks']['quota'] = 'imp_show_quota';
> /* Gets the quota usage from the imap server. $imap_admin &
> * $imap_passwd must be set to fit your own settings. This works
> * with the Cyrus imap server and the Courier imap server > 1.3.12.
> * Note the necessary changes for the Courier server in the comments.
> */
> if (!function_exists('imp_show_quota'))
> {
> function imp_show_quota ($imp)
> {
>
> $quota_html = '';
> $imap_user = $imp['user'];
> $imap_passwd = Secret::read(Secret::getKey('imp'),
> $imp['pass']);
>
> $fp = fsockopen($imp['server'],143,$errno,$sockerr,60);
> if( !$fp )
> {
> return "";
> }
> $input = fgets($fp,55);
> $output = "1 login " . $imap_user . " " . $imap_passwd . "\n";
> fputs($fp,$output);
> $input = fgets($fp,70);
> if (!(eregi("OK",$input)))
> {
> return "";
> }
> $output = "1 GETQUOTAROOT INBOX\n";
> fputs($fp,$output);
> /* read QUOTAROOT INBOX user.xxxxx */
> $input = fgets($fp,128);
> $var4 = fgets($fp,128);
> $output = "1 logout" . "\n";
> fputs($fp,$output);
> $input = fgets($fp,30);
> fclose($fp);
> if (preg_match("/\(STORAGE (\d*)\s*(\d*)\)/",$var4,$val))
> {
> # quota exist do calcs and display
> $taken = $val[1] / 1024.0;
> $total = $val[2] / 1024.0;
> $percent = $taken * 100 / $total;
>
> if ($percent >= 90)
> {
> $class = 'quotaalert';
> } elseif ($percent >= 75)
> {
> $class = 'quotawarn';
> } else
> {
> $class = 'control';
> }
> $quota_html = '<table width="100%" border="0"
> cellpadding="0" cellspacing="0"><tr><td cla
> ss="item">'
> . '<table border="0" cellspacing="2"
> cellpadding="2" width="100%"><tr><td alig
> n="center" class="' . $class . '">'
> . 'Quota: '
> . sprintf("%.0fMB available (%.1f%% used)",
> $total, $percent)
> . '</td></tr></table></td></tr></table>';
> return $quota_html;
> }
> else
> {
> # no quota return
> return "";
> }
>
> }
> }
>
>
> Chris Bowlby wrote:
> >
> > Hi All,
> >
> > I run several domains under a cyrus based IMAP/POP3 client with the HEAD
> > version of imp/horde installed on our machines. We current are just using
> > the standard cyrus server defined in servers.conf but the quota => (...)
> > part of the configuration fails to return a quota to the web page. Is
> > there a work around to get this going?
> >
> > Chris Bowlby,
> > -----------------------------------------------------
> > Manager of Information and Technology.
> > excalibur@hub.org
> > www.hub.org
> > 1-902-542-3657
> > -----------------------------------------------------
> >
> > --
> > IMP mailing list
> > Frequently Asked Questions: http://horde.org/faq/
> > To unsubscribe, mail: imp-unsubscribe@lists.horde.org
>
Chris Bowlby,
-----------------------------------------------------
Manager of Information and Technology.
excalibur@hub.org
www.hub.org
1-902-542-3657
-----------------------------------------------------
More information about the imp
mailing list