+ fputs ($imap_stream, "a010 FETCH $id BODY[$ent_id]\r\n");
+ $data = sqimap_read_data ($imap_stream, 'a010', true, $response, $message);
+ $topline = array_shift($data);
+ while (! ereg('\\* [0-9]+ FETCH ', $topline) && $data)
+ $topline = array_shift($data);
+ $wholemessage = implode('', $data);
+
+ if (ereg('\\{([^\\}]*)\\}', $topline, $regs)) {
+ return substr($wholemessage, 0, $regs[1]);
+ }
+ else if (ereg('"([^"]*)"', $topline, $regs)) {
+ return $regs[1];
+ }
+
+ $str = "Body retrival error. Please report this bug!\n";
+ $str .= "Response: $response\n";
+ $str .= "Message: $message\n";
+ $str .= "FETCH line: $topline";
+ $str .= "---------------\n$wholemessage";
+ foreach ($data as $d)
+ {
+ $str .= htmlspecialchars($d) . "\n";
+ }
+ return $str;
+ }
+
+ function mime_print_body_lines ($imap_stream, $id, $ent_id, $encoding) {
+ // do a bit of error correction. If we couldn't find the entity id, just guess
+ // that it is the first one. That is usually the case anyway.
+ if (!$ent_id) $ent_id = 1;
+
+ // Don't kill the connection if the browser is over a dialup
+ // and it would take over 30 seconds to download it.
+ set_time_limit(0);
+