<?
#
#
#
$DEBUG=0;
#
#
#
include_once("auth.php");
include("email_functions.php");
include("email_config.php");
include("email_header.php");
$PHP_SELF = 'email_message.php';
if($id && e_connect()):
$header = imap_headerinfo($mbox, $id);
$mail_uniq = md5($header->subject . $header->date);
$date = dateFormat(strtotime($header->date),"datetime");
$subject = $header->subject ? decode_subject($header->subject) : "[".$lang_text["wbm_nosubject"]."]";
?>
<table width="430" class="tblbgcolor" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr><td class="titel-3" background="<?=$strSkinName?>/pics/bg_tbl_header.jpg"><b><? echo $subject; ?></b></td></tr>
<tr>
<td>
<? /* START - HEADERS */ ?>
<table class="tblbgcolor" width="100%" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
<td width="5%"><b><? echo $lang_text["wbm_sender"] ?></b></td>
<td><? echo htmlspecialchars(mimeHeaderDecode($header->fromaddress)); ?> (<a class="data" href="email_adlist.php?editID=new&from_email=<? echo urlencode(htmlspecialchars(mimeHeaderDecode($header->fromaddress))) ?>">» <? echo $lang_text['wbm_ad_adbook'] ?></a>)</td>
</tr><tr>
<td width="5%"><b><? echo $lang_text["wbm_to"] ?></b></td>
<td><? echo htmlspecialchars(mimeHeaderDecode($header->toaddress)); ?></td>
</tr>
<? if(isset($header->ccaddress)): ?>
<tr>
<td width="5%"><b><? echo $lang_text["wbm_cc"] ?></b></td>
<td><? echo htmlspecialchars(mimeHeaderDecode($header->ccaddress)); ?></td>
</tr>
<? endif; ?>
<tr>
<td width="5%"><b><? echo $lang_text["wbm_date"] ?></b></td>
<td><? echo $date; ?></td>
</tr>
</table>
<? /* END - HEADERS */ ?>
<? /* START - MENUE */ ?>
<table width="100%" class="tblbgcolor" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
<td align="center" width="33%"><? echo std_button(ltext("wbm_email_reply"), 'javascript:submitReplyForm()'); ?></td>
<td align="center" width="33%"><? echo std_button(ltext("wbm_email_fwd"), 'javascript:submitForwardForm()'); ?></td>
<td align="center" width="33%"><? echo std_button(ltext("wbm_email_del"), "javascript:deleteOneMessage($id)"); ?></td>
</tr>
<tr>
<td align="center"><? echo std_button(ltext("wbm_email_viewsource"), "javascript:location.href='email_viewsource.php?id=$id'"); ?></td>
<td align="center"><? echo std_button(ltext("wbm_email_download"), "javascript:location.href='email_attach.php?id=$id&part=0&uniq=$mail_uniq&inline=0&filename=email.txt'"); ?></td>
<td align="center"><? echo std_button(ltext("wbm_email_print"), "javascript:self.print()"); ?></td>
</tr>
</table>
<? /* END - MENUE */ ?>
<?
$structure = imap_fetchstructure($mbox, $id);
$structarr = headerArray($structure);
$partscount = sizeof($structure->parts);
$attachNumber=0;
if( ($partscount > 1) || ($structure->type == TYPEMULTIPART && $structarr["parameters"]["boundary"]) )
{
?>
<table class="tblbgcolor" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<?
for($i=1; $i<=$partscount; $i+=2){
?>
<tr>
<?
for($j=$i; $j<=$i+1; $j++){
$ha = headerArray($structure->parts[$j]);
if($ha){
$fn = '';
if($ha["dparameters"]["filename"]){
$fn = $ha["dparameters"]["filename"];
}
if($ha["parameters"]["name"]){
$fn = $ha["parameters"]["name"];
}
if(!$fn){
$fn = $lang_text["wbm_unknown"];
}
$inline = showInLine($ha["type"]) ? 1 : 0;
$attachNumber++;
?>
<td>
<a class="data"<? if($inline): ?> target="_blank"<? endif; ?>
href="email_attach.php?id=<? echo $id; ?>&part=<? echo $j; ?>&uniq=<? echo $mail_uniq; ?>&inline=<? echo $inline; ?>">
<img src="<?=$strSkinName?>/webmail_icons/attach.gif" border="0" align="absmiddle">
<?
echo $fn;
?>
</a> (<? echo sizeFormat($ha['bytes']); ?>)</td>
<?
}
}
?>
</tr>
<?
}
?>
</table>
<?
}
/*
echo "<pre>"; print_r($structure);
$z = imap_fetchbody($mbox, $id, $a);
print_r($z);
if(count($structure->parts)){
foreach($structure->parts as $part){
print_r(headerArray($part));
}
}else{
print_r(headerArray($structure));
}
echo "</pre>";
*/
?>
<table class="tblbgcolor" width="100%" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<?
if( ($partscount > 1) || ($structure->type == TYPEMULTIPART && $structarr["parameters"]["boundary"]) ){
for($i=0; $i<=$partscount; $i++){
$ha = headerArray($structure->parts[$i]);
if($i == 0 || showInLine($ha['type'], false)){
$body = imap_fetchbody($mbox, $id, ($i+1));
show_mail( $body, $ha['type'], $ha['encoding'] );
if($i == 0){
$reply_body = $body;
}
}
}
}else{
$ha = headerArray($structure);
show_mail( $reply_body = imap_fetchbody($mbox, $id, 1), $ha['type'], $ha['encoding'] );
}
?>
</table>
</td></tr></table>
<?
$date = explode(" ", $date);
$time = $date[1];
$date = $date[0];
if($sig_pos = strrpos($reply_body, "-- "))
{
$reply_body = substr($reply_body, 0, $sig_pos-1);
}
/* REPLY-FORM */
$reply_zitat = str_replace("%date%",$date,$lang_text["wbm_rezitat"]);
$reply_zitat = str_replace("%time%",$time,$reply_zitat);
$reply_zitat = $reply_zitat."\n> ".str_replace("\n","\n> ",(htmlspecialchars($reply_body))."\n");
if(trim($header->reply_toaddress))
{
$reply_sender = htmlspecialchars(mimeHeaderDecode($header->reply_toaddress));
}
else
{
$reply_sender = htmlspecialchars(mimeHeaderDecode($header->fromaddress));
}
echo "<form action=\"email_neu.php\" name=replyForm method=post>\n";
echo "<input type=hidden name=copy_mail value=\"".htmlspecialchars($date)."\">\n";
echo "<input type=hidden name=copy_to value=\"$reply_sender\">\n";
echo "<input type=hidden name=copy_subject value=\"Re: ".htmlspecialchars($subject)."\">\n";
echo "<input type=hidden name=copy_body value=\"".htmlspecialchars($reply_zitat)."\">";
echo "</form>\n";
/* FORWARD-FORM */
if(isset($replyTo))
{
$fwd_sender = $replyTo;
}
else
{
$fwd_sender = $sender;
}
$fwd_zitat = str_replace("%date%",$date,$lang_text["wbm_fwdzitat"]);
$fwd_zitat = str_replace("%time%",$time,$fwd_zitat);
$fwd_sender = str_replace("\n","",$fwd_sender);
$fwd_sender = str_replace("\r","",$fwd_sender);
$fwd_sender = str_replace("\0","",$fwd_sender);
$fwd_zitat = str_replace("%sender%",$fwd_sender,$fwd_zitat);
$fwd_zitat = $fwd_zitat."\n> ".str_replace("\n","\n> ",(htmlspecialchars($reply_body))."\n");
echo "<form action=\"email_neu.php\" name=forwardForm method=post>\n";
echo "<input type=hidden name=copy_mail value=\"".htmlspecialchars($date)."\">\n";
echo "<input type=hidden name=copy_subject value=\"Fw: ".htmlspecialchars($subject)."\">\n";
echo "<input name=copy_body type=hidden value=\"".htmlspecialchars($fwd_zitat)."\">";
if ($attachNumber){
echo "<input type=hidden name=forwardid value=\"".htmlspecialchars($id)."\">\n";
}
echo "</form>\n";
imap_close($mbox);
endif;
include("email_footer.php");
?>