/** * Displays attachment information * * Stripped version of formatAttachments() function from functions/mime.php. * @param object $message SquirrelMail message object * @param array $exclude_id message parts that are not attachments. * @param string $mailbox mailbox name * @param integer $id message id * @since 1.5.1 and 1.4.6 * @return string html formated attachment information. */ function pf_show_attachments($message, $exclude_id, $mailbox, $id) { global $where, $what, $startMessage, $color, $passed_ent_id; $att_ar = $message->getAttachments($exclude_id); if (!count($att_ar)) { return ''; } $attachments = ''; $urlMailbox = urlencode($mailbox); foreach ($att_ar as $att) { $ent = $att->entity_id; $header = $att->header; $type0 = strtolower($header->type0); $type1 = strtolower($header->type1); $name = ''; if ($type0 == 'message' && $type1 == 'rfc822') { $rfc822_header = $att->rfc822_header; $filename = $rfc822_header->subject; if (trim($filename) == '') { $filename = 'untitled-[' . $ent . ']'; } $from_o = $rfc822_header->from; if (is_object($from_o)) { $from_name = decodeHeader($from_o->getAddress(true)); } else { $from_name = _("Unknown sender"); } $description = '<tr>' . html_tag('td', _("From:"), 'right') . html_tag('td', $from_name, 'left') . '</tr>'; } else { $filename = $att->getFilename(); if ($header->description) { $description = '<tr>' . html_tag('td', _("Info:"), 'right') . html_tag('td', decodeHeader($header->description), 'left') . '</tr>'; } else { $description = ''; } } $display_filename = $filename; // TODO: maybe make it nicer? $attachments .= '<table cellpadding="0" cellspacing="0" border="1"><tr><th colspan="2">' . decodeHeader($display_filename) . '</th></tr>' . '<tr border="0">' . html_tag('td', _("Size:"), 'right') . html_tag('td', show_readable_size($header->size), 'left') . '</tr><tr>' . html_tag('td', _("Type:"), 'right') . html_tag('td', htmlspecialchars($type0) . '/' . htmlspecialchars($type1), 'left') . '</tr>'; if (!empty($description)) { $attachments .= $description; } $attachments .= "</table>\n"; } return $attachments; }
/** * Displays message header row in messages list * * @param array $aMsg contains all message related parameters * @return void */ function printMessageInfo($aMsg) { // FIX ME, remove these globals as well by adding an array as argument for the user settings // specificly meant for header display global $checkall, $color, $default_use_priority, $message_highlight_list, $index_order, $truncate_sender, $email_address, $show_recipient_instead, $use_icons, $icon_theme; /* icons theming */ $color_string = $color[4]; // initialisation: $mailbox = $aMsg['MAILBOX']; $msg = $aMsg['HEADER']; $t = $aMsg['INDX']; $start_msg = $aMsg['PAGEOFFSET']; $last = $aMsg['LAST']; if (isset($aMsg['SEARCH']) && count($aMsg['SEARCH']) > 1) { $where = $aMsg['SEARCH'][0]; $what = $aMsg['SEARCH'][1]; } else { $where = false; $what = false; } $iIndent = $aMsg['INDENT']; $sSubject = isset($msg['SUBJECT']) && $msg['SUBJECT'] != '' ? $msg['SUBJECT'] : _("(no subject)"); $sFrom = isset($msg['FROM']) ? $msg['FROM'] : _("Unknown sender"); $sTo = isset($msg['TO']) ? $msg['TO'] : _("Unknown recipient"); $sCc = isset($msg['CC']) ? $msg['CC'] : ''; $aFlags = isset($msg['FLAGS']) ? $msg['FLAGS'] : array(); $iPrio = isset($msg['PRIORITY']) ? $msg['PRIORITY'] : 3; $iSize = isset($msg['SIZE']) ? $msg['SIZE'] : 0; $sType0 = isset($msg['TYPE0']) ? $msg['TYPE0'] : 'text'; $sType1 = isset($msg['TYPE1']) ? $msg['TYPE1'] : 'plain'; if (isset($msg['INTERNALDATE'])) { $sDate = getDateString(getTimeStamp(explode(' ', $msg['INTERNALDATE']))); } else { $sDate = isset($msg['DATE']) ? getDateString(getTimeStamp(explode(' ', $msg['DATE']))) : ''; } $iId = isset($msg['UID']) ? $msg['UID'] : false; if (!$iId) { return; } if ($GLOBALS['alt_index_colors']) { if (!($t % 2)) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $urlMailbox = urlencode($mailbox); // FIXME, foldertype should be set in right_main.php // in other words, handle as sent is obsoleted from now. // We replace that by providing an array to aMailbox with the to shown headers // that way we are free to show the user different layouts for different folders $bSentFolder = handleAsSent($mailbox); if (!$bSentFolder && $show_recipient_instead) { // If the From address is the same as $email_address, then handle as Sent $from_array = parseAddress($sFrom, 1); if (!isset($email_address)) { global $datadir, $username; $email_address = getPref($datadir, $username, 'email_address'); } $bHandleAsSent = isset($from_array[0][0]) && $from_array[0][0] == $email_address; } else { $bHandleAsSent = $bSentFolder; } // If this is a Sent message, display To address instead of From if ($bHandleAsSent) { $sFrom = $sTo; } // Passing 1 below results in only 1 address being parsed, thus defeating the following code $sFrom = parseAddress($sFrom); /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $sFrom; $senderName = ''; $senderAddress = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; $senderAddress .= ', '; } $sender_address_part = htmlspecialchars($senderNames_part[0]); $sender_name_part = str_replace(' ', ' ', decodeHeader($senderNames_part[1])); if ($sender_name_part) { $senderName .= $sender_name_part; $senderAddress .= $sender_name_part . ' <' . $sender_address_part . '>'; } else { $senderName .= $sender_address_part; $senderAddress .= $sender_address_part; } } } // If Sent, prefix with To: but only if not Sent folder if ($bHandleAsSent ^ $bSentFolder) { $senderName = _("To") . ': ' . $senderName; $senderAddress = _("To") . ': ' . $senderAddress; } // this is a column property which can apply to multiple columns. Do not use vars for one column // only. instead we should use something like this: // 1ed column $aMailbox['columns']['SUBJECT'] value: aray with properties ... // 2ed column $aMailbox['columns']['FROM'] value: aray with properties ... // NB in case of the sentfolder this could be the TO field // properties array example: // 'truncate' => length (0 is no truncate) // 'prefix => if (x in b then do that ) if ($truncate_sender > 0) { $senderName = truncateWithEntities($senderName, $truncate_sender); } $flag = $flag_end = $bold = $bold_end = $fontstr = $fontstr_end = $italic = $italic_end = ''; $bold = '<b>'; $bold_end = '</b>'; foreach ($aFlags as $sFlag => $value) { switch ($sFlag) { case '\\flagged': if ($value) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } break; case '\\seen': if ($value) { $bold = ''; $bold_end = ''; } break; case '\\deleted': if ($value) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } break; } } if ($bHandleAsSent) { $italic = '<i>'; $italic_end = '</i>'; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } /* * Message highlight code */ $matches = array('TO' => 'sTo', 'CC' => 'sCc', 'FROM' => 'sFrom', 'SUBJECT' => 'sSubject'); if (is_array($message_highlight_list) && count($message_highlight_list)) { $sTo = parseAddress($sTo); $sCc = parseAddress($sCc); foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { $match = array('TO', 'CC'); } else { $match = array($match_type); } foreach ($match as $match_type) { switch ($match_type) { case 'TO': case 'CC': case 'FROM': foreach (${$matches}[$match_type] as $address) { $address[0] = decodeHeader($address[0], true, false); $address[1] = decodeHeader($address[1], true, false); if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 4; } } break; default: $headertest = strtolower(decodeHeader(${$matches}[$match_type], true, false)); if (strstr('^^' . $headertest, $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 3; } break; } } } } } /* end Message highlight code */ if (!isset($hlt_color)) { $hlt_color = $color_string; } $col = 0; $sSubject = str_replace(' ', ' ', decodeHeader($sSubject)); $subject = processSubject($sSubject, $iIndent); echo html_tag('tr', '', '', '', 'valign="top"') . "\n"; if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', addCheckBox("msg[{$t}]", $checkall, $iId), 'center', $hlt_color); break; case 2: /* from */ if ($senderAddress != $senderName) { $senderAddress = strtr($senderAddress, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); $title = ' title="' . str_replace('"', "''", $senderAddress) . '"'; } else { $title = ''; } echo html_tag('td', $italic . $bold . $flag . $fontstr . $senderName . $fontstr_end . $flag_end . $bold_end . $italic_end, 'left', $hlt_color, $title); break; case 3: /* date */ if ($sDate == '') { $sDate = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $sDate . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($iIndent) { $td_str .= str_repeat(" ", $iIndent); } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $iId . '&startMessage=' . $start_msg . $searchstr . '"'; $td_str .= ' ' . concat_hook_function('subject_link', array($start_msg, $searchstr)); if ($subject != $sSubject) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($sSubject, $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ // icon message markers // if ($use_icons && $icon_theme != 'none') { $td_str = "<b><small>"; if (isset($aFlags['\\flagged']) && $aFlags['\\flagged'] == true) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/flagged.png" border="0" height="10" width="10" /> '; } if ($default_use_priority) { if ($iPrio == 1 || $iPrio == 2) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_high.png" border="0" height="10" width="5" /> '; } else { if ($iPrio == 5) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_low.png" border="0" height="10" width="5" /> '; } else { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="5" /> '; } } } if ($sType1 == 'mixed') { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/attach.png" border="0" height="10" width="6" />'; } else { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="6" />'; } $msg_icon = ''; if (!isset($aFlags['\\seen']) || $aFlags['\\seen'] == false) { $msg_alt = '(' . _("New") . ')'; $msg_title = '(' . _("New") . ')'; $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_new'; } else { $msg_alt = '(' . _("Read") . ')'; $msg_title = '(' . _("Read") . ')'; $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_read'; } if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { $msg_icon .= '_deleted'; } if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { $msg_alt = '(' . _("Answered") . ')'; $msg_title = '(' . _("Answered") . ')'; $msg_icon .= '_reply'; } $td_str .= '<img src="' . $msg_icon . '.png" border="0" alt="' . $msg_alt . '" title="' . $msg_title . '" height="12" width="18" />'; $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'right', $hlt_color, 'nowrap'); } else { $stuff = false; $td_str = "<b><small>"; if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { $td_str .= _("A"); $stuff = true; } if ($sType1 == 'mixed') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($iPrio == 1 || $iPrio == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($iPrio == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); } break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($iSize) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } /* html for separationlines between rows */ if ($last) { echo '</tr>' . "\n"; } else { echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . $color[0] . '" height="1"></td></tr>' . "\n"; } }
function formatAttachments($message, $exclude_id, $mailbox, $id) { global $where, $what, $startMessage, $color, $passed_ent_id; static $ShownHTML = 0; $att_ar = $message->getAttachments($exclude_id); if (!count($att_ar)) { return ''; } $attachments = ''; $urlMailbox = urlencode($mailbox); foreach ($att_ar as $att) { $ent = $att->entity_id; $header = $att->header; $type0 = strtolower($header->type0); $type1 = strtolower($header->type1); $name = ''; $links['download link']['text'] = _("Download"); $links['download link']['href'] = SM_PATH . "src/download.php?absolute_dl=true&passed_id={$id}&mailbox={$urlMailbox}&ent_id={$ent}"; $ImageURL = ''; if ($type0 == 'message' && $type1 == 'rfc822') { $default_page = SM_PATH . 'src/read_body.php'; $rfc822_header = $att->rfc822_header; $filename = $rfc822_header->subject; if (trim($filename) == '') { $filename = 'untitled-[' . $ent . ']'; } $from_o = $rfc822_header->from; if (is_object($from_o)) { $from_name = $from_o->getAddress(false); } elseif (is_array($from_o) && count($from_o) && is_object($from_o[0])) { // when a digest message is opened and you return to the digest // now the from object is part of an array. This is a workaround. $from_name = $from_o[0]->getAddress(false); } else { $from_name = _("Unknown sender"); } $from_name = decodeHeader($from_name); $description = $from_name; } else { $default_page = SM_PATH . 'src/download.php'; if (is_object($header->disposition)) { $filename = $header->disposition->getProperty('filename'); if (trim($filename) == '') { $name = decodeHeader($header->disposition->getProperty('name')); if (trim($name) == '') { $name = $header->getParameter('name'); if (trim($name) == '') { if (trim($header->id) == '') { $filename = 'untitled-[' . $ent . ']'; } else { $filename = 'cid: ' . $header->id; } } else { $filename = $name; } } else { $filename = $name; } } } else { $filename = $header->getParameter('name'); if (!trim($filename)) { if (trim($header->id) == '') { $filename = 'untitled-[' . $ent . ']'; } else { $filename = 'cid: ' . $header->id; } } } if ($header->description) { $description = decodeHeader($header->description); } else { $description = ''; } } $display_filename = $filename; if (isset($passed_ent_id)) { $passed_ent_id_link = '&passed_ent_id=' . $passed_ent_id; } else { $passed_ent_id_link = ''; } $defaultlink = $default_page . "?startMessage={$startMessage}" . "&passed_id={$id}&mailbox={$urlMailbox}" . '&ent_id=' . $ent . $passed_ent_id_link; if ($where && $what) { $defaultlink .= '&where=' . urlencode($where) . '&what=' . urlencode($what); } // IE does make use of mime content sniffing. Forcing a download // prohibit execution of XSS inside an application/octet-stream attachment if ($type0 == 'application' && $type1 == 'octet-stream') { $defaultlink .= '&absolute_dl=true'; } /* This executes the attachment hook with a specific MIME-type. * If that doesn't have results, it tries if there's a rule * for a more generic type. Finally, a hook for ALL attachment * types is run as well. */ $hookresults = do_hook("attachment {$type0}/{$type1}", $links, $startMessage, $id, $urlMailbox, $ent, $defaultlink, $display_filename, $where, $what); if (count($hookresults[1]) <= 1) { $hookresults = do_hook("attachment {$type0}/*", $links, $startMessage, $id, $urlMailbox, $ent, $defaultlink, $display_filename, $where, $what); } $hookresults = do_hook("attachment */*", $hookresults[1], $startMessage, $id, $urlMailbox, $ent, $hookresults[6], $display_filename, $where, $what); $links = $hookresults[1]; $defaultlink = $hookresults[6]; $attachments .= '<tr><td>' . '<a href="' . $defaultlink . '">' . decodeHeader($display_filename) . '</a> </td>' . '<td><small><b>' . show_readable_size($header->size) . '</b> </small></td>' . '<td><small>[ ' . htmlspecialchars($type0) . '/' . htmlspecialchars($type1) . ' ] </small></td>' . '<td><small>'; $attachments .= '<b>' . $description . '</b>'; $attachments .= '</small></td><td><small> '; $skipspaces = 1; foreach ($links as $val) { if ($skipspaces) { $skipspaces = 0; } else { $attachments .= ' | '; } $attachments .= '<a href="' . $val['href'] . '">' . $val['text'] . '</a>'; } unset($links); $attachments .= "</td></tr>\n"; } return $attachments; }
function printMessageInfo($imapConnection, $t, $not_last = true, $key, $mailbox, $start_msg, $where, $what) { global $checkall, $preselected, $color, $msgs, $msort, $td_str, $msg, $default_use_priority, $message_highlight_list, $index_order, $indent_array, $pos, $thread_sort_messages, $server_sort_order, $row_count, $allow_server_sort, $truncate_subject, $truncate_sender; $color_string = $color[4]; if ($GLOBALS['alt_index_colors']) { if (!isset($row_count)) { $row_count = 0; } $row_count++; if ($row_count % 2) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $msg = $msgs[$key]; if ($mailbox == 'None') { $boxes = sqimap_mailbox_list($imapConnection); $mailbox = $boxes[0]['unformatted']; unset($boxes); } $urlMailbox = urlencode($mailbox); if (handleAsSent($mailbox)) { $msg['FROM'] = $msg['TO']; } $msg['FROM'] = parseAddress($msg['FROM'], 1); /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $msg['FROM']; $senderName = ''; $senderFrom = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; } if ($senderFrom != '') { $senderFrom .= ', '; } if ($senderNames_part[1]) { $senderName .= decodeHeader($senderNames_part[1]); } else { $senderName .= htmlspecialchars($senderNames_part[0]); } $senderFrom .= htmlspecialchars($senderNames_part[0]); } } $senderName = str_replace(' ', ' ', $senderName); echo html_tag('tr', '', '', '', 'valign="top"') . "\n"; if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } else { $flag = ''; $flag_end = ''; } if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) { $bold = '<b>'; $bold_end = '</b>'; } else { $bold = ''; $bold_end = ''; } if (handleAsSent($mailbox)) { $italic = '<i>'; $italic_end = '</i>'; } else { $italic = ''; $italic_end = ''; } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } else { $fontstr = ''; $fontstr_end = ''; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } if (is_array($message_highlight_list) && count($message_highlight_list)) { $msg['TO'] = parseAddress($msg['TO']); $msg['CC'] = parseAddress($msg['CC']); foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { $match = array('TO', 'CC'); } else { $match = array($match_type); } foreach ($match as $match_type) { switch ($match_type) { case 'TO': case 'CC': case 'FROM': foreach ($msg[$match_type] as $address) { $address[0] = decodeHeader($address[0], true, false); $address[1] = decodeHeader($address[1], true, false); if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 4; } } break; default: $headertest = strtolower(decodeHeader($msg[$match_type], true, false)); if (strstr('^^' . $headertest, $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 3; } break; } } } } } if (!isset($hlt_color)) { $hlt_color = $color_string; } if ($checkall == 1 || in_array($msg['ID'], $preselected)) { $checked = ' checked="checked"'; } else { $checked = ''; } $col = 0; $msg['SUBJECT'] = decodeHeader($msg['SUBJECT']); // $subject = processSubject($msg['SUBJECT'], $indent_array[$msg['ID']]); $subject = truncateWithEntities(str_replace(' ', ' ', $msg['SUBJECT']), $truncate_subject); if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', "<input type=\"checkbox\" name=\"msg[{$t}]\" id=\"msg" . $msg['ID'] . "\" value=\"" . $msg['ID'] . "\"{$checked}>", 'center', $hlt_color); break; case 2: /* from */ $from_xtra = ''; $from_xtra = 'title="' . $senderFrom . '"'; echo html_tag('td', html_tag('label', $italic . $bold . $flag . $fontstr . truncateWithEntities($senderName, $truncate_sender) . $fontstr_end . $flag_end . $bold_end . $italic_end, '', '', 'for="msg' . $msg['ID'] . '"'), 'left', $hlt_color, $from_xtra); break; case 3: /* date */ $date_string = $msg['DATE_STRING'] . ''; if ($date_string == '') { $date_string = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $date_string . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($thread_sort_messages == 1) { if (isset($indent_array[$msg['ID']])) { $td_str .= str_repeat(" ", $indent_array[$msg['ID']]); } } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $msg["ID"] . '&startMessage=' . $start_msg . $searchstr . '"'; $td_str .= ' ' . concat_hook_function('subject_link', array($start_msg, $searchstr)); if ($subject != $msg['SUBJECT']) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($msg['SUBJECT'], $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ $stuff = false; $td_str = "<b><small>"; if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) { $td_str .= _("A"); $stuff = true; } if ($msg['TYPE0'] == 'multipart' && $msg['TYPE1'] == 'mixed') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($msg['PRIORITY'] == 1 || $msg['PRIORITY'] == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($msg['PRIORITY'] == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } do_hook("msg_envelope"); $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($msg['SIZE']) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } if ($not_last) { echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . $color[0] . '" height="1"></td></tr>' . "\n"; } else { echo '</tr>' . "\n"; } }
function showInputForm($session, $values = false) { global $send_to, $send_to_cc, $body, $startMessage, $passed_body, $color, $use_signature, $signature, $prefix_sig, $editor_size, $editor_height, $attachments, $subject, $newmail, $use_javascript_addr_book, $send_to_bcc, $passed_id, $mailbox, $from_htmladdr_search, $location_of_buttons, $attachment_dir, $username, $data_dir, $identity, $idents, $draft_id, $delete_draft, $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win, $saved_draft, $mail_sent, $sig_first, $edit_as_new, $action, $username, $compose_messages, $composesession, $default_charset; $composeMessage = $compose_messages[$session]; if ($values) { $send_to = $values['send_to']; $send_to_cc = $values['send_to_cc']; $send_to_bcc = $values['send_to_bcc']; $subject = $values['subject']; $mailprio = $values['mailprio']; $body = $values['body']; $identity = (int) $values['identity']; } else { $send_to = decodeHeader($send_to, true, false); $send_to_cc = decodeHeader($send_to_cc, true, false); $send_to_bcc = decodeHeader($send_to_bcc, true, false); } if ($use_javascript_addr_book) { echo "\n" . '<script language="JavaScript">' . "\n<!--\n" . 'function open_abook() { ' . "\n" . ' var nwin = window.open("addrbook_popup.php","abookpopup",' . '"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" . ' if((!nwin.opener) && (document.windows != null))' . "\n" . ' nwin.opener = document.windows;' . "\n" . "}\n" . "// -->\n</script>\n\n"; } echo "\n" . '<form name="compose" action="compose.php" method="post" ' . 'enctype="multipart/form-data"'; do_hook('compose_form'); echo ">\n"; echo addHidden('startMessage', $startMessage); if ($action == 'draft') { echo addHidden('delete_draft', $passed_id); } if (isset($delete_draft)) { echo addHidden('delete_draft', $delete_draft); } if (isset($session)) { echo addHidden('session', $session); } if (isset($passed_id)) { echo addHidden('passed_id', $passed_id); } if ($saved_draft == 'yes') { echo '<br /><center><b>' . _("Draft Saved") . '</center></b>'; } if ($mail_sent == 'yes') { echo '<br /><center><b>' . _("Your Message has been sent.") . '</center></b>'; } echo '<table align="center" cellspacing="0" border="0">' . "\n"; if ($compose_new_win == '1') { echo '<table align="center" bgcolor="' . $color[0] . '" width="100%" border="0">' . "\n" . ' <tr><td></td>' . html_tag('td', '', 'right') . '<input type="button" name="Close" onClick="return self.close()" value="' . _("Close") . '" /></td></tr>' . "\n"; } if ($location_of_buttons == 'top') { showComposeButtonRow(); } /* display select list for identities */ if (count($idents) > 1) { $ident_list = array(); foreach ($idents as $id => $data) { $ident_list[$id] = $data['full_name'] . ' <' . $data['email_address'] . '>'; } echo ' <tr>' . "\n" . html_tag('td', '', 'right', $color[4], 'width="10%"') . _("From:") . '</td>' . "\n" . html_tag('td', '', 'left', $color[4], 'width="90%"') . ' ' . addSelect('identity', $ident_list, $identity, TRUE); echo ' </td>' . "\n" . ' </tr>' . "\n"; } echo ' <tr>' . "\n" . html_tag('td', '', 'right', $color[4], 'width="10%"') . _("To") . ':</td>' . "\n" . html_tag('td', '', 'left', $color[4], 'width="90%"') . addInput('send_to', $send_to, 60) . '<br />' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . html_tag('td', '', 'right', $color[4]) . _("Cc") . ':</td>' . "\n" . html_tag('td', '', 'left', $color[4]) . addInput('send_to_cc', $send_to_cc, 60) . '<br />' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . html_tag('td', '', 'right', $color[4]) . _("Bcc") . ':</td>' . "\n" . html_tag('td', '', 'left', $color[4]) . addInput('send_to_bcc', $send_to_bcc, 60) . '<br />' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . html_tag('td', '', 'right', $color[4]) . _("Subject") . ':</td>' . "\n" . html_tag('td', '', 'left', $color[4]) . "\n"; echo ' ' . addInput('subject', $subject, 60) . ' </td>' . "\n" . ' </tr>' . "\n\n"; if ($location_of_buttons == 'between') { showComposeButtonRow(); } /* why this distinction? */ if ($compose_new_win == '1') { echo ' <tr>' . "\n" . ' <td bgcolor="' . $color[0] . '" colspan="2" align="center">' . "\n" . ' <textarea name="body" id="body" rows="' . (int) $editor_height . '" cols="' . (int) $editor_size . '" wrap="virtual">'; } else { echo ' <tr>' . "\n" . ' <td bgcolor="' . $color[4] . '" colspan="2">' . "\n" . ' <textarea name="body" id="body" rows="' . (int) $editor_height . '" cols="' . (int) $editor_size . '" wrap="virtual">'; } if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) { $signature = $idents[$identity]['signature']; if ($sig_first == '1') { if ($default_charset == 'iso-2022-jp') { echo "\n\n" . ($prefix_sig == true ? "-- \n" : '') . mb_convert_encoding($signature, 'EUC-JP'); } else { echo "\n\n" . ($prefix_sig == true ? "-- \n" : '') . decodeHeader($signature, false, false); } echo "\n\n" . htmlspecialchars(decodeHeader($body, false, false)); } else { echo "\n\n" . htmlspecialchars(decodeHeader($body, false, false)); if ($default_charset == 'iso-2022-jp') { echo "\n\n" . ($prefix_sig == true ? "-- \n" : '') . mb_convert_encoding($signature, 'EUC-JP'); } else { echo "\n\n" . ($prefix_sig == true ? "-- \n" : '') . decodeHeader($signature, false, false); } } } else { echo htmlspecialchars(decodeHeader($body, false, false)); } echo '</textarea><br />' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n"; if ($location_of_buttons == 'bottom') { showComposeButtonRow(); } else { echo ' <tr>' . "\n" . html_tag('td', '', 'right', '', 'colspan="2"') . "\n" . ' ' . addSubmit(_("Send"), 'send') . ' <br /><br />' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n"; } /* This code is for attachments */ if ((bool) ini_get('file_uploads')) { /* Calculate the max size for an uploaded file. * This is advisory for the user because we can't actually prevent * people to upload too large files. */ $sizes = array(); /* php.ini vars which influence the max for uploads */ $configvars = array('post_max_size', 'memory_limit', 'upload_max_filesize'); foreach ($configvars as $var) { /* skip 0 or empty values */ if ($size = getByteSize(ini_get($var))) { $sizes[] = $size; } } if (count($sizes) > 0) { $maxsize = '(max. ' . show_readable_size(min($sizes)) . ')'; } else { $maxsize = ''; } echo addHidden('MAX_FILE_SIZE', min($sizes)) . ' <tr>' . "\n" . ' <td colspan="2">' . "\n" . ' <table width="100%" cellpadding="1" cellspacing="0" align="center"' . ' border="0" bgcolor="' . $color[9] . '">' . "\n" . ' <tr>' . "\n" . ' <td>' . "\n" . ' <table width="100%" cellpadding="3" cellspacing="0" align="center"' . ' border="0">' . "\n" . ' <tr>' . "\n" . html_tag('td', '', 'right', '', 'valign="middle"') . _("Attach:") . '</td>' . "\n" . html_tag('td', '', 'left', '', 'valign="middle"') . ' <input name="attachfile" size="48" type="file" />' . "\n" . ' <input type="submit" name="attach"' . ' value="' . _("Add") . '" />' . "\n" . $maxsize . ' </td>' . "\n" . ' </tr>' . "\n"; $s_a = array(); if ($composeMessage->entities) { foreach ($composeMessage->entities as $key => $attachment) { $attached_file = $attachment->att_local_name; if ($attachment->att_local_name || $attachment->body_part) { $attached_filename = decodeHeader($attachment->mime_header->getParameter('name')); $type = $attachment->mime_header->type0 . '/' . $attachment->mime_header->type1; $s_a[] = '<table bgcolor="' . $color[0] . '" border="0"><tr><td>' . addCheckBox('delete[]', FALSE, $key) . "</td><td>\n" . $attached_filename . '</td><td>-</td><td> ' . $type . '</td><td>(' . show_readable_size(filesize($attached_file)) . ')</td></tr></table>' . "\n"; } } } if (count($s_a)) { foreach ($s_a as $s) { echo '<tr>' . html_tag('td', '', 'left', $color[0], 'colspan="2"') . $s . '</td></tr>'; } echo '<tr><td colspan="2"><input type="submit" name="do_delete" value="' . _("Delete selected attachments") . "\" />\n" . '</td></tr>'; } echo ' </table>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' </table>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n"; } // End of file_uploads if-block /* End of attachment code */ if ($compose_new_win == '1') { echo '</table>' . "\n"; } echo '</table>' . "\n" . addHidden('username', $username) . addHidden('smaction', $action) . addHidden('mailbox', $mailbox); /* store the complete ComposeMessages array in a hidden input value so we can restore them in case of a session timeout. */ sqgetGlobalVar('QUERY_STRING', $queryString, SQ_SERVER); echo addHidden('restoremessages', serialize($compose_messages)) . addHidden('composesession', $composesession) . addHidden('querystring', $queryString) . "</form>\n"; if (!(bool) ini_get('file_uploads')) { /* File uploads are off, so we didn't show that part of the form. To avoid bogus bug reports, tell the user why. */ echo 'Because PHP file uploads are turned off, you can not attach files '; echo "to this message. Please see your system administrator for details.\r\n"; } do_hook('compose_bottom'); echo '</body></html>' . "\n"; }
/** * Prepares the message headers for display inside a template. The links are calculated, * color for row highlighting is calculated and optionally the strings are truncated. * * @param array $aMailbox (reference) mailbox retrieved from sqm_api_mailbox_select * @param array $aProps properties * @return array $aFormattedMessages array with message headers and format info * @since 1.5.1 * @author Marc Groot Koerkamp */ function prepareMessageList(&$aMailbox, $aProps) { /* Globalize link attributes so plugins can share in modifying them */ global $link, $title, $target, $onclick, $link_extra, $preselected; /* retrieve the properties */ $my_email_address = isset($aProps['email']) ? $aProps['email'] : false; $highlight_list = isset($aProps['config']['highlight_list']) ? $aProps['config']['highlight_list'] : false; $aColumnDesc = isset($aProps['columns']) ? $aProps['columns'] : false; $aExtraColumns = isset($aProps['extra_columns']) ? $aProps['extra_columns'] : array(); $iAccount = isset($aProps['account']) ? (int) $aProps['account'] : 0; $sMailbox = isset($aProps['mailbox']) ? $aProps['mailbox'] : false; $sTargetModule = isset($aProps['module']) ? $aProps['module'] : 'read_body'; /* * TODO 1, retrieve array with identity email addresses in order to match against to,cc and set a flag * $aFormattedMessages[$iUid]['match_identity'] = true * The template can show some image if there is a match. * TODO 2, makes sure the matching is done fast by doing a strpos call on the returned $value */ /** * Only retrieve values for displayable columns */ foreach ($aColumnDesc as $k => $v) { switch ($k) { case SQM_COL_FROM: $aCol[SQM_COL_FROM] = 'from'; break; case SQM_COL_DATE: $aCol[SQM_COL_DATE] = 'date'; break; case SQM_COL_SUBJ: $aCol[SQM_COL_SUBJ] = 'subject'; break; case SQM_COL_FLAGS: $aCol[SQM_COL_FLAGS] = 'FLAGS'; break; case SQM_COL_SIZE: $aCol[SQM_COL_SIZE] = 'SIZE'; break; case SQM_COL_PRIO: $aCol[SQM_COL_PRIO] = 'x-priority'; break; case SQM_COL_ATTACHMENT: $aCol[SQM_COL_ATTACHMENT] = 'content-type'; break; case SQM_COL_INT_DATE: $aCol[SQM_COL_INT_DATE] = 'INTERNALDATE'; break; case SQM_COL_TO: $aCol[SQM_COL_TO] = 'to'; break; case SQM_COL_CC: $aCol[SQM_COL_CC] = 'cc'; break; case SQM_COL_BCC: $aCol[SQM_COL_BCC] = 'bcc'; break; default: break; } } $aExtraHighLightColumns = array(); foreach ($aExtraColumns as $v) { switch ($v) { case SQM_COL_FROM: $aExtraHighLightColumns[] = 'from'; break; case SQM_COL_SUBJ: $aExtraHighLightColumns[] = 'subject'; break; case SQM_COL_TO: $aExtraHighLightColumns[] = 'to'; break; case SQM_COL_CC: $aExtraHighLightColumns[] = 'cc'; break; case SQM_COL_BCC: $aExtraHighLightColumns[] = 'bcc'; break; default: break; } } $aFormattedMessages = array(); $iSetIndx = $aMailbox['SETINDEX']; $aId = $aMailbox['UIDSET'][$iSetIndx]; $aHeaders =& $aMailbox['MSG_HEADERS']; /* use a reference to avoid a copy. MSG_HEADERS can contain large amounts of data */ $iOffset = $aMailbox['OFFSET']; $sort = $aMailbox['SORT']; $iPageOffset = $aMailbox['PAGEOFFSET']; $sMailbox = $aMailbox['NAME']; $sSearch = isset($aMailbox['SEARCH'][$aMailbox['SETINDEX']]) && $aMailbox['SEARCH'][$aMailbox['SETINDEX']] != 'ALL' ? $aMailbox['SEARCH'][$aMailbox['SETINDEX']] : false; $aSearch = $sSearch ? array('search.php', $aMailbox['SETINDEX']) : null; /* avoid improper usage */ if ($sMailbox && isset($iAccount) && $sTargetModule) { $aInitQuery = array("account={$iAccount}", 'mailbox=' . urlencode($sMailbox)); } else { $aInitQuery = false; } if ($aMailbox['SORT'] & SQSORT_THREAD) { $aIndentArray =& $aMailbox['THREAD_INDENT'][$aMailbox['SETINDEX']]; $bThread = true; } else { $bThread = false; } /* * Retrieve value for checkbox column */ if (!sqgetGlobalVar('checkall', $checkall, SQ_GET)) { $checkall = false; } /* * Loop through and display the info for each message. */ $iEnd = $aMailbox['SHOWALL'][$iSetIndx] ? $aMailbox['EXISTS'] : $iOffset + $aMailbox['LIMIT']; for ($i = $iOffset, $t = 0; $i < $iEnd; ++$i) { if (isset($aId[$i])) { $bHighLight = false; $value = $title = $link = $target = $onclick = $link_extra = ''; $aQuery = $aInitQuery !== false ? $aInitQuery : false; $aMsg = $aHeaders[$aId[$i]]; if (isset($aSearch) && count($aSearch) > 1 && $aQuery) { $aQuery[] = "where=" . $aSearch[0]; $aQuery[] = "what=" . $aSearch[1]; } $iUid = isset($aMsg['UID']) ? $aMsg['UID'] : $aId[$i]; if ($aQuery) { $aQuery[] = "passed_id={$aId[$i]}"; $aQuery[] = "startMessage={$iPageOffset}"; } foreach ($aCol as $k => $v) { $title = $link = $target = $onclick = $link_extra = ''; $aColumns[$k] = array(); $value = isset($aMsg[$v]) ? $aMsg[$v] : ''; $sUnknown = _("Unknown recipient"); switch ($k) { case SQM_COL_FROM: $sUnknown = _("Unknown sender"); case SQM_COL_TO: case SQM_COL_CC: case SQM_COL_BCC: $sTmp = false; if ($value) { if ($highlight_list && !$bHighLight) { $bHighLight = highlightMessage($aCol[$k], $value, $highlight_list, $aFormattedMessages[$iUid]); } $aAddressList = parseRFC822Address($value); $sTmp = getAddressString($aAddressList, array('best' => true)); $title = $title_maybe = ''; foreach ($aAddressList as $aAddr) { $sPersonal = isset($aAddr[SQM_ADDR_PERSONAL]) ? $aAddr[SQM_ADDR_PERSONAL] : ''; $sMailbox = isset($aAddr[SQM_ADDR_MAILBOX]) ? $aAddr[SQM_ADDR_MAILBOX] : ''; $sHost = isset($aAddr[SQM_ADDR_HOST]) ? $aAddr[SQM_ADDR_HOST] : ''; if ($sPersonal) { $title .= sm_encode_html_special_chars($sMailbox . '@' . $sHost) . ', '; } else { // if $value gets truncated we need to add the addresses with no // personal name as well $title_maybe .= sm_encode_html_special_chars($sMailbox . '@' . $sHost) . ', '; } } if ($title) { $title = substr($title, 0, -2); // strip ', '; } $sTmp = decodeHeader($sTmp); if (isset($aColumnDesc[$k]['truncate']) && $aColumnDesc[$k]['truncate']) { $sTrunc = sm_truncate_string($sTmp, $aColumnDesc[$k]['truncate'], '...', TRUE); if ($sTrunc != $sTmp) { if (!$title) { $title = $sTmp; } else { if ($title_maybe) { $title = $title . ', ' . $title_maybe; $title = substr($title, 0, -2); // strip ', '; } } } $sTmp = $sTrunc; } } $value = $sTmp ? substr($sTmp, 0, 6) == '"' && substr($sTmp, -6) == '"' ? substr(substr($sTmp, 0, -6), 6) : $sTmp : $sUnknown; break; case SQM_COL_SUBJ: // subject is mime encoded, decode it. // value is sanitized in decoding function. // TODO, verify if it should be done before or after the highlighting $value = decodeHeader($value); if ($highlight_list && !$bHighLight) { $bHighLight = highlightMessage('SUBJECT', $value, $highlight_list, $aFormattedMessages[$iUid]); } $iIndent = isset($aIndentArray[$aId[$i]]) ? $aIndentArray[$aId[$i]] : 0; // FIXME: don't break 8bit symbols and html entities during truncation if (isset($aColumnDesc[$k]['truncate']) && $aColumnDesc[$k]['truncate']) { $sTmp = sm_truncate_string($value, $aColumnDesc[$k]['truncate'] - $iIndent, '...', TRUE); // drop any double spaces since these will be displayed in the title // Nah, it's nice to always have a roll-over //$title = ($sTmp != $value) ? preg_replace('/\s{2,}/', ' ', $value) : ''; $title = preg_replace('/\\s{2,}/', ' ', $value); $value = $sTmp; } /* generate the link to the message */ if ($aQuery) { // TODO, $sTargetModule should be a query parameter so that we can use a single entrypoint $link = $sTargetModule . '.php?' . implode('&', $aQuery); // see top of this function for which attributes are available // in the global scope for plugin use (like $link, $target, // $onclick, $link_extra, $title, and so forth) // plugins are responsible for sharing nicely (such as for // setting the target, etc) $temp = array(&$iPageOffset, &$sSearch, &$aSearch, $aMsg); do_hook('subject_link', $temp); } $value = trim($value) ? $value : _("(no subject)"); /* add thread indentation */ $aColumns[$k]['indent'] = $iIndent; break; case SQM_COL_SIZE: $value = show_readable_size($value); break; case SQM_COL_DATE: case SQM_COL_INT_DATE: $value = getTimeStamp(explode(' ', trim($value))); $title = getDateString($value, TRUE); $value = getDateString($value); break; case SQM_COL_FLAGS: $aFlagColumn = array('seen' => false, 'deleted' => false, 'answered' => false, 'forwarded' => false, 'flagged' => false, 'draft' => false); if (!is_array($value)) { $value = array(); } foreach ($value as $sFlag => $v) { switch ($sFlag) { case '\\seen': $aFlagColumn['seen'] = true; break; case '\\deleted': $aFlagColumn['deleted'] = true; break; case '\\answered': $aFlagColumn['answered'] = true; break; case '$forwarded': $aFlagColumn['forwarded'] = true; break; case '\\flagged': $aFlagColumn['flagged'] = true; break; case '\\draft': $aFlagColumn['draft'] = true; break; default: break; } } $value = $aFlagColumn; break; case SQM_COL_PRIO: $value = $value ? (int) $value : 3; break; case SQM_COL_ATTACHMENT: $value = is_array($value) && $value[0] == 'multipart' && $value[1] == 'mixed' ? true : false; break; case SQM_COL_CHECK: $value = $checkall || in_array($iUid, $preselected); break; default: break; } if ($title) { $aColumns[$k]['title'] = $title; } if ($link) { $aColumns[$k]['link'] = $link; } if ($link_extra) { $aColumns[$k]['link_extra'] = $link_extra; } if ($onclick) { $aColumns[$k]['onclick'] = $onclick; } if ($target) { $aColumns[$k]['target'] = $target; } $aColumns[$k]['value'] = $value; } /* columns which will not be displayed but should be inspected because the highlight list contains rules with those columns */ foreach ($aExtraHighLightColumns as $v) { if ($highlight_list && !$bHighLight && isset($aMsg[$v])) { $bHighLight = highlightMessage($v, $aMsg[$v], $highlight_list, $aFormattedMessages[$iUid]); } } $aFormattedMessages[$iUid]['columns'] = $aColumns; } else { break; } } return $aFormattedMessages; }
/** * Make the internal show_readable_size() function available to templates. //FIXME: I think this is needless since there is no reason templates cannot just call directly to show_readable_size * * @param int size to be converted to human-readable * @return string human-readable form * @since 1.5.2 **/ function humanReadableSize($size) { return show_readable_size($size); }
function formatAttachments($message, $exclude_id, $mailbox, $id) { global $where, $what, $startMessage, $color; static $ShownHTML = 0; $att_ar = $message->getAttachments($exclude_id); if (!count($att_ar)) { return ''; } $attachments = ''; $urlMailbox = urlencode($mailbox); foreach ($att_ar as $att) { $ent = $att->entity_id; $header = $att->header; $type0 = strtolower($header->type0); $type1 = strtolower($header->type1); $name = ''; $links['download link']['text'] = _("Download"); $links['download link']['href'] = SM_PATH . "src/download.php?absolute_dl=true&passed_id={$id}&mailbox={$urlMailbox}&ent_id={$ent}"; $ImageURL = ''; if ($type0 == 'message' && $type1 == 'rfc822') { $default_page = SM_PATH . 'src/read_body.php'; $rfc822_header = $att->rfc822_header; $filename = $rfc822_header->subject; if (trim($filename) == '') { $filename = 'untitled-[' . $ent . ']'; } $from_o = $rfc822_header->from; if (is_object($from_o)) { $from_name = decodeHeader($from_o->getAddress(false)); } else { $from_name = _("Unknown sender"); } $description = $from_name; } else { $default_page = SM_PATH . 'src/download.php'; if (is_object($header->disposition)) { $filename = $header->disposition->getProperty('filename'); if (trim($filename) == '') { $name = decodeHeader($header->disposition->getProperty('name')); if (trim($name) == '') { $name = $header->getParameter('name'); if (trim($name) == '') { if (trim($header->id) == '') { $filename = 'untitled-[' . $ent . ']'; } else { $filename = 'cid: ' . $header->id; } } else { $filename = $name; } } else { $filename = $name; } } } else { $filename = $header->getParameter('name'); if (!trim($filename)) { if (trim($header->id) == '') { $filename = 'untitled-[' . $ent . ']'; } else { $filename = 'cid: ' . $header->id; } } } if ($header->description) { $description = decodeHeader($header->description); } else { $description = ''; } } $display_filename = $filename; if (isset($passed_ent_id)) { $passed_ent_id_link = '&passed_ent_id=' . $passed_ent_id; } else { $passed_ent_id_link = ''; } $defaultlink = $default_page . "?startMessage={$startMessage}" . "&passed_id={$id}&mailbox={$urlMailbox}" . '&ent_id=' . $ent . $passed_ent_id_link; if ($where && $what) { $defaultlink .= '&where=' . urlencode($where) . '&what=' . urlencode($what); } /* This executes the attachment hook with a specific MIME-type. * If that doesn't have results, it tries if there's a rule * for a more generic type. */ $hookresults = do_hook("attachment {$type0}/{$type1}", $links, $startMessage, $id, $urlMailbox, $ent, $defaultlink, $display_filename, $where, $what); if (count($hookresults[1]) <= 1) { $hookresults = do_hook("attachment {$type0}/*", $links, $startMessage, $id, $urlMailbox, $ent, $defaultlink, $display_filename, $where, $what); } $links = $hookresults[1]; $defaultlink = $hookresults[6]; $attachments .= '<tr><td>' . '<a href="' . $defaultlink . '">' . decodeHeader($display_filename) . '</a> </td>' . '<td><small><b>' . show_readable_size($header->size) . '</b> </small></td>' . '<td><small>[ ' . htmlspecialchars($type0) . '/' . htmlspecialchars($type1) . ' ] </small></td>' . '<td><small>'; $attachments .= '<b>' . $description . '</b>'; $attachments .= '</small></td><td><small> '; $skipspaces = 1; foreach ($links as $val) { if ($skipspaces) { $skipspaces = 0; } else { $attachments .= ' | '; } $attachments .= '<a href="' . $val['href'] . '">' . $val['text'] . '</a>'; } unset($links); $attachments .= "</td></tr>\n"; } $attachmentadd = do_hook_function('attachments_bottom', $attachments); if ($attachmentadd != '') { $attachments = $attachmentadd; } return $attachments; }