Print javascript Content-Type to be HTML 4.0 complient
[squirrelmail.git] / src / read_body.php
index fc08e01c9992679a421c5e37bb3cbf18aee81d8d..3f0f0bbe8ebf805a98678772dd46d978ec841249 100644 (file)
@@ -139,25 +139,8 @@ function printer_friendly_link() {
 }
 
 function ServerMDNSupport( $read ) {
-
-    $num = 0;
-    $resp = '';
-    while ($num < count($read) ) {
-        $resp .= $read[$num];
-        $num++;
-    }
-    $read[] = split(' * ', $resp);
-    $num = 0;
-    $ret = FALSE;
-    while ( !$ret && $num < count($read) ) {
-        $ret = preg_match( '/.*PERMANENTFLAGS.*(MDNSent|\\\*).*/i', $read[$num] );
-        /*
-        if ( ereg('PERMANENTFLAGS', $read[$num] ) ) {
-            $ret = ( ereg('mdnsent',strtolower($read[$num]) ) || ereg("\\\*", $read[$num] ) );
-        }
-        */
-        $num++;
-    }
+    /* escaping $ doesn't work -> \x36 */    
+    $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
     return ( $ret );
 }
 
@@ -186,12 +169,7 @@ function SendMDN ( $recipient , $sender) {
             "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
             "\r\n" .
             sprintf( _("Was displayed on %s"), $now );
-/*
-    $body = sprintf( _("This message sent on %s to %s with subject \"%s\" has been displayed on %s."),
-                      $senton, $to, $subject, $now ) .
-            "\r\n" .
-            _("This is no guarantee that the message has been read or understood.") . "\r\n";
-*/
+
     // part2  (RFC2298)
 
     $original_recipient = $to;
@@ -227,20 +205,13 @@ function SendMDN ( $recipient , $sender) {
 
 
 function ToggleMDNflag ( $set ) {
-
     global $imapConnection, $passed_id, $mailbox;
-
-    if ( $set ) {
-        $sg = '+';
-
-    } else {
-        $sg = '-';
-    }
-
-    $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
     sqimap_mailbox_select($imapConnection, $mailbox);
-    $read = sqimap_run_command ($imapConnection, $cmd, true, $response, $readmessage);
-
+    
+    $sg =  $set?'+':'-';
+    $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
+    $read = sqimap_run_command ($imapConnection, $cmd, true, $response, 
+                                $readmessage);
 }
 
 function ClearAttachments() {
@@ -269,8 +240,11 @@ function ClearAttachments() {
     $passed_id
 */
 
+if ( isset( $mailbox ) ) {
+    $mailbox = urldecode( $mailbox );
+}
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-$read = sqimap_mailbox_select($imapConnection, $mailbox);
+$read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
 
 do_hook('html_top');
 
@@ -280,7 +254,7 @@ do_hook('html_top');
 if( $default_use_mdn &&
     ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
 
-    $supportMDN = ServerMDNSupport($read);
+    $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
     $flags = sqimap_get_flags ($imapConnection, $passed_id);
     $FirstTimeSee = !(in_array( 'Seen', $flags ));
 }
@@ -809,7 +783,7 @@ if ($default_use_mdn) {
     if ($mdn_user_support) {
 
         // debug gives you the capability to remove mdn-flags
-        $debug = false;
+        $MDNDebug = false;
         $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
                                 $response, $readmessage);
         $MDN_to = substr($read[1], strpos($read[1], ' '));
@@ -827,7 +801,7 @@ if ($default_use_mdn) {
                 $sendreceipt = 'removeMDN';
                 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
                 $sendreceipt="";
-                if ($debug ) {
+                if ($MDNDebug ) {
                     echo       '<TR>' .
                                  "<TD BGCOLOR=\"$color[9]\"  ALIGN=RIGHT VALIGN=TOP>" .
                                        _("Read receipt") . ': ' .
@@ -848,7 +822,7 @@ if ($default_use_mdn) {
                 }
 
             } // when deleted or draft flag is set don't offer to send a MDN response
-            else if ( ereg('Draft',$read[0] || ereg('Deleted',$read[0])) ) {
+            else if ( ereg('\\Draft',$read[0] || ereg('\\Deleted',$read[0])) ) {
                 echo       '<TR>' .
                             "<TD BGCOLOR=\"$color[9]\"  ALIGN=RIGHT VALIGN=TOP>" .
                                 _("Read receipt") . ': '.
@@ -920,7 +894,7 @@ if ($default_use_mdn) {
             $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
             $sendreceipt="";
 
-            if ($debug && $supportMDN) {
+            if ($MDNDebug && $supportMDN) {
             echo "      <TR>\n" .
                     "         <TD BGCOLOR=\"$color[9]\"  ALIGN=RIGHT VALIGN=TOP>\n" .
                     "            "._("Read receipt").": \n".