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