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