fixed uninitialized urlMailbox bug on bug list
[squirrelmail.git] / src / download.php
index a796ea55b032dcda9a8278777dad968944a0ddfa..a74796399bb58a698909c3ae6c0e4796a27d2bdc 100644 (file)
       include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
-   if (!isset($page_header_php))
-      include("../functions/page_header.php");
    if (!isset($imap_php))
       include("../functions/imap.php");
    if (!isset($mime_php))
       include("../functions/mime.php");
    if (!isset($date_php))
       include("../functions/date.php");
+   if (!isset($i18n_php))
+      include("../functions/i18n.php");
 
    include("../src/load_prefs.php");
 
    function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
       global $where, $what, $charset;
       global $startMessage;
+
+      
       displayPageHeader($color, "None");
 
       echo "<BR><TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
       echo "<TABLE WIDTH=98% BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
       echo "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
 
-      if ($type1 == "html")
-         echo $body;
-      else
-         echo translateText($body, $wrap_at, $charset);
+      if ($type1 != "html")
+         translateText($body, $wrap_at, $charset);
+      
+      echo $body;
 
       echo "</TT></TD></TR></TABLE>";
    }
             $body = decodeBody($body, $header->encoding);
             header("Content-Disposition: attachment; filename=\"$filename\"");
             header("Content-type: application/octet-stream; name=\"$filename\"");
+            set_up_language(getPref($data_dir, $username, "language"));
             if ($type1 == "plain") {
                echo _("Subject") . ": " . decodeHeader(sqStripSlashes($top_header->subject)) . "\n";
                echo "   " . _("From") . ": " . decodeHeader(sqStripSlashes($top_header->from)) . "\n";
       switch ($type0) {
          case "text":
             $body = decodeBody($body, $header->encoding);
+            include("../functions/page_header.php");
             viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
             break;
          case "message":
             $body = decodeBody($body, $header->encoding);
+            include("../functions/page_header.php");
             viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
             break;
          default:
       }
    }
 
+   sqimap_mailbox_close($imapConnection);
    sqimap_logout($imapConnection);
 ?>