Przeglądaj źródła

Rewrote imap functions

Luke Ehresman 25 lat temu
rodzic
commit
5d961ca41b

+ 10 - 19
src/compose.php

@@ -11,7 +11,6 @@
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
-   include("../functions/mailbox.php");
    include("../functions/date.php");
    include("../functions/date.php");
    include("../functions/mime.php");
    include("../functions/mime.php");
    include("../functions/smtp.php");
    include("../functions/smtp.php");
@@ -20,7 +19,7 @@
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
    displayPageHeader($color, "None");
    displayPageHeader($color, "None");
 
 
    // This function is used when not sending or adding attachments
    // This function is used when not sending or adding attachments
@@ -29,8 +28,8 @@
          $reply_id, $send_to, $send_to_cc, $mailbox;
          $reply_id, $send_to, $send_to_cc, $mailbox;
 
 
       if ($forward_id) {
       if ($forward_id) {
-         selectMailbox($imapConnection, $mailbox, $numMessages);
-         $msg = fetchMessage($imapConnection, $forward_id, $mailbox);
+         sqimap_mailbox_select($imapConnection, $mailbox);
+         $msg = sqimap_get_message($imapConnection, $forward_id, $mailbox);
          
          
          if (containsType($msg, "text", "html", $ent_num)) {
          if (containsType($msg, "text", "html", $ent_num)) {
             $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
             $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
@@ -65,8 +64,8 @@
       }
       }
       
       
       if ($reply_id) {
       if ($reply_id) {
-         selectMailbox($imapConnection, $mailbox, $numMessages);
-         $msg = fetchMessage($imapConnection, $reply_id, $mailbox);
+         sqimap_mailbox_select($imapConnection, $mailbox);
+         $msg = sqimap_get_message($imapConnection, $reply_id, $mailbox);
          
          
          if (containsType($msg, "text", "html", $ent_num)) {
          if (containsType($msg, "text", "html", $ent_num)) {
             $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
             $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
@@ -98,10 +97,7 @@
          }
          }
       }
       }
       
       
-      // 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 = sqimap_find_displayable_name($send_to);
       
       
       $send_to = strtolower($send_to);
       $send_to = strtolower($send_to);
       $send_to = ereg_replace("\"", "", $send_to);
       $send_to = ereg_replace("\"", "", $send_to);
@@ -118,14 +114,9 @@
             if ($sendcc[$i] == "")
             if ($sendcc[$i] == "")
                continue;
                continue;
             
             
-            $sendcc[$i] = encodeEmailAddr($sendcc[$i]);
-            $sendcc[$i] = decodeEmailAddr($sendcc[$i]);
-            
-            $whofrom = encodeEmailAddr($msg["HEADER"]["FROM"]);
-            $whofrom = decodeEmailAddr($whofrom);
-            
-            $whoreplyto = encodeEmailAddr($msg["HEADER"]["REPLYTO"]);
-            $whoreplyto = decodeEmailAddr($whoreplyto);
+            $sendcc[$i] = sqimap_find_displayable_name($sendcc[$i]);
+            $whofrom = sqimap_find_displayable_name($msg["HEADER"]["FROM"]);
+            $whoreplyto = sqimap_find_email($msg["HEADER"]["REPLYTO"]);
          
          
             if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) &&
             if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) &&
                 (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) &&
                 (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) &&
@@ -212,7 +203,7 @@
       echo "   <TR>\n";
       echo "   <TR>\n";
       echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
       echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
       if ($use_signature == true)
       if ($use_signature == true)
-         echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>". $body . "\n\n-- \n".$signature."</TEXTAREA><BR>";
+         echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>". $body . "\n\n".$signature."</TEXTAREA><BR>";
       else
       else
          echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>".$body."</TEXTAREA><BR>\n";
          echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>".$body."</TEXTAREA><BR>\n";
       echo "      </TD>\n";
       echo "      </TD>\n";

+ 3 - 4
src/delete_message.php

@@ -1,6 +1,5 @@
 <?
 <?
    include("../config/config.php");
    include("../config/config.php");
-   include("../functions/mailbox.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");
@@ -10,12 +9,12 @@
 
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   sqimap_mailbox_select($imapConnection, $mailbox);
 
 
    displayPageHeader($color, $mailbox);
    displayPageHeader($color, $mailbox);
 
 
-   deleteMessages($imapConnection, $message, $message, $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
+   sqimap_message_delete($imapConnection, $message, $message, $mailbox);
    messages_deleted_message($mailbox, $sort, $startMessage, $color);
    messages_deleted_message($mailbox, $sort, $startMessage, $color);
 ?>
 ?>
 </BODY></HTML>
 </BODY></HTML>

+ 4 - 5
src/download.php

@@ -4,7 +4,6 @@
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
    include("../functions/mime.php");
    include("../functions/mime.php");
-   include("../functions/mailbox.php");
    include("../functions/date.php");
    include("../functions/date.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
@@ -30,12 +29,12 @@
       echo "</TT></TD></TR></TABLE>";
       echo "</TT></TD></TR></TABLE>";
    }
    }
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   selectMailbox($imapConnection, $mailbox, $numMessages);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   sqimap_mailbox_select($imapConnection, $mailbox);
 
 
    // $message contains all information about the message
    // $message contains all information about the message
    // including header and body
    // including header and body
-   $message = fetchMessage($imapConnection, $passed_id, $mailbox);
+   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
 
 
    $type0 = $message["ENTITIES"][$passed_ent_id]["TYPE0"];
    $type0 = $message["ENTITIES"][$passed_ent_id]["TYPE0"];
    $type1 = $message["ENTITIES"][$passed_ent_id]["TYPE1"];
    $type1 = $message["ENTITIES"][$passed_ent_id]["TYPE1"];
@@ -79,5 +78,5 @@
       }
       }
    }
    }
 
 
-   fputs($imapConnection, "1 logout\n");
+   sqimap_logout($imapConnection);
 ?>
 ?>

+ 8 - 10
src/empty_trash.php

@@ -1,6 +1,5 @@
 <?
 <?
    include("../config/config.php");
    include("../config/config.php");
-   include("../functions/mailbox.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");
@@ -9,15 +8,15 @@
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
 
 
-   getFolderList($imapConnection, $boxes);
+   sqimap_mailbox_list($imapConnection, $boxes);
 
 
    $mailbox = $trash_folder;
    $mailbox = $trash_folder;
    fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
    fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
-   $data = imapReadData($imapConnection , "1", false, $response, $message);
+   $data = sqimap_read_data($imapConnection , "1", false, $response, $message);
       
       
-   $dm = findMailboxDelimeter($imapConnection);
+   $dm = sqimap_get_delimiter($imapConnection);
    
    
    // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
    // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
    //    so lets go through the list of subfolders and remove them before removing the
    //    so lets go through the list of subfolders and remove them before removing the
@@ -35,13 +34,12 @@
 //   }
 //   }
 
 
    // lets remove the trash folder
    // lets remove the trash folder
-   removeFolder($imapConnection, $mailbox, $dm);
+//   sqimap_mailbox_delete($imapConnection, $mailbox, $dm);
+   sqimap_mailbox_create($imapConnection, "$trash_folder", "");
 
 
-   createFolder($imapConnection, "$trash_folder", "");
-
-   selectMailbox($imapConnection, $trash_folder, $numMessages);
+   sqimap_mailbox_select($imapConnection, $trash_folder, $numMessages);
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    displayPageHeader($color, $mailbox);
    displayPageHeader($color, $mailbox);
    messages_deleted_message($trash_folder, $sort, $startMessage, $color);
    messages_deleted_message($trash_folder, $sort, $startMessage, $color);
-   fputs($imapConnection, "1 logout");
+   sqimap_logout($imapConnection);
 ?>
 ?>

+ 17 - 17
src/folders.php

@@ -3,7 +3,6 @@
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
-   include("../functions/mailbox.php");
    include("../functions/array.php");
    include("../functions/array.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
@@ -20,8 +19,8 @@
    echo "   </TD></TR>\n";
    echo "   </TD></TR>\n";
    echo "</TABLE>\n";
    echo "</TABLE>\n";
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   getFolderList($imapConnection, $boxes);
+   $imapConnection = sqimap_login ($username, $key, $imapServerAddress, 0);
+   $boxes = sqimap_mailbox_list($imapConnection);
 
 
    /** DELETING FOLDERS **/
    /** DELETING FOLDERS **/
    echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
    echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
@@ -34,15 +33,15 @@
    for ($i = 0; $i < count($boxes); $i++) {
    for ($i = 0; $i < count($boxes); $i++) {
       $use_folder = true;
       $use_folder = true;
       for ($p = 0; $p < count($special_folders); $p++) {
       for ($p = 0; $p < count($special_folders); $p++) {
-         if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
+         if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
             $use_folder = false;
             $use_folder = false;
-         } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
+         } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
             $use_folder = false;
             $use_folder = false;
          }
          }
       }
       }
       if ($use_folder == true) {
       if ($use_folder == true) {
-         $box = $boxes[$i]["UNFORMATTED"];
-         $box2 = $boxes[$i]["FORMATTED"];
+         $box = $boxes[$i]["unformatted"];
+         $box2 = replace_spaces($boxes[$i]["formatted"]);
          echo "         <OPTION VALUE=\"$box\">$box2\n";
          echo "         <OPTION VALUE=\"$box\">$box2\n";
       }
       }
    }
    }
@@ -70,22 +69,23 @@
       echo "<OPTION>[ None ]\n";
       echo "<OPTION>[ None ]\n";
 
 
    for ($i = 0; $i < count($boxes); $i++) {
    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"];
+      if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
+         $box = $boxes[$i]["unformatted"];
+         $box2 = replace_spaces($boxes[$i]["formatted"]);
          echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
          echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
       } else {
       } else {
-         $box = $boxes[$i]["UNFORMATTED"];
-         $box2 = $boxes[$i]["FORMATTED"];
+         $box = $boxes[$i]["unformatted"];
+         $box2 = replace_spaces($boxes[$i]["formatted"]);
          echo "<OPTION VALUE=\"$box\">$box2\n";
          echo "<OPTION VALUE=\"$box\">$box2\n";
       }
       }
    }
    }
    echo "</SELECT></TT><BR>\n";
    echo "</SELECT></TT><BR>\n";
    echo "<FONT FACE=\"Arial,Helvetica\">";
    echo "<FONT FACE=\"Arial,Helvetica\">";
-   if ($show_contain_subfolders_option)
+   if ($show_contain_subfolders_option) {
       echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"><FONT FACE=\"Arial,Helvetica\"> &nbsp;";
       echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"><FONT FACE=\"Arial,Helvetica\"> &nbsp;";
       echo _("Let this folder contain subfolders");
       echo _("Let this folder contain subfolders");
       echo "</FONT><BR>";
       echo "</FONT><BR>";
+   }   
    echo "<INPUT TYPE=SUBMIT VALUE=Create></FONT>\n";
    echo "<INPUT TYPE=SUBMIT VALUE=Create></FONT>\n";
    echo "</FORM><BR></TD></TR><BR>\n";
    echo "</FORM><BR></TD></TR><BR>\n";
 
 
@@ -99,15 +99,15 @@
    for ($i = 0; $i < count($boxes); $i++) {
    for ($i = 0; $i < count($boxes); $i++) {
       $use_folder = true;
       $use_folder = true;
       for ($p = 0; $p < count($special_folders); $p++) {
       for ($p = 0; $p < count($special_folders); $p++) {
-         if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
+         if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
             $use_folder = false;
             $use_folder = false;
-         } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
+         } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
             $use_folder = false;
             $use_folder = false;
          }
          }
       }
       }
       if ($use_folder == true) {
       if ($use_folder == true) {
-         $box = $boxes[$i]["UNFORMATTED"];
-         $box2 = $boxes[$i]["FORMATTED"];
+         $box = $boxes[$i]["unformatted"];
+         $box2 = replace_spaces($boxes[$i]["formatted"]);
          echo "         <OPTION VALUE=\"$box\">$box2\n";
          echo "         <OPTION VALUE=\"$box\">$box2\n";
       }
       }
    }
    }

+ 21 - 19
src/folders_create.php

@@ -1,4 +1,3 @@
-<HTML>
 <?
 <?
    include("../config/config.php");
    include("../config/config.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
@@ -8,11 +7,8 @@
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.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, 0);
-   $dm = findMailboxDelimeter($imapConnection);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   $dm = sqimap_get_delimiter($imapConnection);
 
 
    if (strpos($folder_name, "\"") || strpos($folder_name, ".") ||
    if (strpos($folder_name, "\"") || strpos($folder_name, ".") ||
        strpos($folder_name, "/") || strpos($folder_name, "\\") ||
        strpos($folder_name, "/") || strpos($folder_name, "\\") ||
@@ -25,22 +21,28 @@
       $folder_name = "$folder_name$dm";
       $folder_name = "$folder_name$dm";
 
 
    if (trim($subfolder) == "[ None ]") {
    if (trim($subfolder) == "[ None ]") {
-      createFolder($imapConnection, "$folder_name");
+      sqimap_mailbox_create ($imapConnection, $folder_name, "");
    } else {
    } else {
-      createFolder($imapConnection, "$subfolder$dm$folder_name");
+      sqimap_mailbox_create ($imapConnection, $subfolder.$dm.$folder_name, "");
    }
    }
    fputs($imapConnection, "1 logout\n");
    fputs($imapConnection, "1 logout\n");
 
 
-   echo "<FONT FACE=\"Arial,Helvetica\">";
-   echo "<BR><BR><BR><CENTER><B>";
-   echo _("Folder Created!");
-   echo "</B><BR><BR>";
-   echo _("The folder has been successfully created.");
-   echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
-   echo _("Click here");
-   echo "</A> ";
-   echo _("to continue.");
-   echo "</CENTER></FONT>";
+//   if ($auto_forward == true) {
+//      header ("Location: webmail.php?right_frame=folders.php");
+//   } else {
+      echo "<html><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+      displayPageHeader($color, "None");
+      echo "<FONT FACE=\"Arial,Helvetica\">";
+      echo "<BR><BR><BR><CENTER><B>";
+      echo _("Folder Created!");
+      echo "</B><BR><BR>";
+      echo _("The folder has been successfully created.");
+      echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
+      echo _("Click here");
+      echo "</A> ";
+      echo _("to continue.");
+      echo "</CENTER></FONT>";
+      echo "</BODY></HTML>";
+//   }
 ?>
 ?>
-</BODY></HTML>
 
 

+ 26 - 29
src/folders_delete.php

@@ -3,7 +3,6 @@
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
-   include("../functions/mailbox.php");
    include("../functions/array.php");
    include("../functions/array.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
@@ -12,31 +11,29 @@
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    displayPageHeader($color, "None");  
    displayPageHeader($color, "None");  
    
    
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   getFolderList($imapConnection, $boxes);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   $boxes = sqimap_mailbox_list ($imapConnection);
+   $dm = sqimap_get_delimiter($imapConnection);
 
 
-   $dm = findMailboxDelimeter($imapConnection);
    /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
    /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
-   for ($i = 0; $i < count($boxes[$i]["UNFORMATTED"]); $i++) {
-      if ($boxes[$i]["UNFORMATTED"] == $trash_folder)
-         $tmp_trash_folder = $boxes[$i]["RAW"];
-   }
-
-   $tmpflags = getMailboxFlags($imapConnection, $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;
+   for ($i = 0; $i < count($boxes[$i]["unformatted"]); $i++) {
+      if ($boxes[$i]["unformatted"] == $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 **/
    /** 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 **/
    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 **/
       /** Creates the subfolders under $trash_folder **/
       for ($i = 0; $i < count($boxes); $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($imapConnection, $boxes[$i]["RAW"]);
+         if (($boxes[$i]["unformatted"] == $mailbox) ||
+             (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["unformatted"], $dm);
+            $flags = getMailboxFlags($imapConnection, $boxes[$i]["raw"]);
             for ($b = 0; $b < count($flags); $b++) {
             for ($b = 0; $b < count($flags); $b++) {
                $type = $flags[$b];
                $type = $flags[$b];
             }
             }
@@ -44,32 +41,32 @@
          }
          }
       }
       }
       for ($i = 0; $i < count($boxes); $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 (($boxes[$i]["unformatted"] == $mailbox) ||
+             (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+            sqimap_mailbox_create($imapConnection, $boxes[$i]["unformatted"], $numMessages);
+            $folder = $boxes[$i]["unformatted"];
 
 
             if ($numMessages > 0)
             if ($numMessages > 0)
-               $success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder" . $dm . "$folder");
+               $success = sqimap_messages_copy($imapConnection, 1, $folder);
             else
             else
                $success = true;
                $success = true;
 
 
             if ($success == true)
             if ($success == true)
-               removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"], $dm);
+               sqimap_mailbox_delete($imapConnection, $boxes[$i]["unformatted"]);
          }
          }
       }
       }
    } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
    } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
       fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
       fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
-      $data = imapReadData($imapConnection , "1", false, $response, $message);
+      $data = sqimap_read_data($imapConnection, "1", false, $response, $message);
       while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
       while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
          for ($i = 0; $i < count($boxes); $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"], $dm);
+            if (($boxes[$i]["unformatted"] == $mailbox) ||
+                (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+               sqimap_mailbox_delete($imapConnection, $boxes[$i]["unformatted"], $dm);
             }
             }
          }
          }
          fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
          fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
-         $data = imapReadData($imapConnection , "1", false, $response, $message);
+         $data = sqimap_read_data($imapConnection , "1", false, $response, $message);
       }
       }
    }
    }
 
 

+ 5 - 5
src/folders_rename_do.php

@@ -3,12 +3,11 @@
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
-   include("../functions/mailbox.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   $dm = findMailboxDelimeter($imapConnection);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   $dm = sqimap_get_delimiter($imapConnection);
 
 
    if (strpos($orig, $dm))
    if (strpos($orig, $dm))
       $old_dir = substr($orig, 0, strrpos($orig, $dm));
       $old_dir = substr($orig, 0, strrpos($orig, $dm));
@@ -21,12 +20,13 @@
       $newone = "$new_name";
       $newone = "$new_name";
 
 
    fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
    fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
-   $data = imapReadData($imapConnection, ".", true, $a, $b);
+   $data = sqimap_read_data($imapConnection, ".", true, $a, $b);
 
 
    // Renaming a folder doesn't renames the folder but leaves you unsubscribed
    // Renaming a folder doesn't renames the folder but leaves you unsubscribed
    //    at least on Cyrus IMAP servers.
    //    at least on Cyrus IMAP servers.
+   fputs ($imapConnection, "sub UNSUBSCRIBE \"$orig\"\n");
    fputs ($imapConnection, "sub SUBSCRIBE \"$newone\"\n");
    fputs ($imapConnection, "sub SUBSCRIBE \"$newone\"\n");
-   $data = imapReadData($imapConnection, "sub", true, $a, $b);
+   $data = sqimap_read_data($imapConnection, "sub", true, $a, $b);
 
 
    /** Log out this session **/
    /** Log out this session **/
    fputs($imapConnection, "1 logout");
    fputs($imapConnection, "1 logout");

+ 4 - 5
src/folders_rename_getname.php

@@ -3,14 +3,13 @@
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
-   include("../functions/mailbox.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   selectMailbox($imapConnection, $old, $numMessages);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   sqimap_mailbox_select($imapConnection, $old);
 
 
-   $dm = findMailboxDelimeter($imapConnection);
+   $dm = sqimap_get_delimiter($imapConnection);
    if (strpos($old, $dm)) {
    if (strpos($old, $dm)) {
       $old_name = substr($old, strrpos($old, $dm)+1, strlen($old));
       $old_name = substr($old, strrpos($old, $dm)+1, strlen($old));
       $old_parent = substr($old, 0, strrpos($old, $dm));
       $old_parent = substr($old, 0, strrpos($old, $dm));
@@ -37,7 +36,7 @@
    echo "</TABLE>";
    echo "</TABLE>";
 
 
    /** Log out this session **/
    /** Log out this session **/
-   fputs($imapConnection, "1 logout");
+   sqimap_logout($imapConnection);
 ?>
 ?>
 
 
 
 

+ 16 - 17
src/left_main.php

@@ -18,14 +18,13 @@
    include("../functions/array.php");
    include("../functions/array.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
-   include("../functions/mailbox.php");
 
 
    function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
    function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
       require ("../config/config.php");
       require ("../config/config.php");
 
 
       $mailboxURL = urlencode($real_box);
       $mailboxURL = urlencode($real_box);
-      selectMailbox($imapConnection, $real_box, $numNessages);
-      $unseen = unseenMessages($imapConnection, $numUnseen);
+      sqimap_mailbox_select ($imapConnection, $real_box);
+      $unseen = sqimap_unseen_messages($imapConnection, $numUnseen);
 
 
       echo "<NOBR>";
       echo "<NOBR>";
       if ($unseen)
       if ($unseen)
@@ -39,11 +38,11 @@
 
 
       if ($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 .= "<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 .= replace_spaces($mailbox);
          $line .= "</font></a>";
          $line .= "</font></a>";
       } else {
       } else {
          $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
          $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 .= replace_spaces($mailbox);
          $line .= "</font></a>";
          $line .= "</font></a>";
       }
       }
 
 
@@ -66,7 +65,7 @@
    }
    }
 
 
    // open a connection on the imap port (143)
    // open a connection on the imap port (143)
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
 
 
    /** If it was a successful login, lets load their preferences **/
    /** If it was a successful login, lets load their preferences **/
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
@@ -75,40 +74,40 @@
       echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">"; 
       echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">"; 
       echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">";
       echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">";
    }
    }
+   
    echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
    echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
    echo "<FONT FACE=\"Arial,Helvetica\">";
    echo "<FONT FACE=\"Arial,Helvetica\">";
 
 
-   getFolderList($imapConnection, $boxes);
+   $boxes = sqimap_mailbox_list($imapConnection);
 
 
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
-   echo "Folders</B><BR></FONT>";
+   echo _("Folders") . "</B><BR></FONT>";
 
 
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
    echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
    echo _("refresh folder list");
    echo _("refresh folder list");
    echo "</A>)</FONT></CENTER><BR>";
    echo "</A>)</FONT></CENTER><BR>";
    echo "<FONT FACE=\"Arial,Helvetica\">\n";
    echo "<FONT FACE=\"Arial,Helvetica\">\n";
-   $delimeter = findMailboxDelimeter($imapConnection);
+   $delimeter = sqimap_get_delimiter($imapConnection);
 
 
    for ($i = 0;$i < count($boxes); $i++) {
    for ($i = 0;$i < count($boxes); $i++) {
       $line = "";
       $line = "";
-      $mailbox = $boxes[$i]["FORMATTED"];
-      $boxFlags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]);
+      $mailbox = $boxes[$i]["formatted"];
 
 
-      if (trim($boxFlags[0]) != "") {
+      if ($boxes[$i]["flags"]) {
          $noselect = false;
          $noselect = false;
-         for ($h = 0; $h < count($boxFlags); $h++) {
-            if (strtolower($boxFlags[$h]) == "noselect")
+         for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
+            if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
                $noselect = true;
                $noselect = true;
          }
          }
          if ($noselect == true) {
          if ($noselect == true) {
             $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
             $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
-            $line .= readShortMailboxName($mailbox, $delimeter);
+            $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter));
             $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
             $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
          } else {
          } else {
-            $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash);
+            $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash);
          }
          }
       } else {
       } else {
-         $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash);
+         $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash);
       }
       }
       echo "$line<BR>";
       echo "$line<BR>";
    }
    }

+ 7 - 10
src/move_messages.php

@@ -1,6 +1,5 @@
 <?
 <?
    include("../config/config.php");
    include("../config/config.php");
-   include("../functions/mailbox.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");
@@ -32,10 +31,8 @@
       }
       }
    }
    }
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-
-   // switch to the mailbox, and get the number of messages in it.
-   selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   sqimap_mailbox_select($imapConnection, $mailbox);
 
 
    // If the delete button was pressed, the moveButton variable will not be set.
    // If the delete button was pressed, the moveButton variable will not be set.
    if (!$moveButton) {
    if (!$moveButton) {
@@ -49,7 +46,7 @@
          //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
          //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
          while ($j < count($msg)) {
          while ($j < count($msg)) {
             if ($msg[$i]) {
             if ($msg[$i]) {
-               deleteMessages($imapConnection, $msg[$i], $msg[$i], $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
+               sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
                $j++;
                $j++;
             }
             }
             $i++;
             $i++;
@@ -70,15 +67,15 @@
          while ($j < count($msg)) {
          while ($j < count($msg)) {
             if ($msg[$i]) {
             if ($msg[$i]) {
                /** check if they would like to move it to the trash folder or not */
                /** check if they would like to move it to the trash folder or not */
-               $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
+               $success = sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
                if ($success == true)
                if ($success == true)
-                  setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
+                  sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
                $j++;
                $j++;
             }
             }
             $i++;
             $i++;
          }
          }
          if ($auto_expunge == true)
          if ($auto_expunge == true)
-            expungeBox($imapConnection, $mailbox, $numMessages);
+            sqimap_mailbox_expunge($imapConnection, $mailbox, $numMessages);
 
 
          messages_moved_message($mailbox, $sort, $startMessage, $color);
          messages_moved_message($mailbox, $sort, $startMessage, $color);
       } else {
       } else {
@@ -87,7 +84,7 @@
    }
    }
 
 
    // Log out this session
    // Log out this session
-   fputs($imapConnection, "1 logout");
+   sqimap_logout($imapConnection);
 
 
 ?>
 ?>
 </BODY></HTML>
 </BODY></HTML>

+ 2 - 3
src/options.php

@@ -1,6 +1,5 @@
 <?
 <?
    include("../config/config.php");
    include("../config/config.php");
-   include("../functions/mailbox.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");
@@ -10,8 +9,8 @@
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-   getFolderList($imapConnection, $boxes);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress);
+   $boxes = sqimap_mailbox_list($imapConnection, $boxes);
    fputs($imapConnection, "1 logout\n");
    fputs($imapConnection, "1 logout\n");
 
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";

+ 0 - 1
src/options_submit.php

@@ -1,6 +1,5 @@
 <?
 <?
    include("../config/config.php");
    include("../config/config.php");
-   include("../functions/mailbox.php");
    include("../functions/strings.php");
    include("../functions/strings.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");

+ 3 - 4
src/read_body.php

@@ -4,17 +4,16 @@
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/imap.php");
    include("../functions/imap.php");
    include("../functions/mime.php");
    include("../functions/mime.php");
-   include("../functions/mailbox.php");
    include("../functions/date.php");
    include("../functions/date.php");
 
 
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
 
 
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
-   selectMailbox($imapConnection, $mailbox, $numMessages);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
+   sqimap_mailbox_select($imapConnection, $mailbox);
 
 
    // $message contains all information about the message
    // $message contains all information about the message
    // including header and body
    // including header and body
-   $message = fetchMessage($imapConnection, $passed_id, $mailbox);
+   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
 
 
    echo "<HTML>";
    echo "<HTML>";
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";

+ 4 - 9
src/right_main.php

@@ -29,7 +29,6 @@
    include("../functions/date.php");
    include("../functions/date.php");
    include("../functions/page_header.php");
    include("../functions/page_header.php");
    include("../functions/array.php");
    include("../functions/array.php");
-   include("../functions/mailbox.php");
    include("../functions/mailbox_display.php");
    include("../functions/mailbox_display.php");
    include("../functions/display_messages.php");
    include("../functions/display_messages.php");
 
 
@@ -49,7 +48,7 @@
    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
 
 
    // open a connection on the imap port (143)
    // open a connection on the imap port (143)
-   $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
 
 
    /** If it was a successful login, lets load their preferences **/
    /** If it was a successful login, lets load their preferences **/
    include("../src/load_prefs.php");
    include("../src/load_prefs.php");
@@ -65,18 +64,14 @@
       exit;
       exit;
    }
    }
 
 
-   // switch to the mailbox, and get the number of messages in it.
-   selectMailbox($imapConnection, $mailbox, $numMessages);
-
-   // Display the header at the top of the page
+   sqimap_mailbox_select($imapConnection, $mailbox);
+   $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
    displayPageHeader($color, $mailbox);
    displayPageHeader($color, $mailbox);
 
 
-   // Get the list of messages for this mailbox
    showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color);
    showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color);
 
 
    // close the connection
    // close the connection
-   fputs($imapConnection, "1 logout\n");
-   fclose($imapConnection);
+   sqimap_logout ($imapConnection);
 ?>
 ?>
 </FONT>
 </FONT>
 </BODY>
 </BODY>