6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This is the code to view the message header.
14 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
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');
23 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
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);
31 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
32 $read=sqimap_run_command ($imapConnection, $query,
33 true, $a, $b, $uid_support);
36 for ($i=1; $i < count($read); $i++
) {
37 $line = htmlspecialchars($read[$i]);
39 case (eregi("^>", $line)):
41 $first[$i] = ' ';
44 case (eregi("^[ |\t]", $line)):
48 case (eregi("^([^:]+):(.+)", $line, $regs)):
49 $first[$i] = $regs[1] . ':';
50 $second[$i] = $regs[2];
54 $second[$i] = trim($line);
59 for ($i=0; $i < count($second); $i = $j) {
60 $f = (isset($first[$i]) ?
$first[$i] : '');
61 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
63 while (($first[$j] == '') && ($j < count($first))) {
64 $s .= ' ' . nl2br($second[$j]);
67 if(strtolower($f) != 'message-id:') {
71 $header_output[] = array($f,$s);
74 sqimap_logout($imapConnection);
75 return $header_output;
78 function view_header($header, $mailbox, $color) {
79 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
80 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
82 displayPageHeader($color, $mailbox);
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> - '.
90 echo_template_var($ret_addr);
91 echo '">' ._("View message") . "</a></b></td></tr></table>\n";
93 echo_template_var($header,
95 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
96 "align=center>\n".'<tr><td>',
100 '</td></tr></table>'."\n"
102 echo '</body></html>';
105 /* get global vars */
106 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET
) ) {
107 $passed_id = (int) $temp;
109 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
112 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
115 sqgetGlobalVar('key', $key, SQ_COOKIE
);
116 sqgetGlobalVar('username', $username, SQ_SESSION
);
117 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
118 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
120 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
122 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
124 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
125 view_header($header, $mailbox, $color);