fixed some bugs in email address finding
[squirrelmail.git] / src / read_body.php
CommitLineData
be69e508 1<?
2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
6 include("../functions/mailbox.php");
7 include("../functions/date.php");
8
9 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
10 selectMailbox($imapConnection, $mailbox, $numMessages);
11
12 echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">\n";
13 displayPageHeader($mailbox);
14 $body = fetchBody($imapConnection, $passed_id);
15 getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d);
2844086d 16 getMessageHeadersTo($imapConnection, $passed_id, $passed_id, $t);
be69e508 17
18 $subject = $s[0];
31f3d7c0 19 $url_subj = urlencode(trim($subject));
20
be69e508 21 $d[0] = ereg_replace(" ", " ", $d[0]);
9774bdef 22 $dateParts = explode(" ", trim($d[0]));
23 $dateString = getLongDateString($dateParts);
24
be69e508 25 $from_name = getSenderName($f[0]);
8467bf00 26 $urlMailbox = urlencode($mailbox);
be69e508 27
31f3d7c0 28 $url_from = trim(decodeEmailAddr($f[0]));
29 $url_from = urlencode($url_from);
30
2844086d 31 $to_left = trim($t[0]);
32 for ($i = 0; $to_left;$i++) {
33 if (strpos($to_left, ",")) {
34 $to_ary[$i] = trim(substr($to_left, 0, strpos($to_left, ",")));
35 $to_left = substr($to_left, strpos($to_left, ",")+1, strlen($to_left));
36 }
37 else {
38 $to_ary[$i] = trim($to_left);
39 $to_left = "";
40 }
41 }
42
43 $i = 0;
44 $to_string = "";
45 while ($i < count($to_ary)) {
46 if ($to_string)
47 $to_string = "$to_string<BR>$to_ary[$i]";
48 else
49 $to_string = "$to_ary[$i]";
50
51 $i++;
52 if (count($to_ary) > 1) {
53 if ($show_more == false) {
54 if ($i == 1) {
55 $to_string = "$to_string&nbsp;&nbsp;&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1\">more</A>)";
56 $i = count($to_ary);
57 }
58 } else if ($i == 1) {
59 $to_string = "$to_string&nbsp;&nbsp;&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0\">less</A>)";
60 }
61 }
62 }
63
8467bf00 64 echo "<BR>";
65 echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
66 echo " <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
31f3d7c0 67 echo " <TABLE WIDTH=100% BORDER=0 COLS=2>";
68 echo " <TR>";
69 echo " <TD ALIGN=LEFT WIDTH=50%>";
70 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
71 echo " <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">Message List</A>&nbsp;&nbsp;";
72 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">Delete</A>&nbsp;&nbsp;";
73 echo " </FONT>";
74 echo " </TD><TD WIDTH=50% ALIGN=RIGHT>";
75 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
76 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">Forward</A>&nbsp;&nbsp;";
77 echo " <A HREF=\"compose.php?send_to=$url_from&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply</A>&nbsp;&nbsp;";
78 echo " </FONT>";
79 echo " </TD>";
80 echo " </TR>";
81 echo " </TABLE>";
8467bf00 82 echo " </TD></TR>";
83 echo " <TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
be69e508 84 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2>\n";
85 echo " <TR>\n";
86 /** subject **/
87 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
88 echo " <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
89 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
90 echo " <FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT>\n";
91 echo " </TD>\n";
92 echo " </TR>\n";
93 /** from **/
94 echo " <TR>\n";
95 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
96 echo " <FONT FACE=\"Arial,Helvetica\">From:</FONT>\n";
97 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
98 echo " <FONT FACE=\"Arial,Helvetica\"><B>$from_name</B></FONT>\n";
99 echo " </TD>\n";
100 echo " </TR>\n";
101 /** date **/
102 echo " <TR>\n";
103 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
104 echo " <FONT FACE=\"Arial,Helvetica\">Date:</FONT>\n";
105 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
9774bdef 106 echo " <FONT FACE=\"Arial,Helvetica\"><B>$dateString</B></FONT>\n";
be69e508 107 echo " </TD>\n";
108 echo " </TR>\n";
2844086d 109 /** to **/
110 echo " <TR>\n";
111 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
112 echo " <FONT FACE=\"Arial,Helvetica\">To:</FONT>\n";
113 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
114 echo " <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
115 echo " </TD>\n";
116 echo " </TR>\n";
be69e508 117
118 echo " </TABLE></TD></TR>\n";
119
8467bf00 120 echo " <TR><TD BGCOLOR=FFFFFF WIDTH=100%><BR>\n";
e550d551 121 $i = 0;
122 while ($i < count($body)) {
123 echo "$body[$i]";
be69e508 124 $i++;
125 }
e550d551 126 echo " <BR></TD></TR>\n";
be69e508 127 echo " <TR><TD BGCOLOR=DCDCDC>&nbsp;</TD></TR>";
128 echo "</TABLE>\n";
129
130?>