Browse Source

- Returned sqimap_get_delimiter() to the old code, but left the new code
there to see if anyone could get it working
- Returned sqimap_find_displayable_name() to the old code
- Fixed readShortMailboxName() to deal with dissapearing mailboxes and more
- Returned parseAddres() to the old code

Tyler Akins 25 years ago
parent
commit
d4db78af51
2 changed files with 44 additions and 11 deletions
  1. 30 5
      functions/imap_general.php
  2. 14 6
      functions/strings.php

+ 30 - 5
functions/imap_general.php

@@ -166,11 +166,21 @@
    /******************************************************************************
     **  Returns the delimeter between mailboxes:  INBOX/Test, or INBOX.Test... 
     ******************************************************************************/
-   function sqimap_get_delimiter ($imap_stream) {
+   function sqimap_get_delimiter ($imap_stream = false) {
+      fputs ($imap_stream, ". LIST \"INBOX\" \"\"\r\n");
+      $read = sqimap_read_data($imap_stream, ".", true, $a, $b);
+      $quote_position = strpos ($read[0], "\"");
+      $delim = substr ($read[0], $quote_position+1, 1);
+
+      return $delim;
+   
+   /* According to something that I can't find, this is supposed to work on all systems
+   
       fputs ($imap_stream, "a001 NAMESPACE\r\n");
       $read = sqimap_read_data($imap_stream, "a001", true, $a, $b);
       eregi("\"\" \"(.)\"", $read[0], $regs);
       return $regs[1];
+   */
    }
 
 
@@ -198,6 +208,9 @@
       /** Luke Ehresman <lehresma@css.tayloru.edu>
        ** <lehresma@css.tayloru.edu>
        ** lehresma@css.tayloru.edu
+       **
+       ** What about
+       **    lehresma@css.tayloru.edu (Luke Ehresman)
        **/
 
       if (ereg("<([^>]+)>", $string, $regs)) {
@@ -215,10 +228,22 @@
     **           becomes:   lkehresman@yahoo.com
     ******************************************************************************/
    function sqimap_find_displayable_name ($string) {
-      ereg("^\"?([^\"<]*)[\" <]*([^>]+)>?$", trim($string), $regs);
-      if ($regs[1] == '')
-          return $regs[2];
-      return $regs[1];
+      $string = " ".trim($string);
+      $orig_string = $string;
+      if (strpos($string, "<") && strpos($string, ">")) {
+         if (strpos($string, "<") == 1) {
+            $string = sqimap_find_email($string);
+         } else {
+            $string = trim($string);
+            $string = substr($string, 0, strpos($string, "<"));
+            $string = ereg_replace ("\"", "", $string);   
+         }   
+
+         if (trim($string) == "") {
+            $string = sqimap_find_email($orig_string);
+         }
+      }
+      return $string; 
    }
 
 

+ 14 - 6
functions/strings.php

@@ -15,8 +15,9 @@
    //    of the $haystack is reached.  $needle is a single character
    //*************************************************************************
    function readShortMailboxName($haystack, $needle) {
-      ereg("^$needle?([^$needle]+)$needle*",strrev($haystack),$regs);
-        return strrev($regs[1]);
+      if ($needle == ".") $needle = "\.";
+      ereg("([^$needle]+)$needle?$", $haystack, $regs);
+      return $regs[1];
    }
 
    // Searches for the next position in a string minus white space
@@ -105,11 +106,18 @@
 
    /** Returns an array of email addresses **/
    function parseAddrs($text) {
-      if (trim($text) == "") {
+      if (trim($text) == "")
          return;
-      }
-      $text=ereg_replace("[;,][^<]*<* *([^>]*) *>*",";\\1",",$text");
-      return split("[;]", substr($text,1));
+      $text = str_replace(" ", "", $text);
+      $text = ereg_replace('"[^"]*"', "", $text);
+      $text = ereg_replace("\([^\)]*\)", "", $text);
+      $text = str_replace(",", ";", $text);
+      $array = explode(";", $text);
+      for ($i = 0; $i < count ($array); $i++) {
+			    $array[$i] = eregi_replace ("^.*[<]", "", $array[$i]);
+			    $array[$i] = eregi_replace ("[>].*$", "", $array[$i]);
+		  }
+      return $array;
    }
 
    /** Returns a line of comma separated email addresses from an array **/