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