XHTML fixes
[squirrelmail.git] / src / view_header.php
CommitLineData
a777439a 1<?php
2
3/**
4 * view_header.php
5 *
82d304a0 6 * Copyright (c) 1999-2004 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 *
30967a1e 11 * @version $Id$
8f6f9ba5 12 * @package squirrelmail
a777439a 13 */
86725763 14
30967a1e 15/**
16 * Path for SquirrelMail required files.
17 * @ignore
18 */
86725763 19define('SM_PATH','../');
20
21/* SquirrelMail required files. */
08185f2a 22require_once(SM_PATH . 'include/validate.php');
8650e9e1 23require_once(SM_PATH . 'functions/global.php');
86725763 24require_once(SM_PATH . 'functions/imap.php');
25require_once(SM_PATH . 'functions/html.php');
26require_once(SM_PATH . 'functions/url_parser.php');
a777439a 27
65f8ca87 28function parse_viewheader($imapConnection,$id, $passed_ent_id) {
a777439a 29
dbdfdf6c 30 $header_full = array();
31 if (!$passed_ent_id) {
32 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
6201339c 33 true, $a, $b, TRUE);
dbdfdf6c 34 } else {
35 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
36 $read=sqimap_run_command ($imapConnection, $query,
6201339c 37 true, $a, $b, TRUE);
dbdfdf6c 38 }
a777439a 39 $cnum = 0;
40 for ($i=1; $i < count($read); $i++) {
41 $line = htmlspecialchars($read[$i]);
134e4174 42 switch (true) {
43 case (eregi("^&gt;", $line)):
44 $second[$i] = $line;
45 $first[$i] = '&nbsp;';
46 $cnum++;
47 break;
48 case (eregi("^[ |\t]", $line)):
49 $second[$i] = $line;
50 $first[$i] = '';
51 break;
52 case (eregi("^([^:]+):(.+)", $line, $regs)):
53 $first[$i] = $regs[1] . ':';
54 $second[$i] = $regs[2];
55 $cnum++;
56 break;
57 default:
58 $second[$i] = trim($line);
59 $first[$i] = '';
60 break;
a777439a 61 }
62 }
63 for ($i=0; $i < count($second); $i = $j) {
65f8ca87 64 $f = (isset($first[$i]) ? $first[$i] : '');
65 $s = (isset($second[$i]) ? nl2br($second[$i]) : '');
a777439a 66 $j = $i + 1;
67 while (($first[$j] == '') && ($j < count($first))) {
68 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
69 $j++;
70 }
dbdfdf6c 71 $lowf=strtolower($f);
72 /* do not mark these headers as emailaddresses */
73 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
74 parseEmail($s);
75 }
65f8ca87 76 if ($f) {
36cd4eaa 77 $header_output[] = array($f,$s);
a777439a 78 }
79 }
a777439a 80 sqimap_logout($imapConnection);
98349cf6 81 return $header_output;
a777439a 82}
83
be61c5a6 84function view_header($header, $mailbox, $color) {
1e12d1ff 85 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER);
86 $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr;
be61c5a6 87
88 displayPageHeader($color, $mailbox);
89
3c621ba1 90 echo '<br />' .
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> - '.
a777439a 95 '<a href="';
be61c5a6 96 echo_template_var($ret_addr);
a777439a 97 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
98
be61c5a6 99 echo_template_var($header,
3c621ba1 100 array(
101 '<table width="99%" cellpadding="2" cellspacing="0" border="0" '.
102 "align=center>\n".'<tr><td>',
134e4174 103 '<nobr><tt><b>',
104 '</b>',
105 '</tt></nobr>',
106 '</td></tr></table>'."\n"
107 )
108 );
dcc1cc82 109 echo '</body></html>';
a777439a 110}
111
fe369c70 112/* get global vars */
1e12d1ff 113if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) {
114 $passed_id = (int) $temp;
be61c5a6 115}
1e12d1ff 116if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
fdc9d9b5 117 $mailbox = $temp;
1e12d1ff 118}
119if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
120 $passed_ent_id = '';
121}
122sqgetGlobalVar('key', $key, SQ_COOKIE);
123sqgetGlobalVar('username', $username, SQ_SESSION);
124sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
125sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
be61c5a6 126
127$imapConnection = sqimap_login($username, $key, $imapServerAddress,
128 $imapPort, 0);
129$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
130
131$header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
132view_header($header, $mailbox, $color);
133
3c621ba1 134?>