Bladeren bron

download related fixes

stekkel 23 jaren geleden
bovenliggende
commit
3ef0535ba5
5 gewijzigde bestanden met toevoegingen van 72 en 78 verwijderingen
  1. 10 17
      functions/attachment_common.php
  2. 7 2
      functions/mime.php
  3. 23 18
      src/download.php
  4. 26 38
      src/image.php
  5. 6 3
      src/read_body.php

+ 10 - 17
functions/attachment_common.php

@@ -115,7 +115,6 @@ function attachment_common_link_text(&$Args)
     $Args[6] = $Args[1]['attachment_common']['href'];
     $Args[6] = $Args[1]['attachment_common']['href'];
 }
 }
 
 
-
 function attachment_common_link_message(&$Args)
 function attachment_common_link_message(&$Args)
 {
 {
     $Args[1]['attachment_common']['href'] = '../src/read_body.php?startMessage=' .
     $Args[1]['attachment_common']['href'] = '../src/read_body.php?startMessage=' .
@@ -145,7 +144,6 @@ function attachment_common_link_html(&$Args)
     $Args[6] = $Args[1]['attachment_common']['href'];
     $Args[6] = $Args[1]['attachment_common']['href'];
 }
 }
 
 
-
 function attachment_common_link_image(&$Args)
 function attachment_common_link_image(&$Args)
 {
 {
     global $attachment_common_show_images, $attachment_common_show_images_list;
     global $attachment_common_show_images, $attachment_common_show_images_list;
@@ -156,14 +154,11 @@ function attachment_common_link_image(&$Args)
     
     
     $attachment_common_show_images_list[] = $info;
     $attachment_common_show_images_list[] = $info;
     
     
-    $Args[1]['attachment_common']['href'] = '../src/image.php?startMessage=' .
-        $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
-        '&passed_ent_id=' . $Args[5];
-    
-    if ($Args[8] && $Args[9]) {
-        $Args[1]['attachment_common']['href'] .= '&where=' . 
-        urlencode($Args[8]) . '&what=' . urlencode($Args[9]);
-    }
+    global $QUERY_STRING;
+    $Args[1]['attachment_common']['href'] = '../src/image.php?'. $QUERY_STRING;
+    $Args[1]['attachment_common']['href'] =
+          set_url_var($Args[1]['attachment_common']['href'], 
+	  'ent_id',$Args[5]);
   
   
     $Args[1]['attachment_common']['text'] = _("view");
     $Args[1]['attachment_common']['text'] = _("view");
     
     
@@ -174,13 +169,11 @@ function attachment_common_link_image(&$Args)
 
 
 function attachment_common_link_vcard(&$Args)
 function attachment_common_link_vcard(&$Args)
 {
 {
-    $Args[1]['attachment_common']['href'] = '../src/vcard.php?startMessage=' .
-        $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
-        '&passed_ent_id=' . $Args[5];
-  
-    if (isset($where) && isset($what))
-        $Args[1]['attachment_common']['href'] .= '&where=' . 
-        urlencode($Args[8]) . '&what=' . urlencode($Args[9]);
+    global $QUERY_STRING;
+    $Args[1]['attachment_common']['href'] = '../src/vcard.php?'. $QUERY_STRING;
+    $Args[1]['attachment_common']['href'] =
+          set_url_var($Args[1]['attachment_common']['href'], 
+	  'ent_id',$Args[5]);
   
   
     $Args[1]['attachment_common']['text'] = _("Business Card");
     $Args[1]['attachment_common']['text'] = _("Business Card");
   
   

+ 7 - 2
functions/mime.php

@@ -393,7 +393,7 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
         $name = '';
         $name = '';
         $Links['download link']['text'] = _("download");
         $Links['download link']['text'] = _("download");
         $Links['download link']['href'] =
         $Links['download link']['href'] =
-                "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent";
+                "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent";
         $ImageURL = '';
         $ImageURL = '';
         if ($type0 =='message' && $type1 == 'rfc822') {
         if ($type0 =='message' && $type1 == 'rfc822') {
             $default_page = '../src/read_body.php';
             $default_page = '../src/read_body.php';
@@ -438,9 +438,14 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
         }
         }
 
 
         $display_filename = $filename;
         $display_filename = $filename;
+	if (isset($passed_ent_id)) {
+	   $passed_ent_id_link = '&passed_ent_id='.$passed_ent_id;
+	} else {
+	   $passed_ent_id_link = '';
+	}
         $DefaultLink = $default_page . "?startMessage=$startMessage"
         $DefaultLink = $default_page . "?startMessage=$startMessage"
                      . "&passed_id=$id&mailbox=$urlMailbox"
                      . "&passed_id=$id&mailbox=$urlMailbox"
-                     . "&passed_ent_id=$ent";
+                     . '&ent_id='.$ent.$passed_ent_id_link;
         if ($where && $what) {
         if ($where && $what) {
            $DefaultLink = '&where='. urlencode($where).'&what='.urlencode($what);
            $DefaultLink = '&where='. urlencode($where).'&what='.urlencode($what);
         }
         }

+ 23 - 18
src/download.php

@@ -43,10 +43,16 @@ if (!isset($passed_ent_id)) {
 }
 }
 
 
 $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
 $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
-$message = &$message->getEntity($passed_ent_id);
-
+$subject = $message->rfc822_header->subject;
+$message = &$message->getEntity($ent_id);
 $header = $message->header;
 $header = $message->header;
-$charset = $header->getParameter('charset');
+if ($message->rfc822_header) {
+   $subject = $message->rfc822_header->subject;
+   $charset = $header->content_type->properties['charset'];
+} else {
+   $header = $message->header;
+   $charset = $header->getParameter('charset');
+}
 $type0 = $header->type0;
 $type0 = $header->type0;
 $type1 = $header->type1;
 $type1 = $header->type1;
 $encoding = strtolower($header->encoding);
 $encoding = strtolower($header->encoding);
@@ -85,34 +91,34 @@ if (isset($override_type0)) {
 if (isset($override_type1)) {
 if (isset($override_type1)) {
     $type1 = $override_type1;
     $type1 = $override_type1;
 }
 }
-
-$filename = decodeHeader($message->header->getParameter('filename'));
-
-if (!$filename) {
-    $filename = decodeHeader($message->header->getParameter('name'));
+$filename = '';
+if (is_object($message->header->disposition)) {
+    $filename = decodeHeader($header->disposition->getProperty('filename'));
+    if (!$filename) {
+	$filename = decodeHeader($header->disposition->getProperty('name'));
+    }
 }
 }
-
 if (strlen($filename) < 1) {
 if (strlen($filename) < 1) {
     if ($type1 == 'plain' && $type0 == 'text') {
     if ($type1 == 'plain' && $type0 == 'text') {
         $suffix = 'txt';
         $suffix = 'txt';
-	$filename = $header->subject . '.txt';
+	$filename = $subject . '.txt';
     } else if ($type1 == 'richtext' && $type0 == 'text') {
     } else if ($type1 == 'richtext' && $type0 == 'text') {
         $suffix = 'rtf';
         $suffix = 'rtf';
-	$filename = $header->subject . '.rtf';
+	$filename = $subject . '.rtf';
     } else if ($type1 == 'postscript' && $type0 == 'application') {
     } else if ($type1 == 'postscript' && $type0 == 'application') {
         $suffix = 'ps';
         $suffix = 'ps';
-	$filename = $header->subject . '.ps';
+	$filename = $subject . '.ps';
     } else if ($type1 == 'rfc822' && $type0 == 'message') {
     } else if ($type1 == 'rfc822' && $type0 == 'message') {
         $suffix = 'eml';
         $suffix = 'eml';
-	$filename = $header->subject . '.msg';
+	$filename = $subject . '.msg';
     } else {
     } else {
         $suffix = $type1;
         $suffix = $type1;
     }
     }
 
 
     if (strlen($filename) < 1) {
     if (strlen($filename) < 1) {
-    $filename = "untitled$passed_ent_id.$suffix";
+       $filename = "untitled$ent_id.$suffix";
     } else {
     } else {
-    $filename = "$filename.$suffix";
+       $filename = "$filename.$suffix";
     }
     }
 }
 }
 
 
@@ -138,12 +144,11 @@ if (isset($absolute_dl) && $absolute_dl == 'true') {
 }
 }
 /* be aware that any warning caused by download.php will corrupt the
 /* be aware that any warning caused by download.php will corrupt the
  * attachment in case of ERROR reporting = E_ALL and the output is the screen */
  * attachment in case of ERROR reporting = E_ALL and the output is the screen */
-mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $encoding);
+mime_print_body_lines ($imapConnection, $passed_id, $ent_id, $encoding);
 
 
-/*
 $message = &$message->getEntity('');
 $message = &$message->getEntity('');
 $messages[$mbx_response['UIDVALIDITY']]["$passed_id"] = &$message;
 $messages[$mbx_response['UIDVALIDITY']]["$passed_id"] = &$message;
-*/
+
 /*
 /*
  * This function is verified to work with Netscape and the *very latest*
  * This function is verified to work with Netscape and the *very latest*
  * version of IE.  I don't know if it works with Opera, but it should now.
  * version of IE.  I don't know if it works with Opera, but it should now.

+ 26 - 38
src/image.php

@@ -14,50 +14,38 @@
 require_once('../src/validate.php');
 require_once('../src/validate.php');
 require_once('../functions/date.php');
 require_once('../functions/date.php');
 require_once('../functions/page_header.php');
 require_once('../functions/page_header.php');
-require_once('../src/load_prefs.php');
 require_once('../functions/html.php');
 require_once('../functions/html.php');
+require_once('../src/load_prefs.php');
 
 
 displayPageHeader($color, 'None');
 displayPageHeader($color, 'None');
 
 
-if (isset($where) && isset($what)) {
-  // from a search
-  $ViewMessageLink = '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
-        '&amp;passed_id=' . $passed_id . '&amp;where=' . urlencode($where) . 
-        '&amp;what=' . urlencode($what). '">' . _("View message") . '</a>';
-} else {   
-  $ViewMessageLink = '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
-       '&amp;passed_id=' . $passed_id . '&amp;startMessage=' . $startMessage .
-       '&amp;show_more=0">' . _("View message") . '</a>';
-}
+echo '<BR>' . 
+    '<TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
+    "\n" .
+    '<TR><TD BGCOLOR="' . $color[0] . '">' .
+    '<B><CENTER>' .
+    _("Viewing an image attachment") . " - ";
+
+$msg_url = 'read_body.php?' . $QUERY_STRING;
+$msg_url = set_url_var($msg_url, 'ent_id', 0);
+echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
+
 
 
 $DownloadLink = '../src/download.php?passed_id=' . $passed_id .
 $DownloadLink = '../src/download.php?passed_id=' . $passed_id .
                '&amp;mailbox=' . urlencode($mailbox) . 
                '&amp;mailbox=' . urlencode($mailbox) . 
-               '&amp;passed_ent_id=' . $passed_ent_id . '&amp;absolute_dl=true';
-
-echo '<br>' . 
-    html_tag( 'table',
-        html_tag( 'tr',
-        html_tag( 'td',
-                '<b>' .
-                _("Viewing an image attachment") . ' - ' .
-                $ViewMessageLink . '</b>' ,
-          'center', $color[0] )
-         ) .
-        html_tag( 'tr',
-        html_tag( 'td',
-                    '<a href="' . $DownloadLink . '">' .
-		    _("Download this as a file") .
-                    '</a><br>&nbsp;' . "\n" ,
-          'center' )
-         ) ,
-     'center', '', 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) .
-
-    html_tag( 'table',
-        html_tag( 'tr',
-        html_tag( 'td',
-                '<img src="' . $DownloadLink . '">'
-        , 'left', $color[4] )
-         )
-   , 'center', '', 'border="0" cellspacing="0" cellpadding="2"' );
+               '&amp;ent_id=' . $ent_id . '&amp;absolute_dl=true';
+
+echo '</b></td></tr>' . "\n" .
+    '<tr><td align=center><A HREF="' . $DownloadLink . '">' .
+    _("Download this as a file") .
+    '</A></B><BR>&nbsp;' . "\n" .
+    '</TD></TR></TABLE>' . "\n" .
+
+    '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' . "\n" .
+    '<TR><TD BGCOLOR="' . $color[4] . '">' .
+    '<img src="' . $DownloadLink . '">' .
+
+    '</TD></TR></TABLE>' . "\n";
+    '</body></html>' . "\n";
 
 
 ?>
 ?>

+ 6 - 3
src/read_body.php

@@ -485,9 +485,9 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
    $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
    $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
    if ($compose_new_win == '1') {
    if ($compose_new_win == '1') {
       $s .= '<a href="javascript:void(0)" '. 
       $s .= '<a href="javascript:void(0)" '. 
-            'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as Attachment").'</a>';
+            'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as attachment").'</a>';
    } else {
    } else {
-      $s .= '<a href="'.$comp_action_uri.'">'._("Forward as Attachment").'</a>';
+      $s .= '<a href="'.$comp_action_uri.'">'._("Forward as attachment").'</a>';
    }
    }
    $s .= $topbar_delimiter;
    $s .= $topbar_delimiter;
 
 
@@ -586,6 +586,9 @@ $messages[$uidvalidity][$passed_id] = $message;
 
 
 if (isset($passed_ent_id) && $passed_ent_id) {
 if (isset($passed_ent_id) && $passed_ent_id) {
    $message = $message->getEntity($passed_ent_id);
    $message = $message->getEntity($passed_ent_id);
+   if ($message->type0 != 'message'  && $message->type1 != 'rfc822') {
+      $message = $message->parent;
+   }
    $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support);
    $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support);
    $rfc822_header = new rfc822_header();
    $rfc822_header = new rfc822_header();
    $rfc822_header->parseHeader($read);
    $rfc822_header->parseHeader($read);
@@ -681,7 +684,7 @@ if (($attachment_common_show_images) &&
                 '?' .
                 '?' .
                 'passed_id='     . urlencode($img['passed_id']) .
                 'passed_id='     . urlencode($img['passed_id']) .
                 '&amp;mailbox='       . urlencode($mailbox) .
                 '&amp;mailbox='       . urlencode($mailbox) .
-                '&amp;passed_ent_id=' . urlencode($img['ent_id']) .
+                '&amp;ent_id=' . urlencode($img['ent_id']) .
                 '&amp;absolute_dl=true';
                 '&amp;absolute_dl=true';
 
 
         echo html_tag( 'table', "\n" .
         echo html_tag( 'table', "\n" .