From a8648d7595198531956248bdef0639ce3f965ac3 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Fri, 7 Jan 2000 15:54:53 +0000 Subject: [PATCH] Added some preference options, and debugged many bugs git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@121 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/config.php | 8 +++-- functions/mailbox.php | 78 ------------------------------------------- functions/mime.php | 17 ++++------ functions/smtp.php | 8 +++++ functions/strings.php | 47 +++++++++++++++++++++++--- 5 files changed, 62 insertions(+), 96 deletions(-) diff --git a/config/config.php b/config/config.php index e8954679..90b02c3b 100644 --- a/config/config.php +++ b/config/config.php @@ -37,7 +37,9 @@ // To add a new theme to the options that users can choose from, just add // a new number to the array at the bottom, and follow the pattern. - $theme[0]["PATH"] = "../config/default_theme.php"; // This is your default theme. Can be theme. + // The first one HAS to be here, and is your system's default theme. + // It can be any theme you want + $theme[0]["PATH"] = "../config/default_theme.php"; $theme[0]["NAME"] = "Default"; $theme[1]["PATH"] = "../config/sandstorm_theme.php"; @@ -69,9 +71,9 @@ * will get expunged, removing all messages marked "Deleted". */ - $move_to_trash = true; + $default_move_to_trash = true; $trash_folder = "INBOX.Trash"; - $auto_expunge = true; + $default_auto_expunge = true; // Special Folders are folders that can't be manipulated like normal user created // folders can. A couple of examples would be "INBOX.Trash", "INBOX.Drafts". We have diff --git a/functions/mailbox.php b/functions/mailbox.php index 4cfec184..1f9a5024 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -522,82 +522,4 @@ $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), "") == 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 (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"; - } - - 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; - } ?> diff --git a/functions/mime.php b/functions/mime.php index 6bd52f03..f61322bf 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -117,36 +117,33 @@ as the actual message in the HTML. It contains everything needed, including HTML Tags, Attachments at the bottom, etc. **/ - function formatBody($message, $color) { + function formatBody($message, $color, $wrap_at) { /** this if statement checks for the entity to show as the primary message. To add more of them, just put them in the order that is their priority. **/ $id = $message["INFO"]["ID"]; $urlmailbox = urlencode($message["INFO"]["MAILBOX"]); - $body = ""; if (containsType($message, "text", "html", $ent_num)) { - $body .= decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } else if (containsType($message, "text", "plain", $ent_num)) { - $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br(trim($tmpbody)) . ""; + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } // add other primary displaying message types here else { // find any type that's displayable if (containsType($message, "text", "any_type", $ent_num)) { - $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br(trim($tmpbody)) . ""; + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } else if (containsType($message, "message", "any_type", $ent_num)) { - $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br(trim($tmpbody)) . ""; + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } } /** If there are other types that shouldn't be formatted, add them here **/ if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html") - $body = translateText($body); + $body = translateText($body, $wrap_at); + $body .= "
Download this as a file

"; diff --git a/functions/smtp.php b/functions/smtp.php index 0bfaf935..4c28318e 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -89,6 +89,14 @@ if ($reply_to != "") fputs($smtpConnection, "Reply-To: $reply_to\n"); + + $body_ary = explode("\n", trim($body)); + $body = ""; + for ($i = 0; $i < count($body_ary); $i++) { + if ($body_ary[$i] == ".") + $body_ary[$i] = "."; + $body .= $body_ary[$i] . "\n"; + } fputs($smtpConnection, "$body\n"); // send the body of the message fputs($smtpConnection, ".\n"); // end the DATA part diff --git a/functions/strings.php b/functions/strings.php index 38c8e7b0..5c633d44 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -28,20 +28,23 @@ // Wraps text at $wrap characters function wordWrap($passed, $wrap) { + $passed = str_replace(">", ">", $passed); + $passed = str_replace("<", "<", $passed); + $words = explode(" ", trim($passed)); $i = 0; $line_len = strlen($words[$i])+1; $line = ""; while ($i < count($words)) { while ($line_len < $wrap) { - $line = "$line$words[$i] "; + $line = "$line$words[$i] "; $i++; $line_len = $line_len + strlen($words[$i])+1; } $line_len = strlen($words[$i])+1; if ($line_len < $wrap) { if ($i < count($words)) // don't
the last line - $line = "$line
"; + $line = "$line\n"; } else { $endline = $words[$i]; while ($line_len >= $wrap) { @@ -54,6 +57,9 @@ $i++; } } + + $line = str_replace(">", ">", $line); + $line = str_replace("<", "<", $line); return $line; } @@ -80,9 +86,40 @@ return $to_line; } - function translateText($body) { - $body = ereg_replace(" ", " ", $body); - return $body; + function translateText($body, $wrap_at) { + /** Add any parsing you want to in here */ + $body = trim($body); + $body_ary = explode("\n", $body); + + for ($i = 0; $i < count($body_ary); $i++) { + $line = $body_ary[$i]; + $line = "^^$line"; + + $line = str_replace(">", ">", $line); + $line = str_replace("<", "<", $line); + + if (strlen($line) >= $wrap_at) // -2 because of the ^^ at the beginning + $line = wordWrap($line, $wrap_at); + + $line = str_replace(" ", " ", $line); + $line = str_replace("\t", "        ", $line); + $line = nl2br($line); + + 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"; + } + + $new_body[$i] = "$line"; + } + $bdy = implode("\n", $new_body); + return $bdy; } /* SquirrelMail version number -- DO NOT CHANGE */ -- 2.25.1