X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_messages.php;h=d7f01665e22754b58daf34b04311e1b00c16589b;hb=207dff258a974c7a74e1c8f27fea9a12f96ac356;hp=78c5eb7fa3b96335801f0f0f654279437a43b28b;hpb=5565075350352e7bba6c6a9e68d3216a58efd1d0;p=squirrelmail.git diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 78c5eb7f..d7f01665 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -33,30 +33,48 @@ function sqimap_messages_flag ($imap_stream, $start, $end, $flag) { fputs ($imap_stream, "a001 STORE $start:$end +FLAGS (\\$flag)\r\n"); $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message); - } /****************************************************************************** ** Returns some general header information -- FROM, DATE, and SUBJECT ******************************************************************************/ - function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date) { - //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n"); - fputs ($imap_stream, "a001 FETCH $id RFC822.HEADER\r\n"); + class small_header { + var $from, $subject, $date; + } + + function sqimap_get_small_header ($imap_stream, $id, $sent) { + fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date To From Subject)]\r\n"); $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message); $subject = _("(no subject)"); $from = _("Unknown Sender"); + $g = 0; for ($i = 0; $i < count($read); $i++) { - if (strtolower(substr($read[$i], 0, 5)) == "from:") { - $from = sqimap_find_displayable_name(substr($read[$i], 5)); - } else if (strtolower(substr($read[$i], 0, 5)) == "date:") { + if ($sent == true) { + if (eregi ("^to:", $read[$i])) { + $from = sqimap_find_displayable_name(substr($read[$i], 3)); + } + } else { + if (eregi ("^from:", $read[$i])) { + $from = sqimap_find_displayable_name(substr($read[$i], 5)); + } + } + + if (eregi ("^date:", $read[$i])) { $date = substr($read[$i], 5); - } else if (strtolower(substr($read[$i], 0, 8)) == "subject:") { - $subject = htmlspecialchars(substr($read[$i], 8)); - if (strlen(trim($subject)) == 0) + } else if (eregi ("^subject:", $read[$i])) { + $subject = htmlspecialchars(eregi_replace ("^subject: ", "", $read[$i])); + if (strlen(Chop($subject)) == 0) $subject = _("(no subject)"); } - } + } + + $header = new small_header; + $header->from = $from; + $header->date = $date; + $header->subject = $subject; + + return $header; } /****************************************************************************** @@ -241,7 +259,7 @@ $pos = 0; $header["CC"][$pos] = trim(substr($read[$i], 4)); $i++; - while ((substr($read[$i], 0, 1) == " ") && (trim($read[$i]) != "")) { + while (((substr($read[$i], 0, 1) == " ") || (substr($read[$i], 0, 1) == "\t")) && (trim($read[$i]) != "")){ $pos++; $header["CC"][$pos] = trim($read[$i]); $i++; @@ -252,7 +270,7 @@ $pos = 0; $header["TO"][$pos] = trim(substr($read[$i], 4)); $i++; - while ((substr($read[$i], 0, 1) == " ") && (trim($read[$i]) != "")){ + while (((substr($read[$i], 0, 1) == " ") || (substr($read[$i], 0, 1) == "\t")) && (trim($read[$i]) != "")){ $pos++; $header["TO"][$pos] = trim($read[$i]); $i++; @@ -267,13 +285,13 @@ /** ERROR CORRECTION **/ else if (substr($read[$i], 0, 1) == ")") { - if ($header["SUBJECT"] == "") + if (strlen(trim($header["SUBJECT"])) == 0) $header["SUBJECT"] = _("(no subject)"); - if ($header["FROM"] == "") + if (strlen(trim($header["FROM"])) == 0) $header["FROM"] = _("(unknown sender)"); - if ($header["DATE"] == "") + if (strlen(trim($header["DATE"])) == 0) $header["DATE"] = time(); $i++; }