Initial revision
authorsquirrel <squirrel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 22 Nov 1999 00:32:55 +0000 (00:32 +0000)
committersquirrel <squirrel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 22 Nov 1999 00:32:55 +0000 (00:32 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2 7612ce4b-ef26-0410-bec9-ea0150e637f0

23 files changed:
.mailboxMessageList.php3.swp [new file with mode: 0644]
ATHORS [new file with mode: 0644]
BUG [new file with mode: 0644]
TODO [new file with mode: 0644]
config/config.php3 [new file with mode: 0644]
functions/array.php3 [new file with mode: 0644]
functions/date.php3 [new file with mode: 0644]
functions/imap.php3 [new file with mode: 0644]
functions/pageheader.php3 [new file with mode: 0644]
functions/strings.php3 [new file with mode: 0644]
images/button_next.gif [new file with mode: 0644]
images/down_pointer.gif [new file with mode: 0644]
images/om_mini_logo.gif [new file with mode: 0644]
images/om_webmail.gif [new file with mode: 0644]
images/om_webmail.png [new file with mode: 0644]
images/up_pointer.gif [new file with mode: 0644]
index.html [new file with mode: 0644]
left.php3 [new file with mode: 0644]
login.php3 [new file with mode: 0644]
mailboxMessageList.php3 [new file with mode: 0644]
mailboxMessageListtmp.php3 [new file with mode: 0644]
signout.php3 [new file with mode: 0644]
webmail.php3 [new file with mode: 0644]

diff --git a/.mailboxMessageList.php3.swp b/.mailboxMessageList.php3.swp
new file mode 100644 (file)
index 0000000..a94c0a2
Binary files /dev/null and b/.mailboxMessageList.php3.swp differ
diff --git a/ATHORS b/ATHORS
new file mode 100644 (file)
index 0000000..1ebe068
--- /dev/null
+++ b/ATHORS
@@ -0,0 +1,2 @@
+Nathan Ehresman
+Luke Ehresman
diff --git a/BUG b/BUG
new file mode 100644 (file)
index 0000000..e4d4e62
--- /dev/null
+++ b/BUG
@@ -0,0 +1,4 @@
+KNOWN BUGS
+----------------------------------------
+-  Subject in Nathan's INBOX message 757 is bad
+-  There are no grid lines in IE on message list
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..0e7604f
--- /dev/null
+++ b/TODO
@@ -0,0 +1,15 @@
+TODO
+------------
+-  Don't view "deleted" messages
+-  Write JavaScript for left side bar to auto log out on unload
+-  Todo manager
+-  Bug tracker
+-  Moving messages to folders
+-  Deleting messages (send to trash)
+-  Expunge mailboxes
+
+
+DONE
+------------
+-  (nathan) Abstract header stuff so it can be used on all pages
+-  (luke)   Genericize login page
diff --git a/config/config.php3 b/config/config.php3
new file mode 100644 (file)
index 0000000..3797b6f
--- /dev/null
@@ -0,0 +1,16 @@
+<?
+/* Organization's logo picture (blank if none) */
+$org_logo = "images/om_webmail.gif";
+
+/* Organization's name */
+$org_name = "Operation Mobilization";
+
+/* The server that your imap server is on */
+$imapServerAddress = "adam.usa.om.org";
+
+/* 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>.";
+
+/* SquirrelMail version number */
+$version = "0.0.1";
+?>
diff --git a/functions/array.php3 b/functions/array.php3
new file mode 100644 (file)
index 0000000..18d0e83
--- /dev/null
@@ -0,0 +1,33 @@
+<?
+   function ary_sort($ary,$col, $dir = 1){
+      // The globals are used because USORT determines what is passed to comp2
+      // These should be $this->col and $this->dir in a class
+      // Would beat using globals
+      if(!is_array($col)){
+         $col = array("$col");
+      }
+      $GLOBALS["col"] = $col;  // Column or Columns as an array
+      $GLOBALS["dir"] = $dir;  // Direction, a positive number for ascending a negative for descending
+  
+      function comp2($a,$b,$i = 0) {
+         global $col;
+         global $dir;
+         $c = count($col) -1;
+         if ($a["$col[$i]"] == $b["$col[$i]"]){
+            $r = 0;
+            while($i < $c && $r == 0){
+               $i++;
+               $r = comp2($a,$b,$i);
+            }
+         } elseif($a["$col[$i]"] < $b["$col[$i]"]){
+            $r = -1 * $dir; // Im not sure why you must * dir here, but it wont work just before the return...
+         } else {
+            $r = 1 * $dir;
+         }
+         return $r;
+      }
+  
+      usort($ary,comp2);
+      return $ary;
+   }
+?>
diff --git a/functions/date.php3 b/functions/date.php3
new file mode 100644 (file)
index 0000000..f900868
--- /dev/null
@@ -0,0 +1,144 @@
+<?
+   //*************************************************************************
+   // Takes a date and parses it into usable format
+   //
+   // Tue, 29 Jun 1999 09:52:11 -0500 (EDT)
+   //
+   // $dateParts[0] == <day of week>   Mon, Tue, Wed
+   // $dateParts[1] == <day of month>  23
+   // $dateParts[2] == <month>         Jan, Feb, Mar
+   // $dateParts[3] == <year>          1999
+   // $dateParts[4] == <time>          18:54:23 (HH:MM:SS)
+   // $dateParts[5] == <from GMT>      +0100
+   // $dateParts[6] == <zone>          (EDT)
+   //
+   //*************************************************************************
+
+   function getHour($hour) {
+      $time = explode(":", $hour);
+      return $time[0];
+   }
+
+   function getMinute($min) {
+      $time = explode(":", $min);
+      return $time[1];
+   }
+
+   function getSecond($sec) {
+      $time = explode(":", $sec);
+      return $time[2];
+   }
+
+   function getMonthNum($month) {
+      if (eregi("jan|january", $month, $tmp))
+         $date = "01";
+      else if (eregi("feb|february|febuary", $month, $tmp))
+         $date = "02";
+      else if (eregi("mar|march", $month, $tmp))
+         $date = "03";
+      else if (eregi("apr|april", $month, $tmp))
+         $date = "04";
+      else if (eregi("may", $month, $tmp))
+         $date = "05";
+      else if (eregi("jun|june", $month, $tmp))
+         $date = "06";
+      else if (eregi("jul|july", $month, $tmp))
+         $date = "07";
+      else if (eregi("aug|august", $month, $tmp))
+         $date = "08";
+      else if (eregi("sep|sept|september", $month, $tmp))
+         $date = "09";
+      else if (eregi("oct|october", $month, $tmp))
+         $date = "10";
+      else if (eregi("nov|november", $month, $tmp))
+         $date = "11";
+      else if (eregi("dec|december", $month, $tmp))
+         $date = "12";
+
+      return $date;
+   }
+
+   function getDayOfWeek($day) {
+      $date = "{WEEKDAY}";
+
+      if (eregi("(mon|monday)", $day, $tmp))
+         $date = "Mon";
+      else if (eregi("(tue|tuesday)", $day, $tmp))
+         $date = "Tue";
+      else if (eregi("(wed|wednesday)", $day, $tmp))
+         $date = "Wed";
+      else if (eregi("(thurs|thu|thursday)", $day, $tmp))
+         $date = "Thu";
+      else if (eregi("(fri|friday)", $day, $tmp))
+         $date = "Fri";
+      else if (eregi("(sat|saturday)", $day, $tmp))
+         $date = "Sat";
+      else if (eregi("(sun|sunday)", $day, $tmp))
+         $date = "Sun";
+
+      return $date;
+   }
+
+   function getDayOfMonth($day) {
+      return ereg_replace("^0", "", $day); /* remove a preceeding 0 */
+   }
+
+   function getMonth($month) {
+      $date = "{MONTH}";
+      if (eregi("jan|january", $month, $tmp))
+         $date = "Jan";
+      else if (eregi("feb|february|febuary", $month, $tmp))
+         $date = "Feb";
+      else if (eregi("mar|march", $month, $tmp))
+         $date = "Mar";
+      else if (eregi("apr|april", $month, $tmp))
+         $date = "Apr";
+      else if (eregi("may", $month, $tmp))
+         $date = "May";
+      else if (eregi("jun|june", $month, $tmp))
+         $date = "Jun";
+      else if (eregi("jul|july", $month, $tmp))
+         $date = "Jul";
+      else if (eregi("aug|august", $month, $tmp))
+         $date = "Aug";
+      else if (eregi("sep|sept|september", $month, $tmp))
+         $date = "Sep";
+      else if (eregi("oct|october", $month, $tmp))
+         $date = "Oct";
+      else if (eregi("nov|november", $month, $tmp))
+         $date = "Nov";
+      else if (eregi("dec|december", $month, $tmp))
+         $date = "Dec";
+
+      return $date;
+   }
+
+   function getYear($year) {
+      return $year;
+   }
+
+   function getDateString($dateParts) {
+      /* if the first part is a day */
+      if (eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp)) {
+         $dateParts[0] = getDayOfWeek($dateParts[0]);
+         $dateParts[1] = getDayOfMonth($dateParts[1]);
+         $dateParts[2] = getMonth($dateParts[2]);
+         $dateParts[3] = getYear($dateParts[3]);
+         return "$dateParts[2] $dateParts[1], $dateParts[3]";
+      }
+      $dateParts[0] = getDayOfMonth($dateParts[0]);
+      $dateParts[1] = getMonth($dateParts[1]);
+      $dateParts[2] = getYear($dateParts[2]);
+      return "$dateParts[1] $dateParts[0], $dateParts[2]";
+   }
+
+   function getTimeStamp($dateParts) {
+      $d[0] = getHour($dateParts[4]);
+      $d[1] = getMinute($dateParts[4]);
+      $d[2] = getSecond($dateParts[4]);
+      $d[3] = getMonthNum($dateParts[2]);
+      $d[4] = getDayOfMonth($dateParts[1]);
+      $d[5] = getYear($dateParts[3]);
+      return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
+   }
+?>
diff --git a/functions/imap.php3 b/functions/imap.php3
new file mode 100644 (file)
index 0000000..33140bf
--- /dev/null
@@ -0,0 +1,15 @@
+<?
+   // *****************************************
+   //    Read from the connection until we get either an OK or BAD message.
+   // *****************************************
+   function imapReadData($connection) {
+      $read = fgets($connection, 1024);
+      $counter = 0;
+      while ((substr($read, strpos($read, " ") + 1, 2) != "OK") && (substr($read, strpos($read, " ") + 1, 3) != "BAD")) {
+         $data[$counter] = $read;
+         $read = fgets($connection, 1024);
+         $counter++;
+      }
+      return $data;
+   }
+?>
diff --git a/functions/pageheader.php3 b/functions/pageheader.php3
new file mode 100644 (file)
index 0000000..031a376
--- /dev/null
@@ -0,0 +1,23 @@
+<?
+   function displayPageHeader($mailbox) {
+      /** Here is the header and wrapping table **/
+      $shortBoxName = readShortMailboxName($mailbox, ".");
+      echo "<TABLE BGCOLOR=FFFFFF BORDER=0 COLS=2 WIDTH=100% CELLSPACING=0 CELLPADDING=2>";
+      echo "   <TR BGCOLOR=A0B8C8 WIDTH=50%>";
+      echo "      <TD ALIGN=left>";
+      echo "         <FONT FACE=\"Arial,Helvetica\" SIZE=-1><A HREF=\"signout.php3\" TARGET=_top><B>Sign Out</B></A></FONT>";
+      echo "      </TD><TD ALIGN=right WIDTH=50%>";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><div align=right>Current Folder: <B>$shortBoxName</div></B></FONT>";
+      echo "      </TD>";
+      echo "   </TR><TR>";
+      echo "      <TD ALIGN=left WIDTH=50%>";
+      echo "         <FONT FACE=\"Arial,Helvetica\">Compose</FONT>&nbsp&nbsp";
+      echo "         <FONT FACE=\"Arial,Helvetica\">Addresses</FONT>&nbsp&nbsp";
+      echo "         <FONT FACE=\"Arial,Helvetica\">Options</FONT>&nbsp&nbsp";
+      echo "      </TD><TD ALIGN=right WIDTH=50%>";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"http://adam.usa.om.org/~luke/main.php3\" TARGET=_top>Todos & Bugs</A></FONT>&nbsp&nbsp";
+      echo "         <FONT FACE=\"Arial,Helvetica\">Help!</FONT>";
+      echo "      </TD>";
+      echo "</TABLE>";
+  }
+?>
diff --git a/functions/strings.php3 b/functions/strings.php3
new file mode 100644 (file)
index 0000000..c7b6544
--- /dev/null
@@ -0,0 +1,30 @@
+<?
+   //*************************************************************************
+   // Count the number of occurances of $needle are in $haystack.
+   //*************************************************************************
+   function countCharInString($haystack, $needle) {
+      $len = strlen($haystack);
+      for ($i = 0; $i < $len; $i++) {
+         if ($haystack[$i] == $needle)
+            $count++;
+      }
+      return $count;
+   }
+
+   //*************************************************************************
+   // Read from the back of $haystack until $needle is found, or the begining
+   //    of the $haystack is reached.
+   //*************************************************************************
+   function readShortMailboxName($haystack, $needle) {
+      $len = strlen($haystack);
+      for ($i = $len - 1; ($i >= 0) && (!$found);$i--) {
+         $char = $haystack[$i];
+         if ($char == $needle)
+            $found = 1;
+         else
+            $data .= $char;
+      }
+      return strrev($data);
+   }
+
+?>
diff --git a/images/button_next.gif b/images/button_next.gif
new file mode 100644 (file)
index 0000000..bf75b2f
Binary files /dev/null and b/images/button_next.gif differ
diff --git a/images/down_pointer.gif b/images/down_pointer.gif
new file mode 100644 (file)
index 0000000..bc2d251
Binary files /dev/null and b/images/down_pointer.gif differ
diff --git a/images/om_mini_logo.gif b/images/om_mini_logo.gif
new file mode 100644 (file)
index 0000000..67c220b
Binary files /dev/null and b/images/om_mini_logo.gif differ
diff --git a/images/om_webmail.gif b/images/om_webmail.gif
new file mode 100644 (file)
index 0000000..be940c7
Binary files /dev/null and b/images/om_webmail.gif differ
diff --git a/images/om_webmail.png b/images/om_webmail.png
new file mode 100644 (file)
index 0000000..2851788
Binary files /dev/null and b/images/om_webmail.png differ
diff --git a/images/up_pointer.gif b/images/up_pointer.gif
new file mode 100644 (file)
index 0000000..a7eb5a5
Binary files /dev/null and b/images/up_pointer.gif differ
diff --git a/index.html b/index.html
new file mode 100644 (file)
index 0000000..8a02720
--- /dev/null
@@ -0,0 +1,9 @@
+<HTML>
+   <HEAD>
+      <SCRIPT LANGUAGE="JavaScript">
+         parent.location.href="login.php3"
+      </SCRIPT>
+   </HEAD>
+   <BODY>
+   </BODY>
+</HTML>
diff --git a/left.php3 b/left.php3
new file mode 100644 (file)
index 0000000..a2403a4
--- /dev/null
+++ b/left.php3
@@ -0,0 +1,89 @@
+<?
+   if(!isset($username)) {
+      echo "You need a valid user and password to access this page!";
+      exit;
+   }
+?>
+<HTML>
+<HEAD>
+   <SCRIPT LANGUAGE="JavaScript">
+      function DeleteCookie (name) {
+         var exp = new Date();  
+         exp.setTime (exp.getTime() - 1);  
+         // This cookie is history  
+         var cval = GetCookie (name);  
+         document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
+      }
+
+      function unSetCookies() {
+         DeleteCookie('username');
+         DeleteCookie('key');
+         DeleteCookie('logged_in');
+         alert(document.cookie);
+      }
+   </SCRIPT>
+</HEAD>
+<BODY BGCOLOR=A0B8C8 TEXT="#000000" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE" onUnLoad="unSetCookies()">
+<FONT FACE="Arial,Helvetica">
+<?
+   include("config/config.php3");
+   include("functions/strings.php3");
+   include("functions/imap.php3");
+
+   // *****************************************
+   //    Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX
+   // *****************************************
+   function findMailboxName($mailbox) {
+      // start at -2 so that we skip the initial quote at the end of the mailbox name
+      $i = -2;
+      $char = substr($mailbox, $i, 1);
+      while ($char != "\"") {
+         $i--;
+         $temp .= $char;
+         $char = substr($mailbox, $i, 1);
+      }
+      return strrev($temp);
+   }
+
+   // open a connection on the imap port (143)
+   $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
+   if (!$imapConnection) {
+      echo "Error connecting to IMAP Server.<br>";
+      echo "$errorNumber : $errorString<br>";
+      exit;
+   }
+   $serverInfo = fgets($imapConnection, 256);
+
+   fputs($imapConnection, "1 login $username $key\n");
+   $read = fgets($imapConnection, 1024);
+
+   fputs($imapConnection, "1 list \"\" *\n");
+   $str = imapReadData($imapConnection);
+
+   echo "<FONT FACE=\"Arial,Helvetica\"><B>";
+   echo "<CENTER>$org_name</B><BR>";
+   echo "Folders</CENTER>";
+   echo "</B><BR></FONT>";
+   echo "<code><FONT FACE=\"Arial,Helvetica\">\n";
+   for ($i = 0;$i < count($str); $i++) {
+      $mailbox = Chop($str[$i]);
+      // find the quote at the begining of the mailbox name.
+      //    i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name.
+      $mailbox = findMailboxName($mailbox);
+      $periodCount = countCharInString($mailbox, ".");
+      
+      // indent the correct number of spaces.
+      for ($j = 0;$j < $periodCount;$j++)
+         echo "&nbsp;&nbsp;";
+      
+      $mailboxURL = urlencode($mailbox);
+      echo "<a href=\"mailboxMessageList.php3?sort=0&startMessage=0&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
+      echo readShortMailboxName($mailbox, ".");
+      echo "</FONT></a><br>\n";
+   }
+   echo "</code></FONT>";
+
+   fclose($imapConnection);
+                                  
+?>
+</FONT></BODY></HTML>
diff --git a/login.php3 b/login.php3
new file mode 100644 (file)
index 0000000..98bd70b
--- /dev/null
@@ -0,0 +1,51 @@
+<?
+   setcookie("username", "", time(), "/");
+   setcookie("key", "", time(), "/");
+   setcookie("logged_in", 0, time(), "/");
+?>
+<HTML>
+<BODY BGCOLOR=FFFFFF>
+<?
+   include("config/config.php3");
+
+   echo "<FORM ACTION=webmail.php3 METHOD=POST NAME=f>\n";
+   echo "<CENTER><IMG SRC=\"$org_logo\"</CENTER>\n";
+   echo "<CENTER><FONT FACE=\"Arial,Helvetica\" SIZE=-2>SquirrelMail version $version<BR>By Nathan and Luke Ehresman<BR></FONT><CENTER>\n";
+   echo "<TABLE COLS=1 WIDTH=350>\n";
+   echo "   <TR>\n";
+   echo "      <TD BGCOLOR=CCCCCC>\n";
+   echo "         <B><CENTER><FONT FACE=\"Arial,Helvetica\">$org_name Login</FONT></CENTER></B>\n";
+   echo "      </TD>\n";
+   echo "   </TR><TR>\n";
+   echo "      <TD BGCOLOR=FFFFFF>\n";
+   echo "         <TABLE COLS=2 WIDTH=100%>\n";
+   echo "            <TR>\n";
+   echo "               <TD WIDTH=30% ALIGN=right>\n";
+   echo "                  <FONT FACE=\"Arial,Helvetica\">Name:</FONT>\n";
+   echo "               </TD><TD WIDTH=* ALIGN=left>\n";
+   echo "                  <CENTER><INPUT TYPE=TEXT NAME=username></CENTER>\n";
+   echo "               </TD>\n";
+   echo "            </TR><TR>\n";
+   echo "               <TD WIDTH=30% ALIGN=right>\n";
+   echo "                  <FONT FACE=\"Arial,Helvetica\">Password:</FONT>\n";
+   echo "               </TD><TD WIDTH=* ALIGN=left>\n";
+   echo "                  <CENTER><INPUT TYPE=PASSWORD NAME=key></CENTER>\n";
+   echo "               </TD>\n"; 
+   echo "         </TABLE>\n";
+   echo "      </TD>\n";
+   echo "   </TR><TR>\n";
+   echo "      <TD>\n";
+   echo "         <CENTER><INPUT TYPE=SUBMIT VALUE=Login></CENTER>\n";
+   echo "      </TD>\n";
+   echo "   </TR>\n";
+   echo "</TABLE>\n";
+   echo "</FORM>\n";
+?>
+
+<SCRIPT LANGUAGE="JavaScript">
+   document.f.username.focus(); 
+</SCRIPT>
+
+</BODY>
+</HTML>
+
diff --git a/mailboxMessageList.php3 b/mailboxMessageList.php3
new file mode 100644 (file)
index 0000000..7ba540f
--- /dev/null
@@ -0,0 +1,299 @@
+<?
+   if(!isset($logged_in)) {
+      echo "You must <a href=\"login.php3\">login</a> first.";
+      exit;
+   }
+   if(!isset($username) || !isset($key)) {
+      echo "You need a valid user and password to access this page!";
+      exit;
+   }
+?>
+<HTML>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
+<FONT FACE="Arial,Helvetica"> 
+<?
+   include("config/config.php3");
+   include("functions/imap.php3");
+   include("functions/strings.php3");
+   include("functions/date.php3");
+   include("functions/pageheader.php3");
+   include("functions/array.php3");
+   
+   function selectMailbox($imapConnection, $mailbox, &$numberOfMessages) {
+      // select mailbox
+      fputs($imapConnection, "mailboxSelect SELECT \"$mailbox\"\n");
+      $read = fgets($imapConnection, 1024);
+      while ((substr($read, 0, 16) != "mailboxSelect OK") && (substr($read, 0, 17) != "mailboxSelect BAD")) {
+         if (substr(Chop($read), -6) == "EXISTS") {
+            $array = explode(" ", $read);
+            $numberOfMessages = $array[1];
+         }
+         $read = fgets($imapConnection, 1024);
+      }
+   }
+
+   function getMessageHeaders($imapConnection, $i, &$from, &$subject, &$date) {
+      fputs($imapConnection, "messageFetch FETCH $i:$i RFC822.HEADER.LINES (From Subject Date)\n");
+      $read = fgets($imapConnection, 1024);
+      /* I have to replace <> with [] because HTML uses <> as tags, thus not printing what's in <> */
+      $read = ereg_replace("<", "[", $read);
+      $read = ereg_replace(">", "]", $read);
+
+      while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
+         if (substr($read, 0, 5) == "From:") {
+            $read = ereg_replace("<", "EMAILSTART--", $read);
+            $read = ereg_replace(">", "--EMAILEND", $read);
+            $from = substr($read, 5, strlen($read) - 6);
+         }
+         else if (substr($read, 0, 5) == "Date:") {
+            $read = ereg_replace("<", "[", $read);
+            $read = ereg_replace(">", "]", $read);
+            $date = substr($read, 5, strlen($read) - 6);
+         }
+         else if (substr($read, 0, 8) == "Subject:") {
+            $read = ereg_replace("<", "[", $read);
+            $read = ereg_replace(">", "]", $read);
+            $subject = substr($read, 8, strlen($read) - 9);
+         }
+
+         $read = fgets($imapConnection, 1024);
+      }
+   }
+
+   function getMessageFlags($imapConnection, $i, &$flags) {
+      /**   * 2 FETCH (FLAGS (\Answered \Seen))   */
+      fputs($imapConnection, "messageFetch FETCH $i:$i FLAGS\n");
+      while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
+         if (strpos($read, "FLAGS")) {
+            $read = ereg_replace("\(", "", $read);
+            $read = ereg_replace("\)", "", $read);
+            $read = substr($read, strpos($read, "FLAGS")+6, strlen($read));
+            $read = trim($read);
+            $flags = explode(" ", $read);;
+            $i = 0;
+            while ($i < count($flags)) {
+               $flags[$i] = substr($flags[$i], 1, strlen($flags[$i]));
+               $i++;
+            }
+         } else {
+            $flags[0] = "None";
+         }
+         $read = fgets($imapConnection, 1024);
+      }
+   }
+
+   function getEmailAddr($sender) {
+      if (strpos($sender, "EMAILSTART--") == false)
+         return "";
+
+      $start = strpos($sender, "EMAILSTART--");
+      $emailAddr = substr($sender, $start, strlen($sender));
+
+      return $emailAddr;
+   }
+
+   function getSender($sender) {
+      if (strpos($sender, "EMAILSTART--") == false)
+         return "";
+
+      $first = substr($sender, 0, strpos($sender, "EMAILSTART--"));
+      $second = substr($sender, strpos($sender, "--EMAILEND") +10, strlen($sender));
+      return "$first$second";
+   }
+
+   function getSenderName($sender) {
+      $name = getSender($sender);
+      $emailAddr = getEmailAddr($sender);
+      $emailStart = strpos($emailAddr, "EMAILSTART--");
+      $emailEnd = strpos($emailAddr, "--EMAILEND") - 10;
+
+      if (($emailAddr == "") && ($name == "")) {
+         $from = $sender;
+      }
+      else if ((strstr($name, "?") != false) || (strstr($name, "$") != false) || (strstr($name, "%") != false)){
+         $emailAddr = ereg_replace("EMAILSTART--", "", $emailAddr);
+         $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
+         $from = $emailAddr;
+      }
+      else if (strlen($name) > 0) {
+         $from = $name;
+      }
+      else if (strlen($emailAddr > 0)) {
+         $emailAddr = ereg_replace("EMAILSTART--", "", $emailAddr);
+         $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
+         $from = $emailAddr;
+      }
+
+      $from = trim($from);
+
+      // strip out any quotes if they exist
+      if ((strlen($from) > 0) && ($from[0] == "\"") && ($from[strlen($from) - 1] == "\""))
+         $from = substr($from, 1, strlen($from) - 2);
+      
+      return $from;
+   }
+
+   function printMessageInfo($imapConnection, $i, $from, $subject, $date) {
+      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
+      getMessageFlags($imapConnection, $i, $flags);
+      $dateParts = explode(" ", trim($date));
+      $dateString = getDateString($dateParts);  // this will reformat the date string into a good format for us.
+      $senderName = getSenderName($from);
+      if (strlen(Chop($subject)) == 0)
+         $subject = "(no subject)";
+
+      $j = 0;
+      $deleted = false;
+      $seen = false;
+      $answered = false;
+      while ($j < count($flags)) {
+         if ($flags[$j] == "Deleted") {
+            $deleted = true;
+         } else if ($flags[$j] == "Answered") {
+            $answered = true;
+         } else if ($flags[$j] == "Seen") {
+            $seen = true;
+         }
+         $j++;
+      }
+
+      if ($deleted == false) {
+         echo "<TR>\n";
+         if ($seen == false) {
+            echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$i</B></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>$subject</B></FONT></TD>\n";
+         } else {
+            echo "   <TD><FONT FACE=\"Arial,Helvetica\">$i</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\">$subject</FONT></TD>\n";
+         }
+         echo "</TR>\n";
+      }
+   }
+
+
+
+   /////////////////////////////////////////////////////////////////////////////////
+   //
+   // incoming variables from URL:
+   //    $sort             Direction to sort by date
+   //                         values:  0  -  descending order
+   //                         values:  1  -  ascending order
+   //    $startMessage     Message to start at
+   //    $mailbox          Full Mailbox name
+   //
+   // incoming from cookie:
+   //    $username         duh
+   //    $key              pass
+   //
+   /////////////////////////////////////////////////////////////////////////////////
+   
+   
+   // If the page has been loaded without a specific mailbox,
+   //    just show a page of general info.
+   if (!isset($mailbox)) {
+      displayPageHeader("None");
+      
+      echo "<BR>";
+      echo "<TABLE COLS=1 WIDTH=70% NOBORDER BGCOLOR=FFFFFF ALIGN=CENTER>";
+      echo "   <TR>";
+      echo "      <TD BGCOLOR=DCDCDC>";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><B><CENTER>Welcome to $org_name's WebMail system</CENTER></B></FONT>";
+      echo "   </TD></TR><TR><TD>";
+      echo "   <TR><TD BGCOLOR=FFFFFF>";
+      echo "         <FONT FACE=\"Arial,Helvetica\" SIZE=-1><CENTER>Running SquirrelMail version $version (c) 1999 by Nathan and Luke Ehresman.</CENTER></FONT>";
+      echo "   </TD></TR><TR><TD>";
+      echo "      <TABLE COLS=2 WIDTH=75% NOBORDER align=\"center\">";
+      echo "         <TR>";
+      echo "            <TD BGCOLOR=FFFFFF><CENTER>";
+      if (strlen($org_logo) > 3)
+         echo "               <IMG SRC=\"$org_logo\">";
+      else
+         echo "               <B><FONT FACE=\"Arial,Helvetica\">$org_name</FONT></B>";
+      echo "            </CENTER></TD></TR><TR>";
+      echo "            <TD BGCOLOR=FFFFFF>";
+      echo "               <FONT FACE=\"Arial,Helvetica\">$motd</FONT>";
+      echo "            </TD>";
+      echo "         </TR>";
+      echo "      </TABLE>";
+      echo "   </TD></TR>";
+      echo "</TABLE>";
+      echo "</BODY></HTML>";
+      exit;
+   }
+
+   // open a connection on the imap port (143)
+   $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
+   if (!$imapConnection) {
+      echo "Error connecting to IMAP Server.<br>";
+      echo "$errorNumber : $errorString<br>";
+      exit;
+   }
+   $serverInfo = fgets($imapConnection, 256);
+
+   // login
+   fputs($imapConnection, "1 login $username $key\n");
+   $read = fgets($imapConnection, 1024);
+
+   // switch to the mailbox, and get the number of messages in it.
+   selectMailbox($imapConnection, $mailbox, $numMessages);
+
+   // make a URL safe $mailbox for use in the links
+   $urlMailbox = urlencode($mailbox);
+  
+   displayPageHeader($mailbox);
+   $i = 1;
+   while ($i <= $numMessages) {
+      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
+
+      $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date)));
+      $messages[$i]["ID"] = $i;
+      $messages[$i]["FROM"] = $from;
+      $messages[$i]["SUBJECT"] = $subject;
+      $i++;
+   }
+
+   if ($sort == 0)
+      $msgs = ary_sort($messages, "DATE", -1);
+   else
+      $msgs = ary_sort($messages, "DATE", 1);
+
+   if ($endMessage > 24) {
+      echo "<A HREF=\"mailboxMessageList.php3?sort=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>&nbsp&nbsp&nbsp";
+      $endMessage = 24;
+   }
+
+   /** Display "Next, Previous" on top */
+
+   /** This is the beginning of the message list table.  It wraps around all messages */
+   echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>";
+   echo "<TR><TD BGCOLOR=DCDCDC>";
+   echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=FFFFFF>";
+   echo "<TR BGCOLOR=FFFFCC ALIGN=\"center\">";
+   echo "   <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
+   echo "   <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT></TD>";
+   echo "   <TD WIDTH=15%><FONT FACE=\"Arial,Helvetica\"><B>Date</B></FONT>";
+   if ($sort == 0)
+      echo "   <A HREF=\"mailboxMessageList.php3?sort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"images/up_pointer.gif\" BORDER=0></A></TD>\n";
+   else
+      echo "   <A HREF=\"mailboxMessageList.php3?sort=0&startMessage=0&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"images/down_pointer.gif\" BORDER=0></A></TD>\n";
+   echo "   <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT></TD>\n";
+   echo "</TR>";
+
+   // loop through and display the info for each message.
+   for ($i = $startMessage;$i <= $endMessage; $i++) {
+      printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"]);
+   }
+
+   echo "</TABLE>\n";
+   echo "</TD></TR></TABLE>"; /** End of message-list table */
+
+   /** Display "Next, Previous" on bottom */
+   fclose($imapConnection);
+?>
+</FONT>
+</BODY>
+</HTML>
diff --git a/mailboxMessageListtmp.php3 b/mailboxMessageListtmp.php3
new file mode 100644 (file)
index 0000000..3f6a790
--- /dev/null
@@ -0,0 +1,345 @@
+<?
+   if(!isset($logged_in)) {
+      echo "You must <a href=\"login.php3\">login</a> first.";
+      exit;
+   }
+   if(!isset($username) || !isset($key)) {
+      echo "You need a valid user and password to access this page!";
+      exit;
+   }
+?>
+<HTML>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
+<FONT FACE="Arial,Helvetica"> 
+<?
+   include("config/config.php3");
+   include("functions/imap.php3");
+   include("functions/strings.php3");
+   include("functions/date.php3");
+   include("functions/pageheader.php3");
+   include("functions/array.php3");
+   
+   function selectMailbox($imapConnection, $mailbox, &$numberOfMessages) {
+      // select mailbox
+      fputs($imapConnection, "mailboxSelect SELECT \"$mailbox\"\n");
+      $read = fgets($imapConnection, 1024);
+      while ((substr($read, 0, 16) != "mailboxSelect OK") && (substr($read, 0, 17) != "mailboxSelect BAD")) {
+         if (substr(Chop($read), -6) == "EXISTS") {
+            $array = explode(" ", $read);
+            $numberOfMessages = $array[1];
+         }
+         $read = fgets($imapConnection, 1024);
+      }
+   }
+
+   function getMessageHeaders($imapConnection, $i, &$from, &$subject, &$date) {
+      fputs($imapConnection, "messageFetch FETCH $i:$i RFC822.HEADER.LINES (From Subject Date)\n");
+      $read = fgets($imapConnection, 1024);
+      /* I have to replace <> with [] because HTML uses <> as tags, thus not printing what's in <> */
+      $read = ereg_replace("<", "[", $read);
+      $read = ereg_replace(">", "]", $read);
+
+      while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
+         if (substr($read, 0, 5) == "From:") {
+            $read = ereg_replace("<", "EMAILSTART--", $read);
+            $read = ereg_replace(">", "--EMAILEND", $read);
+            $from = substr($read, 5, strlen($read) - 6);
+         }
+         else if (substr($read, 0, 5) == "Date:") {
+            $read = ereg_replace("<", "[", $read);
+            $read = ereg_replace(">", "]", $read);
+            $date = substr($read, 5, strlen($read) - 6);
+         }
+         else if (substr($read, 0, 8) == "Subject:") {
+            $read = ereg_replace("<", "[", $read);
+            $read = ereg_replace(">", "]", $read);
+            $subject = substr($read, 8, strlen($read) - 9);
+         }
+
+         $read = fgets($imapConnection, 1024);
+      }
+   }
+
+   function getMessageFlags($imapConnection, $i, &$flags) {
+      /**   * 2 FETCH (FLAGS (\Answered \Seen))   */
+      fputs($imapConnection, "messageFetch FETCH $i:$i FLAGS\n");
+      while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
+         if (strpos($read, "FLAGS")) {
+            $read = ereg_replace("\(", "", $read);
+            $read = ereg_replace("\)", "", $read);
+            $read = substr($read, strpos($read, "FLAGS")+6, strlen($read));
+            $read = trim($read);
+            $flags = explode(" ", $read);;
+            $i = 0;
+            while ($i < count($flags)) {
+               $flags[$i] = substr($flags[$i], 1, strlen($flags[$i]));
+               $i++;
+            }
+         } else {
+            $flags[0] = "None";
+         }
+         $read = fgets($imapConnection, 1024);
+      }
+   }
+
+   function getEmailAddr($sender) {
+      if (strpos($sender, "EMAILSTART--") == false)
+         return "";
+
+      $start = strpos($sender, "EMAILSTART--");
+      $emailAddr = substr($sender, $start, strlen($sender));
+
+      return $emailAddr;
+   }
+
+   function getSender($sender) {
+      if (strpos($sender, "EMAILSTART--") == false)
+         return "";
+
+      $first = substr($sender, 0, strpos($sender, "EMAILSTART--"));
+      $second = substr($sender, strpos($sender, "--EMAILEND") +10, strlen($sender));
+      return "$first$second";
+   }
+
+   function getSenderName($sender) {
+      $name = getSender($sender);
+      $emailAddr = getEmailAddr($sender);
+      $emailStart = strpos($emailAddr, "EMAILSTART--");
+      $emailEnd = strpos($emailAddr, "--EMAILEND") - 10;
+
+      if (($emailAddr == "") && ($name == "")) {
+         $from = $sender;
+      }
+      else if ((strstr($name, "?") != false) || (strstr($name, "$") != false) || (strstr($name, "%") != false)){
+         $emailAddr = ereg_replace("EMAILSTART--", "", $emailAddr);
+         $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
+         $from = $emailAddr;
+      }
+      else if (strlen($name) > 0) {
+         $from = $name;
+      }
+      else if (strlen($emailAddr > 0)) {
+         $emailAddr = ereg_replace("EMAILSTART--", "", $emailAddr);
+         $emailAddr = ereg_replace("--EMAILEND", "", $emailAddr);
+         $from = $emailAddr;
+      }
+
+      $from = trim($from);
+
+      // strip out any quotes if they exist
+      if ((strlen($from) > 0) && ($from[0] == "\"") && ($from[strlen($from) - 1] == "\""))
+         $from = substr($from, 1, strlen($from) - 2);
+      
+      return $from;
+   }
+
+   function printMessageInfo($imapConnection, $i, $from, $subject, $date) {
+      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
+      getMessageFlags($imapConnection, $i, $flags);
+      $dateParts = explode(" ", trim($date));
+      $dateString = getDateString($dateParts);  // this will reformat the date string into a good format for us.
+      $senderName = getSenderName($from);
+      if (strlen(Chop($subject)) == 0)
+         $subject = "(no subject)";
+
+      $j = 0;
+      $deleted = false;
+      $seen = false;
+      $answered = false;
+      while ($j < count($flags)) {
+         if ($flags[$j] == "Deleted") {
+            $deleted = true;
+         } else if ($flags[$j] == "Answered") {
+            $answered = true;
+         } else if ($flags[$j] == "Seen") {
+            $seen = true;
+         }
+         $j++;
+      }
+
+      if ($deleted == false) {
+         echo "<TR>\n";
+         if ($seen == false) {
+            echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$i</B></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>$subject</B></FONT></TD>\n";
+         } else {
+            echo "   <TD><FONT FACE=\"Arial,Helvetica\">$i</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\">$subject</FONT></TD>\n";
+         }
+         echo "</TR>\n";
+      }
+   }
+
+
+
+   /////////////////////////////////////////////////////////////////////////////////
+   //
+   // incoming variables from URL:
+   //    $sort             Direction to sort by date
+   //                         values:  0  -  descending order
+   //                         values:  1  -  ascending order
+   //    $startMessage     Message to start at
+   //    $mailbox          Full Mailbox name
+   //
+   // incoming from cookie:
+   //    $username         duh
+   //    $key              pass
+   //
+   /////////////////////////////////////////////////////////////////////////////////
+   
+   
+   // If the page has been loaded without a specific mailbox,
+   //    just show a page of general info.
+   if (!isset($mailbox)) {
+      displayPageHeader("None");
+      
+      echo "<BR>";
+      echo "<TABLE COLS=1 WIDTH=70% NOBORDER BGCOLOR=FFFFFF ALIGN=CENTER>";
+      echo "   <TR>";
+      echo "      <TD BGCOLOR=DCDCDC>";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><B><CENTER>Welcome to $org_name's WebMail system</CENTER></B></FONT>";
+      echo "   </TD></TR><TR><TD>";
+      echo "   <TR><TD BGCOLOR=FFFFFF>";
+      echo "         <FONT FACE=\"Arial,Helvetica\" SIZE=-1><CENTER>Running SquirrelMail version $version (c) 1999 by Nathan and Luke Ehresman.</CENTER></FONT>";
+      echo "   </TD></TR><TR><TD>";
+      echo "      <TABLE COLS=2 WIDTH=75% NOBORDER align=\"center\">";
+      echo "         <TR>";
+      echo "            <TD BGCOLOR=FFFFFF><CENTER>";
+      if (strlen($org_logo) > 3)
+         echo "               <IMG SRC=\"$org_logo\">";
+      else
+         echo "               <B><FONT FACE=\"Arial,Helvetica\">$org_name</FONT></B>";
+      echo "            </CENTER></TD></TR><TR>";
+      echo "            <TD BGCOLOR=FFFFFF>";
+      echo "               <FONT FACE=\"Arial,Helvetica\">$motd</FONT>";
+      echo "            </TD>";
+      echo "         </TR>";
+      echo "      </TABLE>";
+      echo "   </TD></TR>";
+      echo "</TABLE>";
+      echo "</BODY></HTML>";
+      exit;
+   }
+
+   // open a connection on the imap port (143)
+   $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
+   if (!$imapConnection) {
+      echo "Error connecting to IMAP Server.<br>";
+      echo "$errorNumber : $errorString<br>";
+      exit;
+   }
+   $serverInfo = fgets($imapConnection, 256);
+   echo "LOGGING IN<BR>";
+
+   // login
+   fputs($imapConnection, "1 login $username $key\n");
+   $read = fgets($imapConnection, 1024);
+
+   // switch to the mailbox, and get the number of messages in it.
+   selectMailbox($imapConnection, $mailbox, $numMessages);
+
+   // make a URL safe $mailbox for use in the links
+   $urlMailbox = urlencode($mailbox);
+  
+   displayPageHeader($mailbox);
+   $i = 0;
+   echo "NumMessages: $numMessages<BR>";
+   while ($i < $numMessages) {
+      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
+      $messages[$i]["DATE"] = $date;
+      $messages[$i]["ID"] = $i;
+      $messages[$i]["FROM"] = $from;
+      $messages[$i]["SUBJECT"] = $subject;
+      echo "$messages[$i][\"FROM\"]<BR>";
+      $i++;
+   }
+
+   if ($sort == 0) {
+      ary_sort($messages, "SUBJECT", -1);
+   } else {
+      ary_sort($messages, "SUBJECT", 1);
+   }
+
+   /** This is the beginning of the message list table.  It wraps around all messages */
+   echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>";
+//   echo "<TR><TD ALIGN=center><FONT FACE=\"Arial,Helvetica\"><BR>Viewing messages <B>$startMessage</B> to <B>$endMessage</B>&nbsp&nbsp&nbsp($numMessages total)<BR></FONT></TD></TR>";
+   echo "<TR><TD BGCOLOR=DCDCDC>";
+   // display the correct next/Previous listings...
+/*   if ($sort == 1) {
+      if ($endMessage < $numMessages) {
+         $nextGroup = $endMessage + 1;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>&nbsp&nbsp&nbsp";
+      }
+      if ($startMessage > 1) {
+         $nextGroup = $startMessage - 25;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">Previous</A>";
+      }
+   } else {
+      if ($endMessage > 1) {
+         $nextGroup = $endMessage - 1;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=0&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>&nbsp&nbsp&nbsp";
+      }
+      if ($startMessage < $numMessages) {
+         $nextGroup = $startMessage + 25;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=0&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">Previous</A>";
+      }
+   }
+   */
+   echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=FFFFFF>";
+   echo "<TR BGCOLOR=FFFFCC ALIGN=\"center\">";
+   echo "   <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
+   echo "   <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT></TD>";
+   echo "   <TD WIDTH=15%><FONT FACE=\"Arial,Helvetica\"><B>Date</B></FONT>";
+   if ($sort == 0)
+      echo "   <A HREF=\"mailboxMessageList.php3?sort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"images/up_pointer.gif\" BORDER=0></A></TD>\n";
+   else
+      echo "   <A HREF=\"mailboxMessageList.php3?sort=0&startMessage=0&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"images/down_pointer.gif\" BORDER=0></A></TD>\n";
+   echo "   <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT></TD>\n";
+   echo "</TR>";
+
+   // loop through and display the info for each message.
+   if ($sort == 1) {
+      for ($i = $startMessage;$i <= $endMessage; $i++) {
+         getMessageHeaders($imapConnection, $i, $from, $subject, $date);
+         printMessageInfo($imapConnection, $i, $from, $subject, $date);
+      }
+   } else {
+      for ($i = $startMessage;$i >= $endMessage; $i--) {
+         getMessageHeaders($imapConnection, $i, $from, $subject, $date);
+         printMessageInfo($imapConnection, $i, $from, $subject, $date);
+      }
+   }
+   
+   echo "</TABLE>\n";
+
+   // display the correct next/Previous listings...
+   if ($sort == 1) {
+      if ($endMessage < $numMessages) {
+         $nextGroup = $endMessage + 1;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=1&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>&nbsp&nbsp&nbsp";
+      }
+      if ($startMessage > 1) {
+         $nextGroup = $startMessage - 25;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=1&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>";
+      }
+   } else {
+      if ($endMessage > 1) {
+         $nextGroup = $endMessage - 1;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=0&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>&nbsp&nbsp&nbsp";
+      }
+      if ($startMessage < $numMessages) {
+         $nextGroup = $startMessage + 25;
+         echo "<A HREF=\"mailboxMessageList.php3?sort=0&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>";
+      }
+   }
+   echo "</TD></TR></TABLE>"; /** End of message-list table */
+
+   fclose($imapConnection);
+?>
+</FONT>
+</BODY>
+</HTML>
diff --git a/signout.php3 b/signout.php3
new file mode 100644 (file)
index 0000000..693a02f
--- /dev/null
@@ -0,0 +1,34 @@
+<?
+       $username = "";
+       $key = "";
+       $logged_in = 0;
+       
+       setcookie("username", "", time(), "/");
+       setcookie("key", "", time(), "/");
+       setcookie("logged_in", 0, time(), "/");
+?>
+<HTML>
+<BODY BGCOLOR=FFFFFF>
+<?
+   echo "<BR><BR><TABLE BGCOLOR=FFFFFF BORDER=0 COLS=1 WIDTH=50% CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>";
+   echo "   <TR BGCOLOR=A0B8C8 WIDTH=100%>";
+   echo "      <TD ALIGN=CENTER>";
+   echo "         <FONT FACE=\"Arial,Helvetica\"><B>Sign Out</B></FONT>";
+   echo "      </TD>";
+   echo "   </TR>";
+   echo "   <TR BGCOLOR=FFFFFF WIDTH=100%>";
+   echo "      <TD ALIGN=CENTER>";
+   echo "         <FONT FACE=\"Arial,Helvetica\"><BR>You have been successfully signed out.<BR></FONT>";
+   echo "         <FONT FACE=\"Arial,Helvetica\">Click here to <A HREF=\"login.php3\" TARGET=_top>log back in.</A></FONT><BR><BR>";
+   echo "      </TD>";
+   echo "   </TR>";
+   echo "   <TR BGCOLOR=DCDCDC WIDTH=100%>";
+   echo "      <TD ALIGN=CENTER>";
+   echo "         <FONT FACE=\"Arial,Helvetica\"><BR></FONT>";
+   echo "      </TD>";
+   echo "   </TR>";
+   echo "</TABLE>";
+?>
+</BODY>
+</HTML>
+
diff --git a/webmail.php3 b/webmail.php3
new file mode 100644 (file)
index 0000000..1c57f54
--- /dev/null
@@ -0,0 +1,19 @@
+<?
+   if(!isset($username)) {
+      echo "You need a valid user and password to access this page!";
+      exit;
+   }
+
+   setcookie("username", $username, 0, "/");
+   setcookie("key", $key, 0, "/");
+   setcookie("logged_in", 1, 0, "/");
+?>
+<HTML><HEAD>
+<TITLE>
+OM-USA WebMail
+</TITLE>
+<FRAMESET COLS="200, *" NORESIZE BORDER=0>
+   <FRAME SRC="left.php3" NAME="left">
+   <FRAME SRC="mailboxMessageList.php3" NAME="right">
+</FRAMESET>
+</HEAD></HTML>