- $msg = sqimap_get_message($imapConnection, $id, $mailbox);
- $msg = getEntity($msg, $ent_id);
-
- $header = sqimap_get_ent_header($imapConnection,$id,$mailbox,$ent_id);
- $header->id = $id;
- $msg->header = $header;
- $body = formatBody($imapConnection, $msg, $color, $wrap_at);
- $bodyheader = viewHeader($header, $color);
- displayPageHeader($color, 'None');
-
- echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>";
- if ($extracted) {
- echo '<TR><TD width="100%"><center><h1>Message succesfully extracted</h1></center></TD></TR>';
- }
- echo "<TR><TD BGCOLOR=\"$color[0]\">".
- "<B><CENTER>". _("Viewing a message attachment") . " - ";
-
- echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$id&startMessage=$startMessage&show_more=0\">". _("View message") . "</a>";
-
- $urlmailbox = urlencode($mailbox);
-
- echo "</b></td><tr><tr><td><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_id&mailbox=$urlmailbox\">".
- _("Download this as a file").
- "</A></CENTER><BR>".
- "</CENTER></B>".
- "</TD></TR></TABLE>";
- echo "<TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
- "<TR><TD BGCOLOR=\"$color[4]\">";
- echo "$bodyheader </TD></TR></TABLE>";
-
- echo "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
- "<TR><TD BGCOLOR=\"$color[4]\"><TT><BR>";
- echo "$body </TT></TD></TR><table><br>";
- echo '<table width="100%"><tr>'.
- "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\">".
- '<form action="download.php" method="post"><small>'.
- "<input type=\"hidden\" name=\"passed_id\" value=\"$id\">".
- "<input type=\"hidden\" name=\"mailbox\" value=\"".$mailbox."\">".
- "<input type=\"hidden\" name=\"startMessage\" value=\"$startMessage\">".
- "<input type=\"hidden\" name=\"passed_ent_id\" value=\"$ent_id\">".
- "<input type=\"hidden\" name=\"extract_message\" value=\"1\">".
- _("Save to:") .
- ' <select name="targetMailbox">';
- get_extract_to_target_list($imapConnection);
- echo '</select> '.' '.
- '<input type="submit" value="' . _("Extract") . '">'.
- '</small>'.
- '</form>'.
- '</td></table>';
-
-}
-
-function get_extract_to_target_list($imapConnection) {
-
- $boxes = sqimap_mailbox_list($imapConnection);
- for ($i = 0; $i < count($boxes); $i++) {
- if (!in_array('noselect', $boxes[$i]['flags'])) {
- $box = $boxes[$i]['unformatted'];
- $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
- if ( $box2 == 'INBOX' ) {
- $box2 = _("INBOX");
- }
- echo "<option value=\"$box\">$box2</option>\n";
- }
- }
-}
-
-
-function viewHeader($header,$color) {
-
- $bodyheader = '';
-
- /** FORMAT THE FROM STRING **/
- $from_name = decodeHeader(htmlspecialchars($header->from));
- if(isset($from_name) && $from_name !='') {
- $bodyheader .= makeTableEntry($from_name,_("From"), $color);
- }
-
- $subject_string = decodeHeader(htmlspecialchars($header->subject));
- if(isset($subject_string) && $subject_string !='') {
- $bodyheader .= makeTableEntry($subject_string,_("Subject:"), $color);
- }
- /** FORMAT THE TO STRING **/
- $to = formatRecipientString($header->to, "to");
- $to_string = $to['str'];
- $url_to_string = $to['url_str'];
- if(isset($to_string) && $to_string !='') {
- $bodyheader .= makeTableEntry($to_string,_("To:"), $color);
- }
-
- /** FORMAT THE DATE STRING **/
- $dateString = getLongDateString($header->date);
- if(isset($dateString) && $dateString !='') {
- $bodyheader .= makeTableEntry($dateString,_("Date:"), $color);
- }
-
- /** FORMAT THE CC STRING **/
- $cc = formatRecipientString($header->cc, "cc");
- $cc_string = $cc['str'];
- $url_cc_string = $cc['url_str'];
- if(isset($cc_string) && $cc_string !='') {
- $bodyheader .= makeTableEntry($cc_string,_("Cc:"), $color);
- }
-
- /** FORMAT THE BCC STRING **/
- $bcc = formatRecipientString($header->bcc, "bcc");
- $bcc_string = $bcc['str'];
- $url_bcc_string = $bcc['url_str'];
- if(isset($bcc_string) && $bcc_string !='') {
- $bodyheader .= makeTableEntry($bcc_string,_("Bcc:"), $color);
- }
-
- return $bodyheader;
-}