Received is a better word in this instance.
[squirrelmail.git] / src / view_header.php
1 <?php
2
3 /**
4 * view_header.php
5 *
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
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 *
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /**
16 * Path for SquirrelMail required files.
17 * @ignore
18 */
19 define('SM_PATH','../');
20
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');
27
28 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
29
30 $header_full = array();
31 if (!$passed_ent_id) {
32 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
33 true, $a, $b, TRUE);
34 } else {
35 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
36 $read=sqimap_run_command ($imapConnection, $query,
37 true, $a, $b, TRUE);
38 }
39 $cnum = 0;
40 for ($i=1; $i < count($read); $i++) {
41 $line = htmlspecialchars($read[$i]);
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;
61 }
62 }
63 for ($i=0; $i < count($second); $i = $j) {
64 $f = (isset($first[$i]) ? $first[$i] : '');
65 $s = (isset($second[$i]) ? nl2br($second[$i]) : '');
66 $j = $i + 1;
67 while (($first[$j] == '') && ($j < count($first))) {
68 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
69 $j++;
70 }
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 }
76 if ($f) {
77 $header_output[] = array($f,$s);
78 }
79 }
80 sqimap_logout($imapConnection);
81 return $header_output;
82 }
83
84 function view_header($header, $mailbox, $color) {
85 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER);
86 $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr;
87
88 displayPageHeader($color, $mailbox);
89
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> - '.
95 '<a href="';
96 echo_template_var($ret_addr);
97 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
98
99 echo_template_var($header,
100 array(
101 '<table width="99%" cellpadding="2" cellspacing="0" border="0" '.
102 "align=center>\n".'<tr><td>',
103 '<nobr><tt><b>',
104 '</b>',
105 '</tt></nobr>',
106 '</td></tr></table>'."\n"
107 ) );
108 echo '</body></html>';
109 }
110
111 /* get global vars */
112 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) {
113 $passed_id = (int) $temp;
114 }
115 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
116 $mailbox = $temp;
117 }
118 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
119 $passed_ent_id = '';
120 }
121 sqgetGlobalVar('key', $key, SQ_COOKIE);
122 sqgetGlobalVar('username', $username, SQ_SESSION);
123 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
124 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
125
126 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
127 $imapPort, 0);
128 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
129
130 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
131 view_header($header, $mailbox, $color);
132
133 ?>