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