a777439a |
1 | <?php |
2 | |
3 | /** |
4 | * view_header.php |
5 | * |
76911253 |
6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
a777439a |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This is the code to view the message header. |
10 | * |
11 | * $Id$ |
12 | */ |
86725763 |
13 | |
14 | /* Path for SquirrelMail required files. */ |
15 | define('SM_PATH','../'); |
16 | |
17 | /* SquirrelMail required files. */ |
08185f2a |
18 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
19 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
20 | require_once(SM_PATH . 'functions/imap.php'); |
21 | require_once(SM_PATH . 'functions/html.php'); |
22 | require_once(SM_PATH . 'functions/url_parser.php'); |
a777439a |
23 | |
65f8ca87 |
24 | function parse_viewheader($imapConnection,$id, $passed_ent_id) { |
a777439a |
25 | global $uid_support; |
26 | |
27 | $header_full = array(); |
5add5fcc |
28 | if (!$passed_ent_id) { |
29 | $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]", |
a777439a |
30 | true, $a, $b, $uid_support); |
5add5fcc |
31 | } else { |
32 | $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]'; |
33 | $read=sqimap_run_command ($imapConnection, $query, |
34 | true, $a, $b, $uid_support); |
35 | } |
a777439a |
36 | $cnum = 0; |
37 | for ($i=1; $i < count($read); $i++) { |
38 | $line = htmlspecialchars($read[$i]); |
65f8ca87 |
39 | switch (true) { |
40 | case (eregi("^>", $line)): |
a777439a |
41 | $second[$i] = $line; |
42 | $first[$i] = ' '; |
43 | $cnum++; |
65f8ca87 |
44 | break; |
45 | case (eregi("^[ |\t]", $line)): |
a777439a |
46 | $second[$i] = $line; |
47 | $first[$i] = ''; |
65f8ca87 |
48 | break; |
49 | case (eregi("^([^:]+):(.+)", $line, $regs)): |
a777439a |
50 | $first[$i] = $regs[1] . ':'; |
51 | $second[$i] = $regs[2]; |
52 | $cnum++; |
65f8ca87 |
53 | break; |
54 | default: |
a777439a |
55 | $second[$i] = trim($line); |
56 | $first[$i] = ''; |
65f8ca87 |
57 | break; |
a777439a |
58 | } |
59 | } |
60 | for ($i=0; $i < count($second); $i = $j) { |
65f8ca87 |
61 | $f = (isset($first[$i]) ? $first[$i] : ''); |
62 | $s = (isset($second[$i]) ? nl2br($second[$i]) : ''); |
a777439a |
63 | $j = $i + 1; |
64 | while (($first[$j] == '') && ($j < count($first))) { |
65 | $s .= ' ' . nl2br($second[$j]); |
66 | $j++; |
67 | } |
65f8ca87 |
68 | if(strtolower($f) != 'message-id:') { |
27fbf839 |
69 | parseEmail($s); |
70 | } |
65f8ca87 |
71 | if ($f) { |
36cd4eaa |
72 | $header_output[] = array($f,$s); |
a777439a |
73 | } |
74 | } |
a777439a |
75 | sqimap_logout($imapConnection); |
98349cf6 |
76 | return $header_output; |
a777439a |
77 | } |
78 | |
be61c5a6 |
79 | function view_header($header, $mailbox, $color) { |
1e12d1ff |
80 | sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER); |
81 | $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr; |
be61c5a6 |
82 | |
83 | displayPageHeader($color, $mailbox); |
84 | |
a777439a |
85 | echo '<BR>' . |
86 | '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'. |
87 | ' ALIGN="CENTER">' . "\n" . |
88 | " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>". |
89 | _("Viewing Full Header") . '</B> - '. |
90 | '<a href="'; |
be61c5a6 |
91 | echo_template_var($ret_addr); |
a777439a |
92 | echo '">' ._("View message") . "</a></b></td></tr></table>\n"; |
93 | |
be61c5a6 |
94 | echo_template_var($header, |
a777439a |
95 | array( |
96 | "<table width='99%' cellpadding='2' cellspacing='0' border='0'". |
5eb5b57e |
97 | "align=center>\n".'<tr><td>', |
a777439a |
98 | '<nobr><tt><b>', |
99 | '</b>', |
100 | '</tt></nobr>', |
101 | '</td></tr></table>'."\n" |
102 | ) ); |
be61c5a6 |
103 | echo '</body></html>'; |
a777439a |
104 | } |
105 | |
fe369c70 |
106 | /* get global vars */ |
1e12d1ff |
107 | if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) { |
108 | $passed_id = (int) $temp; |
be61c5a6 |
109 | } |
1e12d1ff |
110 | if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) { |
fdc9d9b5 |
111 | $mailbox = $temp; |
1e12d1ff |
112 | } |
113 | if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) { |
114 | $passed_ent_id = ''; |
115 | } |
116 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
117 | sqgetGlobalVar('username', $username, SQ_SESSION); |
118 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
119 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
be61c5a6 |
120 | |
121 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
122 | $imapPort, 0); |
123 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true); |
124 | |
125 | $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id); |
126 | view_header($header, $mailbox, $color); |
127 | |
a777439a |
128 | ?> |