X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmailbox.php;h=45d9021ae6268fc56692bdbdd70227ffd8969926;hp=5e632131a2f88b8a708e2903ebbd5b8f5bdd49fa;hb=f8ba91808cc97117107a82d18d35dd4e4994ca6d;hpb=8405ee3548225c00d3cdb2ba7e298f4585680316 diff --git a/functions/mailbox.php b/functions/mailbox.php index 5e632131..45d9021a 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -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
"; + echo _("Error in message header fetching. Start message: "). $start, _("End message: "). "$end
"; exit; } @@ -227,6 +227,7 @@ function expungeBox($imapConnection, $mailbox) { selectMailbox($imapConnection, $mailbox, $num); fputs($imapConnection, "1 EXPUNGE\n"); + imapReadData($imapConnection, "1", true, $response, $message); } function getFolderNameMinusINBOX($mailbox, $del) { @@ -240,10 +241,11 @@ } /** This function gets all the information about a message. Including Header and body **/ - function fetchMessage($imapConnection, $id) { + function fetchMessage($imapConnection, $id, $mailbox) { + $message["INFO"]["ID"] = $id; + $message["INFO"]["MAILBOX"] = $mailbox; $message["HEADER"] = fetchHeader($imapConnection, $id); $message["ENTITIES"] = fetchBody($imapConnection, $message["HEADER"]["BOUNDARY"], $id, $message["HEADER"]["TYPE0"], $message["HEADER"]["TYPE1"]); - return $message; } @@ -263,7 +265,7 @@ } /** ENCODING TYPE **/ - else if (substr($read[$i], 0, 26) == "Content-Transfer-Encoding:") { + else if (substr(strtolower($read[$i]), 0, 26) == "content-transfer-encoding:") { $header["ENCODING"] = strtolower(trim(substr($read[$i], 26))); } @@ -317,6 +319,18 @@ $header["CHARSET"] = "us-ascii"; } + /** Detects filename if any **/ + if (strpos(strtolower(trim($line)), "name=")) { + $pos = strpos($line, "name=") + 5; + $name = trim($line); + if (strpos($line, " ", $pos) > 0) { + $name = substr($name, $pos, strpos($line, " ", $pos)); + } else { + $name = substr($name, $pos); + } + $name = str_replace("\"", "", $name); + $header["FILENAME"] = $name; + } } /** REPLY-TO **/ @@ -420,14 +434,14 @@ return decodeMime($body, $bound, $type0, $type1); } - function fetchEntityHeader($imapConnection, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset) { + function fetchEntityHeader($imapConnection, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) { /** defaults... if the don't get overwritten, it will display text **/ $type0 = "text"; $type1 = "plain"; $encoding = "us-ascii"; $i = 0; while (trim($read[$i]) != "") { - if (substr($read[$i], 0, 26) == "Content-Transfer-Encoding:") { + if (substr(strtolower($read[$i]), 0, 26) == "content-transfer-encoding:") { $encoding = strtolower(trim(substr($read[$i], 26))); } else if (substr($read[$i], 0, 13) == "Content-Type:") { @@ -442,13 +456,17 @@ $type0 = $cont; } + $read[$i] = trim($read[$i]); $line = $read[$i]; + $i++; while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) { str_replace("\n", "", $line); str_replace("\n", "", $read[$i]); $line = "$line $read[$i]"; $i++; + $read[$i] = trim($read[$i]); } + $i--; /** Detect the boundary of a multipart message **/ if (strpos(strtolower(trim($line)), "boundary=")) { @@ -473,6 +491,19 @@ } $charset = str_replace("\"", "", $charset); } + + /** Detects filename if any **/ + if (strpos(strtolower(trim($line)), "name=")) { + $pos = strpos($line, "name=") + 5; + $name = trim($line); + if (strpos($line, " ", $pos) > 0) { + $name = substr($name, $pos, strpos($line, " ", $pos)); + } else { + $name = substr($name, $pos); + } + $name = str_replace("\"", "", $name); + $filename = $name; + } } $i++; } @@ -492,79 +523,4 @@ $read = $entity; } - function parsePlainTextMessage($line) { - $line = "^^$line"; - - if ((strpos(strtolower($line), "") == false) && - (strpos(strtolower($line), "") == false)) { - $line = str_replace("<", "<", $line); - $line = str_replace(">", ">", $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(" ", " ", $line); - $line = str_replace("\t", "        ", $line); - $line = str_replace("\n", "", $line); - - /** if >> or > are found at the beginning of a line, I'll assume that was - replied text, so make it different colors **/ - if (strpos(trim(str_replace(" ", "", $line)), ">>") == 2) { - $line = substr($line, 2, strlen($line)); - $line = "$line
\n"; - } else if (strpos(trim(str_replace(" ", "", $line)), ">") == 2) { - $line = substr($line, 2, strlen($line)); - $line = "$line
\n"; - } else { - $line = substr($line, 2, strlen($line)); - $line = "$line
\n"; - } - - /** This translates "http://" into a link. It could be made better to accept - "www" and "mailto" also. That should probably be added later. **/ - if (strpos(strtolower($line), "http://") != false) { - $line = ereg_replace("
", "", $line); - $start = strpos(strtolower($line), "http://"); - $link = substr($line, $start, strlen($line)); - - if (strpos($link, " ")) { - $end = strpos($link, " ")-1; - } - else if (strpos($link, " ")) { - $end = strpos($link, " ")-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$link$after
"; - } - - return $line; - } ?>