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