瀏覽代碼

* Word Wrapping works good
* Added "Message List" link to read_body.php
* beginnings of Compose

Luke Ehresman 25 年之前
父節點
當前提交
3fbde0345a
共有 8 個文件被更改,包括 49 次插入29 次删除
  1. 0 3
      config/config.php
  2. 3 1
      functions/mailbox.php
  3. 4 4
      functions/mailbox_display.php
  4. 1 1
      functions/page_header.php
  5. 15 15
      functions/strings.php
  6. 17 0
      src/compose.php
  7. 1 1
      src/folders.php
  8. 8 4
      src/read_body.php

+ 0 - 3
config/config.php

@@ -51,7 +51,4 @@ $special_folders[1] = $trash_folder;
 $special_folders[2] = "INBOX.Sent";
 $special_folders[3] = "INBOX.Drafts";
 $special_folders[4] = "INBOX.Templates";
-
-/** This is the max chars before a line wrap on plain text messages */
-$wrap_max = 80;
 ?>

+ 3 - 1
functions/mailbox.php

@@ -266,7 +266,9 @@
          $line = str_replace(">", ">", $line);
       }
 
-//      $line = wordWrap($line);
+      $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(" ", " ", $line);
       $line = str_replace("\t", "        ", $line);
 

+ 4 - 4
functions/mailbox_display.php

@@ -8,7 +8,7 @@
     **
     **/
 
-   function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox) {
+   function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox, $sort, $startMessage) {
       $senderName = getSenderName($from);
       $urlMailbox = urlencode($mailbox);
       echo "<TR>\n";
@@ -21,7 +21,7 @@
          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";
          echo "   <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
-         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i\">$subject</A></FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage\">$subject</A></FONT></TD>\n";
       }
       echo "</TR>\n";
    }
@@ -230,10 +230,10 @@
          echo "<TR><TD BGCOLOR=FFFFFF COLSPAN=4><CENTER><BR><B>THIS FOLDER IS EMPTY</B><BR>&nbsp</CENTER></TD></TR>";
       } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
          $i = $startMessage - 1;
-         printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox);
+         printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox, $sort, $startMessage);
       } else {
          for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) {
-            printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox);
+            printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox, $sort, $startMessage);
             $t++;
          }
       }

+ 1 - 1
functions/page_header.php

@@ -19,7 +19,7 @@
       echo "   </TR></TABLE>\n";
       echo "<TABLE BGCOLOR=FFFFFF BORDER=0 COLS=2 WIDTH=100% CELLSPACING=0 CELLPADDING=2><TR>";
       echo "      <TD ALIGN=left WIDTH=70%>";
-      echo "         <FONT FACE=\"Arial,Helvetica\">Compose</FONT>&nbsp&nbsp";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"compose.php\">Compose</A></FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\">Addresses</FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"folders.php\">Folders</A></FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\">Options</FONT>&nbsp&nbsp";

+ 15 - 15
functions/strings.php

@@ -27,22 +27,22 @@
       return strrev($data);
    }
 
-   // Wraps text at $wrap_max characters
-   function wordWrap($line) {
-      $newline = $line;
-      $lastpart = $line;
-      $numlines = 0;
-      $wrap_max = 80;
-      while (strlen($lastpart) > $wrap_max) {
-         $pos = $wrap_max;
-         while ((substr($line, $pos, $pos+1) != " ") && ($pos > 0)) {
-            $pos--;
+   // Wraps text at $wrap characters
+   function wordWrap($passed, $wrap) {
+      $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]&nbsp;";
+            $i++;
+            $line_len = $line_len + strlen($words[$i])+1;
          }
-         $before = substr($line, 0, $pos);
-         $lastpart = substr($line, $pos+1, strlen($line));
-         $newline = $before . "<BR>" . $lastpart;
-         $numlines++;
+         if ($i < count($words)) // don't <BR> the last line
+            $line = "$line<BR>";
+         $line_len = strlen($words[$i])+1;
       }
-      return $newline;
+      return $line;
    }
 ?>

+ 17 - 0
src/compose.php

@@ -0,0 +1,17 @@
+<?
+   include("../config/config.php");
+   include("../functions/strings.php");
+   include("../functions/page_header.php");
+   include("../functions/imap.php");
+   include("../functions/mailbox.php");
+   include("../functions/date.php");
+
+   echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">\n";
+   $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 "<INPUT TYPE=SUBMIT VALUE=\"Send\">";
+   echo "</FORM>";
+?>

+ 1 - 1
src/folders.php

@@ -21,7 +21,7 @@
    echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
    echo "<TR><TD BGCOLOR=DCDCDC ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Delete Folder</B></FONT></TD></TR>";
    echo "<TR><TD BGCOLOR=FFFFFF ALIGN=CENTER>";
-   echo "<FORM ACTION=folders_delete.php METHOD=POST>\n";
+   echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
    echo "<SELECT NAME=mailbox><FONT FACE=\"Arial,Helvetica\">\n";
    for ($i = 0; $i < count($boxesUnformatted); $i++) {
       $use_folder = true;

+ 8 - 4
src/read_body.php

@@ -20,10 +20,14 @@
 //   $date = getDateString($date);
    $date = $d[0];
    $from_name = getSenderName($f[0]);
+   $urlMailbox = urlencode($mailbox);
 
-   echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER>\n";
-   echo "   <TR><TD BGCOLOR=DCDCDC>&nbsp;</TD></TR>";
-   echo "   <TR><TD BGCOLOR=FFFFFF>";
+   echo "<BR>";
+   echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
+   echo "   <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
+   echo "      <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">Message List</A>&nbsp;&nbsp;";
+   echo "   </TD></TR>";
+   echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
    echo "   <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2>\n";
    echo "      <TR>\n";
    /** subject **/
@@ -52,7 +56,7 @@
 
    echo "   </TABLE></TD></TR>\n";
 
-   echo "   <TR><TD BGCOLOR=FFFFFF><BR>\n";
+   echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%><BR>\n";
    $i = 0;
    while ($i < count($body)) {
       echo "$body[$i]";