X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_messages.php;h=4b23cf334fd8736e701d02585d6b29e277262489;hb=18e206dd1373a321595d9500bc47e137867d17b4;hp=a28dc43da6ba7af74eedb7da50b0aee947c473d8;hpb=3309f5b9ac78fe8e336d772cad928d2718588f14;p=squirrelmail.git diff --git a/functions/imap_messages.php b/functions/imap_messages.php index a28dc43d..4b23cf33 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -2,7 +2,9 @@ /** ** imap_messages.php ** - ** This implements functions that manipulate messages + ** This implements functions that manipulate messages + ** + ** $Id$ **/ if (!isset($mime_php)) include "../functions/mime.php"; @@ -51,7 +53,8 @@ ** Returns some general header information -- FROM, DATE, and SUBJECT ******************************************************************************/ class small_header { - var $from, $subject, $date, $to, $priority, $message_id; + var $from = '', $subject = '', $date = '', $to = '', + $priority = 0, $message_id = 0, $cc = ''; } function sqimap_get_small_header ($imap_stream, $id, $sent) { @@ -63,6 +66,11 @@ $from = _("Unknown Sender"); $priority = "0"; $messageid = "<>"; + $cc = ""; + $to = ""; + $date = ""; + $type[0] = ""; + $type[1] = ""; $g = 0; for ($i = 0; $i < count($read); $i++) { @@ -110,12 +118,12 @@ fputs ($imap_stream, "a003 FETCH $id RFC822.SIZE\r\n"); $read = sqimap_read_data($imap_stream, "a003", true, $r, $m); - preg_match("/([0-9]+)\)\s*$/i", $read[0], $regs); + eregi("([0-9]+)[^0-9]*$", $read[0], $regs); $size = $regs[1]; $header = new small_header; if ($sent == true) - $header->from = (trim($to) != '')? $to : _('(only Cc/Bcc)'); + $header->from = (trim($to) != '')? $to : _("(only Cc/Bcc)"); else $header->from = $from; @@ -128,7 +136,7 @@ $header->size = $size; $header->type0 = $type[0]; $header->type1 = $type[1]; - + return $header; } @@ -139,7 +147,7 @@ fputs ($imap_stream, "a001 FETCH $i:$i FLAGS\r\n"); $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message); if (ereg("FLAGS(.*)", $read[0], $regs)) - return explode(" ", trim(ereg_replace('[\(\)\\]', '', $regs[1]))); + return explode(" ", trim(ereg_replace('[\\(\\)\\\\]', '', $regs[1]))); return Array('None'); } @@ -149,8 +157,7 @@ ******************************************************************************/ function sqimap_get_message ($imap_stream, $id, $mailbox) { $header = sqimap_get_message_header($imap_stream, $id, $mailbox); - $msg = sqimap_get_message_body($imap_stream, &$header); - return $msg; + return sqimap_get_message_body($imap_stream, $header); } /****************************************************************************** @@ -195,9 +202,6 @@ $hdr->type1 = "plain"; $hdr->charset = "us-ascii"; - preg_match("/\{([0-9]+)\}/", $read[$i], $regs); - preg_match("/[0-9]+/", $regs[0], $regs); - while ($i < count($read)) { if (substr($read[$i], 0, 17) == "MIME-Version: 1.0") { $hdr->mime = true; @@ -235,7 +239,7 @@ } /** Detect the boundary of a multipart message **/ - if (eregi("boundary=\"([^\"]+)\"", $line, $regs)) { + if (eregi('boundary="([^"]+)"', $line, $regs)) { $hdr->boundary = $regs[1]; } @@ -256,7 +260,7 @@ } - else if (strtolower(substr($read[$i], 0, 20)) == "content-disposition:") { + else if (strtolower(substr($read[$i], 0, 20)) == "content-disposition:") { /** Add better dontent-disposition support **/ $line = $read[$i]; @@ -291,7 +295,7 @@ /** FROM **/ else if (strtolower(substr($read[$i], 0, 5)) == "from:") { $hdr->from = trim(substr($read[$i], 5, strlen($read[$i]) - 6)); - if ($hdr->replyto == "") + if (! isset($hdr->replyto) || $hdr->replyto == "") $hdr->replyto = $hdr->from; $i++; } @@ -299,8 +303,8 @@ else if (strtolower(substr($read[$i], 0, 5)) == "date:") { $d = substr($read[$i], 5); $d = trim($d); - $d = ereg_replace(" ", " ", $d); - $d = explode(" ", $d); + $d = strtr($d, array(' ' => ' ')); + $d = explode(' ', $d); $hdr->date = getTimeStamp($d); $i++; } @@ -369,7 +373,7 @@ ******************************************************************************/ function sqimap_get_message_body ($imap_stream, &$header) { $id = $header->id; - return decodeMime($imap_stream, $body, &$header); + return decodeMime($imap_stream, $header); }