浏览代码

get rid of getting the mime_structure of a message. HTML-messages with for
example 15 small inline-images caused 15 times a call to mime_get_structure.

Getting the mime-header is enough in most cases.

stekkel 23 年之前
父节点
当前提交
26b402586f
共有 1 个文件被更改,包括 13 次插入13 次删除
  1. 13 13
      src/download.php

+ 13 - 13
src/download.php

@@ -56,14 +56,18 @@ function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
          "</TT></TD></TR></TABLE>";
          "</TT></TD></TR></TABLE>";
 }
 }
 
 
-function viewMessage($imapConnection, $id, $mailbox, $ent_id, $msg, $color, $wrap_at) {
+function viewMessage($imapConnection, $id, $mailbox, $ent_id, $color, $wrap_at) {
     global $startMessage;
     global $startMessage;
+
+
+    $msg  = sqimap_get_message($imapConnection, $id, $mailbox);    
+    $msg = getEntity($msg, $ent_id);    
+
     $header = sqimap_get_ent_header($imapConnection,$id,$mailbox,$ent_id);
     $header = sqimap_get_ent_header($imapConnection,$id,$mailbox,$ent_id);
     $msg->header = $header;
     $msg->header = $header;
     $msg->header->id = $id;
     $msg->header->id = $id;
     $body = formatBody($imapConnection, $msg, $color, $wrap_at);
     $body = formatBody($imapConnection, $msg, $color, $wrap_at);
     $bodyheader = viewHeader($header, $color);
     $bodyheader = viewHeader($header, $color);
-
     displayPageHeader($color, 'None');
     displayPageHeader($color, 'None');
 
 
     echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
     echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
@@ -236,22 +240,18 @@ function formatRecipientString($recipients, $item ) {
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 sqimap_mailbox_select($imapConnection, $mailbox);
 sqimap_mailbox_select($imapConnection, $mailbox);
 
 
-/*
- * $message contains all information about the message
- * including header and body
- */
-$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
-
-$top_header = $message->header;
-
+if (isset($showHeaders)) {
+  $top_header = sqimap_get_message_header ($imapConnection, $passed_id, $mailbox);
+}
 /*
 /*
  * lets redefine message as this particular entity that we wish to display.
  * lets redefine message as this particular entity that we wish to display.
  * it should hold only the header for this entity.  We need to fetch the body
  * it should hold only the header for this entity.  We need to fetch the body
  * yet before we can display anything.
  * yet before we can display anything.
  */
  */
-$message = getEntity($message, $passed_ent_id);
 
 
-$header = $message->header;
+$header = sqimap_get_mime_ent_header ($imapConnection, $passed_id, $mailbox, $passed_ent_id);
+$header->entity_id = $passed_ent_id;
+$header->mailbox = $mailbox;
 
 
 $charset = $header->charset;
 $charset = $header->charset;
 $type0 = $header->type0;
 $type0 = $header->type0;
@@ -345,7 +345,7 @@ if (isset($absolute_dl) && $absolute_dl == 'true') {
         break;
         break;
     case 'message':
     case 'message':
 	if ($type1 == 'rfc822' ) {
 	if ($type1 == 'rfc822' ) {
-	    viewMessage($imapConnection, $passed_id, $mailbox, $passed_ent_id, $message, $color, $wrap_at);
+	    viewMessage($imapConnection, $passed_id, $mailbox, $passed_ent_id, $color, $wrap_at);
 	} else {
 	} else {
     	    $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
     	    $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
     	    $body = decodeBody($body, $msgheader->encoding);
     	    $body = decodeBody($body, $msgheader->encoding);