From 9774bdefb84a93bc71218da6234b8410b1c0e786 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Tue, 7 Dec 1999 18:47:56 +0000 Subject: [PATCH] Updated (again) how HTML tags render in plain text messages git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@66 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/date.php | 28 ++++++++++++++++++++ functions/mailbox.php | 50 ++++++++++++++++++++++++++++++----- functions/mailbox_display.php | 1 - src/read_body.php | 6 +++-- 4 files changed, 75 insertions(+), 10 deletions(-) diff --git a/functions/date.php b/functions/date.php index ea95e891..c884c718 100644 --- a/functions/date.php +++ b/functions/date.php @@ -158,4 +158,32 @@ $d[5] = getYear(trim($dateParts[2])); return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]); } + + function getLongDateString($dateParts) { + if (eregi("mon|tue|wed|thu|fri|sat|sun", trim($dateParts[0]), $tmp)) { + $date[0] = getDayOfMonth(trim($dateParts[1])); + $date[1] = getMonth(trim($dateParts[2])); + $date[2] = getYear(trim($dateParts[3])); + $date[3] = getHour(trim($dateParts[4])); + $date[4] = getMinute(trim($dateParts[4])); + } else { + $date[0] = getDayOfMonth(trim($dateParts[0])); + $date[1] = getMonth(trim($dateParts[1])); + $date[2] = getYear(trim($dateParts[2])); + $date[3] = getHour(trim($dateParts[3])); + $date[4] = getMinute(trim($dateParts[4])); + } + + if ($date[3] >= 12) { + $date[5] = "p.m."; + if ($date[3] >= 13) + $date[3] = $date[3] - 12; + } else { + $date[5] = "a.m."; + if ($date[3] < 1) + $date[3] = 12; + } + + return "$date[1] $date[0], $date[2]   $date[3]:$date[4] $date[5]"; + } ?> diff --git a/functions/mailbox.php b/functions/mailbox.php index 31eb5542..a0f3d70d 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -282,6 +282,8 @@ $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 **/ @@ -299,24 +301,58 @@ /** 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://"); - $text = substr($line, $start, strlen($line)); - $link = ereg_replace("
", "", $text); + $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); - $line = str_replace($text, "$text", $line); + $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; } +/* + $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)) { diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 1010d31f..3023472f 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -38,7 +38,6 @@ $j = 0; while ($j < $numMessages) { -// echo "$numMessages -- $j -- $subject[$j]
"; $date[$j] = ereg_replace(" ", " ", $date[$j]); $tmpdate = explode(" ", trim($date[$j])); diff --git a/src/read_body.php b/src/read_body.php index 98e7f568..c2122833 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -19,7 +19,9 @@ $url_subj = urlencode(trim($subject)); $d[0] = ereg_replace(" ", " ", $d[0]); - $date = $d[0]; + $dateParts = explode(" ", trim($d[0])); + $dateString = getLongDateString($dateParts); + $from_name = getSenderName($f[0]); $urlMailbox = urlencode($mailbox); @@ -101,7 +103,7 @@ echo " \n"; echo " Date:\n"; echo " \n"; - echo " $date\n"; + echo " $dateString\n"; echo " \n"; echo " \n"; /** to **/ -- 2.25.1