File size: 4.86Kb
<?
#####################################################################
# Copyright (c) 2002 Pau Oliva Fora <[email protected]> #
# Licensed under the GNU GPL. For full terms see the file COPYING. #
#####################################################################
require("config.php");
wmlheader();
$mbox = imap_open ("\{$IMAPSERVER:143}$F", "$U", "$P") or die ("can't connect: " . imap_last_error());
print "<card id=\"mailbody\">\n";
$header = imap_header ($mbox, $msgid, 50, 50, 50);
#$msgfrom = trim(htmlspecialchars(decode($header->fetchfrom)));
#$msgfrom = trim(htmlspecialchars($header->fromaddress));
$from = $header->from;
$msgfrom = sprintf("%s@%s", $from[0]->mailbox,$from[0]->host);
$msgsubject = trim(htmlspecialchars(decode($header->fetchsubject)));
$msgdate = date("d/m/y H:i:s", $header->udate);
#$msgbody = rtrim( (htmlspecialchars( imap_body ($mbox, $msgid) ));
$msgbody = trim( nl2br(htmlspecialchars( imap_body ($mbox, $msgid) )));
$bodysize = strlen($msgbody);
$parts = ceil($bodysize / $MESSAGESIZE);
if ( !isset($part) or $part == 1 ){
//print from and link to reply
echo "<p mode=\"nowrap\">\n";
echo "<small>$S_FROM<anchor title=\"$S_REPLY\">$msgfrom
<go href=\"compose.php?msgto=$msgfrom\" method=\"post\">
<postfield name=\"subject\" value=\"RE:$msgsubject\"/>
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor></small>";
echo "</p>\n";
// print subject
echo "<p mode=\"nowrap\">\n";
echo "<small>$S_SUBJECT $msgsubject</small>";
echo "</p>\n";
// print date
echo "<p mode=\"nowrap\">\n";
echo "<small>$S_DATE $msgdate</small>";
echo "<br/></p>\n";
}
if ( $parts == 1 ) {
// print body
echo "<p mode=\"wrap\">\n";
#for ($i = 0; $i < $MESSAGESIZE; $i++) print("$msgbody[$i]");
echo $msgbody;
echo "\n</p>\n";
} else {
// message is longer than MESSAGESIZE
if ( isset($part) and $part == $parts ) {
// last case
// print body from where we stopped
$position = ($MESSAGESIZE * ($parts - 1));
echo "<p mode=\"wrap\">\n";
echo "<small><b>Part:</b> $part/". $parts ."- <b>Size:</b> $bodysize</small><br/>";
#echo "<br/>POSITION: $position - PART: $part - PARTS: $parts - MESSAGESIZE: $MESSAGESIZE - BODYSIZE: $bodysize<br/>";
for ($i = $position; $i < $bodysize; $i++) print("$msgbody[$i]");
echo "\n</p>\n";
// print from and link to reply
echo "<p><anchor title=\"$S_REPLY\">$S_REPLY
<go href=\"compose.php?msgto=$msgfrom\" method=\"post\">
<postfield name=\"subject\" value=\"RE:$msgsubject\"/>
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor></p>\n";
} else {
// print this part
if (!isset($part) or $part == 1) {
// we are on the 1st part, we have to set part here and link to part 2
echo "<p mode=\"wrap\">\n";
echo "<small><b>Part:</b> 1/". $parts ."- <b>Size:</b> $bodysize</small><br/>";
for ($i = 0; $i < $MESSAGESIZE; $i++) print("$msgbody[$i]");
echo "\n</p>\n";
// print next
echo "<p><anchor title=\"$S_SUBMIT\">$S_NEXT
<go href=\"mailview.php?msgid=$msgid\" method=\"post\">
<postfield name=\"part\" value=\"2\"/>
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor><br/></p>\n";
} else {
// we are on a part that is not 1st, we have to link to next and previous part
// print previous
echo "<p><anchor title=\"$S_SUBMIT\">$S_PREVIOUS
<go href=\"mailview.php?msgid=$msgid\" method=\"post\">
<postfield name=\"part\" value=\"";
echo $part - 1;
echo "\"/>
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor><br/></p>\n";
$position = ($MESSAGESIZE * ($part - 1));
echo "<p mode=\"wrap\">\n";
echo "<small><b>Part:</b> $part/". $parts ."- <b>Size:</b> $bodysize</small><br/>";
for ($i = $position; $i < $position + $MESSAGESIZE; $i++) print("$msgbody[$i]");
echo "\n</p>\n";
// print next
echo "<p><anchor title=\"$S_SUBMIT\">$S_NEXT
<go href=\"mailview.php?msgid=$msgid\" method=\"post\">
<postfield name=\"part\" value=\"";
echo $part + 1;
echo "\"/>
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor><br/></p>\n";
}
}
}
// always print delete and return
echo "<p><anchor title=\"$S_SUBMIT\">$S_DELETE
<go href=\"maildel.php?msgid=$msgid\" method=\"post\">
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor></p>\n";
echo "<p><anchor title=\"$S_SUBMIT\">$S_RETURN
<go href=\"index.php\" method=\"post\">
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor>\n";
echo "</p>\n";
imap_close($mbox);
wmlfooter();
?>