[imp] IMAP Quota Redhat 7.3 extra code UPDATED
Arie Kraak
maillists@obdnwh.nl
Tue, 4 Jun 2002 20:08:29 +0200
This is a multi-part message in MIME format.
---------------------- multipart/related attachment
------=_NextPart_001_0038_01C20C03.9854E190
Hi there,
Here's the updated code. I didn't tested the first time. But this code =
wil work.
It wil return;
and if quota's dont work it wil return.
Quota not available
Arie Kraak jr.
if (!function_exists('imp_show_quota')) {
function imp_show_quota ($imp) {
$imap_admin =3D $imp['user'];
$passwd_array =3D posix_getpwnam($imap_admin);
$homedir =3D split("/", $passwd_array['dir']);
$realname =3D split(",", $passwd_array['gecos']);
$quota_html =3D '<table width=3D"100%" border=3D"0" =
cellpadding=3D"0" cellspacing=3D"0"><tr><td class=3D"item"><table =
border=3D"0" cellspacing=3D"0" cellpadding=3D"0" width=3D"100%"><tr>';
$quota_html .=3D '<td align=3D"left" class=3D"header">Login: ' . =
$realname[0] . " (" . $imap_admin . ")" . '</td>';
$junk =3D exec("sudo /usr/bin/quota -u $imap_admin | grep =
/dev/md1",
$quota_data,$return_code);
if ($return_code =3D=3D 0 && count($quota_data) =3D=3D 1) {
$splitted =3D split("[[:blank:]]+", trim($quota_data[0]));
$taken =3D $splitted[1] / 1000 ; $total =3D $splitted[2] / =
1000 ;
$percent =3D $taken * 100 / $total ;
if ($percent >=3D 90) {
$color =3D '#FF0000';
} elseif ($percent >=3D 80) {
$color =3D '#FCE30D';
} else {
$color =3D '#339933';
}
$quota_html .=3D '<td align=3D"center" class=3D"header">';
$quota_html .=3D sprintf("<font size=3D-2>Quota on /%s: =
%.1fMB/%.1fMB (%.1f%%)</font>", $homedir[1], $taken, $total, $percent);
$quota_html .=3D '</td><td width=3D"30" class=3D"header" =
align=3D"right"><font size=3D"-3">0%</font></td><td width=3D"200" =
class=3D"header">';
$quota_html .=3D '<table width=3D"100%"><tr><td =
bgcolor=3D"#ccccff"><div style=3D"height:6px; width:'. sprintf("%.1f%%", =
$percent). '; font-size:3px; background-color:'.$color.'">';
$quota_html .=3D '</div></td></tr></table></td><td =
width=3D"30" class=3D"header" align=3D"left"><font =
size=3D"-3">100%</font>';
} else {
$quota_html .=3D '<td align=3D"center" class=3D"header">';
$quota_html .=3D "Quota not available";
}
$quota_html .=3D '</td></tr></table></td></tr></table>';
return $quota_html;
}
}
------=_NextPart_001_0038_01C20C03.9854E190
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi there,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Here's the updated code. I didn't =
tested the first=20
time. But this code wil work.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It wil return;</FONT></DIV>
<DIV><IMG align=3Dbaseline alt=3D"" border=3D0 hspace=3D0=20
src=3D"cid:003601c20bf2$d4b9c210$4101a8c0@laptoparie"></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>and if quota's dont work it wil=20
return.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Quota not =
available</STRONG></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Arie Kraak jr.</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>if (!function_exists('imp_show_quota')) =
{<BR> function imp_show_quota ($imp)=20
{<BR> $imap_admin =3D=20
$imp['user'];<BR> =
$passwd_array =3D=20
posix_getpwnam($imap_admin);<BR>  =
;=20
$homedir =3D split("/",=20
$passwd_array['dir']);<BR> =
$realname =3D=20
split(",",=20
$passwd_array['gecos']);<BR> =20
$quota_html =3D '<table width=3D"100%" border=3D"0" cellpadding=3D"0" =
cellspacing=3D"0"><tr><td class=3D"item"><table =
border=3D"0"=20
cellspacing=3D"0" cellpadding=3D"0"=20
width=3D"100%"><tr>';<BR> &nb=
sp;=20
$quota_html .=3D '<td align=3D"left" class=3D"header">Login: ' . =
$realname[0] .=20
" (" . $imap_admin . ")" .=20
'</td>';<BR> $junk =3D =
exec("sudo=20
/usr/bin/quota -u $imap_admin | grep=20
/dev/md1",<BR>  =
; =20
$quota_data,$return_code);<BR> =
if=20
($return_code =3D=3D 0 && count($quota_data) =3D=3D 1)=20
{<BR> =
$splitted =3D=20
split("[[:blank:]]+",=20
trim($quota_data[0]));<BR>  =
; =20
$taken =3D $splitted[1] / 1000 ; $total =3D $splitted[2] / 1000=20
;<BR> =
$percent =3D=20
$taken * 100 / $total=20
;<BR> if =
($percent=20
>=3D 90)=20
{<BR> &n=
bsp; =20
$color =3D=20
'#FF0000';<BR>  =
; }=20
elseif ($percent >=3D 80)=20
{<BR> &n=
bsp; =20
$color =3D=20
'#FCE30D';<BR>  =
; }=20
else=20
{<BR> &n=
bsp; =20
$color =3D=20
'#339933';<BR>  =
;=20
}<BR> =
$quota_html .=3D=20
'<td align=3D"center"=20
class=3D"header">';<BR>  =
; =20
$quota_html .=3D sprintf("<font size=3D-2>Quota on /%s: =
%.1fMB/%.1fMB=20
(%.1f%%)</font>", $homedir[1], $taken, $total,=20
$percent);<BR>  =
;=20
$quota_html .=3D '</td><td width=3D"30" class=3D"header"=20
align=3D"right"><font =
size=3D"-3">0%</font></td><td=20
width=3D"200"=20
class=3D"header">';<BR>  =
; =20
$quota_html .=3D '<table width=3D"100%"><tr><td=20
bgcolor=3D"#ccccff"><div style=3D"height:6px; width:'. =
sprintf("%.1f%%",=20
$percent). '; font-size:3px;=20
background-color:'.$color.'">';<BR>  =
; =20
$quota_html .=3D=20
'</div></td></tr></table></td><td =
width=3D"30"=20
class=3D"header" align=3D"left"><font=20
size=3D"-3">100%</font>';<BR>  =
; }=20
else =
{<BR> =20
$quota_html .=3D '<td align=3D"center"=20
class=3D"header">';<BR>  =
; =20
$quota_html .=3D "Quota not=20
available";<BR> =20
}<BR> $quota_html .=3D=20
'</td></tr></table></td></tr></table>=
';<BR> =20
return $quota_html;<BR> =
}<BR>}<BR></FONT></DIV></BODY></HTML>
------=_NextPart_001_0038_01C20C03.9854E190--
---------------------- multipart/related attachment
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 7664 bytes
Desc: not available
Url : http://lists.horde.org/archives/imp/attachments/7e39ba6f/attachment.gif
---------------------- multipart/related attachment--