Bladeren bron

Added some preference options, and debugged many bugs

Luke Ehresman 25 jaren geleden
bovenliggende
commit
081c511520
5 gewijzigde bestanden met toevoegingen van 62 en 96 verwijderingen
  1. 5 3
      config/config.php
  2. 0 78
      functions/mailbox.php
  3. 7 10
      functions/mime.php
  4. 8 0
      functions/smtp.php
  5. 42 5
      functions/strings.php

+ 5 - 3
config/config.php

@@ -37,7 +37,9 @@
 //  To add a new theme to the options that users can choose from, just add
 //  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.
 //  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[0]["NAME"] = "Default";
 
 
     $theme[1]["PATH"] = "../config/sandstorm_theme.php";
     $theme[1]["PATH"] = "../config/sandstorm_theme.php";
@@ -69,9 +71,9 @@
  *           will get expunged, removing all messages marked "Deleted".
  *           will get expunged, removing all messages marked "Deleted".
  */
  */
 
 
-    $move_to_trash = true;
+    $default_move_to_trash = true;
     $trash_folder = "INBOX.Trash";
     $trash_folder = "INBOX.Trash";
-    $auto_expunge = true;
+    $default_auto_expunge = true;
 
 
 //  Special Folders are folders that can't be manipulated like normal user created
 //  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
 //  folders can.  A couple of examples would be "INBOX.Trash", "INBOX.Drafts".  We have

+ 0 - 78
functions/mailbox.php

@@ -522,82 +522,4 @@
       $read = $entity;
       $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("<", "&lt;", $line);
-         $line = str_replace(">", "&gt;", $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(" ", "&nbsp;", $line);
-      $line = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
-      $line = str_replace("\n", "", $line);
-
-      if (strpos(trim(str_replace("&nbsp;", "", $line)), "&gt;&gt;") == 2) {
-         $line = substr($line, 2, strlen($line));
-         $line = "<TT><FONT COLOR=FF0000>$line</FONT></TT><BR>\n";
-      } else if (strpos(trim(str_replace("&nbsp;", "", $line)), "&gt;") == 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, "&nbsp;")) {
-            $end = strpos($link, "&nbsp;")-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;
-   }
 ?>
 ?>

+ 7 - 10
functions/mime.php

@@ -117,36 +117,33 @@
        as the actual message in the HTML.   It contains everything needed, including
        as the actual message in the HTML.   It contains everything needed, including
        HTML Tags, Attachments at the bottom, etc.
        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
       /** 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.
           add more of them, just put them in the order that is their priority.
        **/
        **/
       $id = $message["INFO"]["ID"];
       $id = $message["INFO"]["ID"];
       $urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
       $urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
-      $body = "";
 
 
       if (containsType($message, "text", "html", $ent_num)) {
       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)) {
       } 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
       // add other primary displaying message types here
       else {
       else {
          // find any type that's displayable
          // find any type that's displayable
          if (containsType($message, "text", "any_type", $ent_num)) {
          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)) {
          } 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 there are other types that shouldn't be formatted, add them here **/
       if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html")
       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>";
       $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>";
 
 

+ 8 - 0
functions/smtp.php

@@ -89,6 +89,14 @@
       if ($reply_to != "")
       if ($reply_to != "")
          fputs($smtpConnection, "Reply-To: $reply_to\n");
          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, "$body\n"); // send the body of the message
 
 
       fputs($smtpConnection, ".\n"); // end the DATA part
       fputs($smtpConnection, ".\n"); // end the DATA part

+ 42 - 5
functions/strings.php

@@ -28,20 +28,23 @@
 
 
    // Wraps text at $wrap characters
    // Wraps text at $wrap characters
    function wordWrap($passed, $wrap) {
    function wordWrap($passed, $wrap) {
+      $passed = str_replace("&gt;", ">", $passed);
+      $passed = str_replace("&lt;", "<", $passed);
+
       $words = explode(" ", trim($passed));
       $words = explode(" ", trim($passed));
       $i = 0;
       $i = 0;
       $line_len = strlen($words[$i])+1;
       $line_len = strlen($words[$i])+1;
       $line = "";
       $line = "";
       while ($i < count($words)) {
       while ($i < count($words)) {
          while ($line_len < $wrap) {
          while ($line_len < $wrap) {
-            $line = "$line$words[$i]&nbsp;";
+            $line = "$line$words[$i] ";
             $i++;
             $i++;
             $line_len = $line_len + strlen($words[$i])+1;
             $line_len = $line_len + strlen($words[$i])+1;
          }
          }
          $line_len = strlen($words[$i])+1;
          $line_len = strlen($words[$i])+1;
          if ($line_len < $wrap) {
          if ($line_len < $wrap) {
             if ($i < count($words)) // don't <BR> the last line
             if ($i < count($words)) // don't <BR> the last line
-               $line = "$line<BR>";
+               $line = "$line\n";
          } else {
          } else {
             $endline = $words[$i];
             $endline = $words[$i];
             while ($line_len >= $wrap) {
             while ($line_len >= $wrap) {
@@ -54,6 +57,9 @@
             $i++;
             $i++;
          }
          }
       }
       }
+
+      $line = str_replace(">", "&gt;", $line);
+      $line = str_replace("<", "&lt;", $line);
       return $line;
       return $line;
    }
    }
 
 
@@ -80,9 +86,40 @@
       return $to_line;
       return $to_line;
    }
    }
 
 
-   function translateText($body) {
-      $body = ereg_replace(" ", "&nbsp;", $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(">", "&gt;", $line);
+         $line = str_replace("<", "&lt;", $line);
+
+         if (strlen($line) >= $wrap_at) // -2 because of the ^^ at the beginning
+            $line = wordWrap($line, $wrap_at);
+
+         $line = str_replace(" ", "&nbsp;", $line);
+         $line = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
+         $line = nl2br($line);
+
+         if (strpos(trim(str_replace("&nbsp;", "", $line)), "&gt;&gt;") == 2) {
+            $line = substr($line, 2, strlen($line));
+            $line = "<TT><FONT COLOR=FF0000>$line</FONT></TT><BR>\n";
+         } else if (strpos(trim(str_replace("&nbsp;", "", $line)), "&gt;") == 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 */
    /* SquirrelMail version number -- DO NOT CHANGE */