I believe everything is compatable with all IMAP servers now
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 16 Dec 1999 21:18:54 +0000 (21:18 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 16 Dec 1999 21:18:54 +0000 (21:18 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@83 7612ce4b-ef26-0410-bec9-ea0150e637f0

19 files changed:
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
functions/imap.php
functions/mailbox.php
functions/mailbox_display.php
functions/page_header.php
functions/strings.php
index.html
src/delete_message.php
src/empty_trash.php
src/folders.php
src/folders_create.php
src/folders_delete.php
src/folders_rename_do.php
src/folders_rename_getname.php
src/left_main.php
src/login.php
src/move_messages.php
src/right_main.php

diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..c7aea18
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,280 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..fe5c2d4
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,9 @@
+Version 0.1 -- December 14, 1999
+--------------------------------
+- Message composing (with to, cc, bcc)
+- Message viewing, including HTML messages
+- Basic MIME support, no attachments...yet
+- Message sorting by Date, Name, or subject
+- Folder manipulation (deleting, creating, moving, and renaming)
+- IMAP email (currently only Cyrus IMAP server has been tested)
+- Many other features that are basic email functionality
index 4f11ed9072d7f43691a5f7232e6204fa280d4137..62bfe30b96ffdd112a4c92e5fddecfa23363fdbb 100644 (file)
@@ -7,33 +7,90 @@
     **/
 
    /** Read from the connection until we get either an OK or BAD message. **/
-   function imapReadData($connection) {
+   function imapReadData($connection, $pre, $handle_errors, &$response, &$message) {
+      require ("../config/config.php");
+
       $read = fgets($connection, 1024);
       $counter = 0;
-      while ((substr($read, strpos($read, " ") + 1, 2) != "OK") && (substr($read, strpos($read, " ") + 1, 3) != "BAD")) {
+      while ((substr($read, 0, strlen("$pre OK")) != "$pre OK") &&
+             (substr($read, 0, strlen("$pre BAD")) != "$pre BAD") &&
+             (substr($read, 0, strlen("$pre NO")) != "$pre NO")) {
          $data[$counter] = $read;
          $read = fgets($connection, 1024);
          $counter++;
       }
+      if (substr($read, 0, strlen("$pre OK")) == "$pre OK") {
+         $response = "OK";
+         $message = trim(substr($read, strlen("$pre OK"), strlen($read)));
+      } else if (substr($read, 0, strlen("$pre BAD")) == "$pre BAD") {
+         $response = "BAD";
+         $message = trim(substr($read, strlen("$pre BAD"), strlen($read)));
+      } else {
+         $response = "NO";
+         $message = trim(substr($read, strlen("$pre NO"), strlen($read)));
+      }
+
+      if ($handle_errors == true) {
+         if ($response == "NO") {
+            echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>:  Could not complete request.</B> </FONT><BR><FONT COLOR=CC0000>&nbsp;&nbsp;<B>Reason given:</B> $message</FONT><BR><BR>";
+            exit;
+         } else if ($response == "BAD") {
+            echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>:  Bad or malformed request.</B></FONT><BR><FONT COLOR=CC0000>&nbsp;&nbsp;<B>Server responded:</B> $message</FONT><BR><BR>";
+            exit;
+         }
+      }
+
       return $data;
    }
 
    /** 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);
+      $mailbox = trim($mailbox);
+      if (substr($mailbox,  strlen($mailbox)-1, strlen($mailbox)) == "\"") {
+         $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
+         $pos = strrpos($mailbox, "\"") + 1;
+         $box = substr($mailbox, $pos, strlen($mailbox));
+      } else {
+         $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox));
       }
-      echo $tmp;
-      return strrev($temp);
+      return $box;
+   }
+
+   /** Finds the delimeter between mailboxes **/
+   function findMailboxDelimeter($imapConnection) {
+      fputs($imapConnection, ". list \"\" \"\"\n");
+      $read = fgets($imapConnection, 1024);
+
+      $pos = strrpos($read, "\"");
+      $read = substr($read, 0, $pos);
+
+      $pos = strrpos($read, "\"");
+      $read = substr($read, 0, $pos);
+
+      $pos = strrpos($read, "\"");
+      $read = substr($read, 0, $pos);
+
+      $pos = strrpos($read, "\"");
+      $read = substr($read, $pos+1, strlen($read));
+
+      $tmp = fgets($imapConnection, 1024);
+      return $read;
+   }
+
+   function getMailboxFlags($mailbox) {
+      $mailbox = trim($mailbox);
+      $mailbox = substr($mailbox, strpos($mailbox, "(")+1, strlen($mailbox));
+      $mailbox = substr($mailbox, 0, strpos($mailbox, ")"));
+      $mailbox = str_replace("\\", "", $mailbox);
+      $mailbox = strtolower($mailbox);
+      $mailbox = explode(" ", $mailbox);
+      return $mailbox;
    }
 
    // handles logging onto an imap server.
-   function loginToImapServer($username, $key, $imapServerAddress) {
+   function loginToImapServer($username, $key, $imapServerAddress, $hide) {
+      require("../config/config.php");
+
       $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
       if (!$imapConnection) {
          echo "Error connecting to IMAP Server.<br>";
       $serverInfo = fgets($imapConnection, 256);
  
       // login
-      fputs($imapConnection, "1 login $username $key\n");
+      fputs($imapConnection, "a001 LOGIN $username $key\n");
       $read = fgets($imapConnection, 1024);
-      if (strpos($read, "NO")) {
-         error_username_password_incorrect();
-         exit;
+      if ($debug_login == true) {
+         echo "SERVER SAYS: $read<BR>";
       }
-      
+
+      if (substr($read, 0, 7) != "a001 OK") {
+         if (!$hide) {
+            if (substr($read, 0, 8) == "a001 BAD") {
+               echo "Bad request: $read<BR>";
+               exit;
+            }
+            else if (substr($read, 0, 7) == "a001 NO") {
+               echo "<BR>";
+               echo "<TABLE COLS=1 WIDTH=70% NOBORDER BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
+               echo "   <TR>";
+               echo "      <TD BGCOLOR=\"$color[0]\">";
+               echo "         <FONT FACE=\"Arial,Helvetica\" COLOR=\"$color[2]\"><B><CENTER>ERROR</CENTER></B></FONT>";
+               echo "   </TD></TR><TR><TD>";
+               echo "      <CENTER><FONT FACE=\"Arial,Helvetica\"><BR>Unknown user or password incorrect.<BR><A HREF=\"login.php\" TARGET=_top>Click here to try again</A>.</FONT></CENTER>";
+               echo "   </TD></TR>";
+               echo "</TABLE>";
+               echo "</BODY></HTML>";
+               exit;
+            }
+            else {
+               echo "Unknown error: $read<BR>";
+               exit;
+            }
+         } else {
+            exit;
+         }
+      }
+
       return $imapConnection;
    }
 
    /** must be sent in the form:  user.<USER>.<FOLDER> **/
-   function createFolder($imapConnection, $folder) {
+   function createFolder($imapConnection, $folder, $type) {
+      require ("../config/config.php");
+
+      if (strtolower($type) == "noselect") {
+         $dm = findMailboxDelimeter($imapConnection);
+         $folder = "$folder$dm";
+      } else {
+         $folder = "$folder";
+      }
       fputs($imapConnection, "1 create \"$folder\"\n");
+      $data = imapReadData($imapConnection, "1", false, $response, $message);
+
+      if ($response == "NO") {
+         echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>:  Could not complete request.</B> </FONT><BR><FONT COLOR=CC0000>&nbsp;&nbsp;<B>Reason given:</B> $message</FONT><BR><BR>";
+         echo "Possible solutions:<BR><LI>You may need to specify that the folder is a subfolder of INBOX</LI>";
+         exit;
+      } else if ($response == "BAD") {
+         echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>:  Bad or malformed request.</B></FONT><BR><FONT COLOR=CC0000>&nbsp;&nbsp;<B>Server responded:</B> $message</FONT><BR><BR>";
+         exit;
+      }
    }
 
-   /** must be sent in the form:  user.<USER>.<FOLDER> **/
    function removeFolder($imapConnection, $folder) {
       fputs($imapConnection, "1 delete \"$folder\"\n");
+      $data = imapReadData($imapConnection, "1", false, $response, $message);
+      if ($response == "NO") {
+         echo "<FONT FACE=\"Arial,Helvetica\" COLOR=FF0000><B>ERROR</B>:  Could not delete the folder $folder.</FONT>";
+         echo "<FONT FACE=\"Arial,Helvetica\" COLOR=\"$color[8]\">Probable causes:</FONT><BR>";
+         echo "<FONT FACE=\"Arial,Helvetica\" COLOR=\"$color[8]\"><LI>This folder may contain subfolders.  Delete all subfolders first</LI></FONT>";
+         exit;
+      } else if ($response == "BAD") {
+         echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>:  Bad or malformed request.</B></FONT><BR><FONT COLOR=CC0000>&nbsp;&nbsp;<B>Server responded:</B> $message</FONT><BR><BR>";
+         exit;
+      }
    }
 
    /** Sends back two arrays, boxesFormatted and boxesUnformatted **/
-   function getFolderList($imapConnection, &$boxesFormatted, &$boxesUnformatted) {
+   function getFolderList($imapConnection, &$boxesFormatted, &$boxesUnformatted, &$boxesRaw) {
       fputs($imapConnection, "1 list \"\" *\n");
-      $str = imapReadData($imapConnection);
+      $str = imapReadData($imapConnection, "1", true, $response, $message);
 
+      $dm = findMailboxDelimeter($imapConnection);
       for ($i = 0;$i < count($str); $i++) {
          $mailbox = chop($str[$i]);
+         $boxesRaw[$i] = $mailbox;
+
          $mailbox = findMailboxName($mailbox);
-         $periodCount = countCharInString($mailbox, ".");
+         $periodCount = countCharInString($mailbox, $dm);
 
          // indent the correct number of spaces.
          for ($j = 0;$j < $periodCount;$j++)
             $boxesFormatted[$i] = "$boxesFormatted[$i]&nbsp;&nbsp;";
 
-         $boxesFormatted[$i] = $boxesFormatted[$i] . readShortMailboxName($mailbox, ".");
+         $boxesFormatted[$i] = $boxesFormatted[$i] . readShortMailboxName($mailbox, $dm);
          $boxesUnformatted[$i] = $mailbox;
       }
    }
index 383da2df4aa8614d610c5ab094968b3dd67a8430..8babee25da3c04a93b0c52d194eef12a7ad1ed9b 100644 (file)
    function selectMailbox($imapConnection, $mailbox, &$numberOfMessages) {
       // select mailbox
       fputs($imapConnection, "mailboxSelect SELECT \"$mailbox\"\n");
-      $read = fgets($imapConnection, 1024);
-      $unseen = false;
-      while ((substr($read, 0, 16) != "mailboxSelect OK") && (substr($read, 0, 17) != "mailboxSelect BAD")) {
-         if (substr(Chop($read), -6) == "EXISTS") {
-            $array = explode(" ", $read);
+      $data = imapReadData($imapConnection, "mailboxSelect");
+      for ($i = 0; $i < count($data); $i++) {
+         if (substr(Chop($data[$i]), -6) == "EXISTS") {
+            $array = explode(" ", $data[$i]);
             $numberOfMessages = $array[1];
          }
-         $read = fgets($imapConnection, 1024);
       }
    }
 
       fputs($imapConnection, "1 EXPUNGE\n");
    }
 
-   function getFolderNameMinusINBOX($mailbox) {
-      if (substr($mailbox, 0, 6) == "INBOX.")
-         $box = substr($mailbox, 6, strlen($mailbox));
+   function getFolderNameMinusINBOX($mailbox, $del) {
+      $inbox = "INBOX" . $del;
+      if (substr($mailbox, 0, strlen($inbox)) == $inbox)
+         $box = substr($mailbox, strlen($inbox), strlen($mailbox));
       else
          $box = $mailbox;
 
index 66c7fde5402ae105ced9ad078ba9857ca207d9e5..98007b0415932618fc00be84d3b20eee5c9b7950 100644 (file)
@@ -9,6 +9,8 @@
     **/
 
    function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox, $sort, $startMessage) {
+      require ("../config/config.php");
+
       $senderName = getSenderName($from);
       $urlMailbox = urlencode($mailbox);
       $subject = trim(stripslashes($subject));
@@ -31,7 +33,7 @@
     ** This function loops through a group of messages in the mailbox and shows them
     **/
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
-      include("../config/config.php");
+      require ("../config/config.php");
 
       if (1 <= $numMessages) {
          getMessageHeaders($imapConnection, 1, $numMessages, $from, $subject, $date);
       echo "      <TD WIDTH=30% ALIGN=LEFT>\n";
       echo "         <NOBR><FONT FACE=\"Arial,Helvetica\" SIZE=2><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"Move to:\">\n";
       echo "         <SELECT NAME=\"targetMailbox\">\n";
-      getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted);
+      getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
       for ($i = 0; $i < count($boxesUnformatted); $i++) {
          $use_folder = true;
          for ($p = 0; $p < count($special_folders); $p++) {
index b5c99694dde338f1fc1f2cc284d61fb66eb1a9e6..e798fad03cb19602735191113bd4f38686db2814 100644 (file)
@@ -14,7 +14,7 @@
       echo "      <TD ALIGN=left WIDTH=30%>";
       echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"signout.php\" TARGET=_top><B>Sign Out</B></A></FONT>";
       echo "      </TD><TD ALIGN=right WIDTH=70%>";
-      echo "         <FONT FACE=\"Arial,Helvetica\"><div align=right>Current Folder: <B>$shortBoxName</div></B></FONT>";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><div align=right>Current Folder: <B>$shortBoxName&nbsp;</div></B></FONT>";
       echo "      </TD>";
       echo "   </TR></TABLE>\n";
       echo "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 COLS=2 WIDTH=100% CELLSPACING=0 CELLPADDING=2><TR>";
index 348b62d75516995bd926ddd91e125d847046b725..c3cdc3a31091ae13a9c54365a585f380684dc760 100644 (file)
    //    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;
+      if (strpos($haystack, $needle)) {
+         $pos = strrpos($haystack, $needle) + 1;
+         $data = substr($haystack, $pos, strlen($haystack));
+      } else {
+         $data = $haystack;
       }
-      return strrev($data);
+      return $data;
    }
 
    // Wraps text at $wrap characters
index 2dbf5dbf36eb3fc7b060ec83605915b9ba8d50cc..213d9d012c4e00103948ad7feb73e1b0602db657 100644 (file)
@@ -1,9 +1,6 @@
 <HTML>
-   <HEAD>
-      <SCRIPT LANGUAGE="JavaScript">
-         parent.location.href="src/login.php"
-      </SCRIPT>
-   </HEAD>
+   <META HTTP-EQUIV="REFRESH" CONTENT="0;URL=src/login.php">
    <BODY>
+   <CENTER>You will be automatically forwarded.<BR>If not, <A HREF="src/login.php">click here</A>.</CENTER>
    </BODY>
 </HTML>
index f490f4cf782b2bd8b63d37f1c3efeb07c0e2be4d..5381264c2acf34ec20fd55d1dcc862706fd1aa47 100644 (file)
@@ -14,6 +14,6 @@
    displayPageHeader($color, $mailbox);
 
    deleteMessages($imapConnection, $message, $message, $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
-   messages_deleted_message($mailbox, $sort, $startMessage);
+   messages_deleted_message($mailbox, $sort, $startMessage, $color);
 ?>
 </BODY></HTML>
\ No newline at end of file
index 2cf16df18af4139071d31f999753e75130cb99c8..1d177b551c7eea6e000f73f947c1358dc8cc0a1e 100644 (file)
@@ -8,47 +8,27 @@
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
 
-   // switch to the mailbox, and get the number of messages in it.
-   selectMailbox($imapConnection, $mailbox, $numMessages);
-
-   if ($mailbox != $trash_folder) {
-      echo "ERROR -- I'm not in the trash folder!<BR>";
-      exit;
-   }
-
-
-   /** GET FOLDER ARRAY OF TRASH SUBFOLDERS **/
-   fputs($imapConnection, "1 list \"\" *\n");
-   $str = imapReadData($imapConnection);
-
-   for ($i = 0;$i < count($str); $i++) {
-      $box = Chop($str[$i]);
-      $mailbox = findMailboxName($box);
-
-      if (strpos($box, $trash_folder) > 0) {
-         $folders[$i] = $mailbox;
-      } else {
-         $folders[$i] = "NOPE";
+   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+
+   $mailbox = $trash_folder;
+   fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
+   $data = imapReadData($imapConnection , "1", false, $response, $message);
+   while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
+      for ($i = 0; $i < count($boxesUnformatted); $i++) {
+         if (($boxesUnformatted[$i] == $mailbox) ||
+             (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            removeFolder($imapConnection, "$boxesUnformatted[$i]");
+         }
       }
+      fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
+      $data = imapReadData($imapConnection , "1", false, $response, $message);
    }
 
-   // mark them as deleted
-   setMessageFlag($imapConnection, 1, $numMessages, "Deleted");
-   expungeBox($imapConnection, $mailbox);
-
-   // remove subfolders
-   for ($i = 0; $i < count($folders); $i++) {
-      if (($folders[$i] == "NOPE") || ($folders[$i] == "$trash_folder")) {
-      } else {
-         $thisfolder = getFolderNameMinusINBOX($folders[$i]);
-         $thisfolder = "user.$username.$thisfolder";
-         removeFolder($imapConnection, $thisfolder);
-      }
-   }
+   createFolder($imapConnection, "$trash_folder", "");
 
    selectMailbox($imapConnection, $trash_folder, $numMessages);
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    displayPageHeader($color, $mailbox);
-   messages_deleted_message($trash_folder, $sort, $startMessage);
+   messages_deleted_message($trash_folder, $sort, $startMessage, $color);
    fputs($imapConnection, "1 logout");
 ?>
index 0dd352f6f02d69cac0206dda18935e88b7e73d8d..f25c2c4241add52e0e094c20625cc89812c3e2de 100644 (file)
@@ -16,7 +16,7 @@
    echo "</TABLE>\n";
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted);
+   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
 
    /** DELETING FOLDERS **/
    echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
    echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
    echo "&nbsp;&nbsp;as a subfolder of<BR>";
    echo "<SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
+   if ($default_sub_of_inbox == false)
+      echo "<OPTION SELECTED>[ None ]\n";
+   else
+      echo "<OPTION>[ None ]\n";
+
    for ($i = 0;$i < count($boxesUnformatted); $i++) {
-      echo "<OPTION>$boxesUnformatted[$i]\n";
+      if (($boxesUnformatted[$i] == $special_folders[0]) && ($default_sub_of_inbox == true))
+         echo "<OPTION SELECTED>$boxesUnformatted[$i]\n";
+      else
+         echo "<OPTION>$boxesUnformatted[$i]\n";
    }
    echo "</SELECT><BR>\n";
    echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
    echo "</FORM><BR></TD></TR><BR>\n";
 
    /** RENAMING FOLDERS **/
-   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Rename or Move Folder</B></FONT></TD></TR>";
+   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Rename a Folder</B></FONT></TD></TR>";
    echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
    echo "<FORM ACTION=folders_rename_getname.php METHOD=POST>\n";
    echo "<SELECT NAME=old><FONT FACE=\"Arial,Helvetica\">\n";
@@ -71,7 +79,7 @@
          echo "   <OPTION>$boxesUnformatted[$i]\n";
    }
    echo "</SELECT>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=\"Rename or Move\">\n";
+   echo "<INPUT TYPE=SUBMIT VALUE=\"Rename\">\n";
    echo "</FORM></TD></TR></TABLE><BR>\n";
 
 ?>
index e259dc03720354948301373f5cbeac8a0c29162c..171fbad9269c017082232ff98db7af0fc44e9052 100644 (file)
@@ -1,5 +1,4 @@
 <HTML>
-<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=webmail.php?right_frame=folders.php" TARGET=_top>
 <?
    include("../config/config.php");
    include("../functions/strings.php");
@@ -8,10 +7,15 @@
 
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-   fputs($imapConnection, "1 create \"$subfolder.$folder_name\"\n");
+   $dm = findMailboxDelimeter($imapConnection);
+   if (trim($subfolder) == "[ None ]") {
+      createFolder($imapConnection, "$folder_name");
+   } else {
+      createFolder($imapConnection, "$subfolder$dm$folder_name");
+   }
    fputs($imapConnection, "1 logout\n");
 
-   echo "<CENTER><BR><BR>You will be automatically forwarded.<BR>If not, <A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>click here</A></CENTER>";
+   echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>";
 ?>
 </BODY></HTML>
 
index 430bb00be7a11f90092eddc6ffcdd5dbf5215829..6e214ecd551b08fd6fe4ef77f74282bdb73a8c87 100644 (file)
@@ -5,26 +5,46 @@
    include("../functions/imap.php");
    include("../functions/mailbox.php");
 
+   echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-   selectMailbox($imapConnection, $mailbox, $numMessages);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted);
+   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+
+   $dm = findMailboxDelimeter($imapConnection);
+   /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
+   for ($i = 0; $i < count($boxesUnformatted); $i++) {
+      if ($boxesUnformatted[$i] == $trash_folder)
+         $tmp_trash_folder = $boxesRaw[$i];
+   }
+
+   $tmpflags = getMailboxFlags($tmp_trash_folder);
+   $can_move_to_trash = true;
+   for ($i = 0; $i < count($tmpflags); $i++) {
+      if (strtolower($tmpflags[$i]) == "noinferiors")
+         $can_move_to_trash = false;
+   }
 
    /** Lets start removing the folders and messages **/
-   if ($move_to_trash == true) { /** if they wish to move messages to the trash **/
+   if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
       /** Creates the subfolders under $trash_folder **/
       for ($i = 0; $i < count($boxesUnformatted); $i++) {
-         if (substr($boxesUnformatted[$i], 0, strlen($mailbox)) == $mailbox) {
-            $folderWithoutINBOX = getFolderNameMinusINBOX($boxesUnformatted[$i]);
-            createFolder($imapConnection, "$trash_folder.$folderWithoutINBOX");
+         if (($boxesUnformatted[$i] == $mailbox) ||
+             (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            $folderWithoutINBOX = getFolderNameMinusINBOX($boxesUnformatted[$i], $dm);
+            $flags = getMailboxFlags($boxesRaw[$i]);
+            for ($b = 0; $b < count($flags); $b++) {
+               $type = $flags[$b];
+            }
+            createFolder($imapConnection, "$trash_folder" . $dm . "$folderWithoutINBOX", $type);
          }
       }
       for ($i = 0; $i < count($boxesUnformatted); $i++) {
-         if (substr($boxesUnformatted[$i], 0, strlen($mailbox)) == $mailbox) {
+         if (($boxesUnformatted[$i] == $mailbox) ||
+             (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
             selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages);
             $folder = getFolderNameMinusINBOX($boxesUnformatted[$i]);
 
             if ($numMessages > 0)
-               $success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder.$folder");
+               $success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder" . $dm . "$folder");
             else
                $success = true;
 
                removeFolder($imapConnection, "$boxesUnformatted[$i]");
          }
       }
-   } else { /** if they do NOT wish to move messages to the trash **/
-      for ($i = 0; $i < count($boxesUnformatted); $i++) {
-         if (substr($boxesUnformatted[$i], 0, strlen($mailbox)) == $mailbox) {
-            removeFolder($imapConnection, "$boxesUnformatted[$i]");
+   } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
+      fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
+      $data = imapReadData($imapConnection , "1", false, $response, $message);
+      while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
+         for ($i = 0; $i < count($boxesUnformatted); $i++) {
+            if (($boxesUnformatted[$i] == $mailbox) ||
+                (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+               removeFolder($imapConnection, "$boxesUnformatted[$i]");
+            }
          }
+         fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
+         $data = imapReadData($imapConnection , "1", false, $response, $message);
       }
    }
 
    /** Log out this session **/
    fputs($imapConnection, "1 logout");
 
-   echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>";
    echo "</BODY></HTML>";
 ?>
index 5c7e9ababc0bf454ba08ebc7a41f4a06b339b67e..b13ff6bdc5f5d6e72d5bc27918eaf93fc89eece9 100644 (file)
@@ -6,8 +6,25 @@
    include("../functions/mailbox.php");
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
+   $dm = findMailboxDelimeter($imapConnection);
+
+   if (strpos($orig, $dm))
+      $old_dir = substr($orig, 0, strrpos($orig, $dm));
+   else
+      $old_dir = "";
+
+   if ($old_dir != "")
+      $newone = "$old_dir$dm$new_name";
+   else
+      $newone = "$new_name";
+
+   fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
+   $data = imapReadData($imapConnection, ".", true, $a, $b);
+
+/*   fputs ($imapConnection, ". RENAME \"$old_name\" \"$mailbox\"\n";
+
    selectMailbox($imapConnection, $orig, $numMessages);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted);
+   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
 
    $mailbox = "$subfolder.$new_name";
    $old_name = substr($orig, strrpos($orig, ".")+1, strlen($orig));
@@ -39,7 +56,7 @@
          }
       }
    }
-
+*/
    /** Log out this session **/
    fputs($imapConnection, "1 logout");
 
index 6f9fba1f0bad6839fd1b396942f733b764cb7b35..5a8dec1c664a3f1519bdc1b8dd6d06f874cce578 100644 (file)
@@ -7,28 +7,25 @@
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
    selectMailbox($imapConnection, $old, $numMessages);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted);
+   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
 
-   $old_name = substr($old, strrpos($old, ".")+1, strlen($old));
-   $old_parent = substr($old, 0, strrpos($old, "."));
+   $dm = findMailboxDelimeter($imapConnection);
+   if (strpos($old, $dm)) {
+      $old_name = substr($old, strrpos($old, $dm)+1, strlen($old));
+      $old_parent = substr($old, 0, strrpos($old, $dm));
+   } else {
+      $old_name = $old;
+      $old_parent = "";
+   }
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    displayPageHeader($color, "None");
    echo "<TABLE WIDTH=100% COLS=1>";
-   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Rename or Move a folder</B></FONT></TD></TR>";
+   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Rename a folder</B></FONT></TD></TR>";
    echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
    echo "<FORM ACTION=folders_rename_do.php METHOD=POST>\n";
-   echo "Original Name: &nbsp;&nbsp;<INPUT TYPE=TEXT SIZE=25 NAME=new_name VALUE=\"$old_name\"><BR>\n";
-   echo "As a subfolder of: &nbsp;&nbsp;";
+   echo "New name: &nbsp;&nbsp;<INPUT TYPE=TEXT SIZE=25 NAME=new_name VALUE=\"$old_name\"><BR>\n";
    echo "<INPUT TYPE=HIDDEN NAME=orig VALUE=\"$old\">";
-   echo "<SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
-   for ($i = 0;$i < count($boxesUnformatted); $i++) {
-      if ($boxesUnformatted[$i] == $old_parent)
-         echo "<OPTION SELECTED>$boxesUnformatted[$i]\n";
-      else
-         echo "<OPTION>$boxesUnformatted[$i]\n";
-   }
-   echo "</SELECT><BR>\n";
    echo "<INPUT TYPE=SUBMIT VALUE=Submit>\n";
    echo "</FORM><BR></TD></TR>";
    echo "</TABLE>";
index e3725eb8f151036a9403d8f1cbdb091ba0c9a6ff..b224497b55887402220e834898c8001245af11a4 100644 (file)
 <HTML>
 <?
    include("../config/config.php");
+   include("../functions/array.php");
    include("../functions/strings.php");
    include("../functions/imap.php");
    include("../functions/mailbox.php");
 
+   function formatMailboxName($imapConnection, $mailbox, $delimeter) {
+      require ("../config/config.php");
+
+      $mailboxURL = urlencode($mailbox);
+      selectMailbox($imapConnection, $mailbox, $numNessages);
+      $unseen = unseenMessages($imapConnection, $numUnseen);
+
+      if ($unseen)
+         $line .= "<B>";
+
+      $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
+      $line .= readShortMailboxName($mailbox, $delimeter);
+      if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
+         $urlMailbox = urlencode($mailbox);
+         $line .= "</A>&nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
+      }
+      $line .= "</FONT></a>\n";
+      if ($numUnseen > 0) {
+         $line .= "</B>&nbsp;</FONT><FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
+      }
+      return $line;
+   }
+
    echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
    echo "<FONT FACE=\"Arial,Helvetica\">";
-
    // open a connection on the imap port (143)
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
+   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
 
    fputs($imapConnection, "1 list \"\" *\n");
-   $str = imapReadData($imapConnection);
+   $str = imapReadData($imapConnection, "1", true, $response, $message);
 
-   echo "<FONT FACE=\"Arial,Helvetica\" COLOR=000000 SIZE=4><B><CENTER>";
+   echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
    echo "Folders</B><BR></FONT>";
-   echo "<FONT FACE=\"Arial,Helvetica\" COLOR=000000 SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>";
+   echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>";
    echo "<FONT FACE=\"Arial,Helvetica\">\n";
+   $delimeter = findMailboxDelimeter($imapConnection);
    for ($i = 0;$i < count($str); $i++) {
       $mailbox = Chop($str[$i]);
+      $boxFlags = getMailboxFlags($mailbox);
       $mailbox = findMailboxName($mailbox);
 
-      // 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.
-      $periodCount = countCharInString($mailbox, ".");
-      
+      $boxCount = countCharInString($mailbox, $delimeter);
+
+      $line = "";
       // indent the correct number of spaces.
-      for ($j = 0;$j < $periodCount;$j++)
-         echo "&nbsp;&nbsp;";
-      
-      $mailboxURL = urlencode($mailbox);
-      selectMailbox($imapConnection, $mailbox, $numNessages);
-      $unseen = unseenMessages($imapConnection, $numUnseen);
-      if ($unseen)
-         echo "<B>";
-      echo "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
-      echo readShortMailboxName($mailbox, ".");
-      if (($move_to_trash == true) && ($mailbox == $trash_folder)) {
-         $urlMailbox = urlencode($mailbox);
-         echo "</A>&nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
+      for ($j = 0;$j < $boxCount;$j++)
+         $line .= "&nbsp;&nbsp;";
+
+      if (trim($boxFlags[0]) != "") {
+         for ($h = 0; $h < count($boxFlags); $h++) {
+            if (strtolower($boxFlags[$h]) == "noselect") {
+               $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
+               $line .= readShortMailboxName($mailbox, $delimeter);
+               $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
+            } else {
+               $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
+            }
+         }
+      } else {
+         $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
       }
-      echo "</FONT></a>\n";
-      if ($numUnseen > 0) {
-         echo "</B>&nbsp;</FONT><FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
+      $folder_list[$i]["FORMATTED"] = trim($line);
+      $folder_list[$i]["PLAIN"] = trim($mailbox);
+      $folder_list[$i]["ID"] = $i;
+   }
+
+   /** Alphebetize the folders */
+   $original = $folder_list;
+
+   for ($i = 0; $i < count($original); $i++) {
+      $folder_list[$i]["PLAIN"] = strtolower($folder_list[$i]["PLAIN"]);
+   }
+
+   $folder_list = ary_sort($folder_list, "PLAIN", 1);
+
+   for ($i = 0; $i < count($original); $i++) {
+      for ($j = 0; $j < count($original); $j++) {
+         if ($folder_list[$i]["ID"] == $original[$j]["ID"]) {
+            $folder_list[$i]["PLAIN"] = $original[$j]["PLAIN"];
+            $folder_list[$i]["FORMATTED"] = $original[$j]["FORMATTED"];
+         }
       }
-      echo "<BR>\n";
    }
+
+   /** If it is the inbox, list it first **/
+   for ($i = 0; $i < count($folder_list); $i++) {
+      if ($folder_list[$i]["PLAIN"] == $special_folders[0]) {
+         echo "<FONT FACE=\"Arial,Helvetica\">";
+         echo trim($folder_list[$i]["FORMATTED"]);
+         echo "</FONT><BR>";
+         $folder_list[$i]["USED"] = true;
+      }
+   }
+   /** Now the other special folders **/
+   if ($list_special_folders_first == true) {
+      for ($i = 0; $i < count($folder_list); $i++) {
+         for ($j = 1; $j < count($special_folders); $j++) {
+            if (substr($folder_list[$i]["PLAIN"], 0, strlen($special_folders[$j])) == $special_folders[$j]) {
+               echo "<FONT FACE=\"Arial,Helvetica\">";
+               echo trim($folder_list[$i]["FORMATTED"]);
+               echo "</FONT><BR>";
+               $folder_list[$i]["USED"] = true;
+            }
+         }
+      }
+   }
+   /** Then list all the other ones  (not equal to INBOX)         **/
+   /**   NOTE:  .mailboxlist is a netscape thing.. just ignore it **/
+   for ($i = 0; $i < count($folder_list); $i++) {
+      if (($folder_list[$i]["PLAIN"] != $special_folders[0]) &&
+          ($folder_list[$i]["PLAIN"] != ".mailboxlist") &&
+          ($folder_list[$i]["USED"] == false))  {
+         echo "<FONT FACE=\"Arial,Helvetica\">";
+         echo trim($folder_list[$i]["FORMATTED"]);
+         echo "</FONT><BR>";
+      }
+   }
+
    echo "</FONT>";
 
    fclose($imapConnection);
index 4e1197a2bf1efc11442a345909e777ba265a8b4b..b8a46bc605980da474c845acab8ac624805f27ed 100644 (file)
    echo "</TABLE>\n";
    echo "</FORM>\n";
 ?>
-
-<SCRIPT LANGUAGE="JavaScript">
-   document.f.username.focus(); 
-</SCRIPT>
-
 </BODY>
 </HTML>
 
index 93c48ec2b1bfa2dbc563096dc38d2a4b3860addb..280a2399589b19f9766f2adc68dcf136fad2fa14 100644 (file)
@@ -53,7 +53,7 @@
             }
             $i++;
          }
-         messages_deleted_message($mailbox, $sort, $startMessage);
+         messages_deleted_message($mailbox, $sort, $startMessage, $color);
       } else {
          echo "<BR><BR><CENTER>No messages selected.</CENTER>";
       }
@@ -79,9 +79,9 @@
          if ($auto_expunge == true)
             expungeBox($imapConnection, $mailbox, $numMessages);
 
-         messages_moved_message($mailbox, $sort, $startMessage);
+         messages_moved_message($mailbox, $sort, $startMessage, $color);
       } else {
-         error_message("No messages were selected.", $mailbox, $sort, $startMessage);
+         error_message("No messages were selected.", $mailbox, $sort, $startMessage, $color);
       }
    }
 
index ed51ab2013f3e49762c953dacdd0e23488055663..1def94edfdb5ffb4280ea0ed82db1001b205d77a 100644 (file)
@@ -46,7 +46,6 @@
    //
    /////////////////////////////////////////////////////////////////////////////////
 
-
    // open a connection on the imap port (143)
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);