<?php
- /** mime.php
- **
- ** This contains the functions necessary to detect and decode MIME
- ** messages.
- **
- ** $Id$
- **/
-
- if (defined('mime_php'))
- return;
- define('mime_php', true);
-
- require_once('../functions/imap.php');
-
- /** Setting up the objects that have the structure for the message **/
- class msg_header {
- /** msg_header contains generic variables for values that **/
- /** could be in a header. **/
-
- var $type0 = '', $type1 = '', $boundary = '', $charset = '';
- var $encoding = '', $size = 0, $to = array(), $from = '', $date = '';
- var $cc = array(), $bcc = array(), $reply_to = '', $subject = '';
- var $id = 0, $mailbox = '', $description = '', $filename = '';
- var $entity_id = 0, $message_id = 0, $name = '';
- }
+/**
+ * mime.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This contains the functions necessary to detect and decode MIME
+ * messages.
+ *
+ * $Id$
+ */
+
+/*****************************************************************/
+/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
+/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
+/*** + Base level indent should begin at left margin, as ***/
+/*** the require_once below. ***/
+/*** + All identation should consist of four space blocks ***/
+/*** + Tab characters are evil. ***/
+/*** + all comments should use "slash-star ... star-slash" ***/
+/*** style -- no pound characters, no slash-slash style ***/
+/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
+/*** ALWAYS USE { AND } CHARACTERS!!! ***/
+/*** + Please use ' instead of ", when possible. Note " ***/
+/*** should always be used in _( ) function calls. ***/
+/*** Thank you for your help making the SM code more readable. ***/
+/*****************************************************************/
+
+require_once('../functions/imap.php');
+require_once('../functions/attachment_common.php');
+
+/** Setting up the objects that have the structure for the message **/
+class msg_header {
+ /** msg_header contains generic variables for values that **/
+ /** could be in a header. **/
+
+ var $type0 = '', $type1 = '', $boundary = '', $charset = '';
+ var $encoding = '', $size = 0, $to = array(), $from = '', $date = '';
+ var $cc = array(), $bcc = array(), $reply_to = '', $subject = '';
+ var $id = 0, $mailbox = '', $description = '', $filename = '';
+ var $entity_id = 0, $message_id = 0, $name = '';
+ // var $priority = "";
+}
class message {
/** message is the object that contains messages. It is a recursive
} else if (ereg('"([^"]*)"', $topline, $regs)) {
$ret = $regs[1];
} else {
- $ret = "Body retrival error. Please report this bug!\n" .
- "Response: $response\n" .
- "Message: $message\n" .
- "FETCH line: $topline" .
- "---------------\n$wholemessage";
-
- foreach ($data as $d) {
- $ret .= htmlspecialchars($d) . "\n";
+ global $where, $what, $mailbox, $passed_id, $startMessage;
+ $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id";
+ if (isset($where) && isset($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);
+
+ echo '<b><font color=$color[2]>Body retrieval error. The reason for this is most probably that<BR> ' .
+ 'the message is malformed. Please help us making future versions<BR> ' .
+ "better by submitting this message to the developers knowledgebase!<BR>\n" .
+ "<A HREF=\"../src/retrievalerror.php?$par\">Submit message</A><BR>" .
+
+ "<tt>Response: $response<BR>" .
+ "Message: $message<BR>" .
+ "FETCH line: $topline<BR></tt></font></b>";
+
+ fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
+ $data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
+ array_shift($data);
+ $wholemessage = implode('', $data);
+
+ $ret = "---------------\n$wholemessage";
+
}
return( $ret );
}
} else {
$body = formatAttachments ($message, -1, $message->header->mailbox, $id);
}
- return( $body );
+ return ($body);
}
// A recursive function that returns a list of attachments with links
if ($ShownHTML == 0) {
$ShownHTML = 1;
- $body .= "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=2 BORDER=0 BGCOLOR=\"$color[0]\"><TR>\n" .
+ $body .= "<TABLE WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2 BORDER=0 BGCOLOR=\"$color[0]\"><TR>\n" .
"<TH ALIGN=\"left\" BGCOLOR=\"$color[9]\"><B>\n" .
_("Attachments") . ':' .
"</B></TH></TR><TR><TD>\n" .
$body = quoted_printable_decode($body);
- /*
- Following code has been comented as I see no reason for it.
- If there is any please tell me a mingo@rotedic.com
-
while (ereg("=\n", $body))
$body = ereg_replace ("=\n", "", $body);
- */
+
} else if ($encoding == 'base64') {
$body = base64_decode($body);
}
// Encode only if the string contains 8-bit characters or =?
$j = strlen( $string );
- $l = FALSE; // Must be encoded ?
+ $l = strstr($string, '=?'); // Must be encoded ?
$ret = '';
for( $i=0; $i < $j; ++$i) {
switch( $string{$i} ) {
$ret .= '=3D';
break;
case '?':
- $l = TRUE;
$ret .= '=3F';
break;
case '_':
$j = strlen( $body ); // Legnth of the HTML
$ret = ''; // Returned string
$bgcolor = '#ffffff'; // Background style color (defaults to white)
+ $textcolor = '#000000'; // Foreground style color (defaults to black)
$leftmargin = ''; // Left margin style
$title = ''; // HTML title if any
$i = 0;
while( $i < $j ) {
if( $body{$i} == '<' ) {
- $tag = $body{$i+1}.$body{$i+2}.$body{$i+3}.$body{$i+4};
+ $pos = $i + 1;
+ $tag = '';
+ while ($body{$pos} == ' ' || $body{$pos} == "\t" ||
+ $body{$pos} == "\n")
+ $pos ++;
+ while (strlen($tag) < 4 && $body{$pos} != ' ' &&
+ $body{$pos} != "\t" && $body{$pos} != "\n") {
+ $tag .= $body{$pos};
+ $pos ++;
+ }
switch( strtoupper( $tag ) ) {
// Strips the entire tag and contents
case 'APPL':
$style .= $body{$i};
$i++;
}
- stripComments( &$i, $j, &$body );
+ stripComments( $i, $j, $body );
$style = strtoupper( trim( $style ) );
if( $style == 'BODY' ) {
// Next we look into the definitions of the body style
}
$styleblk .= $body{$i};
}
- stripComments( &$i, $j, &$body );
+ stripComments( $i, $j, $body );
if( $body{$i} <> '>' )
$i++;
}
$ret .= '<b>' . _("Title:") . " </b>$title<br>\n";
$ret .= "<TABLE";
$i += 5;
+ if (! isset($base))
+ $base = '';
$ret .= stripEvent( $i, $j, $body, $id, $base );
- //if( $bgcolor <> '' )
- $ret .= " bgcolor=$bgcolor";
- $ret .= ' width=100%><tr>';
+ $ret .= " bgcolor=$bgcolor width=\"100%\"><tr>";
if( $leftmargin <> '' )
$ret .= "<td width=$leftmargin> </td>";
$ret .= '<td>';
+ if (strtolower($bgcolor) == 'ffffff' ||
+ strtolower($bgcolor) == '#ffffff')
+ $ret .= '<font color=#000000>';
break;
case 'BASE':
$i += 5;
}
break;
case '/BOD':
- $ret .= '</td></tr></TABLE>';
+ $ret .= '</font></td></tr></TABLE>';
$i += 6;
break;
default:
// Following tags can contain some event handler, lets search it
stripComments( $i, $j, $body );
+ if (! isset($base))
+ $base = '';
$ret .= stripEvent( $i, $j, $body, $id, $base ) . '>';
// $ret .= "<!-- $tag detected -->";
}
return( $ret );
}
-?>
\ No newline at end of file
+?>