// 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";
* 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
$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("<", "<", $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 = "<TT><FONT COLOR=FF0000>$line</FONT></TT><BR>\n";
- } else if (strpos(trim(str_replace(" ", "", $line)), ">") == 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, " ")) {
- $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<A HREF=\"$link\" TARGET=_top>$link</A>$after<BR>";
- }
-
- return $line;
- }
?>
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 .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+ $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 .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+ $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 .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+ $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 .= "<BR><SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">Download this as a file</A></CENTER><BR></SMALL>";
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
// 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 <BR> the last line
- $line = "$line<BR>";
+ $line = "$line\n";
} else {
$endline = $words[$i];
while ($line_len >= $wrap) {
$i++;
}
}
+
+ $line = str_replace(">", ">", $line);
+ $line = str_replace("<", "<", $line);
return $line;
}
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 = "<TT><FONT COLOR=FF0000>$line</FONT></TT><BR>\n";
+ } else if (strpos(trim(str_replace(" ", "", $line)), ">") == 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";
+ }
+
+ $new_body[$i] = "$line";
+ }
+ $bdy = implode("\n", $new_body);
+ return $bdy;
}
/* SquirrelMail version number -- DO NOT CHANGE */