X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=a4588362c4a0b64eb3ebaeb0c7e3b11b82054287;hb=b7043f905faff3c0e7e6ab8bfe7a658372de3ce2;hp=c2edcfa1630d43c7a8b38955b5e0df6e71464184;hpb=0606ca1f5af67cd6a90fa695c8a33478a04d7a7f;p=squirrelmail.git diff --git a/src/read_body.php b/src/read_body.php index c2edcfa1..a4588362 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -1,91 +1,106 @@ $value) { + if ($passed_id == $value) { + if ($key == $count) { + break; + } + $result = $server_sort_array[$key + 1]; + break; } - } else { - for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { - if ($currentArrayIndex == $msgs[$key]['ID']) { - next($msort); + } + } else { + if (is_array($msort)) { + for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { + if ($passed_id == $msgs[$key]['ID']) { + next($msort); $key = key($msort); - if (isset($key)) + if (isset($key)){ $result = $msgs[$key]['ID']; break; + } } } } - return ($result); } + return $result; +} - /** Removes just one address from the list of addresses. */ - function RemoveAddress(&$addr_list, $addr) { - if ($addr != '') { - foreach (array_keys($addr_list, $addr) as $key_to_delete) { - unset($addr_list[$key_to_delete]); +/** + * Given an IMAP message id number, this will look it up in the cached + * and sorted msgs array and return the index of the previous message + * + * @param int $passed_id The current message UID + * @return the index of the next valid message from the array + */ +function findPreviousMessage($numMessages, $passed_id) { + global $msort, $sort, $msgs, + $thread_sort_messages, + $allow_server_sort, $server_sort_array; + $result = -1; + if (!is_array($server_sort_array)) { + $thread_sort_messages = 0; + $allow_server_sort = FALSE; + } + if ($thread_sort_messages || $allow_server_sort ) { + foreach($server_sort_array as $key=>$value) { + if ($passed_id == $value) { + if ($key == 0) { + break; + } + $result = $server_sort_array[$key - 1]; + break; } } - } - - /** returns the index of the previous message from the array. */ - function findPreviousMessage() { - global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection; - global $mailbox, $data_dir, $username; - $result = -1; - - if ($sort == 6) { - $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); - if ($currentArrayIndex != $numMessages) { - $result = $currentArrayIndex + 1; - } - } else { - for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { - if ($currentArrayIndex == $msgs[$key]['ID']) { + } else { + if (is_array($msort)) { + for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { + if ($passed_id == $msgs[$key]['ID']) { prev($msort); $key = key($msort); if (isset($key)) { @@ -94,565 +109,854 @@ require_once('../functions/url_parser.php'); } } } - } - return ($result); + } } + return $result; +} - /** - * Displays a link to a page where the message is displayed more - * "printer friendly". - */ - function printer_friendly_link() { - global $passed_id, $mailbox, $ent_num, $color; - global $pf_subtle_link; - global $javascript_on; +/** + * Displays a link to a page where the message is displayed more + * "printer friendly". + * @param string $mailbox Name of current mailbox + * @param int $passed_id + */ +function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) { + global $javascript_on, $color; + + $params = '?passed_ent_id=' . $passed_ent_id . + '&mailbox=' . urlencode($mailbox) . + '&passed_id=' . $passed_id; + + $print_text = _("View Printable Version"); + + $result = ''; + /* Output the link. */ + if ($javascript_on) { + $result = '\n" . + "$print_text\n"; + } else { + $result = '$print_text\n"; + } + return $result; +} - if (strlen(trim($mailbox)) < 1) { - $mailbox = 'INBOX'; - } +function ServerMDNSupport($read) { + /* escaping $ doesn't work -> \x36 */ + $ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read); + return $ret; +} - $params = '?passed_ent_id=' . $ent_num; - $params .= '&mailbox=' . urlencode($mailbox); - $params .= '&passed_id=' . $passed_id; +function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) { + global $username, $attachment_dir, + $version, $attachments, $squirrelmail_language, $default_charset, + $languages, $useSendmail, $domain, $sent_folder, + $popuser, $data_dir, $username; - $print_text = _("View Printable Version"); + sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER); - if (!$pf_subtle_link) { - /* The link is large, on the bottom of the header panel. */ - $result = '
';
-
- $cnum = 0;
- for ($i=1; $i < count($read); $i++) {
- $line = htmlspecialchars($read[$i]);
- if (eregi("^>", $line)) {
- $second[$i] = $line;
- $first[$i] = ' ';
- $cnum++;
- } else if (eregi("^[ |\t]", $line)) {
- $second[$i] = $line;
- $first[$i] = '';
- } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
- $first[$i] = $regs[1] . ':';
- $second[$i] = $regs[2];
- $cnum++;
+ // part 1 (RFC2298)
+ $senton = getLongDateString( $header->date );
+ $to_array = $header->to;
+ $to = '';
+ foreach ($to_array as $line) {
+ $to .= ' '.$line->getAddress();
+ }
+ $now = getLongDateString( time() );
+ set_my_charset();
+ $body = _("Your message") . "\r\n\r\n" .
+ "\t" . _("To:") . ' ' . decodeHeader($to,false,false) . "\r\n" .
+ "\t" . _("Subject:") . ' ' . decodeHeader($header->subject,false,false) . "\r\n" .
+ "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
+ "\r\n" .
+ sprintf( _("Was displayed on %s"), $now );
+
+ $special_encoding = '';
+ if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
+ function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
+ $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
+ if (strtolower($default_charset) == 'iso-2022-jp') {
+ if (mb_detect_encoding($body) == 'ASCII') {
+ $special_encoding = '8bit';
} else {
- $second[$i] = trim($line);
- $first[$i] = '';
- }
- }
- for ($i=0; $i < count($second); $i = $j) {
- if (isset($first[$i])) {
- $f = $first[$i];
- }
- if (isset($second[$i])) {
- $s = nl2br($second[$i]);
- }
- $j = $i + 1;
- while (($first[$j] == '') && ($j < count($first))) {
- $s .= ' ' . nl2br($second[$j]);
- $j++;
+ $body = mb_convert_encoding($body, 'JIS');
+ $special_encoding = '7bit';
}
- parseEmail($s);
- if (isset($f)) echo " |