X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmime.php;h=f68d3717ba412cd63fec29986f9f4b3b2a1bce9f;hp=a1394a6647e2c632e9f20043219e0024de0f7c86;hb=034fddf9fea6ada6e708501c95b113ae6b9126ea;hpb=8196f7718f60f8b76a36c5d50c76b5d9c2ae2e4e diff --git a/functions/mime.php b/functions/mime.php index a1394a66..f68d3717 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -12,35 +12,8 @@ * $Id$ */ -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; - } -} +require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/attachment_common.php'); /* --------------------------------------------------------------------------------- */ /* MIME DECODING */ @@ -50,42 +23,69 @@ 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; - - // 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; + displayPageHeader( $color, urldecode($mailbox) ); + echo "
\n\n" . + '' . htmlspecialchars($read) . ' |