[Fwd: Re: [imp] Free space info into IMP]

Paul M Fleming pfleming@som.siu.edu
Tue, 27 Feb 2001 13:52:16 -0600


To check quota try the following piece of code:

-----------------
<HTML>
<TITLE> Check your e-mail quota</TITLE>

<h2> Check your e-mail quota </h2>
<br>
<br>

<form action="check_quota.php" method=post>
<?php
switch ($prev_page)
{
  case ("entry_page"): 
     if ($login == $never_set)
          { print "username is missing<br>\n";
            exit;
          }

     if ($pass == $never_set)
          { print "password is missing<br>\n";
            exit;
          }
$host = "mailserver";
$port = 143;
$sockerr = "socket open error";
$errno = 9999;
$logerr = "login error";
        
        $fp = fsockopen($host,$port,$errno,$sockerr,120);
        
        if( !$fp ) { 
                print "$sockerr ($errno)<br>\n"; 
}       

        /* read OK IMAP Proxy agent banner */
        $input = fgets($fp,55);  

        /* send the login */    
        $output = "1 login " . $login . " " .  $pass . "\n";
        fputs($fp,$output);

        /* read 1 OK User logged in */
        $input = fgets($fp,70);

        /* check for OK to see if user logged on */
        if (!(eregi("OK",$input))) {

                /* not a valid userid/password, logout and close socket
*/
                print "Invalid userid or password<br>\n"; 
                $output = "1 logout" . "\n";
                fputs($fp,$output);
                $input = fgets($fp,30);
                fclose($fp);
                exit;
}       

        $output = "1 GETQUOTAROOT INBOX\n";
        fputs($fp,$output);
        /* read QUOTAROOT INBOX user.xxxxx */
        $input = fgets($fp,128);


        /* read  QUOTA user.userid (STORAGE xxxxx xxxxx) */
        $var4 = fgets($fp,128);
        
        /* issue logout and close socket */
        $output = "1 logout" . "\n";
        fputs($fp,$output);
        $input = fgets($fp,30);
        fclose($fp);

                
        if (preg_match("/\(STORAGE (\d*)\s*(\d*)\)/",$var4,$val)) {
                /* process quota info if it exists */   
                printf("Your maximum is $val[2] kilobytes, <B> %.0f %%
used. </B>\n",($val[1]/$val[2])*100);
        }
        else
        {
                print "NO QUOTA";
        }
?>

        
<?php

    break;

  default:
?>
        <CENTER>
        <TABLE BORDER=0>
        <TR>
        <TD>
        Username:
        </TD>
        <TD>
        <input name="login" value="" size=16>
        </TD>
        </TR>
        <TR>
        <TD>
        Password:
        </TD>
        <TD>
        <input name="pass" value="" type=password size=16>
        </TD>
        </TR>
        <TR>
        <TD>
        <TR>
        <TD>
        <TD ALIGN=CENTER COLSPAN=2>
        <input type=submit value="Check e-mail quota">
        <INPUT type="hidden" name="prev_page" value="entry_page">
        </TD>
        </TR>
        </TABLE>
        </form>
        </CENTER>
        <HR>
        <INPUT type="hidden" name="prev_page" value="entry_page">
<?php
}
?>
</FORM>
</HTML>
------------------

Dan Ellis wrote:
> 
> There's a function called imap_alerts() that I use to display any imap warnings
> given by the IMAP server.
> 
> I believe this is the only way to (without going out of the IMAP protocol)
> accomplish this knwledge.
> 
> I can give you the exact mod.  It was like three lines of code...
> 
> Dan
> 
> Quoting "Federico E. Petronio" <petronio@ifeva.edu.ar>:
> 
> >
> > Hi. Recently I found that some users have problems using IMP related to
> > "out of space" for folders in server ( Quotas ). Primary when they want
> > to
> > move mails from Inbox to other folder because they have no way to know
> > that
> > have run out of space. I know that this is not an IMP problem. But I
> > looking for putting some info about used and free space into their
> > IMP's
> > pages.
> >
> > Is there some PHP IMAP function that I can use to print the used space
> > for
> > folders ? or any function in PHP that can reach this objective.
> >
> > Is there any plan to add this kind of info to the official IMP's pages.
> >
> > I am running PHP 4.0.3pl1. And the IMAP server is not the same running
> > IMP.
> >
> > Thanks a lot.
> >
> > --
> >                                         Federico Petronio
> >                                         petronio@ifeva.edu.ar
> >                                         Linux User #129974
> >
> > ---
> > Unix IS user friendly. It's just selective about who its friends are.
> >
> >
> >
> >
> > --
> > IMP mailing list: http://horde.org/imp/
> > Frequently Asked Questions: http://horde.org/faq/
> > To unsubscribe, mail: imp-unsubscribe@lists.horde.org
> >
> >
> 
> -------------------------------------------------
> Sent by Black Hills Fibercom Webmail!
> 
> --
> IMP mailing list: http://horde.org/imp/
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe@lists.horde.org