Fixed some string issues.
[squirrelmail.git] / src / view_header.php
CommitLineData
a777439a 1<?php
2
3/**
4 * view_header.php
5 *
6 * Copyright (c) 1999-2002 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 * $Id$
12 */
86725763 13
14/* Path for SquirrelMail required files. */
15define('SM_PATH','../');
16
17/* SquirrelMail required files. */
08185f2a 18require_once(SM_PATH . 'include/validate.php');
86725763 19require_once(SM_PATH . 'functions/imap.php');
20require_once(SM_PATH . 'functions/html.php');
21require_once(SM_PATH . 'functions/url_parser.php');
a777439a 22
5add5fcc 23function parse_viewheader($imapConnection,$id, $passed_ent_id) {
a777439a 24 global $uid_support;
25
26 $header_full = array();
5add5fcc 27 if (!$passed_ent_id) {
28 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
a777439a 29 true, $a, $b, $uid_support);
5add5fcc 30 } else {
31 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
32 $read=sqimap_run_command ($imapConnection, $query,
33 true, $a, $b, $uid_support);
34 }
a777439a 35 $cnum = 0;
36 for ($i=1; $i < count($read); $i++) {
37 $line = htmlspecialchars($read[$i]);
38 if (eregi("^&gt;", $line)) {
39 $second[$i] = $line;
40 $first[$i] = '&nbsp;';
41 $cnum++;
42 } else if (eregi("^[ |\t]", $line)) {
43 $second[$i] = $line;
44 $first[$i] = '';
45 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
46 $first[$i] = $regs[1] . ':';
47 $second[$i] = $regs[2];
48 $cnum++;
49 } else {
50 $second[$i] = trim($line);
51 $first[$i] = '';
52 }
53 }
54 for ($i=0; $i < count($second); $i = $j) {
55 if (isset($first[$i])) {
56 $f = $first[$i];
57 }
58 if (isset($second[$i])) {
59 $s = nl2br($second[$i]);
60 }
61 $j = $i + 1;
62 while (($first[$j] == '') && ($j < count($first))) {
63 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
64 $j++;
65 }
66 parseEmail($s);
67 if (isset($f)) {
36cd4eaa 68 $header_output[] = array($f,$s);
a777439a 69 }
70 }
a777439a 71 sqimap_logout($imapConnection);
98349cf6 72 return $header_output;
a777439a 73}
74
be61c5a6 75function view_header($header, $mailbox, $color) {
76 global $QUERY_STRING, $base_uri;
77
78 $ret_addr = $base_uri . 'src/read_body.php?'.$QUERY_STRING;
79
80 displayPageHeader($color, $mailbox);
81
a777439a 82 echo '<BR>' .
83 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
84 ' ALIGN="CENTER">' . "\n" .
85 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
86 _("Viewing Full Header") . '</B> - '.
87 '<a href="';
be61c5a6 88 echo_template_var($ret_addr);
a777439a 89 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
90
be61c5a6 91 echo_template_var($header,
a777439a 92 array(
93 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
5eb5b57e 94 "align=center>\n".'<tr><td>',
a777439a 95 '<nobr><tt><b>',
96 '</b>',
97 '</tt></nobr>',
98 '</td></tr></table>'."\n"
99 ) );
be61c5a6 100 echo '</body></html>';
a777439a 101}
102
be61c5a6 103if (!isset($passed_ent_id)) {
104 $passed_ent_id = '';
105}
106$mailbox = decodeHeader($mailbox);
107
108$imapConnection = sqimap_login($username, $key, $imapServerAddress,
109 $imapPort, 0);
110$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
111
112$header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
113view_header($header, $mailbox, $color);
114
a777439a 115?>