瀏覽代碼

Added MUCH better composing

Luke Ehresman 25 年之前
父節點
當前提交
178a49c801
共有 8 個文件被更改,包括 87 次插入8 次删除
  1. 4 0
      config/config.php
  2. 4 3
      functions/mailbox.php
  3. 1 1
      functions/mailbox_display.php
  4. 47 0
      functions/smtp.php
  5. 14 2
      functions/strings.php
  6. 6 2
      src/compose.php
  7. 10 0
      src/compose_send.php
  8. 1 0
      src/read_body.php

+ 4 - 0
config/config.php

@@ -7,6 +7,10 @@ $org_name = "Operation Mobilization";
 
 /* The server that your imap server is on */
 $imapServerAddress = "adam.usa.om.org";
+$imapPort = 143;
+
+$smtpServerAddress = "adam.usa.om.org";
+$smtpPort = 25;
 
 /* This is displayed right after they log in */
 $motd = "  Welcome to OM's webmail system, SquirrelMail.  We are currently in beta, and have not yet released a full version of SquirrelMail.  Please feel free to look around, and please report any bugs to <A HREF=\"mailto:nathan@usa.om.org\">Nathan</A> or <A HREF=\"mailto:luke@usa.om.org\">Luke</A>.";

+ 4 - 3
functions/mailbox.php

@@ -269,6 +269,7 @@
       $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(" ", "&nbsp;", $line);
       $line = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
 
@@ -289,7 +290,8 @@
           "www" and "mailto" also.  That should probably be added later. **/
       if (strpos(strtolower($line), "http://") != false) {
          $start = strpos(strtolower($line), "http://");
-         $link = substr($line, $start, strlen($line));
+         $text = substr($line, $start, strlen($line));
+         $link = ereg_replace("<BR>", "", $text);
 
          if (strpos($link, "&"))
             $end = strpos($link, "&");
@@ -299,8 +301,7 @@
             $end = strlen($link);
 
          $link = substr($link, 0, $end);
-
-         $line = str_replace($link, "<A HREF=\"$link\" TARGET=_top>$link</A>", $line);
+         $line = str_replace($text, "<A HREF=\"$link\" TARGET=_top>$text</A>", $line);
       }
 
       return $line;

+ 1 - 1
functions/mailbox_display.php

@@ -16,7 +16,7 @@
          echo "   <TD><FONT FACE=\"Arial,Helvetica\"><nobr><B><input type=checkbox name=\"msg[$t]\" value=$i></B></nobr></FONT></TD>\n";
          echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$senderName</B></FONT></TD>\n";
          echo "   <TD><CENTER><B><FONT FACE=\"Arial,Helvetica\">$dateString</FONT></B></CENTER></TD>\n";
-         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i\">$subject</A></B></FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage\">$subject</A></B></FONT></TD>\n";
       } else {
          echo "   <TD><FONT FACE=\"Arial,Helvetica\"><nobr><input type=checkbox name=\"msg[$t]\" value=$i></nobr></FONT></TD>\n";
          echo "   <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";

+ 47 - 0
functions/smtp.php

@@ -0,0 +1,47 @@
+<?
+   /** smtp.php
+    **
+    ** This contains all the functions needed to send messages through
+    ** an smtp server.
+    **/
+
+   function smtpReadData($smtpConnection) {
+      $read = fgets($smtpConnection, 1024);
+      $counter = 0;
+      while ($read) {
+         echo $read . "<BR>";
+         $data[$counter] = $read;
+         $read = fgets($smtpConnection, 1024);
+         $counter++;
+      }
+   }
+
+   function sendMessage($to, $subject, $body) {
+      echo "<FONT FACE=\"Arial,Helvetica\">";
+      $smtpConnection = fsockopen("10.4.1.1", 25, $errorNumber, $errorString);
+      if (!$smtpConnection) {
+         echo "Error connecting to SMTP Server.<br>";
+         echo "$errorNumber : $errorString<br>";
+         exit;
+      }
+      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+
+      fputs($smtpConnection, "MAIL FROM:<luke@usa.om.org>\n");
+      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+
+      fputs($smtpConnection, "RCPT TO:<$to>\n");
+      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+
+      fputs($smtpConnection, "DATA\n");
+      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+
+      fputs($smtpConnection, "Subject: $subject\n");
+      fputs($smtpConnection, "$body\n");
+      fputs($smtpConnection, ".\n");
+      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+
+      fputs($smtpConnection, "QUIT\n");
+      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+      echo "</FONT>";
+   }
+?>

+ 14 - 2
functions/strings.php

@@ -39,9 +39,21 @@
             $i++;
             $line_len = $line_len + strlen($words[$i])+1;
          }
-         if ($i < count($words)) // don't <BR> the last line
-            $line = "$line<BR>";
          $line_len = strlen($words[$i])+1;
+         if ($line_len < $wrap) {
+            if ($i < count($words)) // don't <BR> the last line
+               $line = "$line<BR>";
+         } else {
+            $endline = $words[$i];
+            while ($line_len >= $wrap) {
+               $bigline = substr($endline, 0, $wrap);
+               $endline = substr($endline, $wrap, strlen($endline));
+               $line_len = strlen($endline);
+               $line = "$line$bigline<BR>";
+            }
+            $line = "$line$endline<BR>";
+            $i++;
+         }
       }
       return $line;
    }

+ 6 - 2
src/compose.php

@@ -10,8 +10,12 @@
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
    displayPageHeader($mailbox);
 
-   echo "<FORM action=\"mailto:luke@usa.om.org\" METHOD=POST>\n";
-   echo "<TEXTAREA NAME=body ROWS=20 COLS=82></TEXTAREA>";
+   echo "<FORM action=\"compose_send.php\" METHOD=POST>\n";
+   echo "<CENTER>";
+   echo "<INPUT TYPE=TEXT NAME=passed_to>";
+   echo "<INPUT TYPE=TEXT NAME=passed_subject>";
+   echo "<TEXTAREA NAME=passed_body ROWS=20 COLS=72 WRAP=SOFT></TEXTAREA><BR>";
    echo "<INPUT TYPE=SUBMIT VALUE=\"Send\">";
+   echo "</CENTER>";
    echo "</FORM>";
 ?>

+ 10 - 0
src/compose_send.php

@@ -0,0 +1,10 @@
+<?
+   include("../config/config.php");
+   include("../functions/strings.php");
+   include("../functions/page_header.php");
+   include("../functions/mailbox.php");
+   include("../functions/smtp.php");
+
+   sendMessage($passed_to, $passed_subject, $passed_body);
+   echo "<A HREF=\"right_main.php\">RETURN</A>";
+?>

+ 1 - 0
src/read_body.php

@@ -13,6 +13,7 @@
    displayPageHeader($mailbox);
    $body = fetchBody($imapConnection, $passed_id);
    getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d);
+//   setMessageFlag($imapConnection, $passed_id, $passed_id, "Seen");
 
    $subject = $s[0];
    $d[0] = ereg_replace("  ", " ", $d[0]);