From 43fa235da354c8b53aa69ba745c1d398a758fcaf Mon Sep 17 00:00:00 2001 From: svncommit <devs@roundcube.net> Date: Wed, 26 Oct 2005 05:42:19 -0400 Subject: [PATCH] --- program/lib/imap.inc | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 9ee476e..7f4c93a 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -52,6 +52,7 @@ var $recent; var $rootdir; var $delimiter; + var $capability = array(); } class iilBasicHeader{ @@ -246,6 +247,9 @@ function iil_C_NameSpace(&$conn){ global $my_prefs; + if (!in_array('NAMESPACE', $conn->capability)) + return false; + if ($my_prefs["rootdir"]) return true; fputs($conn->fp, "ns1 NAMESPACE\r\n"); @@ -325,16 +329,16 @@ } //open socket connection - $conn->fp = @fsockopen($host, $ICL_PORT); + $conn->fp = @fsockopen($host, $ICL_PORT, $errno, $errstr, 10); if (!$conn->fp){ - $iil_error = "Could not connect to $host at port $ICL_PORT"; + $iil_error = "Could not connect to $host at port $ICL_PORT: $errstr"; $iil_errornum = -1; return false; } $iil_error.="Socket connection established\r\n"; $line=iil_ReadLine($conn->fp, 300); - + if (strcasecmp($auth_method, "check")==0){ //check for supported auth methods @@ -345,9 +349,12 @@ fputs($conn->fp, "cp01 CAPABILITY\r\n"); do{ $line = trim(chop(iil_ReadLine($conn->fp, 100))); + $conn->message.="$line\n"; $a = explode(" ", $line); if ($line[0]=="*"){ while ( list($k, $w) = each($a) ){ + if ($w!='*' && $w!='CAPABILITY') + $conn->capability[] = $w; if ((strcasecmp($w, "AUTH=CRAM_MD5")==0)|| (strcasecmp($w, "AUTH=CRAM-MD5")==0)){ $auth_method = "auth"; @@ -362,6 +369,7 @@ //do CRAM-MD5 authentication fputs($conn->fp, "a000 AUTHENTICATE CRAM-MD5\r\n"); $line = trim(chop(iil_ReadLine($conn->fp, 1024))); + $conn->message.="$line\n"; if ($line[0]=="+"){ $conn->message.='Got challenge: '.htmlspecialchars($line)."\n"; //got a challenge string, try CRAM-5 @@ -1237,8 +1245,13 @@ $result[$id]->cc = str_replace("\n", " ", $headers["cc"]); $result[$id]->encoding = str_replace("\n", " ", $headers["content-transfer-encoding"]); $result[$id]->ctype = str_replace("\n", " ", $headers["content-type"]); - //$result[$id]->in_reply_to = ereg_replace("[\n<>]",'', $headers['in-reply-to']); - list($result[$id]->ctype,$foo) = explode(";", $headers["content-type"]); + $result[$id]->in_reply_to = ereg_replace("[\n<>]",'', $headers['in-reply-to']); + + list($result[$id]->ctype, $ctype_add) = explode(";", $headers["content-type"]); + + if (preg_match('/charset="?([a-z0-9\-]+)"?/i', $ctype_add, $regs)) + $result[$id]->charset = $regs[1]; + $messageID = $headers["message-id"]; if ($messageID) $messageID = substr(substr($messageID, 1), 0, strlen($messageID)-2); else $messageID = "mid:".$id; @@ -1386,7 +1399,7 @@ $result=array(); reset($index); while (list($key, $val)=each($index)){ - $result[$i]=$a[$key]; + $result[$key]=$a[$key]; $i++; } } @@ -1438,7 +1451,7 @@ $line=chop(iil_ReadLine($fp, 100)); if ($line[0]=="*") $c++; }while (!iil_StartsWith($line, "flg")); - + if (iil_ParseResult($line) == 0){ iil_C_ExpireCachedItems($conn, $mailbox, $messages); return $c; @@ -1872,7 +1885,7 @@ } } -function iil_C_Append(&$conn, $folder, $message){ +function iil_C_Append(&$conn, $folder, &$message){ if (!$folder) return false; $fp = $conn->fp; -- Gitblit v1.9.1