From df8e8ec9eee72743d0f14a8409aacf66c4a80d89 Mon Sep 17 00:00:00 2001 From: yllar <yllar.pajus@gmail.com> Date: Mon, 11 Dec 2006 12:09:34 -0500 Subject: [PATCH] updated da, de_DE, pt_BR, bs_BA, fr, pl, et_EE translations --- program/lib/imap.inc | 109 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 81 insertions(+), 28 deletions(-) diff --git a/program/lib/imap.inc b/program/lib/imap.inc index bef2de9..6bc47a1 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -39,7 +39,15 @@ - Added BCC and REFERENCE to the list of headers to fetch in iil_C_FetchHeaders() - Leave messageID unchanged in iil_C_FetchHeaders() - Avoid stripslahes in iil_Connect() + - Escape quotes and backslashes in iil_C_Login() + - Added patch to iil_SortHeaders() by Richard Green - Removed <br> from error messages (better for logging) + - Added patch to iil_C_Sort() enabling UID SORT commands + - Added function iil_C_ID2UID() + - Casting date parts in iil_StrToTime() to avoid mktime() warnings + - Also acceppt LIST responses in iil_C_ListSubscribed() + - Sanity check of $message_set in iil_C_FetchHeaders(), iil_C_FetchHeaderIndex(), iil_C_FetchThreadHeaders() + - Implemented UID FETCH in iil_C_FetchHeaders() - Removed some debuggers (echo ...) ********************************************************/ @@ -218,8 +226,9 @@ function iil_C_Login(&$conn, $user, $password){ + $password = strtr($password, array('"'=>'\\"', '\\' => '\\\\')); fputs($conn->fp, "a001 LOGIN $user \"$password\"\r\n"); - + do{ $line = iil_ReadReply($conn->fp); }while(!iil_StartsWith($line, "a001 ")); @@ -610,15 +619,15 @@ //$month_a=array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); $month_str=$a[1]; $month=$IMAP_MONTHS[$month_str]; - $day=$a[0]; - $year=$a[2]; + $day=(int)$a[0]; + $year=(int)$a[2]; $time=$a[3]; $tz_str = $a[4]; $tz = substr($tz_str, 0, 3); - $ta=explode(":",$time); + $ta = explode(":",$time); $hour=(int)$ta[0]-(int)$tz; - $minute=$ta[1]; - $second=$ta[2]; + $minute=(int)$ta[1]; + $second=(int)$ta[2]; //make UNIX timestamp $time2 = mktime($hour, $minute, $second, $month, $day, $year); @@ -626,7 +635,7 @@ return $time2; } -function iil_C_Sort(&$conn, $mailbox, $field, $add=''){ +function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE, $encoding='US-ASCII'){ /* Do "SELECT" command */ if (!iil_C_Select($conn, $mailbox)) return false; @@ -634,10 +643,16 @@ if ($field=='INTERNALDATE') $field='ARRIVAL'; $fields = array('ARRIVAL'=>1,'CC'=>1,'DATE'=>1,'FROM'=>1,'SIZE'=>1,'SUBJECT'=>1,'TO'=>1); - if (!$fields[$field]) return false; + if (!$fields[$field]) + return false; + $is_uid = $is_uid ? 'UID ' : ''; + + if (!empty($add)) + $add = " $add"; + $fp = $conn->fp; - $command = 's SORT ('.$field.') US-ASCII ALL '."$add\r\n"; + $command = 's '. $is_uid .'SORT ('.$field.') '.$encoding.' ALL'."$add\r\n"; $line = $data = ''; if (!fputs($fp, $command)) return false; @@ -655,7 +670,7 @@ return $out; } -function iil_C_FetchHeaderIndex(&$conn, $mailbox, $message_set, $index_field,$normalize=true){ +function iil_C_FetchHeaderIndex(&$conn, $mailbox, $message_set, $index_field, $normalize=true){ global $IMAP_USE_INTERNAL_DATE; $c=0; @@ -665,7 +680,9 @@ if (empty($index_field)) $index_field="DATE"; $index_field = strtoupper($index_field); - if (empty($message_set)) return array(); + list($from_idx, $to_idx) = explode(':', $message_set); + if (empty($message_set) || (isset($to_idx) && (int)$from_idx > (int)$to_idx)) + return false; //$fields_a["DATE"] = ($IMAP_USE_INTERNAL_DATE?6:1); $fields_a['DATE'] = 1; @@ -921,7 +938,9 @@ global $clock; global $index_a; - if (empty($message_set)) return false; + list($from_idx, $to_idx) = explode(':', $message_set); + if (empty($message_set) || (isset($to_idx) && (int)$from_idx > (int)$to_idx)) + return false; $result = array(); $uids = iil_C_FetchUIDs($conn, $mailbox); @@ -1002,7 +1021,9 @@ function iil_C_BuildThreads2(&$conn, $mailbox, $message_set, &$clock){ global $index_a; - if (empty($message_set)) return false; + list($from_idx, $to_idx) = explode(':', $message_set); + if (empty($message_set) || (isset($to_idx) && (int)$from_idx > (int)$to_idx)) + return false; $result=array(); $roots=array(); @@ -1177,15 +1198,17 @@ return $t_index; } -function iil_C_FetchHeaders(&$conn, $mailbox, $message_set){ +function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false){ global $IMAP_USE_INTERNAL_DATE; $c=0; $result=array(); $fp = $conn->fp; - if (empty($message_set)) return array(); - + list($from_idx, $to_idx) = explode(':', $message_set); + if (empty($message_set) || (isset($to_idx) && (int)$from_idx > (int)$to_idx)) + return false; + /* Do "SELECT" command */ if (!iil_C_Select($conn, $mailbox)){ $conn->error = "Couldn't select $mailbox"; @@ -1211,7 +1234,8 @@ /* FETCH date,from,subject headers */ $key="fh".($c++); - $request=$key." FETCH $message_set (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID REFERENCE)])\r\n"; + $prefix=$uidfetch?" UID":""; + $request=$key.$prefix." FETCH $message_set (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID REFERENCE)])\r\n"; if (!fputs($fp, $request)) return false; do{ @@ -1289,7 +1313,7 @@ Sample reply line: "* 3 FETCH (UID 2417 RFC822.SIZE 2730 FLAGS (\Seen \Deleted))" */ $command_key="fh".($c++); - $request= $command_key." FETCH $message_set (UID RFC822.SIZE FLAGS INTERNALDATE)\r\n"; + $request= $command_key.$prefix." FETCH $message_set (UID RFC822.SIZE FLAGS INTERNALDATE)\r\n"; if (!fputs($fp, $request)) return false; do{ $line=chop(iil_ReadLine($fp, 200)); @@ -1381,10 +1405,10 @@ } -function iil_C_FetchHeader(&$conn, $mailbox, $id){ +function iil_C_FetchHeader(&$conn, $mailbox, $id, $uidfetch=false){ $fp = $conn->fp; - $a=iil_C_FetchHeaders($conn, $mailbox, $id); - if (is_array($a)) return $a[$id]; + $a=iil_C_FetchHeaders($conn, $mailbox, $id, $uidfetch); + if (is_array($a)) return array_shift($a); else return false; } @@ -1396,7 +1420,7 @@ if (empty($flag)) $flag="ASC"; $flag=strtoupper($flag); $stripArr = ($field=='subject') ? array('Re: ','Fwd: ','Fw: ',"\"") : array("\""); - + $c=count($a); if ($c>0){ /* @@ -1406,12 +1430,22 @@ and use that to sort the main array. */ - // create "index" array + // create "index" array $index=array(); reset($a); while (list($key, $val)=each($a)){ - $data=$a[$key]->$field; - if (is_string($data)) $data=strtoupper(str_replace($stripArr, "", $data)); + + if ($field=="timestamp"){ + $data = @strtotime($val->date); + if ($data == false) + $data = $val->timestamp; + } + else { + $data = $val->$field; + if (is_string($data)) + $data=strtoupper(str_replace($stripArr, "", $data)); + } + $index[$key]=$data; } @@ -1557,6 +1591,25 @@ } } return false; +} + +function iil_C_ID2UID(&$conn, $folder, $id){ + $fp = $conn->fp; + $result=-1; + if ($id > 0) { + if (iil_C_Select($conn, $folder)){ + $key = "FUID"; + if (fputs($fp, "$key FETCH $id (UID)\r\n")){ + do{ + $line=chop(iil_ReadLine($fp, 1024)); + if (eregi("^\* $id FETCH \(UID (.*)\)", $line, $r)){ + $result = $r[1]; + } + } while (!preg_match("/^$key/", $line)); + } + } + } + return $result; } function iil_C_Search(&$conn, $folder, $criteria){ @@ -1716,7 +1769,7 @@ $line=iil_ReadLine($fp, 500); $line=iil_MultLine($fp, $line); $a = explode(" ", $line); - if (($line[0]=="*") && ($a[1]=="LSUB")){ + if (($line[0]=="*") && ($a[1]=="LSUB" || $a[1]=="LIST")){ $line = rtrim($line); // split one line $a=iil_ExplodeQuotedString(" ", $line); @@ -1836,7 +1889,7 @@ $remaining = $bytes - $received; $line = iil_ReadLine($fp, 1024); $len = strlen($line); - if ($len > $remaining) substr($line, 0, $remaining); + if ($len > $remaining) $line = substr($line, 0, $remaining); $received += strlen($line); if ($mode==1) $result .= chop($line)."\n"; else if ($mode==2){ echo chop($line)."\n"; flush(); } @@ -2068,4 +2121,4 @@ return (iil_C_Expunge($conn, $folder) >= 0); } -?> \ No newline at end of file +?> -- Gitblit v1.9.1