a777439a |
1 | <?php |
2 | |
3 | /** |
4 | * view_header.php |
5 | * |
a777439a |
6 | * This is the code to view the message header. |
7 | * |
47ccfad4 |
8 | * @copyright © 1999-2006 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
10 | * @version $Id$ |
8f6f9ba5 |
11 | * @package squirrelmail |
a777439a |
12 | */ |
86725763 |
13 | |
30967a1e |
14 | /** |
15 | * Path for SquirrelMail required files. |
16 | * @ignore |
17 | */ |
86725763 |
18 | define('SM_PATH','../'); |
19 | |
20 | /* SquirrelMail required files. */ |
5c4ff7bf |
21 | include_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
22 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
23 | require_once(SM_PATH . 'functions/imap.php'); |
24 | require_once(SM_PATH . 'functions/html.php'); |
25 | require_once(SM_PATH . 'functions/url_parser.php'); |
a777439a |
26 | |
65f8ca87 |
27 | function parse_viewheader($imapConnection,$id, $passed_ent_id) { |
a777439a |
28 | |
e44fc2eb |
29 | $header_output = array(); |
4a44f12c |
30 | $second = array(); |
79df8884 |
31 | $first = array(); |
e44fc2eb |
32 | |
dbdfdf6c |
33 | if (!$passed_ent_id) { |
91e0dccc |
34 | $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]", |
6201339c |
35 | true, $a, $b, TRUE); |
dbdfdf6c |
36 | } else { |
37 | $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]'; |
91e0dccc |
38 | $read=sqimap_run_command ($imapConnection, $query, |
6201339c |
39 | true, $a, $b, TRUE); |
91e0dccc |
40 | } |
a777439a |
41 | $cnum = 0; |
42 | for ($i=1; $i < count($read); $i++) { |
43 | $line = htmlspecialchars($read[$i]); |
134e4174 |
44 | switch (true) { |
45 | case (eregi("^>", $line)): |
46 | $second[$i] = $line; |
47 | $first[$i] = ' '; |
48 | $cnum++; |
49 | break; |
50 | case (eregi("^[ |\t]", $line)): |
51 | $second[$i] = $line; |
52 | $first[$i] = ''; |
53 | break; |
54 | case (eregi("^([^:]+):(.+)", $line, $regs)): |
55 | $first[$i] = $regs[1] . ':'; |
56 | $second[$i] = $regs[2]; |
57 | $cnum++; |
58 | break; |
59 | default: |
60 | $second[$i] = trim($line); |
61 | $first[$i] = ''; |
62 | break; |
a777439a |
63 | } |
64 | } |
65 | for ($i=0; $i < count($second); $i = $j) { |
65f8ca87 |
66 | $f = (isset($first[$i]) ? $first[$i] : ''); |
91e0dccc |
67 | $s = (isset($second[$i]) ? nl2br($second[$i]) : ''); |
a777439a |
68 | $j = $i + 1; |
69 | while (($first[$j] == '') && ($j < count($first))) { |
70 | $s .= ' ' . nl2br($second[$j]); |
71 | $j++; |
72 | } |
dbdfdf6c |
73 | $lowf=strtolower($f); |
74 | /* do not mark these headers as emailaddresses */ |
75 | if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') { |
76 | parseEmail($s); |
77 | } |
65f8ca87 |
78 | if ($f) { |
36cd4eaa |
79 | $header_output[] = array($f,$s); |
a777439a |
80 | } |
81 | } |
a777439a |
82 | sqimap_logout($imapConnection); |
98349cf6 |
83 | return $header_output; |
a777439a |
84 | } |
85 | |
be61c5a6 |
86 | function view_header($header, $mailbox, $color) { |
1e12d1ff |
87 | sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER); |
88 | $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr; |
be61c5a6 |
89 | |
90 | displayPageHeader($color, $mailbox); |
91 | |
3c621ba1 |
92 | echo '<br />' . |
93 | '<table width="100%" cellpadding="2" cellspacing="0" border="0" '. |
94 | 'align="center">' . "\n" . |
95 | '<tr><td bgcolor="'.$color[9].'" width="100%" align="center"><b>'. |
96 | _("Viewing Full Header") . '</b> - '. |
91e0dccc |
97 | '<a href="'; |
be61c5a6 |
98 | echo_template_var($ret_addr); |
a74103dd |
99 | echo '">' ._("View message") . "</a></td></tr></table>\n"; |
a777439a |
100 | |
91e0dccc |
101 | echo_template_var($header, |
3c621ba1 |
102 | array( |
103 | '<table width="99%" cellpadding="2" cellspacing="0" border="0" '. |
104 | "align=center>\n".'<tr><td>', |
a74103dd |
105 | '<tt style="white-space: nowrap;"><b>', |
134e4174 |
106 | '</b>', |
a74103dd |
107 | '</tt>', |
91e0dccc |
108 | '</td></tr></table>'."\n" |
134e4174 |
109 | ) |
110 | ); |
dcc1cc82 |
111 | echo '</body></html>'; |
a777439a |
112 | } |
113 | |
fe369c70 |
114 | /* get global vars */ |
1e12d1ff |
115 | if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) { |
116 | $passed_id = (int) $temp; |
be61c5a6 |
117 | } |
1e12d1ff |
118 | if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) { |
fdc9d9b5 |
119 | $mailbox = $temp; |
1e12d1ff |
120 | } |
121 | if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) { |
122 | $passed_ent_id = ''; |
91e0dccc |
123 | } |
1e12d1ff |
124 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
125 | sqgetGlobalVar('username', $username, SQ_SESSION); |
126 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
127 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
be61c5a6 |
128 | |
91e0dccc |
129 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
be61c5a6 |
130 | $imapPort, 0); |
131 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
132 | |
91e0dccc |
133 | $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id); |
be61c5a6 |
134 | view_header($header, $mailbox, $color); |
135 | |
5c4ff7bf |
136 | ?> |