more warnings removed
[squirrelmail.git] / src / download.php
index 03505fb3c7c28a35c9d7450e771c8a85fdbcb1f9..a5b0382a13ac9011286fc6671cb5116cf4e512cc 100644 (file)
@@ -7,12 +7,14 @@
     **
     **  Handles attachment downloads to the users computer.
     **  Also allows displaying of attachments when possible.
+    **
+    **  $Id$
     **/
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($imap_php))
       include("../functions/imap.php");
    if (!isset($mime_php))
    //    is displayable (text or html), it will load them up in a text
    //    viewer (built in to squirrelmail).  Otherwise, it sets the
    //    content-type as application/octet-stream
-
-   header("Pragma: ");
-   header("Content-Description: SquirrelMail Attachment");
-   if ($absolute_dl == "true") {
+   
+   if (isset($absolute_dl) && $absolute_dl == "true") {
       switch($type0) {
          case "text":
             $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
             $body = decodeBody($body, $header->encoding);
-            header("Content-Disposition: attachment; filename=$filename");
-            header("Content-type: application/octet-stream; name=$filename");
+            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 trim($body);
             break;
          default:
-            header("Content-Disposition: attachment; filename=$filename");
-            header("Content-type: application/octet-stream; name=$filename");
+            header("Content-Disposition: attachment; filename=\"$filename\"");
+            header("Content-type: application/octet-stream; name=\"$filename\"");
             mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $header->encoding);
             break;
       }
             } else {
                 $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
                 $body = decodeBody($body, $header->encoding);
-                header("Content-type: $type0/$type1; name=$filename");
-                header("Content-Disposition: attachment; filename=$filename");
+                header("Content-type: $type0/$type1; name=\"$filename\"");
+                header("Content-Disposition: attachment; filename=\"$filename\"");
                 echo $body;
             }
             break;