X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmailbox.php;h=a0f3d70d660b62c4026bdfd0e8a3f294c08bf8d5;hb=8eea5dd306881cc75bf2223f61eb56b738478073;hp=846e1a60b39ea7313a5e49ef802e88d4ed5a92d5;hpb=e550d5517eebba0d7922d82e3b649c0ac16889c2;p=squirrelmail.git
diff --git a/functions/mailbox.php b/functions/mailbox.php
index 846e1a60..a0f3d70d 100644
--- a/functions/mailbox.php
+++ b/functions/mailbox.php
@@ -116,6 +116,16 @@
}
}
+ function decodeEmailAddr($sender) {
+ $emailAddr = getEmailAddr($sender);
+ $emailStart = strpos($emailAddr, "EMAILSTART--");
+ $emailEnd = strpos($emailAddr, "--EMAILEND") - 10;
+
+ $emailAddr = ereg_replace("EMAILSTART--", "", $emailAddr);
+ $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
+ return $emailAddr;
+ }
+
function getEmailAddr($sender) {
if (strpos($sender, "EMAILSTART--") == false)
return "";
@@ -266,9 +276,14 @@
$line = str_replace(">", ">", $line);
}
-// $line = wordWrap($line);
+ $wrap_at = 80; // 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);
+ $line = str_replace("\r", "", $line);
/** if >> or > are found at the beginning of a line, I'll assume that was
replied text, so make it different colors **/
@@ -286,21 +301,93 @@
/** 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, "&");
- else if (strpos($link, "<"))
+ 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($link, 0, $end);
+ $link = substr($line, $start, $end);
+ $end = $end + $start;
+ $before = substr($line, 0, $start);
+ $after = substr($line, $end, strlen($line));
- $line = str_replace($link, "$link", $line);
+ $line = "$before$link$after
";
}
return $line;
}
+
+/*
+ $start = strpos(strtolower($line), "http://");
+ $text = substr($line, $start, strlen($line));
+ $linktext = substr($link, 0, $end);
+ $link = trim(ereg_replace("
", "", $linktext));
+
+
+// $line = str_replace($text, "$link", $line);
+*/
+
+ function getMessageHeadersTo($imapConnection, $start, $end, &$to) {
+ $rel_start = $start;
+ if (($start > $end) || ($start < 1)) {
+ echo "Error in message header fetching. Start message: $start, End message: $end
";
+ exit;
+ }
+
+ $pos = 0;
+ while ($rel_start <= $end) {
+ if ($end - $rel_start > 50) {
+ $rel_end = $rel_start + 49;
+ } else {
+ $rel_end = $end;
+ }
+ fputs($imapConnection, "messageFetch FETCH $rel_start:$rel_end RFC822.HEADER.LINES (To)\n");
+ $read = fgets($imapConnection, 1024);
+
+ while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
+ if (substr($read, 0, 3) == "To:") {
+ $read = ereg_replace("<", "<", $read);
+ $read = ereg_replace(">", ">", $read);
+ $to[$pos] = substr($read, 3, strlen($read));
+ if (strlen(Chop($to[$pos])) == 0)
+ $to[$pos] = "Unknown Recipients";
+ }
+ else if (substr($read, 0, 1) == ")") {
+ if ($subject[$pos] == "")
+ $subject[$pos] = "Unknown Recipients";
+ $pos++;
+ }
+
+ $read = fgets($imapConnection, 1024);
+ }
+ $rel_start = $rel_start + 50;
+ }
+ }
+
?>