Fixed a bug in displaying email addresses in the message list.
[squirrelmail.git] / functions / mailbox.php
index 4cfec18484f13443d32e1ed059121f6c9b32b97f..b07e2543a544c06d7202233c9e76a14702eb3105 100644 (file)
@@ -49,7 +49,7 @@
    function getMessageHeaders($imapConnection, $start, $end, &$from, &$subject, &$date) {
       $rel_start = $start;
       if (($start > $end) || ($start < 1)) {
-         echo "Error in message header fetching.  Start message: $start, End message: $end<BR>";
+         echo _("Error in message header fetching.  Start message: "). $start, _("End message: "). "$end<BR>";
          exit;
       }
 
     **  individually.  I'm not sure why it happens like that, but that's what my
     **  testing found.  Perhaps later I will be proven wrong and this will change.
     **/
-   function getMessageFlags($imapConnection, $j, &$flags) {
+   function getMessageFlags($imapConnection, $low, $high, &$flags) {
       /**   * 2 FETCH (FLAGS (\Answered \Seen))   */
-      fputs($imapConnection, "messageFetch FETCH $j:$j FLAGS\n");
+      fputs($imapConnection, "messageFetch FETCH $low:$high FLAGS\n");
       $read = fgets($imapConnection, 1024);
       $count = 0;
       while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
          if (strpos($read, "FLAGS")) {
             $read = ereg_replace("\(", "", $read);
             $read = ereg_replace("\)", "", $read);
+            $read = str_replace("\\", "", $read);
             $read = substr($read, strpos($read, "FLAGS")+6, strlen($read));
             $read = trim($read);
-            $flags = explode(" ", $read);;
-            $s = 0;
-            while ($s < count($flags)) {
-               $flags[$s] = substr($flags[$s], 1, strlen($flags[$s]));
-               $s++;
-            }
+            $flags[$count] = explode(" ", $read);;
          } else {
-            $flags[0] = "None";
+            $flags[$count][0] = "None";
          }
          $count++;
          $read = fgets($imapConnection, 1024);
          $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
          $from = $emailAddr;
       }
-      else if (strlen($name) > 0) {
+      else if (strlen(trim($name)) > 0) {
          $from = $name;
       }
       else if (strlen($emailAddr > 0)) {
    function expungeBox($imapConnection, $mailbox) {
       selectMailbox($imapConnection, $mailbox, $num);
       fputs($imapConnection, "1 EXPUNGE\n");
+      imapReadData($imapConnection, "1", true, $response, $message);
    }
 
    function getFolderNameMinusINBOX($mailbox, $del) {
       $read = $entity;
    }
 
-   function parseHTMLMessage($line) {
-      /** Add any parsing you want to in here **/
-      return $line;
-   }
-
-   function parsePlainTextMessage($line) {
-      /** Add any parsing you want to in here */
-
-      $line = "^^$line";
-
-      if ((strpos(strtolower($line), "<!") == false) &&
-          (strpos(strtolower($line), "<html>") == false) &&
-          (strpos(strtolower($line), "</html>") == false)) {
-         $line = str_replace("<", "&lt;", $line);
-         $line = str_replace(">", "&gt;", $line);
-      }
-
-      $wrap_at = 86; // Make this configurable int the config file some time
-      if (strlen($line) - 2 >= $wrap_at) // -2 because of the ^^ at the beginning
-         $line = wordWrap($line, $wrap_at);
-
-      $line = str_replace(" ", "&nbsp;", $line);
-      $line = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
-      $line = str_replace("\n", "", $line);
-
-      if (strpos(trim(str_replace("&nbsp;", "", $line)), "&gt;&gt;") == 2) {
-         $line = substr($line, 2, strlen($line));
-         $line = "<TT><FONT COLOR=FF0000>$line</FONT></TT><BR>\n";
-      } else if (strpos(trim(str_replace("&nbsp;", "", $line)), "&gt;") == 2) {
-         $line = substr($line, 2, strlen($line));
-         $line = "<TT><FONT COLOR=800000>$line</FONT></TT><BR>\n";
-      } else {
-         $line = substr($line, 2, strlen($line));
-         $line = "<TT><FONT COLOR=000000>$line</FONT></TT><BR>\n";
-      }
-
-      if (strpos(strtolower($line), "http://") != false) {
-         $line = ereg_replace("<BR>", "", $line);
-         $start = strpos(strtolower($line), "http://");
-         $link = substr($line, $start, strlen($line));
-
-         if (strpos($link, " ")) {
-            $end = strpos($link, " ")-1;
-         }
-         else if (strpos($link, "&nbsp;")) {
-            $end = strpos($link, "&nbsp;")-1;
-         }
-         else if (strpos($link, "<")) {
-            $end = strpos($link, "<");
-         }
-         else if (strpos($link, ">")) {
-            $end = strpos($link, ">");
-         }
-         else if (strpos($link, "(")) {
-            $end = strpos($link, "(")-1;
-         }
-         else if (strpos($link, ")")) {
-            $end = strpos($link, ")")-1;
-         }
-         else if (strpos($link, "{")) {
-            $end = strpos($link, "{")-1;
-         }
-         else if (strpos($link, "}")) {
-            $end = strpos($link, "}")-1;
-         }
-         else
-            $end = strlen($link);
-
-         $link = substr($line, $start, $end);
-         $end = $end + $start;
-         $before = substr($line, 0, $start);
-         $after  = substr($line, $end, strlen($line));
-
-         $line = "$before<A HREF=\"$link\" TARGET=_top>$link</A>$after<BR>";
-      }
-
-      return $line;
-   }
 ?>