Put names to checkboxes that can be used by others
[squirrelmail.git] / src / view_header.php
1 <?php
2
3 /**
4 * view_header.php
5 *
6 * This is the code to view the message header.
7 *
8 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @version $Id$
11 * @package squirrelmail
12 */
13
14 /** This is the view_header page */
15 define('PAGE_NAME', 'view_header');
16
17 /**
18 * Include the SquirrelMail initialization file.
19 */
20 require('../include/init.php');
21
22 /* SquirrelMail required files. */
23 require_once(SM_PATH . 'functions/imap.php');
24 require_once(SM_PATH . 'functions/url_parser.php');
25
26 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
27
28 $header_output = array();
29 $second = array();
30 $first = array();
31
32 if (!$passed_ent_id) {
33 $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
34 true, $a, $b, TRUE);
35 } else {
36 $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
37 $read=sqimap_run_command ($imapConnection, $query,
38 true, $a, $b, TRUE);
39 }
40 $cnum = 0;
41 for ($i=1; $i < count($read); $i++) {
42 $line = htmlspecialchars($read[$i]);
43 switch (true) {
44 case (eregi("^&gt;", $line)):
45 $second[$i] = $line;
46 $first[$i] = '&nbsp;';
47 $cnum++;
48 break;
49 case (eregi("^[ |\t]", $line)):
50 $second[$i] = $line;
51 $first[$i] = '';
52 break;
53 case (eregi("^([^:]+):(.+)", $line, $regs)):
54 $first[$i] = $regs[1] . ':';
55 $second[$i] = $regs[2];
56 $cnum++;
57 break;
58 default:
59 $second[$i] = trim($line);
60 $first[$i] = '';
61 break;
62 }
63 }
64 for ($i=0; $i < count($second); $i = $j) {
65 $f = (isset($first[$i]) ? $first[$i] : '');
66 $s = (isset($second[$i]) ? nl2br($second[$i]) : '');
67 $j = $i + 1;
68 while (($first[$j] == '') && ($j < count($first))) {
69 $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
70 $j++;
71 }
72 $lowf=strtolower($f);
73 /* do not mark these headers as emailaddresses */
74 if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
75 parseEmail($s);
76 }
77 if ($f) {
78 $header_output[] = array($f,$s);
79 }
80 }
81 sqimap_logout($imapConnection);
82 return $header_output;
83 }
84
85 /* get global vars */
86 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) {
87 $passed_id = (int) $temp;
88 }
89 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
90 $mailbox = $temp;
91 }
92 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
93 $passed_ent_id = '';
94 }
95 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
96
97 $imapConnection = sqimap_login($username, false, $imapServerAddress,
98 $imapPort, 0);
99 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
100 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
101
102 $aTemplateHeaders = array();
103 foreach ($header as $h) {
104 $aTemplateHeaders[] = array (
105 'Header' => $h[0],
106 'Value' => $h[1]
107 );
108 }
109
110 sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER);
111 $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr;
112
113 displayPageHeader( $color, $mailbox );
114
115 $oTemplate->assign('view_message_href', $ret_addr);
116 $oTemplate->assign('headers', $aTemplateHeaders);
117
118 $oTemplate->display('view_header.tpl');
119
120 $oTemplate->display('footer.tpl');