fputs ($imap_stream, "a001 FETCH $id BODY[$ent_id]\r\n");
$topline = fgets ($imap_stream, 1024);
- $size = substr ($topline, strpos($topline, "{")+1);
- $size = substr ($size, 0, strpos($size, "}"));
- $read = fread ($imap_stream, $size);
- return $read;
+ if (ereg('\{([^\}]*)\}', $topline, $regs)) {
+ return fread ($imap_stream, $regs[1]);
+ }
+ else if (ereg('"([^"]*)"', $topline, $regs)) {
+ return $regs[1];
+ }
+ return "Body retrival error, please report this bug!\n\nTop line is \"$topline\"\n";
}
/* -[ END MIME DECODING ]----------------------------------------------------------- */
// If there are other types that shouldn't be formatted, add
// them here
- if ($message->header->type1 != "html") {
+ if ($body_message->header->type1 != "html") {
translateText($body, $wrap_at, $body_message->header->charset);
}
$HookResults = do_hook("attachment $type0/$type1", $Links,
$startMessage, $id, $urlMailbox, $ent, $DefaultLink,
- $where, $what);
+ $display_filename, $where, $what);
$Links = $HookResults[1];
$DefaultLink = $HookResults[6];
$body .= '<TR><TD> </TD><TD>';
$body .= "<A HREF=\"$DefaultLink\">$display_filename</A> </TD>";
- $size = $message->header->size / 1024;
- settype($size, "integer");
- $body .= "<TD><SMALL><b>" . $size . "k</b> </small></TD>";
+ $body .= '<TD><SMALL><b>' . show_readable_size($message->header->size) .
+ '</b> </small></TD>';
$body .= "<TD><SMALL>[ $type0/$type1 ] </SMALL></TD>";
$body .= '<TD><SMALL>';
if ($message->header->description)
global $default_charset;
// Encode only if the string contains 8-bit characters or =?
- if (ereg("([\200-\377])|=\\?", $string)) {
+ if (ereg("([\200-\377]|=\\?)", $string)) {
$newstring = "=?$default_charset?Q?";
// First the special characters