Even more rg=0
[squirrelmail.git] / src / view_header.php
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 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
16
17 /* SquirrelMail required files. */
18 require_once(SM_PATH . 'include/validate.php');
19 require_once(SM_PATH . 'functions/imap.php');
20 require_once(SM_PATH . 'functions/html.php');
21 require_once(SM_PATH . 'functions/url_parser.php');
22
23 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
24 global $uid_support;
25
26 $header_full = array();
27 if (!$passed_ent_id) {
28 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
29 true, $a, $b, $uid_support);
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 }
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 if(strtolower($f) != 'message-id:')
67 {
68 parseEmail($s);
69 }
70 if (isset($f)) {
71 $header_output[] = array($f,$s);
72 }
73 }
74 sqimap_logout($imapConnection);
75 return $header_output;
76 }
77
78 function view_header($header, $mailbox, $color) {
79 global $base_uri;
80
81 $ret_addr = $base_uri . 'src/read_body.php?'.$_SERVER['QUERY_STRING'];
82
83 displayPageHeader($color, $mailbox);
84
85 echo '<BR>' .
86 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
87 ' ALIGN="CENTER">' . "\n" .
88 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
89 _("Viewing Full Header") . '</B> - '.
90 '<a href="';
91 echo_template_var($ret_addr);
92 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
93
94 echo_template_var($header,
95 array(
96 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
97 "align=center>\n".'<tr><td>',
98 '<nobr><tt><b>',
99 '</b>',
100 '</tt></nobr>',
101 '</td></tr></table>'."\n"
102 ) );
103 echo '</body></html>';
104 }
105
106 /* get global vars */
107 $passed_id = $_GET['passed_id'];
108 $username = $_SESSION['username'];
109 $key = $_COOKIE['key'];
110 $delimiter = $_SESSION['delimiter'];
111 $onetimepad = $_SESSION['onetimepad'];
112
113 if (!isset($_GET['passed_ent_id'])) {
114 $passed_ent_id = '';
115 } else {
116 $passed_ent_id = $_GET['passed_ent_id'];
117 }
118
119 $mailbox = decodeHeader($_GET['mailbox']);
120
121 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
122 $imapPort, 0);
123 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
124
125 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
126 view_header($header, $mailbox, $color);
127
128 ?>