6 * This is the code to view the message header.
8 * @copyright © 1999-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 * Include the SquirrelMail initialization file.
17 require('../include/init.php');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/url_parser.php');
23 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
25 $header_output = array();
29 if (!$passed_ent_id) {
30 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
33 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
34 $read=sqimap_run_command ($imapConnection, $query,
38 for ($i=1; $i < count($read); $i++
) {
39 $line = htmlspecialchars($read[$i]);
41 case (eregi("^>", $line)):
43 $first[$i] = ' ';
46 case (eregi("^[ |\t]", $line)):
50 case (eregi("^([^:]+):(.+)", $line, $regs)):
51 $first[$i] = $regs[1] . ':';
52 $second[$i] = $regs[2];
56 $second[$i] = trim($line);
61 for ($i=0; $i < count($second); $i = $j) {
62 $f = (isset($first[$i]) ?
$first[$i] : '');
63 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
65 while (($first[$j] == '') && ($j < count($first))) {
66 $s .= ' ' . nl2br($second[$j]);
70 /* do not mark these headers as emailaddresses */
71 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
75 $header_output[] = array($f,$s);
78 sqimap_logout($imapConnection);
79 return $header_output;
83 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET
) ) {
84 $passed_id = (int) $temp;
86 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
89 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
92 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
94 $imapConnection = sqimap_login($username, false, $imapServerAddress,
96 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
97 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
99 $aTemplateHeaders = array();
100 foreach ($header as $h) {
101 $aTemplateHeaders[] = array (
107 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
108 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
110 displayPageHeader( $color, $mailbox );
112 $oTemplate->assign('view_message_href', $ret_addr);
113 $oTemplate->assign('headers', $aTemplateHeaders);
115 $oTemplate->display('view_header.tpl');
117 $oTemplate->display('footer.tpl');