Redid the way folders are listed
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 18 Dec 1999 16:08:29 +0000 (16:08 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 18 Dec 1999 16:08:29 +0000 (16:08 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@84 7612ce4b-ef26-0410-bec9-ea0150e637f0

17 files changed:
functions/array.php
functions/imap.php
functions/mailbox.php
functions/mailbox_display.php
functions/smtp.php
functions/strings.php
src/compose.php
src/compose_send.php
src/empty_trash.php
src/folders.php
src/folders_create.php
src/folders_delete.php
src/folders_rename_getname.php
src/left_main.php
src/login.php
src/move_messages.php
src/webmail.php

index 99dd1264f67354545c0458bc15ff5c4431a0d2ac..65498fc1c7cea0d18eb88bb310c2e2c05ff543b9 100644 (file)
       }
       $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) {
+
+      usort($ary,comp2);
+      return $ary;
+  }
+
+  function comp2($a,$b,$i = 0) {
          global $col;
          global $dir;
          $c = count($col) -1;
@@ -34,8 +38,4 @@
          }
          return $r;
       }
-  
-      usort($ary,comp2);
-      return $ary;
-   }
 ?>
index 62bfe30b96ffdd112a4c92e5fddecfa23363fdbb..0362e32c97e5a61366bb964ae670d7d92985da80 100644 (file)
 
       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>";
+            echo "<BR><B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>:  Could not complete request.</B> </FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>&nbsp;&nbsp;<B>Reason given:</B> $message</FONT FACE=\"Arial,Helvetica\"><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>";
+            echo "<BR><B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>:  Bad or malformed request.</B></FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>&nbsp;&nbsp;<B>Server responded:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
             exit;
          }
       }
       $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>";
+         echo "<BR><B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>:  Could not complete request.</B> </FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>&nbsp;&nbsp;<B>Reason given:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
+         echo "<FONT FACE=\"Arial,Helvetica\">Possible solutions:<BR><LI>You may need to specify that the folder is a subfolder of INBOX</LI>";
+         echo "<LI>Try renaming the folder to something different.</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>";
+         echo "<B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>:  Bad or malformed request.</B></FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>&nbsp;&nbsp;<B>Server responded:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
          exit;
       }
    }
    }
 
    /** Sends back two arrays, boxesFormatted and boxesUnformatted **/
-   function getFolderList($imapConnection, &$boxesFormatted, &$boxesUnformatted, &$boxesRaw) {
+   function getFolderList($imapConnection, &$boxes) {
+      require ("../config/config.php");
+
       fputs($imapConnection, "1 list \"\" *\n");
       $str = imapReadData($imapConnection, "1", true, $response, $message);
 
       $dm = findMailboxDelimeter($imapConnection);
+      $g = 0;
       for ($i = 0;$i < count($str); $i++) {
          $mailbox = chop($str[$i]);
-         $boxesRaw[$i] = $mailbox;
+         if (substr(findMailboxName($mailbox), 0, 1) != ".") {
+            $boxes[$g]["RAW"] = $mailbox;
 
-         $mailbox = findMailboxName($mailbox);
-         $periodCount = countCharInString($mailbox, $dm);
+            $mailbox = findMailboxName($mailbox);
+            $periodCount = countCharInString($mailbox, $dm);
 
-         // indent the correct number of spaces.
-         for ($j = 0;$j < $periodCount;$j++)
-            $boxesFormatted[$i] = "$boxesFormatted[$i]&nbsp;&nbsp;";
+            // indent the correct number of spaces.
+            for ($j = 0;$j < $periodCount;$j++)
+               $boxes[$g]["FORMATTED"] = $boxes[$g]["FORMATTED"] . "&nbsp;&nbsp;";
 
-         $boxesFormatted[$i] = $boxesFormatted[$i] . readShortMailboxName($mailbox, $dm);
-         $boxesUnformatted[$i] = $mailbox;
+            $boxes[$g]["FORMATTED"] = $boxes[$g]["FORMATTED"] . readShortMailboxName($mailbox, $dm);
+            $boxes[$g]["UNFORMATTED"] = $mailbox;
+            $boxes[$g]["ID"] = $g;
+            $g++;
+         }
       }
+
+      $original = $boxes;
+
+      for ($i = 0; $i < count($original); $i++) {
+         $boxes[$i]["UNFORMATTED"] = strtolower($boxes[$i]["UNFORMATTED"]);
+      }
+
+      $boxes = ary_sort($boxes, "UNFORMATTED", 1);
+
+      for ($i = 0; $i < count($original); $i++) {
+         for ($j = 0; $j < count($original); $j++) {
+            if ($boxes[$i]["ID"] == $original[$j]["ID"]) {
+               $boxes[$i]["UNFORMATTED"] = $original[$j]["UNFORMATTED"];
+               $boxes[$i]["FORMATTED"] = $original[$j]["FORMATTED"];
+               $boxes[$i]["RAW"] = $original[$j]["RAW"];
+            }
+         }
+      }
+
+      for ($i = 0; $i < count($boxes); $i++) {
+         if ($boxes[$i]["UNFORMATTED"] == $special_folders[0]) {
+            $boxesnew[0]["FORMATTED"] = $boxes[$i]["FORMATTED"];
+            $boxesnew[0]["UNFORMATTED"] = trim($boxes[$i]["UNFORMATTED"]);
+            $boxesnew[0]["RAW"] = trim($boxes[$i]["RAW"]);
+            $boxes[$i]["USED"] = true;
+         }
+      }
+      if ($list_special_folders_first == true) {
+         for ($i = 0; $i < count($boxes); $i++) {
+            for ($j = 1; $j < count($special_folders); $j++) {
+               if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($special_folders[$j])) == $special_folders[$j]) {
+                  $pos = count($boxesnew);
+                  $boxesnew[$pos]["FORMATTED"] = $boxes[$i]["FORMATTED"];
+                  $boxesnew[$pos]["RAW"] = trim($boxes[$i]["RAW"]);
+                  $boxesnew[$pos]["UNFORMATTED"] = trim($boxes[$i]["UNFORMATTED"]);
+                  $boxes[$i]["USED"] = true;
+               }
+            }
+         }
+      }
+      for ($i = 0; $i < count($boxes); $i++) {
+         if (($boxes[$i]["UNFORMATTED"] != $special_folders[0]) &&
+             ($boxes[$i]["UNFORMATTED"] != ".mailboxlist") &&
+             ($boxes[$i]["USED"] == false))  {
+            $pos = count($boxesnew);
+            $boxesnew[$pos]["FORMATTED"] = $boxes[$i]["FORMATTED"];
+            $boxesnew[$pos]["RAW"] = trim($boxes[$i]["RAW"]);
+            $boxesnew[$pos]["UNFORMATTED"] = trim($boxes[$i]["UNFORMATTED"]);
+            $boxes[$i]["USED"] = true;
+         }
+      }
+
+      $boxes = $boxesnew;
    }
 
    function deleteMessages($imapConnection, $a, $b, $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox) {
index 8babee25da3c04a93b0c52d194eef12a7ad1ed9b..9febb9417f4efcfc45f49ed69a07be03ba73a4ac 100644 (file)
@@ -66,8 +66,7 @@
          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);
+               $read = encodeEmailAddr("$read");
                $from[$pos] = substr($read, 5, strlen($read) - 6);
             }
             else if (substr($read, 0, 5) == "Date:") {
       }
    }
 
+   function encodeEmailAddr($string) {
+      $string = ereg_replace("<", "EMAILSTART--", $string);
+      $string = ereg_replace(">", "--EMAILEND", $string);
+      return $string;
+   }
+
    function setMessageFlag($imapConnection, $i, $q, $flag) {
       fputs($imapConnection, "messageStore STORE $i:$q +FLAGS (\\$flag)\n");
    }
index 98007b0415932618fc00be84d3b20eee5c9b7950..435facc0fb441c27fb7a3f26383020c281d2e8f8 100644 (file)
@@ -33,7 +33,7 @@
     ** This function loops through a group of messages in the mailbox and shows them
     **/
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
-      require ("../config/config.php");
+      include ("../config/config.php");
 
       if (1 <= $numMessages) {
          getMessageHeaders($imapConnection, 1, $numMessages, $from, $subject, $date);
          }
       }
 
-//      $j = 0;
-//      while ($j < $numMessages) {
-//         $sub = $msgs[$j]["SUBJECT"];
-//         $id = $msgs[$j]["ID"];
-//         echo "$id -- $sub<BR>";
-//         $j++;
-//      }
-//exit;
-
       if ($startMessage + 24 < $numMessages) {
          $endMessage = $startMessage + 24;
       } else {
       echo "<TR><TD BGCOLOR=\"$color[0]\">";
 
       echo "\n\n\n<FORM name=messageList method=post action=\"move_messages.php?msg=$msg&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage\">";
-      echo "<TABLE BGCOLOR=\"$color[0]\">\n";
+      echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0>\n";
       echo "   <TR>\n";
-      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, $boxesRaw);
-      for ($i = 0; $i < count($boxesUnformatted); $i++) {
+      echo "      <TD WIDTH=60% ALIGN=LEFT>\n";
+      echo "         <NOBR><FONT FACE=\"Arial,Helvetica\"><SMALL>Move selected to: </SMALL></FONT>";
+      echo "         <TT><SMALL><SELECT NAME=\"targetMailbox\">";
+
+      getFolderList($imapConnection, $boxes);
+      for ($i = 0; $i < count($boxes); $i++) {
          $use_folder = true;
          for ($p = 0; $p < count($special_folders); $p++) {
-            // don't allow moving messages to any special folder EXCEPT for INBOX.
-            if (($boxesUnformatted[$i] == $special_folders[$p]) && ($boxesUnformatted[$i] != "INBOX")) {
+            if ($boxes[$i]["UNFORMATTED"] == $special_folders[0]) {
+               $use_folder = true;
+            } else if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
                $use_folder = false;
-            } else if (substr($boxesUnformatted[$i], 0, strlen($trash_folder)) == $trash_folder) {
+            } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
                $use_folder = false;
             }
          }
-         if ($use_folder == true)
-            echo "         <OPTION VALUE=\"$boxesUnformatted[$i]\">$boxesUnformatted[$i]\n";
+         if ($use_folder == true) {
+            $box = $boxes[$i]["UNFORMATTED"];
+            $box2 = $boxes[$i]["FORMATTED"];
+            echo "         <OPTION VALUE=\"$box\">$box2\n";
+         }
       }
-      echo "         </SELECT></NOBR></FONT>\n";
+      echo "         </SELECT></SMALL></TT>";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"Move\"></SMALL></FONT></NOBR>\n";
 
       echo "      </TD>\n";
-      echo "      <TD WIDTH=70% ALIGN=RIGHT>\n";
-      echo "         <NOBR><FONT FACE=\"Arial,Helvetica\" SIZE=2><INPUT TYPE=SUBMIT VALUE=\"Delete\">&nbsp;checked messages</FONT></NOBR>\n";
+      echo "      <TD WIDTH=40% ALIGN=RIGHT>\n";
+      echo "         <NOBR><FONT FACE=\"Arial,Helvetica\"><SMALL><INPUT TYPE=SUBMIT VALUE=\"Delete\">&nbsp;checked messages</SMALL></FONT></NOBR>\n";
       echo "      </TD>";
       echo "   </TR>\n";
 
       echo "<TR><TD BGCOLOR=\"$color[0]\">";
       echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[4]\">";
       echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
-      echo "   <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
+      echo "   <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>&nbsp;</B></FONT></TD>";
       /** FROM HEADER **/
       echo "   <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT>";
       if ($sort == 2)
       /** SUBJECT HEADER **/
       echo "   <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT>\n";
       if ($sort == 4)
-         echo "   <A HREF=\"right_main.php?sort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
+        echo "   <A HREF=\"right_main.php?sort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
       else if ($sort == 5)
          echo "   <A HREF=\"right_main.php?sort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
       else
index 066fca59886347ad18beff08b934bd0bb105fb10..c733470ddf4e4600970a549206199ec675b343cb 100644 (file)
@@ -58,6 +58,9 @@
          fputs($smtpConnection, "Cc: <$cc_list>\n"); // Who the CCs are
       }
       fputs($smtpConnection, "X-Mailer: SquirrelMail (version $version)\n"); // Identify SquirrelMail
+      fputs($smtpConnection, "Reply-To: $from\n");
+      fputs($smtpConnection, "MIME-Version: 1.0\n");
+      fputs($smtpConnection, "Content-Type: text/plain; charset=us-ascii\n");
 
       fputs($smtpConnection, "$body\n"); // send the body of the message
       fputs($smtpConnection, ".\n"); // end the DATA part
index c3cdc3a31091ae13a9c54365a585f380684dc760..142d13a5f1f185f39367721979c7930296d5014f 100644 (file)
@@ -1,4 +1,5 @@
 <?
+
    //*************************************************************************
    // Count the number of occurances of $needle are in $haystack.
    //*************************************************************************
@@ -75,4 +76,7 @@
       }
       return $to_line;
    }
+
+   /* SquirrelMail version number -- DO NOT CHANGE */
+   $version = "0.1.2";
 ?>
index ac450160b701413147ae849554d098e0100c2628..cfa8136c128a16950f7177e9b3115f86c5d51b68 100644 (file)
       }
    }
 
+   // Add some decoding information
+   $send_to = encodeEmailAddr($send_to);
+   // parses the field and returns only the email address
+   $send_to = decodeEmailAddr($send_to);
+
+   $send_to = strtolower($send_to);
    $send_to = ereg_replace("\"", "", $send_to);
    $send_to = stripslashes($send_to);
 
index 57dc4dad83ac3cd3da389adced484c1b534fc426..a0cdabde1c0406f73ea8f54efb4a772c6d51c698 100644 (file)
@@ -45,7 +45,8 @@
 
    sendMessage($smtpServerAddress, $smtpPort, $username, $domain, $passed_to, $passed_cc, $passed_bcc, $passed_subject, $passed_body, $version);
 
-   echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=right_main.php\">";
+   if ($auto_forwarding == true)
+      echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=right_main.php\">";
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
 
    displayPageHeader($color, "None");
index 1d177b551c7eea6e000f73f947c1358dc8cc0a1e..3de6307345f37f1797f5fcceee19911da5d857c8 100644 (file)
@@ -5,19 +5,20 @@
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/imap.php");
+   include("../functions/array.php");
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
 
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+   getFolderList($imapConnection, $boxes);
 
    $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]");
+      for ($i = 0; $i < count($boxes); $i++) {
+         if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+             (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
          }
       }
       fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
index f25c2c4241add52e0e094c20625cc89812c3e2de..e67e73fe3cbf53e2d64517bea4f2afe477460956 100644 (file)
@@ -4,6 +4,7 @@
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/mailbox.php");
+   include("../functions/array.php");
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
 
    echo "</TABLE>\n";
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+   getFolderList($imapConnection, $boxes);
 
    /** DELETING FOLDERS **/
    echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
    echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Delete Folder</B></FONT></TD></TR>";
    echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
    echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
-   echo "<SELECT NAME=mailbox><FONT FACE=\"Arial,Helvetica\">\n";
-   for ($i = 0; $i < count($boxesUnformatted); $i++) {
+   echo "<TT><SELECT NAME=mailbox>\n";
+   for ($i = 0; $i < count($boxes); $i++) {
       $use_folder = true;
       for ($p = 0; $p < count($special_folders); $p++) {
-         if ($boxesUnformatted[$i] == $special_folders[$p]) {
+         if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
             $use_folder = false;
-         } else if (substr($boxesUnformatted[$i], 0, strlen($trash_folder)) == $trash_folder) {
+         } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
             $use_folder = false;
          }
       }
-
-      if ($use_folder == true)
-         echo "<OPTION>$boxesUnformatted[$i]\n";
+      if ($use_folder == true) {
+         $box = $boxes[$i]["UNFORMATTED"];
+         $box2 = $boxes[$i]["FORMATTED"];
+         echo "         <OPTION VALUE=\"$box\">$box2\n";
+      }
    }
-   echo "</SELECT>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=Delete>\n";
+
+   echo "</SELECT></TT>\n";
+   echo "<FONT FACE=\"Arial,Helvetica\"><INPUT TYPE=SUBMIT VALUE=Delete></FONT>\n";
    echo "</FORM><BR></TD></TR><BR>\n";
 
    /** CREATING FOLDERS **/
    echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
    echo "<FORM ACTION=folders_create.php METHOD=POST>\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";
+   echo "<FONT FACE=\"Arial,Helvetica\">as a subfolder of</FONT><BR>";
+   echo "<TT><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++) {
-      if (($boxesUnformatted[$i] == $special_folders[0]) && ($default_sub_of_inbox == true))
-         echo "<OPTION SELECTED>$boxesUnformatted[$i]\n";
-      else
-         echo "<OPTION>$boxesUnformatted[$i]\n";
+   for ($i = 0; $i < count($boxes); $i++) {
+      if (($boxes[$i]["UNFORMATTED"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
+         $box = $boxes[$i]["UNFORMATTED"];
+         $box2 = $boxes[$i]["FORMATTED"];
+         echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
+      } else {
+         $box = $boxes[$i]["UNFORMATTED"];
+         $box2 = $boxes[$i]["FORMATTED"];
+         echo "<OPTION VALUE=\"$box\">$box2\n";
+      }
    }
-   echo "</SELECT><BR>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
+   echo "</SELECT></TT><BR>\n";
+   echo "<FONT FACE=\"Arial,Helvetica\">";
+   if ($show_contain_subfolders_option)
+      echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"><FONT FACE=\"Arial,Helvetica\"> &nbsp;Let this folder contain subfolders</FONT><BR>";
+   echo "<INPUT TYPE=SUBMIT VALUE=Create></FONT>\n";
    echo "</FORM><BR></TD></TR><BR>\n";
 
    /** RENAMING FOLDERS **/
    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";
-   for ($i = 0; $i < count($boxesUnformatted); $i++) {
+   echo "<TT><SELECT NAME=old><FONT FACE=\"Arial,Helvetica\">\n";
+   for ($i = 0; $i < count($boxes); $i++) {
       $use_folder = true;
       for ($p = 0; $p < count($special_folders); $p++) {
-         if ($boxesUnformatted[$i] == $special_folders[$p]) {
+         if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
+            $use_folder = false;
+         } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
             $use_folder = false;
          }
       }
-      if ($use_folder == true)
-         echo "   <OPTION>$boxesUnformatted[$i]\n";
+      if ($use_folder == true) {
+         $box = $boxes[$i]["UNFORMATTED"];
+         $box2 = $boxes[$i]["FORMATTED"];
+         echo "         <OPTION VALUE=\"$box\">$box2\n";
+      }
    }
-   echo "</SELECT>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=\"Rename\">\n";
+   echo "</SELECT></TT>\n";
+   echo "<FONT FACE=\"Arial,Helvetica\"><INPUT TYPE=SUBMIT VALUE=\"Rename\"></FONT>\n";
    echo "</FORM></TD></TR></TABLE><BR>\n";
 
 ?>
index 171fbad9269c017082232ff98db7af0fc44e9052..b34a53328d37e8b8d972185267d9575c6984c477 100644 (file)
@@ -4,10 +4,24 @@
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
+   include("../functions/display_messages.php");
 
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+   displayPageHeader($color, "None");
+
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
    $dm = findMailboxDelimeter($imapConnection);
+
+   if (strpos($folder_name, "\"") || strpos($folder_name, ".") ||
+       strpos($folder_name, "/") || strpos($folder_name, "\\") ||
+       strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
+      plain_error_message("Illegal folder name.  Please select a different name.<BR><A HREF=\"../src/folders.php\">Click here to go back</A>.", $color);
+      exit;
+   }
+
+   if ($contain_subs == true)
+      $folder_name = "$folder_name$dm";
+
    if (trim($subfolder) == "[ None ]") {
       createFolder($imapConnection, "$folder_name");
    } else {
index 6e214ecd551b08fd6fe4ef77f74282bdb73a8c87..7b635a355b26248875ec0ea1ce461d36e947c5f7 100644 (file)
@@ -4,16 +4,17 @@
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/mailbox.php");
+   include("../functions/array.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);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+   getFolderList($imapConnection, $boxes);
 
    $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];
+   for ($i = 0; $i < count($boxes[$i]["UNFORMATTED"]); $i++) {
+      if ($boxes[$i]["UNFORMATTED"] == $trash_folder)
+         $tmp_trash_folder = $boxes[$i]["RAW"];
    }
 
    $tmpflags = getMailboxFlags($tmp_trash_folder);
    /** Lets start removing the folders and messages **/
    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 (($boxesUnformatted[$i] == $mailbox) ||
-             (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
-            $folderWithoutINBOX = getFolderNameMinusINBOX($boxesUnformatted[$i], $dm);
-            $flags = getMailboxFlags($boxesRaw[$i]);
+      for ($i = 0; $i < count($boxes); $i++) {
+         if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+             (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"], $dm);
+            $flags = getMailboxFlags($boxes[$i]["RAW"]);
             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 (($boxesUnformatted[$i] == $mailbox) ||
-             (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
-            selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages);
-            $folder = getFolderNameMinusINBOX($boxesUnformatted[$i]);
+      for ($i = 0; $i < count($boxes); $i++) {
+         if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+             (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            selectMailbox($imapConnection, $boxes[$i]["UNFORMATTED"], $numMessages);
+            $folder = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"]);
 
             if ($numMessages > 0)
                $success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder" . $dm . "$folder");
                $success = true;
 
             if ($success == true)
-               removeFolder($imapConnection, "$boxesUnformatted[$i]");
+               removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
          }
       }
    } 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]");
+         for ($i = 0; $i < count($boxes); $i++) {
+            if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+                (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+               removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
             }
          }
          fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
index 5a8dec1c664a3f1519bdc1b8dd6d06f874cce578..bd78024c5f9882c0d118b8655aac001c847cae4c 100644 (file)
@@ -7,7 +7,6 @@
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
    selectMailbox($imapConnection, $old, $numMessages);
-   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
 
    $dm = findMailboxDelimeter($imapConnection);
    if (strpos($old, $dm)) {
index b224497b55887402220e834898c8001245af11a4..e4ca02f69d12d8a475f60128b0179390764dd3e0 100644 (file)
       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>)";
+      $special_color = false;
+      for ($i = 0; $i < count($special_folders); $i++) {
+         if (($special_folders[$i] == $mailbox) && ($use_special_folder_color == true))
+            $special_color = true;
+      }
+
+      if ($special_color == true) {
+         $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\"  COLOR=\"$color[11]\">";
+         $line .= readShortMailboxName($mailbox, $delimeter);
+         $line .= "</font></a>";
+      } else {
+         $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);
+         $line .= "</font></a>";
       }
-      $line .= "</FONT></a>\n";
+
+      if ($unseen)
+         $line .= "</B>";
+
       if ($numUnseen > 0) {
-         $line .= "</B>&nbsp;</FONT><FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
+         $line .= "&nbsp;<FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
+      }
+
+      if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
+         $urlMailbox = urlencode($mailbox);
+         $line .= "<FONT FACE=\"Arial,Helvetica\" SIZE=2>";
+         $line .= "&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";
       }
       return $line;
    }
    // open a connection on the imap port (143)
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
 
-   fputs($imapConnection, "1 list \"\" *\n");
-   $str = imapReadData($imapConnection, "1", true, $response, $message);
+   getFolderList($imapConnection, $boxes);
 
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
    echo "Folders</B><BR></FONT>";
    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);
+   for ($i = 0;$i < count($boxes); $i++) {
+      $mailbox = $boxes[$i]["UNFORMATTED"];
+      $boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
 
       $boxCount = countCharInString($mailbox, $delimeter);
 
          $line .= "&nbsp;&nbsp;";
 
       if (trim($boxFlags[0]) != "") {
+         $noselect = false;
          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);
-      }
-      $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"];
+            if (strtolower($boxFlags[$h]) == "noselect")
+               $noselect = true;
          }
-      }
-   }
 
-   /** 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;
-            }
+         if ($noselect == true) {
+            $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);
       }
-   }
-   /** 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 "$line<BR>";
    }
 
    echo "</FONT>";
index b8a46bc605980da474c845acab8ac624805f27ed..714c14453821bd9238ab7069fa6de7029e469826 100644 (file)
@@ -13,6 +13,7 @@
 <HTML>
 <?
    include("../config/config.php");
+   include("../functions/strings.php");
 
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<FORM ACTION=webmail.php METHOD=\"POST\" NAME=f>\n";
index 280a2399589b19f9766f2adc68dcf136fad2fa14..eab4901e1f1f4823d7345d0a3fd5dfdd17a54a2d 100644 (file)
@@ -47,7 +47,6 @@
          //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
          while ($j < count($msg)) {
             if ($msg[$i]) {
-               echo "MSG: $msg[$i]<BR>";
                deleteMessages($imapConnection, $msg[$i], $msg[$i], $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
                $j++;
             }
@@ -55,7 +54,7 @@
          }
          messages_deleted_message($mailbox, $sort, $startMessage, $color);
       } else {
-         echo "<BR><BR><CENTER>No messages selected.</CENTER>";
+         error_message("No messages were selected.", $mailbox, $sort, $startMessage, $color);
       }
    } else {    // Move messages
       displayPageHeader($color, $mailbox);
index 060c923ca47577f527beab0538c858f4edc75ed1..aaaaf785a0ffe7643d2ed728c415915705e4a3b2 100644 (file)
 ?>
 <HTML><HEAD>
 <TITLE>
-OM-USA WebMail
+<?
+   include ("../config/config.php");
+   echo "$org_title";
+?>
 </TITLE>
 <FRAMESET COLS="200, *" NORESIZE BORDER=0>