<?php
/**
* view_header.php
*
* This is the code to view the message header.
*
* @copyright 1999-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: view_header.php 14845 2020年01月07日 08:09:34Z pdontthink $
* @package squirrelmail
*/
/** This is the view_header page */
define ('PAGE_NAME', 'view_header');
/**
* Include the SquirrelMail initialization file.
*/
require('../include/init.php');
/* SquirrelMail required files. */
require_once(SM_PATH . 'functions/imap.php');
require_once(SM_PATH . 'functions/url_parser.php');
/**
* Extract message headers
*
* @param resource $imapConnection
* @param string $id Message ID
* @param string $passed_ent_id Nested/attached/embedded message ID (if any)
*
* @return array List of all message headers, where each
* element is a sub-array that contains two
* elements: header name and header value
* (in that order) where the header value is
* HTML-formatted, ready for display in browser
*
*/
$header_output = array();
$second = array();
$first = array();
if (!$passed_ent_id) {
true, $a, $b, TRUE);
} else {
$query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
true, $a, $b, TRUE);
}
$cnum = 0;
for ($i=
1; $i <
count ($read); $i++
) {
switch (true) {
$second[$i] = $line;
$first[$i] = ' ';
$cnum++;
break;
// FIXME: is the pipe character below a mistake? I think the original author might have thought it carried special meaning in the character class, which it does not... but then again, I am not currently trying to understand what this code actually does
$second[$i] = $line;
$first[$i] = '';
break;
case (preg_match ('/^([^:]+):(.+)/', $line, $regs)):
$first[$i] = $regs[1] . ':';
$second[$i] = $regs[2];
$cnum++;
break;
default:
$second[$i] =
trim ($line);
$first[$i] = '';
break;
}
}
for ($i=
0; $i <
count ($second); $i =
$j) {
$f = (isset($first[$i]) ? $first[$i] : '');
$s =
(isset
($second[$i]) ?
nl2br ($second[$i]) :
'');
$j = $i + 1;
while (($first[$j] ==
'') &&
($j <
count ($first))) {
$s .=
' ' .
nl2br ($second[$j]);
$j++;
}
/* do not mark these headers as emailaddresses */
if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
}
if ($f) {
$header_output[] = array($f,$s);
}
}
return $header_output;
}
/* get global vars */
$mailbox = $temp;
}
$passed_ent_id = '';
}
global $imap_stream_options; // in case not defined in config
$imapConnection =
sqimap_login ($username, false, $imapServerAddress,
$imapPort, 0, $imap_stream_options);
$aTemplateHeaders = array();
foreach ($header as $h) {
$aTemplateHeaders[] = array (
'Header' => $h[0],
'Value' => $h[1]
);
}
$ret_addr =
SM_PATH .
'src/read_body.php?'.
$queryStr;
$oTemplate->assign('view_message_href', $ret_addr);
$oTemplate->assign('headers', $aTemplateHeaders);
$oTemplate->display('view_header.tpl');
$oTemplate->display('footer.tpl');