X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=20d476e700796d428407c9770850967502b6bd17;hb=7af26ef836641288a0a4a4e0deff817b1ca60878;hp=7a726a2217ba99861eb1211ac08fc650124f6f8a;hpb=ec41cfc7ff0a557b1edf4ee29929003944816fe1;p=squirrelmail.git
diff --git a/functions/mime.php b/functions/mime.php
index 7a726a22..20d476e7 100644
--- a/functions/mime.php
+++ b/functions/mime.php
@@ -3,7 +3,7 @@
/**
* mime.php
*
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 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
@@ -12,78 +12,78 @@
* $Id$
*/
-require_once('../functions/imap.php');
-require_once('../functions/attachment_common.php');
+require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . '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 = '',
- $encoding = '', $size = 0, $to = array(), $from = '', $date = '',
- $cc = array(), $bcc = array(), $reply_to = '', $subject = '',
- $id = 0, $mailbox = '', $description = '', $filename = '',
- $entity_id = 0, $message_id = 0, $name = '', $priority = 3, $type = '';
-}
-
-class message {
- /** message is the object that contains messages. It is a recursive
- object in that through the $entities variable, it can contain
- more objects of type message. See documentation in mime.txt for
- a better description of how this works.
- **/
- var $header = '', $entities = array();
-
- function addEntity ($msg) {
- $this->entities[] = $msg;
- }
-}
-
-/* --------------------------------------------------------------------------------- */
-/* MIME DECODING */
-/* --------------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+/* MIME DECODING */
+/* -------------------------------------------------------------------------- */
/* This function gets the structure of a message and stores it in the "message" class.
* It will return this object for use with all relevant header information and
* fully parsed into the standard "message" object format.
*/
-function mime_structure ($imap_stream, $header) {
-
- $ssid = sqimap_session_id();
- $lsid = strlen( $ssid );
- $id = $header->id;
- fputs ($imap_stream, "$ssid FETCH $id BODYSTRUCTURE\r\n");
- //
- // This should use sqimap_read_data instead of reading it itself
- //
- $read = fgets ($imap_stream, 9216);
- $bodystructure = '';
- while ( substr($read, 0, $lsid) <> $ssid &&
- !feof( $imap_stream ) ) {
- $bodystructure .= $read;
- $read = fgets ($imap_stream, 9216);
- }
- $read = $bodystructure;
- // isolate the body structure and remove beginning and end parenthesis
- $read = trim(substr ($read, strpos(strtolower($read), 'bodystructure') + 13));
+function mime_structure ($bodystructure, $flags=array()) {
+ /* Isolate the body structure and remove beginning and end parenthesis. */
+ $read = trim(substr ($bodystructure, strpos(strtolower($bodystructure), 'bodystructure') + 13));
$read = trim(substr ($read, 0, -1));
- $end = mime_match_parenthesis(0, $read);
- while ($end == strlen($read)-1) {
- $read = trim(substr ($read, 0, -1));
- $read = trim(substr ($read, 1));
- $end = mime_match_parenthesis(0, $read);
+ $i = 0;
+ $msg = Message::parseStructure($read,$i);
+ if (!is_object($msg)) {
+ include_once(SM_PATH . 'functions/display_messages.php');
+ global $color, $mailbox;
+ /* removed urldecode because $_GET is auto urldecoded ??? */
+ displayPageHeader( $color, $mailbox );
+ $errormessage = _("SquirrelMail could not decode the bodystructure of the message");
+ $errormessage .= '
'._("the provided bodystructure by your imap-server").':
';
+ $errormessage .= '
' . htmlspecialchars($read) . ''; + plain_error_message( $errormessage, $color ); + echo '