[imp] IMAP Quota Redhat 7.3 extra code
eltonic40
eltonic40@ecotech.com.lr
Tue, 4 Jun 2002 20:00:36 -0000
This is a multi-part message in MIME format.
---------------------- multipart/related attachment
------=_NextPart_001_0027_01C20C02.805F43B0
I did some hacks to the supplied code to get it working on my setup.
However I was not able to get the $realname variable out. So how do I
get the real name of the person using a courier-imap server? I keeps
returning =93Array=94.
=20
eltonic40
+37747-511958
Jesus Is Lord
=20
-----Original Message-----
From: imp-bounces@lists.horde.org [mailto:imp-bounces@lists.horde.org]
On Behalf Of Arie Kraak
Sent: Sunday, June 02, 2002 6:38 AM
To: imp@lists.horde.org
Subject: [imp] IMAP Quota Redhat 7.3 extra code
=20
I changed the code a bit,
=20
Here's the result.
=20
=20
// See the 'imp_show_quota' function below for an example.
$conf['hooks']['quota'] =3D 'imp_show_quota';
=20
/* Gets the quota usage for a user. */
/* This requires a modified "quota" command that allows the httpd server
*/
/* account to get quotas for other users... It also requires that your
*/
/* web server and imap server be the same server or at least have shared
*/
/* authentication and file servers (e.g. via NIS/NFS)
*/
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']);
=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" =
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>';
=20
$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);
} else {
$quota_html .=3D '<td align=3D"center" class=3D"header">';
$quota_html .=3D "Quota not available";
}
$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></td></tr></table></td></tr></table>';
return $quota_html;
}
}
=20
Arie Kraak jr.
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002
=20
=20
------=_NextPart_001_0027_01C20C02.805F43B0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DWindows-1252">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 10">
<meta name=3DOriginator content=3D"Microsoft Word 10">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C20C02.7D928F20">
<link rel=3DEdit-Time-Data href=3D"cid:editdata.mso@01C20C02.7D928F20">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:EnvelopeVis/>
<w:Compatibility>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:??=A8=AC?;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:553679495 -2147483648 8 0 66047 0;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:536871559 0 0 0 415 0;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:SimSun;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:SimSun;}
span.EmailStyle17
{mso-style-type:personal-reply;
mso-style-noshow:yes;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:navy;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */=20
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=3Dwhite lang=3DEN-US link=3Dblue vlink=3Dpurple =
style=3D'tab-interval:.5in'>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I did some hacks to the supplied =
code to
get it working on my setup. <span class=3DGramE>However I was not able =
to get the
$<span class=3DSpellE>realname</span> variable out.</span> So how do I =
get the
real name of the person using a courier-<span class=3DSpellE>imap</span> =
server?
I keeps returning =93Array=94.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<p class=3DMsoAutoSig><font size=3D2 color=3Dnavy face=3DVerdana><span
style=3D'font-size:10.0pt;font-family:Verdana;color:navy;mso-no-proof:yes=
'>eltonic40<o:p></o:p></span></font></p>
<p class=3DMsoAutoSig><font size=3D2 color=3Dnavy face=3DVerdana><span
style=3D'font-size:10.0pt;font-family:Verdana;color:navy;mso-no-proof:yes=
'>+37747-511958<o:p></o:p></span></font></p>
<p class=3DMsoAutoSig><font size=3D2 color=3Dnavy face=3DVerdana><span
style=3D'font-size:10.0pt;font-family:Verdana;color:navy;mso-no-proof:yes=
'>Jesus
Is Lord<o:p></o:p></span></font></p>
</div>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> =
imp-bounces@lists.horde.org
[mailto:imp-bounces@lists.horde.org] <b><span =
style=3D'font-weight:bold'>On
Behalf Of </span></b>Arie Kraak<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Sunday, June 02, =
2002 6:38
AM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
imp@lists.horde.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> [imp] IMAP Quota =
Redhat
7.3 extra code</span></font></p>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'><o:p> </o:p></span></font></p>
<div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>I changed the code a =
bit,<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Here's the =
result.<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><img width=3D687 =
height=3D167
id=3D"_x0000_i1025" src=3D"cid:image001.gif@01C20C02.7D928F20" =
align=3Dbaseline
border=3D0><o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>// See the 'imp_show_quota' =
function
below for an example.<br>
$conf['hooks']['quota'] =3D =
'imp_show_quota';<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>/* Gets the quota usage for =
a
user. */<br>
/* This requires a modified "quota" command that allows the =
httpd
server */<br>
/* account to get quotas for other users... It also requires that
your */<br>
/* web server and imap server be the same server or at least have shared =
*/<br>
/* authentication and file servers (e.g. via
NIS/NFS)  =
;
*/<br>
if (!function_exists('imp_show_quota')) {<br>
function imp_show_quota ($imp) {<br>
$imap_admin =3D =
$imp['user'];<br>
$passwd_array =3D
posix_getpwnam($imap_admin);<br>
$homedir =3D =
split("/",
$passwd_array['dir']);<br>
$realname =3D =
split(",",
$passwd_array['gecos']);<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> &nbs=
p;
$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>';<br>
$quota_html .=3D '<td
align=3D"left" class=3D"header">Login: ' . =
$realname[0] .
" (" . $imap_admin . ")" . =
'</td>';<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> &nbs=
p;
$junk =3D exec("sudo /usr/bin/quota -u $imap_admin | grep =
/dev/md1",<br>
&=
nbsp;
$quota_data,$return_code);<br>
if ($return_code =3D=3D 0 =
&&
count($quota_data) =3D=3D 1) {<br>
$splitted =
=3D
split("[[:blank:]]+", trim($quota_data[0]));<br>
$taken =3D
$splitted[1] / 1000 ; $total =3D $splitted[2] / 1000 ;<br>
$percent =
=3D $taken
* 100 / $total ;<br>
if =
($percent >=3D
90) {<br>
&=
nbsp;
$color =3D '#FF0000';<br>
} elseif =
($percent
>=3D 80) {<br>
&=
nbsp;
$color =3D '#FCE30D';<br>
} else =
{<br>
&=
nbsp;
$color =3D '#339933';<br>
}<br>
$quota_html =
.=3D
'<td align=3D"center" class=3D"header">';<br>
$quota_html =
.=3D
sprintf("<font size=3D-2>Quota on /%s: %.1fMB/%.1fMB
(%.1f%%)</font>", $homedir[1], $taken, $total, $percent);<br>
} else {<br>
=
$quota_html
.=3D '<td align=3D"center" =
class=3D"header">';<br>
=
$quota_html
.=3D "Quota not available";<br>
}<br>
$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">';<br>
$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.'">';<br>
$quota_html .=3D
'</div></td></tr></table></td><td
width=3D"30" class=3D"header" =
align=3D"left"><font
size=3D"-3">100%</font></td></tr></tabl=
e></td></tr></table>';<br>
return $quota_html;<br>
}<br>
}<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></fo=
nt></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Arie Kraak =
jr.<o:p></o:p></span></font></p>
</div>
</div>
</div>
</body>
</html>
<BR>
<P><FONT SIZE=3D2>---<BR>
Incoming mail is certified Virus Free.<BR>
Checked by AVG anti-virus system (http://www.grisoft.com).<BR>
Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002<BR>
</FONT> </P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> </FONT> </P><BR>
<P><FONT SIZE=3D2>---<BR>
Outgoing mail is certified Virus Free.<BR>
Checked by AVG anti-virus system (http://www.grisoft.com).<BR>
Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002<BR>
</FONT> </P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> </FONT> </P>
------=_NextPart_001_0027_01C20C02.805F43B0--
---------------------- 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/e5031a74/attachment.gif
---------------------- multipart/related attachment--