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