From 1d2ce1c34e00aac31c2dacfc5473b8f389395f82 Mon Sep 17 00:00:00 2001 From: fidian Date: Fri, 27 Oct 2000 17:06:21 +0000 Subject: [PATCH] - 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 git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@824 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 35 ++++++++++++++++++++++++++++++----- functions/strings.php | 20 ++++++++++++++------ 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index c4d1d9c1..784a75d2 100755 --- a/functions/imap_general.php +++ b/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 + ** + ** 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; } diff --git a/functions/strings.php b/functions/strings.php index bee3eaa0..06057912 100644 --- a/functions/strings.php +++ b/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 **/ -- 2.25.1