6 * Copyright (c) 1999-2002 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.
13 require_once('../src/validate.php');
14 require_once('../functions/imap.php');
15 require_once('../functions/html.php');
16 require_once('../functions/url_parser.php');
18 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
21 $header_full = array();
22 if (!$passed_ent_id) {
23 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
24 true, $a, $b, $uid_support);
26 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
27 $read=sqimap_run_command ($imapConnection, $query,
28 true, $a, $b, $uid_support);
31 for ($i=1; $i < count($read); $i++
) {
32 $line = htmlspecialchars($read[$i]);
33 if (eregi("^>", $line)) {
35 $first[$i] = ' ';
37 } else if (eregi("^[ |\t]", $line)) {
40 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
41 $first[$i] = $regs[1] . ':';
42 $second[$i] = $regs[2];
45 $second[$i] = trim($line);
49 for ($i=0; $i < count($second); $i = $j) {
50 if (isset($first[$i])) {
53 if (isset($second[$i])) {
54 $s = nl2br($second[$i]);
57 while (($first[$j] == '') && ($j < count($first))) {
58 $s .= ' ' . nl2br($second[$j]);
63 $header_output[] = array($f,$s);
66 sqimap_logout($imapConnection);
67 return $header_output;
70 function view_header($header, $mailbox, $color) {
71 global $QUERY_STRING, $base_uri;
73 $ret_addr = $base_uri . 'src/read_body.php?'.$QUERY_STRING;
75 displayPageHeader($color, $mailbox);
78 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
79 ' ALIGN="CENTER">' . "\n" .
80 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
81 _("Viewing Full Header") . '</B> - '.
83 echo_template_var($ret_addr);
84 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
86 echo_template_var($header,
88 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
89 "align=center>\n".'<tr><td>',
93 '</td></tr></table>'."\n"
95 echo '</body></html>';
98 if (!isset($passed_ent_id)) {
101 $mailbox = decodeHeader($mailbox);
103 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
105 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
107 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
108 view_header($header, $mailbox, $color);