support for viewing headers of message/rfc822 attachments
[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 */
13
14
5add5fcc 15function parse_viewheader($imapConnection,$id, $passed_ent_id) {
a777439a 16 global $uid_support;
17
18 $header_full = array();
5add5fcc 19 if (!$passed_ent_id) {
20 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
a777439a 21 true, $a, $b, $uid_support);
5add5fcc 22 } else {
23 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
24 $read=sqimap_run_command ($imapConnection, $query,
25 true, $a, $b, $uid_support);
26 }
a777439a 27 $cnum = 0;
28 for ($i=1; $i < count($read); $i++) {
29 $line = htmlspecialchars($read[$i]);
30 if (eregi("^&gt;", $line)) {
31 $second[$i] = $line;
32 $first[$i] = '&nbsp;';
33 $cnum++;
34 } else if (eregi("^[ |\t]", $line)) {
35 $second[$i] = $line;
36 $first[$i] = '';
37 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
38 $first[$i] = $regs[1] . ':';
39 $second[$i] = $regs[2];
40 $cnum++;
41 } else {
42 $second[$i] = trim($line);
43 $first[$i] = '';
44 }
45 }
46 for ($i=0; $i < count($second); $i = $j) {
47 if (isset($first[$i])) {
48 $f = $first[$i];
49 }
50 if (isset($second[$i])) {
51 $s = nl2br($second[$i]);
52 }
53 $j = $i + 1;
54 while (($first[$j] == '') && ($j < count($first))) {
55 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
56 $j++;
57 }
58 parseEmail($s);
59 if (isset($f)) {
36cd4eaa 60 $header_output[] = array($f,$s);
a777439a 61 }
62 }
a777439a 63 sqimap_logout($imapConnection);
98349cf6 64 return $header_output;
a777439a 65}
66
67function view_header($template_vars, $pageheader='', $pagefooter='') {
5eb5b57e 68 global $color;
a777439a 69
70 echo $pageheader;
71 echo '<BR>' .
72 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
73 ' ALIGN="CENTER">' . "\n" .
74 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
75 _("Viewing Full Header") . '</B> - '.
76 '<a href="';
77 echo_template_var($template_vars['return_address']);
78 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
79
80 echo_template_var($template_vars['full_header'],
81 array(
82 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
5eb5b57e 83 "align=center>\n".'<tr><td>',
a777439a 84 '<nobr><tt><b>',
85 '</b>',
86 '</tt></nobr>',
87 '</td></tr></table>'."\n"
88 ) );
89 echo $pagefooter;
90}
91
92?>