X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmime.php;h=28c7e5545f03ffe7e48a6c58d2a398ee6e214069;hp=4cc1ccaa11c9c72c3b3dc8a9b9b7b9f3eae4b65b;hb=19d470aa121cacdd916319ec6b55af180562805e;hpb=43fdb2a474b990b8b7db21bfb05b30a70ac768a0;ds=sidebyside diff --git a/functions/mime.php b/functions/mime.php index 4cc1ccaa..28c7e554 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -15,33 +15,6 @@ 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 - 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 = ''; - var $entities = array(); - - function addEntity ($msg) { - $this->entities[] = $msg; - } -} - /* --------------------------------------------------------------------------------- */ /* MIME DECODING */ /* --------------------------------------------------------------------------------- */ @@ -50,38 +23,64 @@ class message { * 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) { - - sqimap_messages_flag ($imap_stream, $header->id, $header->id, 'Seen'); - $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, 10000); - $bodystructure = ''; - while ( substr($read, 0, $lsid) <> $ssid && - !feof( $imap_stream ) ) { - $bodystructure .= $read; - $read = fgets ($imap_stream, 10000); - } - $read = $bodystructure; - + +function mime_structure ($bodystructure, $flags=array()) { + // isolate the body structure and remove beginning and end parenthesis - $read = trim(substr ($read, strpos(strtolower($read), 'bodystructure') + 13)); + $read = trim(substr ($bodystructure, strpos(strtolower($bodystructure), 'bodystructure') + 13)); + $msg =& new Message(); $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); + $res = $msg->parseStructure($read); + $msg = $res[0]; + if (!is_object($msg)) { + include_once( '../functions/display_messages.php' ); + global $color, $mailbox; + displayPageHeader( $color, urldecode($mailbox) ); + echo "
\n\n" . + ''.htmlspecialchars($read).' |