6 * Copyright (c) 1999-2003 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.
14 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
17 /* SquirrelMail required files. */
18 require_once(SM_PATH
. 'include/validate.php');
19 require_once(SM_PATH
. 'functions/global.php');
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');
24 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
27 $header_full = array();
28 if (!$passed_ent_id) {
29 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
30 true, $a, $b, $uid_support);
32 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
33 $read=sqimap_run_command ($imapConnection, $query,
34 true, $a, $b, $uid_support);
37 for ($i=1; $i < count($read); $i++
) {
38 $line = htmlspecialchars($read[$i]);
40 case (eregi("^>", $line)):
42 $first[$i] = ' ';
45 case (eregi("^[ |\t]", $line)):
49 case (eregi("^([^:]+):(.+)", $line, $regs)):
50 $first[$i] = $regs[1] . ':';
51 $second[$i] = $regs[2];
55 $second[$i] = trim($line);
60 for ($i=0; $i < count($second); $i = $j) {
61 $f = (isset($first[$i]) ?
$first[$i] : '');
62 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
64 while (($first[$j] == '') && ($j < count($first))) {
65 $s .= ' ' . nl2br($second[$j]);
69 /* do not mark these headers as emailaddresses */
70 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
74 $header_output[] = array($f,$s);
77 sqimap_logout($imapConnection);
78 return $header_output;
81 function view_header($header, $mailbox, $color) {
82 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
83 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
85 displayPageHeader($color, $mailbox);
88 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
89 ' ALIGN="CENTER">' . "\n" .
90 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
91 _("Viewing Full Header") . '</B> - '.
93 echo_template_var($ret_addr);
94 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
96 echo_template_var($header,
98 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
99 "align=center>\n".'<tr><td>',
103 '</td></tr></table>'."\n"
105 echo '</body></html>';
108 /* get global vars */
109 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET
) ) {
110 $passed_id = (int) $temp;
112 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
115 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
118 sqgetGlobalVar('key', $key, SQ_COOKIE
);
119 sqgetGlobalVar('username', $username, SQ_SESSION
);
120 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
121 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
123 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
125 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
127 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
128 view_header($header, $mailbox, $color);