6 * This is the code to view the message header.
8 * @copyright © 1999-2005 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 * Path for SquirrelMail required files.
18 define('SM_PATH','../');
20 /* SquirrelMail required files. */
21 require_once(SM_PATH
. 'include/validate.php');
22 require_once(SM_PATH
. 'functions/global.php');
23 require_once(SM_PATH
. 'functions/imap.php');
24 require_once(SM_PATH
. 'functions/html.php');
25 require_once(SM_PATH
. 'functions/url_parser.php');
27 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
29 $header_output = array();
33 if (!$passed_ent_id) {
34 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
37 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
38 $read=sqimap_run_command ($imapConnection, $query,
42 for ($i=1; $i < count($read); $i++
) {
43 $line = htmlspecialchars($read[$i]);
45 case (eregi("^>", $line)):
47 $first[$i] = ' ';
50 case (eregi("^[ |\t]", $line)):
54 case (eregi("^([^:]+):(.+)", $line, $regs)):
55 $first[$i] = $regs[1] . ':';
56 $second[$i] = $regs[2];
60 $second[$i] = trim($line);
65 for ($i=0; $i < count($second); $i = $j) {
66 $f = (isset($first[$i]) ?
$first[$i] : '');
67 $s = (isset($second[$i]) ?
nl2br($second[$i]) : '');
69 while (($first[$j] == '') && ($j < count($first))) {
70 $s .= ' ' . nl2br($second[$j]);
74 /* do not mark these headers as emailaddresses */
75 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
79 $header_output[] = array($f,$s);
82 sqimap_logout($imapConnection);
83 return $header_output;
86 function view_header($header, $mailbox, $color) {
87 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER
);
88 $ret_addr = SM_PATH
. 'src/read_body.php?'.$queryStr;
90 displayPageHeader($color, $mailbox);
93 '<table width="100%" cellpadding="2" cellspacing="0" border="0" '.
94 'align="center">' . "\n" .
95 '<tr><td bgcolor="'.$color[9].'" width="100%" align="center"><b>'.
96 _("Viewing Full Header") . '</b> - '.
98 echo_template_var($ret_addr);
99 echo '">' ._("View message") . "</a></td></tr></table>\n";
101 echo_template_var($header,
103 '<table width="99%" cellpadding="2" cellspacing="0" border="0" '.
104 "align=center>\n".'<tr><td>',
105 '<tt style="white-space: nowrap;"><b>',
108 '</td></tr></table>'."\n"
111 echo '</body></html>';
114 /* get global vars */
115 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET
) ) {
116 $passed_id = (int) $temp;
118 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
121 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
124 sqgetGlobalVar('key', $key, SQ_COOKIE
);
125 sqgetGlobalVar('username', $username, SQ_SESSION
);
126 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
127 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
129 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
131 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
133 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
134 view_header($header, $mailbox, $color);