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.
12 * @package squirrelmail
15 /** Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/global.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/html.php');
23 require_once(SM_PATH
. 'functions/url_parser.php');
25 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
28 $header_full = array();
29 if (!$passed_ent_id) {
30 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
31 true, $a, $b, $uid_support);
33 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
34 $read=sqimap_run_command ($imapConnection, $query,
35 true, $a, $b, $uid_support);
38 for ($i=1; $i < count($read); $i++
) {
39 $line = htmlspecialchars($read[$i]);
41 case (eregi("^>", $line)):
43 $first[$i] = ' ';
46 case (eregi("^[ |\t]", $line)):
50 case (eregi("^([^:]+):(.+)", $line, $regs)):
51 $first[$i] = $regs[1] . ':';
52 $second[$i] = $regs[2];
56 $second[$i] = trim($line);
61 for ($i=0; $i < count($second); $i = $j) {
62 $f = (isset($first[$i]) ?
$first[$i] : '');
63 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
65 while (($first[$j] == '') && ($j < count($first))) {
66 $s .= ' ' . nl2br($second[$j]);
70 /* do not mark these headers as emailaddresses */
71 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
75 $header_output[] = array($f,$s);
78 sqimap_logout($imapConnection);
79 return $header_output;
82 function view_header($header, $mailbox, $color) {
83 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
84 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
86 displayPageHeader($color, $mailbox);
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> - '.
94 echo_template_var($ret_addr);
95 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
97 echo_template_var($header,
99 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
100 "align=center>\n".'<tr><td>',
104 '</td></tr></table>'."\n"
106 echo '</body></html>';
109 /* get global vars */
110 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET
) ) {
111 $passed_id = (int) $temp;
113 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
116 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
119 sqgetGlobalVar('key', $key, SQ_COOKIE
);
120 sqgetGlobalVar('username', $username, SQ_SESSION
);
121 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
122 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
124 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
126 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
128 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
129 view_header($header, $mailbox, $color);