6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This is the code to view the message header.
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/global.php');
24 require_once(SM_PATH
. 'functions/imap.php');
25 require_once(SM_PATH
. 'functions/html.php');
26 require_once(SM_PATH
. 'functions/url_parser.php');
28 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
30 $header_full = array();
31 if (!$passed_ent_id) {
32 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
35 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
36 $read=sqimap_run_command ($imapConnection, $query,
40 for ($i=1; $i < count($read); $i++
) {
41 $line = htmlspecialchars($read[$i]);
43 case (eregi("^>", $line)):
45 $first[$i] = ' ';
48 case (eregi("^[ |\t]", $line)):
52 case (eregi("^([^:]+):(.+)", $line, $regs)):
53 $first[$i] = $regs[1] . ':';
54 $second[$i] = $regs[2];
58 $second[$i] = trim($line);
63 for ($i=0; $i < count($second); $i = $j) {
64 $f = (isset($first[$i]) ?
$first[$i] : '');
65 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
67 while (($first[$j] == '') && ($j < count($first))) {
68 $s .= ' ' . nl2br($second[$j]);
72 /* do not mark these headers as emailaddresses */
73 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
77 $header_output[] = array($f,$s);
80 sqimap_logout($imapConnection);
81 return $header_output;
84 function view_header($header, $mailbox, $color) {
85 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
86 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
88 displayPageHeader($color, $mailbox);
91 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
92 ' ALIGN="CENTER">' . "\n" .
93 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
94 _("Viewing Full Header") . '</B> - '.
96 echo_template_var($ret_addr);
97 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
99 echo_template_var($header,
101 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
102 "align=center>\n".'<tr><td>',
106 '</td></tr></table>'."\n"
108 echo '</body></html>';
111 /* get global vars */
112 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET
) ) {
113 $passed_id = (int) $temp;
115 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
118 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
121 sqgetGlobalVar('key', $key, SQ_COOKIE
);
122 sqgetGlobalVar('username', $username, SQ_SESSION
);
123 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
124 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
126 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
128 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
130 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
131 view_header($header, $mailbox, $color);