6 * This is the code to view the message header.
8 * @copyright © 1999-2009 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
14 /** This is the view_header page */
15 define('PAGE_NAME', 'view_header');
18 * Include the SquirrelMail initialization file.
20 require('../include/init.php');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'functions/imap.php');
24 require_once(SM_PATH
. 'functions/url_parser.php');
26 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
28 $header_output = array();
32 if (!$passed_ent_id) {
33 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
36 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
37 $read=sqimap_run_command ($imapConnection, $query,
41 for ($i=1; $i < count($read); $i++
) {
42 $line = htmlspecialchars($read[$i]);
44 case (eregi("^>", $line)):
46 $first[$i] = ' ';
49 case (eregi("^[ |\t]", $line)):
53 case (eregi("^([^:]+):(.+)", $line, $regs)):
54 $first[$i] = $regs[1] . ':';
55 $second[$i] = $regs[2];
59 $second[$i] = trim($line);
64 for ($i=0; $i < count($second); $i = $j) {
65 $f = (isset($first[$i]) ?
$first[$i] : '');
66 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
68 while (($first[$j] == '') && ($j < count($first))) {
69 $s .= ' ' . nl2br($second[$j]);
73 /* do not mark these headers as emailaddresses */
74 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
78 $header_output[] = array($f,$s);
81 sqimap_logout($imapConnection);
82 return $header_output;
86 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
, NULL, SQ_TYPE_BIGINT
);
87 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
90 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
93 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
95 $imapConnection = sqimap_login($username, false, $imapServerAddress,
97 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
98 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
100 $aTemplateHeaders = array();
101 foreach ($header as $h) {
102 $aTemplateHeaders[] = array (
108 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
109 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
111 displayPageHeader( $color, $mailbox );
113 $oTemplate->assign('view_message_href', $ret_addr);
114 $oTemplate->assign('headers', $aTemplateHeaders);
116 $oTemplate->display('view_header.tpl');
118 $oTemplate->display('footer.tpl');