return( $pos );
}
-function mime_fetch_body ($imap_stream, $id, $ent_id ) {
- // 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)
+function mime_fetch_body($imap_stream, $id, $ent_id ) {
+
+ /*
+ * 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;
- $data = sqimap_run_command ($imap_stream, "FETCH $id BODY[$ent_id]", true, $response, $message);
+ }
+
+ $cmd = "FETCH $id BODY[$ent_id]";
+ $data = sqimap_run_command ($imap_stream, $cmd, true, $response, $message);
$topline = array_shift($data);
- while (! ereg('\\* [0-9]+ FETCH ', $topline) && $data)
+ while (! ereg('\\* [0-9]+ FETCH ', $topline) && $data) {
$topline = array_shift($data);
+ }
$wholemessage = implode('', $data);
if (ereg('\\{([^\\}]*)\\}', $topline, $regs)) {
$ret = substr( $wholemessage, 0, $regs[1] );
}
$k++;
}
- if ( $base <> '' )
-
+ if ( $base <> '' ) {
$ret = "<base href=\"$base\">" . $ret;
+ }
}
} else if (ereg('"([^"]*)"', $topline, $regs)) {
$ret = $regs[1];
} else {
global $where, $what, $mailbox, $passed_id, $startMessage;
- $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id";
+ $par = 'mailbox=' . urlencode($mailbox) . "&passed_id=$passed_id";
if (isset($where) && isset($what)) {
- $par .= "&where=".urlencode($where)."&what=".urlencode($what);
+ $par .= '&where='. urlencode($where) . "&what=" . urlencode($what);
} else {
$par .= "&startMessage=$startMessage&show_more=0";
}
- $par .= '&response='.urlencode($response).'&message='.urlencode($message).
- '&topline='.urlencode($topline);
+ $par .= '&response=' . urlencode($response) .
+ '&message=' . urlencode($message).
+ '&topline=' . urlencode($topline);
- echo '<b><font color=$color[2]>' .
+ echo '<tt><br>' .
+ '<table width="80%"><tr>' .
+ '<tr><td colspan=2>' .
_("Body retrieval error. The reason for this is most probably that the message is malformed. Please help us making future versions better by submitting this message to the developers knowledgebase!") .
- "<A HREF=\"../src/retrievalerror.php?$par\">Submit message</A><BR>" .
- '<tt>' . _("Response:") . "$response<BR>" .
- _("Message:") . " $message<BR>" .
- _("FETCH line:") . " $topline<BR></tt></font></b>";
+ " <A HREF=\"../src/retrievalerror.php?$par\"><br>" .
+ _("Submit message") . '</A><BR> ' .
+ '</td></tr>' .
+ '<td><b>' . _("Command:") . "</td><td>$cmd</td></tr>" .
+ '<td><b>' . _("Response:") . "</td><td>$response</td></tr>" .
+ '<td><b>' . _("Message:") . "</td><td>$message</td></tr>" .
+ '<td><b>' . _("FETCH line:") . "</td><td>$topline</td></tr>" .
+ "</table><BR></tt></font><hr>";
$data = sqimap_run_command ($imap_stream, "FETCH $passed_id BODY[]", true, $response, $message);
array_shift($data);
$wholemessage = implode('', $data);
- $ret = "---------------\n$wholemessage";
-
+ $ret = $wholemessage;
}
return( $ret );
}
if (!ini_get("safe_mode")) {
set_time_limit(0);
}
-
+
fputs ($imap_stream, "$sid FETCH $id BODY[$ent_id]\r\n");
$cnt = 0;
$continue = true;
* RFC1522 (MIME Part Two: Message Header Extensions for Non-ASCII Text).
*/
function decodeHeader ($string, $utfencode=true) {
- if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
+
+if ( is_array( $string ) ) {
+ $string = implode("\n", $string );
+}
+
+if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
$string, $res)) {
- if (ucfirst($res[2]) == 'B') {
+ if (ucfirst($res[2]) == 'B') {
$replace = base64_decode($res[3]);
- } else {
+ } else {
$replace = str_replace('_', ' ', $res[3]);
- // Convert lowercase Quoted Printable to uppercase for
- // quoted_printable_decode to understand it.
- while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))", $replace, $res)) {
- $replace = str_replace($res[1], strtoupper($res[1]), $replace);
- }
+ // Convert lowercase Quoted Printable to uppercase for
+ // quoted_printable_decode to understand it.
+ while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))",
+ $replace, $res)) {
+ $replace = str_replace($res[1], strtoupper($res[1]), $replace);
+ }
$replace = quoted_printable_decode($replace);
- }
- /* Only encode into entities by default. Some places
+ }
+ /* Only encode into entities by default. Some places
don't need the encoding, like the compose form. */
- if ($utfencode){
- $replace = charset_decode ($res[1], $replace);
- }
+ if ($utfencode){
+ $replace = charset_decode ($res[1], $replace);
+ }
+
+ // Remove the name of the character set.
+ $string = eregi_replace ('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
+ $replace, $string);
- // Remove the name of the character set.
- $string = eregi_replace ('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
- $replace, $string);
+ // In case there should be more encoding in the string: recurse
+ $string = decodeHeader($string);
+}
- // In case there should be more encoding in the string: recurse
- return (decodeHeader($string));
- } else
- return ($string);
+return ($string);
}
/*
if ( $l ) {
$string = "=?$default_charset?Q?$ret?=";
}
-
+
return( $string );
}
case '/HEA':
case '!DOC':
case 'META':
- case 'DIV ':
- case '/DIV':
+ //case 'DIV ':
+ //case '/DIV':
case '!-- ':
$i += 4;
while ( $body{$i} <> '>' &&
$src = '../images/' . _("sec_remove_eng.png");
}
$ret .= 'src="' . $src . '" ';
- $i = $k - 3;
+ $i = $k - 2;
} else {
$ret .= 'src';
$i = $i + 3;