コード例 #1
0
/**
 * 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 = '&amp;where=' . $where . '&amp;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('&nbsp;', ' ', 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("&nbsp;&nbsp;&nbsp;&nbsp;", $iIndent);
                    }
                    $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&amp;passed_id=' . $iId . '&amp;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 .= '&nbsp;';
                        }
                        $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";
    }
}
コード例 #2
0
ファイル: decodeheader.php プロジェクト: jprice/EHCP
echo "011\n";
foreach ($header as $test) {
    echo htmlentities(decodeHeader($test, false, true, true));
    echo "\n";
}
echo "--------\n";
echo "(download) 100\n";
foreach ($header as $test) {
    echo htmlentities(decodeHeader($test, true, false, false));
    echo "\n";
}
echo "--------\n";
echo "101\n";
foreach ($header as $test) {
    echo htmlentities(decodeHeader($test, true, false, true));
    echo "\n";
}
echo "--------\n";
echo "(default) 110\n";
foreach ($header as $test) {
    echo htmlentities(decodeHeader($test, true, true, false));
    echo "\n";
}
echo "--------\n";
echo "111\n";
foreach ($header as $test) {
    echo htmlentities(decodeHeader($test, true, true, true));
    echo "\n";
}
echo "--------\n";
echo '</pre></body></html>';
コード例 #3
0
ファイル: mailbox_display.php プロジェクト: jprice/EHCP
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('&nbsp;', ' ', $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 = '&amp;where=' . $where . '&amp;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('&nbsp;', ' ', $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("&nbsp;&nbsp;&nbsp;&nbsp;", $indent_array[$msg['ID']]);
                        }
                    }
                    $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&amp;passed_id=' . $msg["ID"] . '&amp;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 .= '&nbsp;';
                    }
                    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";
    }
}
コード例 #4
0
    // sometimes I see ',,' instead of ',' seperating addresses *shrug*
    $cc = pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces);
    $to = pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces);
    // the body should have no leading zeros
    // disabled because it destroys html mail
    //    $body = pf_clean_string($body, 0);
    // clean up everything else...
    $subject = pf_clean_string($subject, $num_leading_spaces);
    $from = pf_clean_string($from, $num_leading_spaces);
    $date = pf_clean_string($date, $num_leading_spaces);
}
// end cleanup
$to = decodeHeader($to);
$cc = decodeHeader($cc);
$from = decodeHeader($from);
$subject = decodeHeader($subject);
// --end display setup--
/* --start browser output-- */
displayHtmlHeader($subject, '', FALSE);
echo '<body text="#000000" bgcolor="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">' . "\n" . html_tag('table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"') . html_tag('tr', html_tag('td', _("From") . '&nbsp;', 'left', '', 'valign="top"') . html_tag('td', $from, 'left')) . "\n" . html_tag('tr', html_tag('td', _("Subject") . '&nbsp;', 'left', '', 'valign="top"') . html_tag('td', $subject, 'left')) . "\n" . html_tag('tr', html_tag('td', _("Date") . '&nbsp;', 'left') . html_tag('td', htmlspecialchars($date), 'left')) . "\n" . html_tag('tr', html_tag('td', _("To") . '&nbsp;', 'left', '', 'valign="top"') . html_tag('td', $to, 'left')) . "\n";
if (strlen($cc) > 0) {
    /* only show Cc: if it's there... */
    echo html_tag('tr', html_tag('td', _("Cc") . '&nbsp;', 'left', '', 'valign="top"') . html_tag('td', $cc, 'left'));
}
/* body */
echo html_tag('tr', html_tag('td', '<hr noshade size="1" /><br />' . "\n" . $body, 'left', '', 'colspan="2"')) . "\n" . '</table>' . "\n" . '</body></html>';
/* --end browser output-- */
/* --start pf-specific functions-- */
/**
 * Function should clean layout of printed messages when user
 * enables "Printer Friendly Clean Display" option.
コード例 #5
0
ファイル: read_body.php プロジェクト: jprice/EHCP
function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee)
{
    global $default_use_mdn, $default_use_priority, $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on, $squirrelmail_language;
    $header = $message->rfc822_header;
    $env = array();
    $env[_("Subject")] = decodeHeader($header->subject);
    $from_name = $header->getAddr_s('from');
    if (!$from_name) {
        $from_name = $header->getAddr_s('sender');
        if (!$from_name) {
            $from_name = _("Unknown sender");
        }
    }
    $env[_("From")] = decodeHeader($from_name);
    $env[_("Date")] = getLongDateString($header->date, $header->date_unparsed);
    $env[_("To")] = formatRecipientString($header->to, "to");
    $env[_("Cc")] = formatRecipientString($header->cc, "cc");
    $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
    if ($default_use_priority) {
        $env[_("Priority")] = htmlspecialchars(getPriorityStr($header->priority));
    }
    if ($show_xmailer_default) {
        $env[_("Mailer")] = decodeHeader($header->xmailer);
    }
    if ($default_use_mdn) {
        if ($mdn_user_support) {
            if ($header->dnt) {
                if ($message->is_mdnsent) {
                    $env[_("Read receipt")] = _("sent");
                } else {
                    $env[_("Read receipt")] = _("requested");
                    if (!(handleAsSent($mailbox) || $message->is_deleted || $passed_ent_id)) {
                        $mdn_url = $PHP_SELF;
                        $mdn_url = set_url_var($mdn_url, 'mailbox', urlencode($mailbox));
                        $mdn_url = set_url_var($mdn_url, 'passed_id', $passed_id);
                        $mdn_url = set_url_var($mdn_url, 'passed_ent_id', $passed_ent_id);
                        $mdn_url = set_url_var($mdn_url, 'sendreceipt', 1);
                        if ($FirstTimeSee && $javascript_on) {
                            $script = '<script language="JavaScript" type="text/javascript">' . "\n";
                            $script .= '<!--' . "\n";
                            $script .= 'if(window.confirm("' . _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . '")) {  ' . "\n" . '    sendMDN()' . '}' . "\n";
                            $script .= '// -->' . "\n";
                            $script .= '</script>' . "\n";
                            echo $script;
                        }
                        $env[_("Read receipt")] .= '&nbsp;<a href="' . $mdn_url . '">[' . _("Send read receipt now") . ']</a>';
                    }
                }
            }
        }
    }
    $s = '<table width="100%" cellpadding="0" cellspacing="2" border="0"';
    $s .= ' align="center" bgcolor="' . $color[0] . '">';
    foreach ($env as $key => $val) {
        if ($val) {
            $s .= '<tr>';
            $s .= html_tag('td', '<b>' . $key . ':&nbsp;&nbsp;</b>', 'right', '', 'valign="top" width="20%"') . "\n";
            $s .= html_tag('td', $val, 'left', '', 'valign="top" width="80%"') . "\n";
            $s .= '</tr>';
        }
    }
    echo '<table bgcolor="' . $color[9] . '" width="100%" cellpadding="1"' . ' cellspacing="0" border="0" align="center">' . "\n";
    echo '<tr><td height="5" colspan="2" bgcolor="' . $color[4] . '"></td></tr><tr><td align="center">' . "\n";
    echo $s;
    do_hook('read_body_header');
    formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
    echo '</table>';
    echo '</td></tr><tr><td height="5" colspan="2" bgcolor="' . $color[4] . '"></td></tr>' . "\n";
    echo '</table>';
}
コード例 #6
0
/**
 * 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;
}
コード例 #7
0
 /**
  * Get file name used for mime part
  * @return string file name
  * @since 1.3.2
  */
 function getFilename()
 {
     $filename = '';
     $header = $this->header;
     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-[' . $this->entity_id . ']' . '.' . strtolower($header->type1);
                     } else {
                         $filename = 'cid: ' . $header->id . '.' . strtolower($header->type1);
                     }
                 } else {
                     $filename = $name;
                 }
             } else {
                 $filename = $name;
             }
         }
     } else {
         $filename = $header->getParameter('filename');
         if (!trim($filename)) {
             $filename = $header->getParameter('name');
             if (!trim($filename)) {
                 if (!trim($header->id)) {
                     $filename = 'untitled-[' . $this->entity_id . ']' . '.' . strtolower($header->type1);
                 } else {
                     $filename = 'cid: ' . $header->id . '.' . strtolower($header->type1);
                 }
             }
         }
     }
     return $filename;
 }
コード例 #8
0
 if ($header) {
     if (!$contentset && preg_match("/^.*(content-type:)\\s*(\\w+)\\/(\\w+).*/i", $line, $reg)) {
         if (strtolower($reg[2]) == 'message' && strtolower($reg[3]) == 'rfc822') {
             $messageheader = true;
         }
         $content[$content_indx]['type'] = "{$reg['2']}/{$reg['3']}";
         $contentset = true;
         if ($reg[2] == 'image') {
             $entities["{$entStr}"] = array();
             $entities["{$entStr}"]['entity'] = $entStr;
             $entities["{$entStr}"]['contenttype'] = $reg[2] . '/' . $reg[3];
         }
     } else {
         if (!$nameset && preg_match("/^.*(name=\\s*)\"(.*)\".*/i", $line, $reg)) {
             $name = htmlspecialchars($reg[2]);
             $content[$content_indx]['name'] = decodeHeader($name);
             $nameset = true;
             if (isset($entities["{$entStr}"])) {
                 $entities["{$entStr}"]['name'] = urlEncode($reg[2]);
             }
         } else {
             if (preg_match("/^.*(content-transfer-encoding:)\\s*(\\w+-?(\\w+)?).*/i", $line, $reg)) {
                 $encoding = $reg[2];
                 if (isset($entities["{$entStr}"])) {
                     $entities["{$entStr}"]['encoding'] = $reg[2];
                 }
                 $content[$content_indx]['encoding'] = $encoding;
                 $mimeentity = '';
             }
         }
     }
コード例 #9
0
ファイル: imap_messages.php プロジェクト: jprice/EHCP
/**
 * Retrieves a list with headers, flags, size or internaldate from the imap server
 */
function sqimap_get_small_header_list($imap_stream, $msg_list, $show_num = false)
{
    global $squirrelmail_language, $color, $data_dir, $username, $imap_server_type;
    global $uid_support, $allow_server_sort;
    /* Get the small headers for each message in $msg_list */
    $maxmsg = sizeof($msg_list);
    if ($show_num != '999999') {
        $msgs_str = sqimap_message_list_squisher($msg_list);
    } else {
        $msgs_str = '1:*';
    }
    $messages = array();
    $read_list = array();
    /*
     * We need to return the data in the same order as the caller supplied
     * in $msg_list, but IMAP servers are free to return responses in
     * whatever order they wish... So we need to re-sort manually
     */
    for ($i = 0; $i < sizeof($msg_list); $i++) {
        $messages["{$msg_list[$i]}"] = array();
    }
    $internaldate = getPref($data_dir, $username, 'internal_date_sort', SMPREF_ON);
    if ($internaldate) {
        $query = "FETCH {$msgs_str} (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)])";
    } else {
        $query = "FETCH {$msgs_str} (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)])";
    }
    $read_list = sqimap_run_command_list($imap_stream, $query, true, $response, $message, $uid_support);
    $i = 0;
    foreach ($read_list as $r) {
        /* initialize/reset vars */
        $subject = _("(no subject)");
        $from = _("Unknown Sender");
        $priority = 0;
        $messageid = '<>';
        $type = array('', '');
        $cc = $to = $inrepto = '';
        $size = 0;
        // use unset because we do isset below
        unset($date);
        $flag_seen = $flag_answered = $flag_deleted = $flag_flagged = false;
        $read = implode('', $r);
        /*
         * #id<space>FETCH<space>(
         */
        /* extract the message id */
        $i_space = strpos($read, ' ', 2);
        $id = substr($read, 2, $i_space - 2);
        $fetch = substr($read, $i_space + 1, 5);
        if (!is_numeric($id) && $fetch !== 'FETCH') {
            set_up_language($squirrelmail_language);
            echo '<br /><b><font color="' . $color[2] . '">' . _("ERROR: Could not complete request.") . '</b><br />' . _("Unknown response from IMAP server:") . ' 1.' . htmlspecialchars($read) . "</font><br />\n";
            break;
        }
        $i = strpos($read, '(', $i_space + 5);
        $read = substr($read, $i + 1);
        $i_len = strlen($read);
        $i = 0;
        while ($i < $i_len && $i !== false) {
            /* get argument */
            $read = trim(substr($read, $i));
            $i_len = strlen($read);
            $i = strpos($read, ' ');
            $arg = substr($read, 0, $i);
            ++$i;
            switch ($arg) {
                case 'UID':
                    $i_pos = strpos($read, ' ', $i);
                    if (!$i_pos) {
                        $i_pos = strpos($read, ')', $i);
                    }
                    if ($i_pos) {
                        $unique_id = substr($read, $i, $i_pos - $i);
                        $i = $i_pos + 1;
                    } else {
                        break 3;
                    }
                    break;
                case 'FLAGS':
                    $flags = parseArray($read, $i);
                    if (!$flags) {
                        break 3;
                    }
                    foreach ($flags as $flag) {
                        $flag = strtolower($flag);
                        switch ($flag) {
                            case '\\seen':
                                $flag_seen = true;
                                break;
                            case '\\answered':
                                $flag_answered = true;
                                break;
                            case '\\deleted':
                                $flag_deleted = true;
                                break;
                            case '\\flagged':
                                $flag_flagged = true;
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 'RFC822.SIZE':
                    $i_pos = strpos($read, ' ', $i);
                    if (!$i_pos) {
                        $i_pos = strpos($read, ')', $i);
                    }
                    if ($i_pos) {
                        $size = substr($read, $i, $i_pos - $i);
                        $i = $i_pos + 1;
                    } else {
                        break 3;
                    }
                    break;
                case 'INTERNALDATE':
                    $date = parseString($read, $i);
                    //if ($tmpdate === false) break 3;
                    //$tmpdate = str_replace('  ',' ',$tmpdate);
                    //$tmpdate = explode(' ',$tmpdate);
                    //$date = str_replace('-',' ',$tmpdate[0]) . " " .
                    //                            $tmpdate[1] . ' ' . $tmpdate[2];
                    break;
                case 'BODY.PEEK[HEADER.FIELDS':
                case 'BODY[HEADER.FIELDS':
                    $i = strpos($read, '{', $i);
                    $header = parseString($read, $i);
                    if ($header === false) {
                        break 2;
                    }
                    /* First we replace all \r\n by \n, and unfold the header */
                    $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "), array("\n", ' ', ' '), $header));
                    /* Now we can make a new header array with */
                    /* each element representing a headerline  */
                    $hdr = explode("\n", $hdr);
                    foreach ($hdr as $line) {
                        $pos = strpos($line, ':');
                        if ($pos > 0) {
                            $field = strtolower(substr($line, 0, $pos));
                            if (!strstr($field, ' ')) {
                                /* valid field */
                                $value = trim(substr($line, $pos + 1));
                                switch ($field) {
                                    case 'to':
                                        $to = $value;
                                        break;
                                    case 'cc':
                                        $cc = $value;
                                        break;
                                    case 'from':
                                        $from = $value;
                                        break;
                                    case 'date':
                                        $date = $value;
                                        break;
                                    case 'x-priority':
                                    case 'importance':
                                    case 'priority':
                                        $priority = parsePriority($value);
                                        break;
                                    case 'subject':
                                        $subject = $value;
                                        if ($subject == "") {
                                            $subject = _("(no subject)");
                                        }
                                        break;
                                    case 'content-type':
                                        $type = strtolower($value);
                                        if ($pos = strpos($type, ";")) {
                                            $type = substr($type, 0, $pos);
                                        }
                                        $type = explode("/", $type);
                                        if (empty($type[0])) {
                                            $type[0] = 'text';
                                            // I had this added, but not committed to CVS.... did it help fix something?
                                            //                                    $type[1] = 'plain';
                                        }
                                        if (empty($type[1])) {
                                            $type[1] = 'plain';
                                        }
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                    }
                    break;
                default:
                    ++$i;
                    break;
            }
        }
        if (isset($date)) {
            $date = str_replace('  ', ' ', $date);
            $tmpdate = explode(' ', trim($date));
        } else {
            $tmpdate = $date = array();
        }
        if ($uid_support) {
            $msgi = "{$unique_id}";
            $messages[$msgi]['ID'] = $unique_id;
        } else {
            $msgi = "{$id}";
            $messages[$msgi]['ID'] = $id;
        }
        $messages[$msgi]['TIME_STAMP'] = getTimeStamp($tmpdate);
        $messages[$msgi]['DATE_STRING'] = getDateString($messages[$msgi]['TIME_STAMP']);
        $messages[$msgi]['FROM'] = $from;
        //parseAddress($from);
        $messages[$msgi]['SUBJECT'] = $subject;
        //        if (handleAsSent($mailbox)) {
        $messages[$msgi]['TO'] = $to;
        //parseAddress($to);
        //        }
        $messages[$msgi]['PRIORITY'] = $priority;
        $messages[$msgi]['CC'] = $cc;
        //parseAddress($cc);
        $messages[$msgi]['SIZE'] = $size;
        $messages[$msgi]['TYPE0'] = $type[0];
        $messages[$msgi]['TYPE1'] = $type[1];
        $messages[$msgi]['FLAG_DELETED'] = $flag_deleted;
        $messages[$msgi]['FLAG_ANSWERED'] = $flag_answered;
        $messages[$msgi]['FLAG_SEEN'] = $flag_seen;
        $messages[$msgi]['FLAG_FLAGGED'] = $flag_flagged;
        /* non server sort stuff */
        if (!$allow_server_sort) {
            $from = parseAddress($from);
            if ($from[0][1]) {
                $from = decodeHeader($from[0][1], true, false);
            } else {
                $from = $from[0][0];
            }
            $messages[$msgi]['FROM-SORT'] = $from;
            $subject_sort = strtolower(decodeHeader($subject, true, false));
            if (preg_match("/^(?:(?:vedr|sv|re|aw|fw|fwd|\\[\\w\\]):\\s*)*\\s*(.*)\$/si", $subject_sort, $matches)) {
                $messages[$msgi]['SUBJECT-SORT'] = $matches[1];
            } else {
                $messages[$msgi]['SUBJECT-SORT'] = $subject_sort;
            }
        }
        ++$msgi;
    }
    array_reverse($messages);
    $new_messages = array();
    foreach ($messages as $i => $message) {
        $new_messages[] = $message;
    }
    return $new_messages;
}
コード例 #10
0
ファイル: index.php プロジェクト: laiello/bitcero-modules
    require 'trackbacks.php';
    die;
}
/**
 * Si el primer valor es submit
 * entonces se muestra el formulario
 * para enviar un artículo
 */
if ($vars[0] == 'submit') {
    require 'submit.php';
    die;
}
if ($vars[0] == 'edit') {
    $vars['edit'] = $vars[1];
    require 'submit.php';
    die;
}
if ($yesquery || $vars[0] == '') {
    require 'home.php';
    die;
}
header("HTTP/1.0 404 Not Found");
if (substr(php_sapi_name(), 0, 3) == 'cgi') {
    header('Status: 404 Not Found', TRUE);
} else {
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
}
echo "<h1>ERROR 404. Document not Found</h1>";
die;
decodeHeader();
コード例 #11
0
ファイル: mime.php プロジェクト: BackupTheBerlios/hpt-obm-svn
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&amp;passed_id={$id}&amp;mailbox={$urlMailbox}&amp;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 = '&amp;passed_ent_id=' . $passed_ent_id;
        } else {
            $passed_ent_id_link = '';
        }
        $defaultlink = $default_page . "?startMessage={$startMessage}" . "&amp;passed_id={$id}&amp;mailbox={$urlMailbox}" . '&amp;ent_id=' . $ent . $passed_ent_id_link;
        if ($where && $what) {
            $defaultlink .= '&amp;where=' . urlencode($where) . '&amp;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>&nbsp;</td>' . '<td><small><b>' . show_readable_size($header->size) . '</b>&nbsp;&nbsp;</small></td>' . '<td><small>[ ' . htmlspecialchars($type0) . '/' . htmlspecialchars($type1) . ' ]&nbsp;</small></td>' . '<td><small>';
        $attachments .= '<b>' . $description . '</b>';
        $attachments .= '</small></td><td><small>&nbsp;';
        $skipspaces = 1;
        foreach ($links as $val) {
            if ($skipspaces) {
                $skipspaces = 0;
            } else {
                $attachments .= '&nbsp;&nbsp;|&nbsp;&nbsp;';
            }
            $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;
}
コード例 #12
0
ファイル: vcard.php プロジェクト: teammember8/roundcube
    $vcard_safe['url'] = '<a href="' . $vcard_safe['url'] . '" target="_blank">' . $vcard_safe['url'] . '</a>';
}
$vcard = array();
foreach ($ShowValues as $k => $v) {
    if (isset($vcard_safe[$k]) && $vcard_safe[$k]) {
        $vcard[$v] = $vcard_safe[$k];
    }
}
$dl = '../src/download.php?absolute_dl=true&amp;passed_id=' . urlencode($passed_id) . '&amp;mailbox=' . urlencode($mailbox) . '&amp;ent_id=' . urlencode($ent_id);
if (isset($vcard_nice['email;internet'])) {
    $email = $vcard_nice['email;internet'];
} else {
    $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
    $header = $message->rfc822_header;
    $from_name = $header->getAddr_s('from');
    $email = getEmail(decodeHeader($from_name));
}
$opts = array();
if (isset($vcard_nice['url'])) {
    $opts[$vcard_nice['url']] = _("Web Page");
}
if (isset($vcard_nice['adr'])) {
    $opts[$vcard_nice['adr']] = _("Address");
}
if (isset($vcard_nice['title'])) {
    $opts[$vcard_nice['title']] = _("Title");
}
if (isset($vcard_nice['org'])) {
    $opts[$vcard_nice['org']] = _("Organization / Department");
}
if (isset($vcard_nice['title'])) {
コード例 #13
0
ファイル: compose.php プロジェクト: teammember8/roundcube
function showInputForm($session, $values = false)
{
    global $send_to, $send_to_cc, $send_to_bcc, $body, $startMessage, $action, $attachments, $use_signature, $signature, $prefix_sig, $session_expired, $editor_size, $editor_height, $subject, $newmail, $use_javascript_addr_book, $passed_id, $mailbox, $fwduid, $from_htmladdr_search, $location_of_buttons, $attachment_dir, $username, $data_dir, $identity, $idents, $delete_draft, $mailprio, $compose_new_win, $saved_draft, $mail_sent, $sig_first, $composeMessage, $composesession, $default_charset, $compose_onsubmit, $oTemplate, $oErrorHandler;
    if (checkForJavascript()) {
        $onfocus = ' onfocus="alreadyFocused=true;"';
        $onfocus_array = array('onfocus' => 'alreadyFocused=true;');
    } else {
        $onfocus = '';
        $onfocus_array = array();
    }
    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) {
        //FIXME: NO HTML IN CORE!
        echo "\n" . '<script type="text/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";
    }
    //FIXME: NO HTML IN CORE!
    echo "\n" . '<form name="compose" action="compose.php" method="post" ' . 'enctype="multipart/form-data"';
    $compose_onsubmit = array();
    global $null;
    do_hook('compose_form', $null);
    // Plugins that use compose_form hook can add an array entry
    // to the globally scoped $compose_onsubmit; we add them up
    // here and format the form tag's full onsubmit handler.
    // Each plugin should use "return false" if they need to
    // stop form submission but otherwise should NOT use "return
    // true" to give other plugins the chance to do what they need
    // to do; SquirrelMail itself will add the final "return true".
    // Onsubmit text is enclosed inside of double quotes, so plugins
    // need to quote accordingly.
    //
    // Also, plugin authors should try to retain compatibility with
    // the Compose Extras plugin by resetting its compose submit
    // counter when preventing form submit.  Use this code:
    // if (your-code-here) { submit_count = 0; return false; }
    //
    if (checkForJavascript()) {
        if (empty($compose_onsubmit)) {
            $compose_onsubmit = array();
        } else {
            if (!is_array($compose_onsubmit)) {
                $compose_onsubmit = array($compose_onsubmit);
            }
        }
        $onsubmit_text = '';
        foreach ($compose_onsubmit as $text) {
            $text = trim($text);
            if (!empty($text)) {
                if (substr($text, -1) != ';' && substr($text, -1) != '}') {
                    $text .= '; ';
                }
                $onsubmit_text .= $text;
            }
        }
        if (!empty($onsubmit_text)) {
            //FIXME: DON'T ECHO HTML FROM CORE!
            echo ' onsubmit="' . $onsubmit_text . ' return true;"';
        }
    }
    //FIXME: NO HTML IN CORE!
    echo ">\n";
    //FIXME: DON'T ECHO HTML FROM CORE!
    echo addHidden('smtoken', sm_generate_security_token());
    //FIXME: DON'T ECHO HTML FROM CORE!
    echo addHidden('startMessage', $startMessage);
    if ($action == 'draft') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('delete_draft', $passed_id);
    }
    if (isset($delete_draft)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('delete_draft', $delete_draft);
    }
    if (isset($session)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('session', $session);
    }
    if (isset($passed_id)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('passed_id', $passed_id);
    }
    if (isset($fwduid)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('fwduid', $fwduid);
    }
    if ($saved_draft == 'yes') {
        $oTemplate->assign('note', _("Your draft has been saved."));
        $oTemplate->display('note.tpl');
    }
    if ($mail_sent == 'yes') {
        $oTemplate->assign('note', _("Your mail has been sent."));
        $oTemplate->display('note.tpl');
    }
    if ($compose_new_win == '1') {
        $oTemplate->display('compose_newwin_close.tpl');
    }
    if ($location_of_buttons == 'top') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        showComposeButtonRow();
    }
    $identities = array();
    if (count($idents) > 1) {
        reset($idents);
        foreach ($idents as $id => $data) {
            $identities[$id] = $data['full_name'] . ' &lt;' . $data['email_address'] . '&gt;';
        }
    }
    $oTemplate->assign('identities', $identities);
    $oTemplate->assign('identity_def', $identity);
    $oTemplate->assign('input_onfocus', 'onfocus="' . join(' ', $onfocus_array) . '"');
    $oTemplate->assign('to', sm_encode_html_special_chars($send_to));
    $oTemplate->assign('cc', sm_encode_html_special_chars($send_to_cc));
    $oTemplate->assign('bcc', sm_encode_html_special_chars($send_to_bcc));
    $oTemplate->assign('subject', sm_encode_html_special_chars($subject));
    // access keys...
    //
    global $accesskey_compose_to, $accesskey_compose_cc, $accesskey_compose_identity, $accesskey_compose_bcc, $accesskey_compose_subject;
    $oTemplate->assign('accesskey_compose_identity', $accesskey_compose_identity);
    $oTemplate->assign('accesskey_compose_to', $accesskey_compose_to);
    $oTemplate->assign('accesskey_compose_cc', $accesskey_compose_cc);
    $oTemplate->assign('accesskey_compose_bcc', $accesskey_compose_bcc);
    $oTemplate->assign('accesskey_compose_subject', $accesskey_compose_subject);
    $oTemplate->display('compose_header.tpl');
    if ($location_of_buttons == 'between') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        showComposeButtonRow();
    }
    $body_str = '';
    if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
        $signature = $idents[$identity]['signature'];
        if ($sig_first == '1') {
            /*
             * FIXME: test is specific to ja_JP translation implementation.
             * This test might apply incorrect conversion to other translations, but
             * use of 7bit iso-2022-jp charset in other translations might have other
             * issues too.
             */
            if ($default_charset == 'iso-2022-jp') {
                $body_str = "\n\n" . ($prefix_sig == true ? "-- \n" : '') . mb_convert_encoding($signature, 'EUC-JP');
            } else {
                $body_str = "\n\n" . ($prefix_sig == true ? "-- \n" : '') . decodeHeader($signature, false, false);
            }
            $body_str .= "\n\n" . sm_encode_html_special_chars(decodeHeader($body, false, false));
        } else {
            $body_str = "\n\n" . sm_encode_html_special_chars(decodeHeader($body, false, false));
            // FIXME: test is specific to ja_JP translation implementation. See above comments.
            if ($default_charset == 'iso-2022-jp') {
                $body_str .= "\n\n" . ($prefix_sig == true ? "-- \n" : '') . mb_convert_encoding($signature, 'EUC-JP');
            } else {
                $body_str .= "\n\n" . ($prefix_sig == true ? "-- \n" : '') . decodeHeader($signature, false, false);
            }
        }
    } else {
        $body_str = sm_encode_html_special_chars(decodeHeader($body, false, false));
    }
    $oTemplate->assign('editor_width', (int) $editor_size);
    $oTemplate->assign('editor_height', (int) $editor_height);
    $oTemplate->assign('input_onfocus', 'onfocus="' . join(' ', $onfocus_array) . '"');
    $oTemplate->assign('body', $body_str);
    $oTemplate->assign('show_bottom_send', $location_of_buttons != 'bottom');
    // access keys...
    //
    global $accesskey_compose_body, $accesskey_compose_send;
    $oTemplate->assign('accesskey_compose_body', $accesskey_compose_body);
    $oTemplate->assign('accesskey_compose_send', $accesskey_compose_send);
    $oTemplate->display('compose_body.tpl');
    if ($location_of_buttons == 'bottom') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        showComposeButtonRow();
    }
    // composeMessage can be empty when coming from a restored session
    if (is_object($composeMessage) && $composeMessage->entities) {
        $attach_array = $composeMessage->entities;
    }
    if ($session_expired && !empty($attachments) && is_array($attachments)) {
        $attach_array = $attachments;
    }
    /* 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, and -1 which means 'unlimited' */
            if ($size = getByteSize(ini_get($var))) {
                if ($size != '-1') {
                    $sizes[] = $size;
                }
            }
        }
        $attach = array();
        global $username, $attachment_dir;
        $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
        if (!empty($attach_array)) {
            foreach ($attach_array 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;
                    $a = array();
                    $a['Key'] = $key;
                    $a['FileName'] = $attached_filename;
                    $a['ContentType'] = $type;
                    $a['Size'] = filesize($hashed_attachment_dir . '/' . $attached_file);
                    $attach[$key] = $a;
                }
            }
        }
        $max = min($sizes);
        $oTemplate->assign('max_file_size', empty($max) ? -1 : $max);
        $oTemplate->assign('attachments', $attach);
        // access keys...
        //
        global $accesskey_compose_attach_browse, $accesskey_compose_attach, $accesskey_compose_delete_attach;
        $oTemplate->assign('accesskey_compose_attach_browse', $accesskey_compose_attach_browse);
        $oTemplate->assign('accesskey_compose_attach', $accesskey_compose_attach);
        $oTemplate->assign('accesskey_compose_delete_attach', $accesskey_compose_delete_attach);
        $oTemplate->display('compose_attachments.tpl');
    }
    // End of file_uploads if-block
    /* End of attachment code */
    $oTemplate->assign('username', $username);
    $oTemplate->assign('smaction', $action);
    $oTemplate->assign('mailbox', $mailbox);
    sqgetGlobalVar('QUERY_STRING', $queryString, SQ_SERVER);
    $oTemplate->assign('querystring', $queryString);
    $oTemplate->assign('composesession', $composesession);
    $oTemplate->assign('send_button_count', unique_widget_name('send', TRUE));
    if (!empty($attach_array)) {
        $oTemplate->assign('attachments', urlencode(serialize($attach_array)));
    }
    $aUserNotices = array();
    // File uploads are off, so we didn't show that part of the form.
    // To avoid bogus bug reports, tell the user why.
    if (!(bool) ini_get('file_uploads')) {
        $aUserNotices[] = _("Because PHP file uploads are turned off, you can not attach files to this message. Please see your system administrator for details.");
    }
    $oTemplate->assign('user_notices', $aUserNotices);
    $oTemplate->display('compose_form_close.tpl');
    if ($compose_new_win == '1') {
        $oTemplate->display('compose_newwin_close.tpl');
    }
    $oErrorHandler->setDelayedErrors(false);
    $oTemplate->display('footer.tpl');
}
コード例 #14
0
ファイル: mime.php プロジェクト: teammember8/roundcube
/**
 * Generate attachments array for passing to templates.
 *
 * @since 1.5.2
 * @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
 */
function buildAttachmentArray($message, $exclude_id, $mailbox, $id)
{
    global $where, $what, $startMessage, $color, $passed_ent_id, $base_uri;
    $att_ar = $message->getAttachments($exclude_id);
    $urlMailbox = urlencode($mailbox);
    $attachments = array();
    foreach ($att_ar as $att) {
        $ent = $att->entity_id;
        $header = $att->header;
        $type0 = strtolower($header->type0);
        $type1 = strtolower($header->type1);
        $name = '';
        $links = array();
        $links['download link']['text'] = _("Download");
        $links['download link']['href'] = $base_uri . "src/download.php?absolute_dl=true&amp;passed_id={$id}&amp;mailbox={$urlMailbox}&amp;ent_id={$ent}";
        if ($type0 == 'message' && $type1 == 'rfc822') {
            $default_page = $base_uri . '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));
            } elseif (is_array($from_o) && count($from_o) && is_object($from_o[0])) {
                // something weird happens when a digest message is opened and you return to the digest
                // now the from object is part of an array. Probably the parseHeader call overwrites the info
                // retrieved from the bodystructure in a different way. We need to fix this later.
                // possible starting point, do not fetch header we already have and inspect how
                // the rfc822_header object behaves.
                $from_name = decodeHeader($from_o[0]->getAddress(false));
            } else {
                $from_name = _("Unknown sender");
            }
            $description = _("From") . ': ' . $from_name;
        } else {
            $default_page = $base_uri . 'src/download.php';
            $filename = $att->getFilename();
            if ($header->description) {
                $description = decodeHeader($header->description);
            } else {
                $description = '';
            }
        }
        $display_filename = $filename;
        if (isset($passed_ent_id)) {
            $passed_ent_id_link = '&amp;passed_ent_id=' . $passed_ent_id;
        } else {
            $passed_ent_id_link = '';
        }
        $defaultlink = $default_page . "?startMessage={$startMessage}" . "&amp;passed_id={$id}&amp;mailbox={$urlMailbox}" . '&amp;ent_id=' . $ent . $passed_ent_id_link;
        if ($where && $what) {
            $defaultlink .= '&amp;where=' . urlencode($where) . '&amp;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 .= '&amp;absolute_dl=true';
        }
        /* This executes the attachment hook with a specific MIME-type.
         * It also allows plugins to run if there's a rule for a more
         * generic type. Finally, a hook for ALL attachment types is
         * run as well.
         */
        // First remember the default link.
        $defaultlink_orig = $defaultlink;
        /* The API for this hook has changed as of 1.5.2 so that all plugin
           arguments are passed in an array instead of each their own plugin
           argument, and arguments are passed by reference, so instead of
           returning any changes, changes should simply be made to the original
           arguments themselves. */
        $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, &$defaultlink, &$display_filename, &$where, &$what);
        do_hook("attachment {$type0}/{$type1}", $temp);
        /* The API for this hook has changed as of 1.5.2 so that all plugin
           arguments are passed in an array instead of each their own plugin
           argument, and arguments are passed by reference, so instead of
           returning any changes, changes should simply be made to the original
           arguments themselves. */
        $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, &$defaultlink, &$display_filename, &$where, &$what);
        // Do not let a generic plugin change the default link if a more
        // specialized one already did it...
        if ($defaultlink != $defaultlink_orig) {
            $dummy = '';
            $temp[5] =& $dummy;
        }
        do_hook("attachment {$type0}/*", $temp);
        /* The API for this hook has changed as of 1.5.2 so that all plugin
           arguments are passed in an array instead of each their own plugin
           argument, and arguments are passed by reference, so instead of
           returning any changes, changes should simply be made to the original
           arguments themselves. */
        $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, &$defaultlink, &$display_filename, &$where, &$what);
        // Do not let a generic plugin change the default link if a more
        // specialized one already did it...
        if ($defaultlink != $defaultlink_orig) {
            $dummy = '';
            $temp[5] =& $dummy;
        }
        do_hook("attachment */*", $temp);
        $this_attachment = array();
        $this_attachment['Name'] = decodeHeader($display_filename);
        $this_attachment['Description'] = $description;
        $this_attachment['DefaultHREF'] = $defaultlink;
        $this_attachment['DownloadHREF'] = $links['download link']['href'];
        $this_attachment['ViewHREF'] = isset($links['attachment_common']) ? $links['attachment_common']['href'] : '';
        $this_attachment['Size'] = $header->size;
        $this_attachment['ContentType'] = sm_encode_html_special_chars($type0 . '/' . $type1);
        $this_attachment['OtherLinks'] = array();
        foreach ($links as $val) {
            if ($val['text'] == _("Download") || $val['text'] == _("View")) {
                continue;
            }
            if (empty($val['text']) && empty($val['extra'])) {
                continue;
            }
            $temp = array();
            $temp['HREF'] = $val['href'];
            $temp['Text'] = (empty($val['text']) ? '' : $val['text']) . (empty($val['extra']) ? '' : $val['extra']);
            $this_attachment['OtherLinks'][] = $temp;
        }
        $attachments[] = $this_attachment;
        unset($links);
    }
    return $attachments;
}
コード例 #15
0
ファイル: mime.php プロジェクト: jin255ff/company_website
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&amp;passed_id={$id}&amp;mailbox={$urlMailbox}&amp;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 = '&amp;passed_ent_id=' . $passed_ent_id;
        } else {
            $passed_ent_id_link = '';
        }
        $defaultlink = $default_page . "?startMessage={$startMessage}" . "&amp;passed_id={$id}&amp;mailbox={$urlMailbox}" . '&amp;ent_id=' . $ent . $passed_ent_id_link;
        if ($where && $what) {
            $defaultlink .= '&amp;where=' . urlencode($where) . '&amp;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 .= '&amp;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>&nbsp;</td>' . '<td><small><b>' . show_readable_size($header->size) . '</b>&nbsp;&nbsp;</small></td>' . '<td><small>[ ' . htmlspecialchars($type0) . '/' . htmlspecialchars($type1) . ' ]&nbsp;</small></td>' . '<td><small>';
        $attachments .= '<b>' . $description . '</b>';
        $attachments .= '</small></td><td><small>&nbsp;';
        $skipspaces = 1;
        foreach ($links as $val) {
            if ($skipspaces) {
                $skipspaces = 0;
            } else {
                $attachments .= '&nbsp;&nbsp;|&nbsp;&nbsp;';
            }
            $attachments .= '<a href="' . $val['href'] . '">' . $val['text'] . '</a>';
        }
        unset($links);
        $attachments .= "</td></tr>\n";
    }
    return $attachments;
}
コード例 #16
0
/**
 * Attach messages to a compose session
 *
 * @param  resource $imapConnection imap connection
 * @param  array $aMsgHeaders
 * @return int $composesession unique compose_session_id where the attached messages belong to
 * @author Marc Groot Koerkamp
 */
function attachSelectedMessages($imapConnection, $aMsgHeaders)
{
    sqgetGlobalVar('composesession', $composesession, SQ_SESSION);
    sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
    if (!isset($compose_messages) || is_null($compose_messages)) {
        $compose_messages = array();
        sqsession_register($compose_messages, 'compose_messages');
    }
    if (!$composesession) {
        $composesession = 1;
        sqsession_register($composesession, 'composesession');
    } else {
        $composesession++;
        sqsession_register($composesession, 'composesession');
    }
    $composeMessage = new Message();
    $rfc822_header = new Rfc822Header();
    $composeMessage->rfc822_header = $rfc822_header;
    $composeMessage->reply_rfc822_header = '';
    foreach ($aMsgHeaders as $iUid => $aMsgHeader) {
        /**
         * Retrieve the full message
         */
        $body_a = sqimap_run_command($imapConnection, "FETCH {$iUid} RFC822", true, $response, $readmessage, TRUE);
        if ($response == 'OK') {
            $subject = isset($aMsgHeader['subject']) ? $aMsgHeader['subject'] : $iUid;
            array_shift($body_a);
            array_pop($body_a);
            $body = implode('', $body_a);
            $body .= "\r\n";
            global $username, $attachment_dir;
            $filename = sq_get_attach_tempfile();
            $fullpath = getHashedDir($username, $attachment_dir) . '/' . $filename;
            $fp = fopen($fullpath, 'wb');
            fwrite($fp, $body);
            fclose($fp);
            $composeMessage->initAttachment('message/rfc822', $subject . '.eml', $filename);
            // create subject for new message
            //
            $subject = decodeHeader($subject, false, false, true);
            $subject = str_replace('"', "'", $subject);
            $subject = trim($subject);
            if (substr(strtolower($subject), 0, 4) != 'fwd:') {
                $subject = 'Fwd: ' . $subject;
            }
            $composeMessage->rfc822_header->subject = $subject;
        }
    }
    $compose_messages[$composesession] = $composeMessage;
    sqsession_register($compose_messages, 'compose_messages');
    return $composesession;
}
コード例 #17
0
ファイル: move_messages.php プロジェクト: jprice/EHCP
function attachSelectedMessages($msg, $imapConnection)
{
    global $username, $attachment_dir, $startMessage, $data_dir, $composesession, $uid_support, $mailbox, $msgs, $thread_sort_messages, $allow_server_sort, $show_num, $compose_messages;
    if (!isset($compose_messages)) {
        $compose_messages = array();
        sqsession_register($compose_messages, 'compose_messages');
    }
    if (!$composesession) {
        $composesession = 1;
        sqsession_register($composesession, 'composesession');
    } else {
        $composesession++;
        sqsession_register($composesession, 'composesession');
    }
    $hashed_attachment_dir = getHashedDir($username, $attachment_dir, $composesession);
    if ($thread_sort_messages || $allow_server_sort) {
        $start_index = 0;
    } else {
        $start_index = ($startMessage - 1) * $show_num;
    }
    $i = 0;
    $j = 0;
    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
    $composeMessage = new Message();
    $rfc822_header = new Rfc822Header();
    $composeMessage->rfc822_header = $rfc822_header;
    $composeMessage->reply_rfc822_header = '';
    while ($j < count($msg)) {
        if (isset($msg[$i])) {
            $id = $msg[$i];
            $body_a = sqimap_run_command($imapConnection, "FETCH {$id} RFC822", true, $response, $readmessage, $uid_support);
            if ($response == 'OK') {
                $message = sqimap_get_message($imapConnection, $id, $mailbox);
                // fetch the subject for the message from the object
                $filename = $message->rfc822_header->subject;
                if (empty($filename)) {
                    $filename = "untitled-" . $message->entity_id;
                }
                $filename .= '.msg';
                $filename = decodeHeader($filename, false, false);
                array_shift($body_a);
                array_pop($body_a);
                $body = implode('', $body_a);
                $body .= "\r\n";
                $localfilename = GenerateRandomString(32, 'FILE', 7);
                $full_localfilename = "{$hashed_attachment_dir}/{$localfilename}";
                while (file_exists($full_localfilename)) {
                    $localfilename = GenerateRandomString(32, 'FILE', 7);
                    $full_localfilename = "{$hashed_attachment_dir}/{$localfilename}";
                }
                $fp = fopen($full_localfilename, 'wb');
                fwrite($fp, $body);
                fclose($fp);
                $composeMessage->initAttachment('message/rfc822', $filename, $localfilename);
            }
            $j++;
        }
        $i++;
    }
    $compose_messages[$composesession] = $composeMessage;
    sqsession_register($compose_messages, 'compose_messages');
    session_write_close();
    return $composesession;
}
コード例 #18
0
if (is_object($message->header->disposition)) {
    $filename = $header->disposition->getProperty('filename');
    if (!$filename) {
        $filename = $header->disposition->getProperty('name');
    }
    if (!$filename) {
        $filename = $header->getParameter('name');
    }
} else {
    $filename = $header->getParameter('name');
}
$filename = decodeHeader($filename, true, false);
$filename = charset_encode($filename, $default_charset, false);
// If name is not set, use subject of email
if (strlen($filename) < 1) {
    $filename = decodeHeader($subject, true, true);
    $filename = charset_encode($filename, $default_charset, false);
    if ($type1 == 'plain' && $type0 == 'text') {
        $suffix = 'txt';
    } else {
        if ($type1 == 'richtext' && $type0 == 'text') {
            $suffix = 'rtf';
        } else {
            if ($type1 == 'postscript' && $type0 == 'application') {
                $suffix = 'ps';
            } else {
                if ($type1 == 'rfc822' && $type0 == 'message') {
                    $suffix = 'msg';
                } else {
                    $suffix = $type1;
                }
コード例 #19
0
function sqimap_get_small_header_list($imap_stream, $msg_list)
{
    global $squirrelmail_language, $color, $data_dir, $username, $imap_server_type;
    global $uid_support, $allow_server_sort;
    /* Get the small headers for each message in $msg_list */
    $sid = sqimap_session_id($uid_support);
    $maxmsg = sizeof($msg_list);
    $msgs_str = sqimap_message_list_squisher($msg_list);
    $messages = array();
    $read_list = array();
    /*
     * We need to return the data in the same order as the caller supplied
     * in $msg_list, but IMAP servers are free to return responses in
     * whatever order they wish... So we need to re-sort manually
     */
    for ($i = 0; $i < sizeof($msg_list); $i++) {
        $id2index[$msg_list[$i]] = $i;
    }
    $internaldate = getPref($data_dir, $username, 'internal_date_sort');
    if ($internaldate) {
        $query = "{$sid} FETCH {$msgs_str} (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Content-Type)])\r\n";
    } else {
        $query = "{$sid} FETCH {$msgs_str} (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Content-Type)])\r\n";
    }
    fputs($imap_stream, $query);
    $readin_list = sqimap_read_data_list($imap_stream, $sid, false, $response, $message);
    $i = 0;
    foreach ($readin_list as $r) {
        if (!$uid_support) {
            if (!preg_match("/^\\*\\s+([0-9]+)\\s+FETCH/iAU", $r[0], $regs)) {
                set_up_language($squirrelmail_language);
                echo '<br><b><font color=$color[2]>' . _("ERROR : Could not complete request.") . '</b><br>' . _("Unknown response from IMAP server: ") . ' 1.' . htmlspecialchars($r[0]) . "</font><br>\n";
            } else {
                if (!isset($id2index[$regs[1]]) || !count($id2index[$regs[1]])) {
                    set_up_language($squirrelmail_language);
                    echo '<br><b><font color=$color[2]>' . _("ERROR : Could not complete request.") . '</b><br>' . _("Unknown message number in reply from server: ") . htmlspecialchars($regs[1]) . "</font><br>\n";
                } else {
                    $read_list[$id2index[$regs[1]]] = $r;
                }
            }
        } else {
            if (!preg_match("/^\\*\\s+([0-9]+)\\s+FETCH.*UID\\s+([0-9]+)\\s+/iAU", $r[0], $regs)) {
                set_up_language($squirrelmail_language);
                echo '<br><b><font color=$color[2]>' . _("ERROR : Could not complete request.") . '</b><br>' . _("Unknown response from IMAP server: ") . ' 1.' . htmlspecialchars($r[0]) . "</font><br>\n";
            } else {
                if (!isset($id2index[$regs[2]]) || !count($id2index[$regs[2]])) {
                    set_up_language($squirrelmail_language);
                    echo '<br><b><font color=$color[2]>' . _("ERROR : Could not complete request.") . '</b><br>' . _("Unknown message number in reply from server: ") . htmlspecialchars($regs[2]) . "</font><br>\n";
                } else {
                    $read_list[$id2index[$regs[2]]] = $r;
                    $unique_id = $regs[2];
                }
            }
        }
    }
    arsort($read_list);
    $patterns = array("/^To:(.*)\$/AUi", "/^From:(.*)\$/AUi", "/^X-Priority:(.*)\$/AUi", "/^Cc:(.*)\$/AUi", "/^Date:(.*)\$/AUi", "/^Subject:(.*)\$/AUi", "/^Content-Type:(.*)\$/AUi");
    $regpattern = '';
    for ($msgi = 0; $msgi < $maxmsg; $msgi++) {
        $subject = _("(no subject)");
        $from = _("Unknown Sender");
        $priority = 0;
        $messageid = '<>';
        $cc = $to = $date = $type[0] = $type[1] = $inrepto = '';
        $flag_seen = $flag_answered = $flag_deleted = $flag_flagged = false;
        $read = $read_list[$msgi];
        $prevline = false;
        foreach ($read as $read_part) {
            //unfold multi-line headers
            if ($prevline && $prevline[strlen($prevline) - 1] == "\n" && ($read_part[0] == ' ' || $read_part[0] == "\t")) {
                $read_part = substr($prevline, 0, -2) . preg_replace('/(\\t\\s+)/', ' ', $read_part);
            }
            $prevline = $read_part;
            if ($read_part[0] == '*') {
                if ($internaldate) {
                    if (preg_match("/^.+INTERNALDATE\\s+\"(.+)\".+/iUA", $read_part, $reg)) {
                        $tmpdate = trim($reg[1]);
                        $tmpdate = str_replace('  ', ' ', $tmpdate);
                        $tmpdate = explode(' ', $tmpdate);
                        $date = str_replace('-', ' ', $tmpdate[0]) . " " . $tmpdate[1] . ' ' . $tmpdate[2];
                    }
                }
                if (preg_match("/^.+RFC822.SIZE\\s+(\\d+).+/iA", $read_part, $reg)) {
                    $size = $reg[1];
                }
                if (preg_match("/^.+FLAGS\\s+\\((.*)\\).+/iUA", $read_part, $regs)) {
                    $flags = explode(' ', trim($regs[1]));
                    foreach ($flags as $flag) {
                        $flag = strtolower($flag);
                        if ($flag == '\\seen') {
                            $flag_seen = true;
                        } else {
                            if ($flag == '\\answered') {
                                $flag_answered = true;
                            } else {
                                if ($flag == '\\deleted') {
                                    $flag_deleted = true;
                                } else {
                                    if ($flag == '\\flagged') {
                                        $flag_flagged = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if (preg_match("/^.+UID\\s+(\\d+).+/iA", $read_part, $reg)) {
                    $unique_id = $reg[1];
                }
            } else {
                $firstchar = strtoupper($read_part[0]);
                if ($firstchar == 'T') {
                    $regpattern = $patterns[0];
                    $id = 1;
                } else {
                    if ($firstchar == 'F') {
                        $regpattern = $patterns[1];
                        $id = 2;
                    } else {
                        if ($firstchar == 'X') {
                            $regpattern = $patterns[2];
                            $id = 3;
                        } else {
                            if ($firstchar == 'C') {
                                if (strtolower($read_part[1]) == 'c') {
                                    $regpattern = $patterns[3];
                                    $id = 4;
                                } else {
                                    if (strtolower($read_part[1]) == 'o') {
                                        $regpattern = $patterns[6];
                                        $id = 7;
                                    }
                                }
                            } else {
                                if ($firstchar == 'D' && !$internaldate) {
                                    $regpattern = $patterns[4];
                                    $id = 5;
                                } else {
                                    if ($firstchar == 'S') {
                                        $regpattern = $patterns[5];
                                        $id = 6;
                                    } else {
                                        $regpattern = '';
                                    }
                                }
                            }
                        }
                    }
                }
                if ($regpattern) {
                    if (preg_match($regpattern, $read_part, $regs)) {
                        switch ($id) {
                            case 1:
                                $to = trim($regs[1]);
                                break;
                            case 2:
                                $from = trim($regs[1]);
                                break;
                            case 3:
                                $priority = $regs[1];
                                break;
                            case 4:
                                $cc = trim($regs[1]);
                                break;
                            case 5:
                                $date = $regs[1];
                                break;
                            case 6:
                                $subject = trim($regs[1]);
                                if ($subject == "") {
                                    $subject = _("(no subject)");
                                }
                                break;
                            case 7:
                                $type = strtolower(trim($regs[1]));
                                if ($pos = strpos($type, ";")) {
                                    $type = substr($type, 0, $pos);
                                }
                                $type = explode("/", $type);
                                if (!is_array($type)) {
                                    $type[0] = 'text';
                                }
                                if (!isset($type[1])) {
                                    $type[1] = '';
                                }
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
        if (isset($date)) {
            $date = str_replace('  ', ' ', $date);
            $tmpdate = explode(' ', trim($date));
        } else {
            $tmpdate = $date = array('', '', '', '', '', '');
        }
        if ($uid_support) {
            $messages[$msgi]['ID'] = $unique_id;
        } else {
            $messages[$msgi]['ID'] = $msg_list[$msgi];
        }
        $messages[$msgi]['TIME_STAMP'] = getTimeStamp($tmpdate);
        $messages[$msgi]['DATE_STRING'] = getDateString($messages[$msgi]['TIME_STAMP']);
        $messages[$msgi]['FROM'] = parseAddress($from);
        $messages[$msgi]['SUBJECT'] = $subject;
        //        if (handleAsSent($mailbox)) {
        $messages[$msgi]['TO'] = parseAddress($to);
        //        }
        $messages[$msgi]['PRIORITY'] = $priority;
        $messages[$msgi]['CC'] = parseAddress($cc);
        $messages[$msgi]['SIZE'] = $size;
        $messages[$msgi]['TYPE0'] = $type[0];
        $messages[$msgi]['FLAG_DELETED'] = $flag_deleted;
        $messages[$msgi]['FLAG_ANSWERED'] = $flag_answered;
        $messages[$msgi]['FLAG_SEEN'] = $flag_seen;
        $messages[$msgi]['FLAG_FLAGGED'] = $flag_flagged;
        /* non server sort stuff */
        if (!$allow_server_sort) {
            $from = parseAddress($from);
            if ($from[0][1]) {
                $from = decodeHeader($from[0][1]);
            } else {
                $from = $from[0][0];
            }
            $messages[$msgi]['FROM-SORT'] = $from;
            $subject_sort = strtolower(decodeHeader($subject));
            if (preg_match("/^(vedr|sv|re|aw):\\s*(.*)\$/si", $subject_sort, $matches)) {
                $messages[$msgi]['SUBJECT-SORT'] = $matches[2];
            } else {
                $messages[$msgi]['SUBJECT-SORT'] = $subject_sort;
            }
        }
    }
    return $messages;
}
コード例 #20
0
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" . '         &nbsp;&nbsp;<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') . '         &nbsp;&nbsp;&nbsp;&nbsp;<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.&nbsp;' . 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" . '                          &nbsp;&nbsp;<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";
}
コード例 #21
0
function parseAddress($address, $max = 0, $addr_ar = array(), $group = '', $host = '')
{
    $pos = 0;
    $j = strlen($address);
    $personal = '';
    $addr = '';
    $comment = '';
    if ($max && ($max = count($addr_ar))) {
        return $addr_ar;
    }
    while ($pos < $j) {
        if ($max && ($max = count($addr_ar))) {
            return $addr_ar;
        }
        $char = $address[$pos];
        switch ($char) {
            case '=':
                if (preg_match('/^(=\\?([^?]*)\\?(Q|B)\\?([^?]*)\\?=)(.*)/Ui', substr($address, $pos), $reg)) {
                    if (!$personal) {
                        $personal = substr($address, 0, $pos);
                    }
                    $personal .= $reg[1];
                    $pos += strlen($personal);
                }
                ++$pos;
                break;
            case '"':
                /* get the personal name */
                ++$pos;
                if ($address[$pos] == '"') {
                    ++$pos;
                } else {
                    $personal_start = $personal_end = $pos;
                    while ($pos < $j) {
                        $personal_end = strpos($address, '"', $pos);
                        if ($personal_end - 2 > 0 && (substr($address, $personal_end - 2, 2) === '\\"' || substr($address, $personal_end - 2, 2) === '\\\\')) {
                            $pos = $personal_end + 1;
                        } else {
                            $personal = substr($address, $personal_start, $personal_end - $personal_start);
                            break;
                        }
                    }
                    if ($personal_end) {
                        /* prohibit endless loops due to very wrong addresses */
                        $pos = $personal_end + 1;
                    } else {
                        $pos = $j;
                    }
                }
                break;
            case '<':
                /* get email address */
                $addr_start = $pos;
                $addr_end = strpos($address, '>', $addr_start);
                $addr = substr($address, $addr_start + 1, $addr_end - $addr_start - 1);
                $pos = $addr_end + 1;
                break;
            case '(':
                /* rip off comments */
                $addr_start = $pos;
                $pos = strpos($address, ')');
                if ($pos !== false) {
                    $comment = substr($address, $addr_start + 1, $pos - $addr_start - 1);
                    $address_start = substr($address, 0, $addr_start);
                    $address_end = substr($address, $pos + 1);
                    $address = $address_start . $address_end;
                }
                $j = strlen($address);
                $pos = $addr_start + 1;
                break;
            case ',':
                /* we reached a delimiter */
                if ($addr == '') {
                    $addr = substr($address, 0, $pos);
                } else {
                    if ($personal == '') {
                        $personal = trim(substr($address, 0, $addr_start));
                    }
                }
                if (!$personal && $comment) {
                    $personal = $comment;
                }
                if ($personal) {
                    $personal = decodeHeader($personal);
                }
                $addr_ar[] = array($addr, $personal);
                $address = trim(substr($address, $pos + 1));
                $j = strlen($address);
                $pos = 0;
                $personal = '';
                $addr = '';
                break;
            case ':':
                /* process the group addresses */
                /* group marker */
                $group = substr($address, 0, $pos);
                $address = substr($address, $pos + 1);
                $result = parseAddress($address, $max, $addr_ar, $group);
                $addr_ar = array($result[0]);
                $pos = $result[1];
                $address = substr($address, $pos++);
                $j = strlen($address);
                $group = '';
                break;
            case ';':
                if ($group) {
                    $address = substr($address, 0, $pos - 1);
                }
                ++$pos;
                break;
            default:
                ++$pos;
                break;
        }
    }
    if ($addr == '') {
        $addr = substr($address, 0, $pos);
    } else {
        if ($personal == '') {
            $personal = trim(substr($address, 0, $addr_start));
        }
    }
    if (!$personal && $comment) {
        $personal = $comment;
    }
    $email = $addr;
    if ($group && $addr == '') {
        /* no addresses found in group */
        $personal = $group;
        $addr_ar[] = array('', $personal);
        return array($addr_ar, $pos + 1);
    } elseif ($group) {
        $addr_ar[] = array($addr, $personal);
        return array($addr_ar, $pos + 1);
    } else {
        if ($personal || $addr) {
            $addr_ar[] = array($addr, $personal);
        }
    }
    return $addr_ar;
}
コード例 #22
0
ファイル: read_body.php プロジェクト: teammember8/roundcube
function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee)
{
    global $default_use_mdn, $default_use_priority, $show_xmailer_default, $mdn_user_support, $PHP_SELF, $squirrelmail_language, $oTemplate;
    $mailbox = $aMailbox['NAME'];
    $header = $message->rfc822_header;
    $env = array();
    $env[_("Subject")] = str_replace("&nbsp;", " ", decodeHeader($header->subject));
    $from_name = $header->getAddr_s('from');
    if (!$from_name) {
        $from_name = $header->getAddr_s('sender');
    }
    if (!$from_name) {
        $env[_("From")] = _("Unknown sender");
    } else {
        $env[_("From")] = decodeHeader($from_name);
    }
    $env[_("Date")] = getLongDateString($header->date, $header->date_unparsed);
    $env[_("To")] = formatRecipientString($header->to, "to");
    $env[_("Cc")] = formatRecipientString($header->cc, "cc");
    $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
    if ($default_use_priority) {
        $oTemplate->assign('message_priority', $header->priority);
        $env[_("Priority")] = $oTemplate->fetch('read_message_priority.tpl');
    }
    if ($show_xmailer_default) {
        $oTemplate->assign('xmailer', decodeHeader($header->xmailer));
        $env[_("Mailer")] = $oTemplate->fetch('read_xmailer.tpl');
    }
    // this is used for both mdn and also general use for plugins, etc
    $oTemplate->assign('first_time_reading', $FirstTimeSee);
    if ($default_use_mdn) {
        if ($mdn_user_support) {
            if ($header->dnt) {
                $mdn_url = $PHP_SELF;
                $mdn_url = set_url_var($mdn_url, 'mailbox', urlencode($mailbox));
                $mdn_url = set_url_var($mdn_url, 'passed_id', $passed_id);
                $mdn_url = set_url_var($mdn_url, 'passed_ent_id', $passed_ent_id);
                $mdn_url = set_url_var($mdn_url, 'sendreceipt', 1);
                $oTemplate->assign('read_receipt_sent', $message->is_mdnsent);
                $oTemplate->assign('send_receipt_href', $mdn_url);
                $env[_("Read Receipt")] = $oTemplate->fetch('read_handle_receipt.tpl');
            }
        }
    }
    $statuses = array();
    if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS'])) {
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\deleted']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\deleted'] === true) {
            $statuses[] = _("deleted");
        }
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\answered']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\answered'] === true) {
            $statuses[] = _("answered");
        }
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\draft']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\draft'] === true) {
            $statuses[] = _("draft");
        }
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\flagged']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\flagged'] === true) {
            $statuses[] = _("flagged");
        }
        if (count($statuses)) {
            $env[_("Status")] = implode(', ', $statuses);
        }
    }
    $env[_("Options")] = formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
    $oTemplate->assign('headers_to_display', $env);
    $oTemplate->display('read_headers.tpl');
}