squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

view_header.php
Go to the documentation of this file.
1 <?php
2 
15 define('PAGE_NAME', 'view_header');
16 
21 define('SM_PATH','../');
22 
23 /* SquirrelMail required files. */
24 require_once(SM_PATH . 'include/validate.php');
25 require_once(SM_PATH . 'functions/global.php');
26 require_once(SM_PATH . 'functions/imap.php');
27 require_once(SM_PATH . 'functions/html.php');
28 require_once(SM_PATH . 'functions/url_parser.php');
29 
30 function parse_viewheader($imapConnection,$id, $passed_ent_id) {
31  global $uid_support;
32 
33  $header_full = array();
34  $header_output = array();
35  $second = array();
36  $first = array();
37 
38  if (!$passed_ent_id) {
39  $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
40  true, $a, $b, $uid_support);
41  } else {
42  $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
44  true, $a, $b, $uid_support);
45  }
46  $cnum = 0;
47 
48  for ($i=1; $i < count($read); $i++) {
49  $line = htmlspecialchars($read[$i]);
50  switch (true) {
51  case (preg_match('/^&gt;/i', $line)):
52  $second[$i] = $line;
53  $first[$i] = '&nbsp;';
54  $cnum++;
55  break;
56 // 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
57  case (preg_match('/^[ |\t]/', $line)):
58  $second[$i] = $line;
59  $first[$i] = '';
60  break;
61  case (preg_match('/^([^:]+):(.+)/', $line, $regs)):
62  $first[$i] = $regs[1] . ':';
63  $second[$i] = $regs[2];
64  $cnum++;
65  break;
66  default:
67  $second[$i] = trim($line);
68  $first[$i] = '';
69  break;
70  }
71  }
72 
73  for ($i=0; $i < count($second); $i = $j) {
74  $f = (isset($first[$i]) ? $first[$i] : '');
75  $s = (isset($second[$i]) ? nl2br($second[$i]) : '');
76  $j = $i + 1;
77  while (($first[$j] == '') && ($j < count($first))) {
78  $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br($second[$j]);
79  $j++;
80  }
81  $lowf=strtolower($f);
82  /* do not mark these headers as emailaddresses */
83  if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
84  parseEmail($s);
85  }
86  if ($f) {
87  $header_output[] = array($f,$s);
88  }
89  }
90  return $header_output;
91 }
92 
94  sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER);
95  $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr;
96 
98 
99  echo '<br />' .
100  '<table width="100%" cellpadding="2" cellspacing="0" border="0" '.
101  'align="center">' . "\n" .
102  '<tr><td bgcolor="'.$color[9].'" width="100%" align="center"><b>'.
103  _("Viewing Full Header") . '</b> - '.
104  '<a href="';
105  echo_template_var($ret_addr);
106  echo '">' ._("View message") . "</a></b></td></tr></table>\n";
107 
109  array(
110  '<table width="99%" cellpadding="2" cellspacing="0" border="0" '.
111  "align=center>\n".'<tr><td>',
112  '<nobr><tt><b>',
113  '</b>',
114  '</tt></nobr>',
115  '</td></tr></table>'."\n"
116  )
117  );
118  echo '</body></html>';
119 }
120 
121 /* get global vars */
122 if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) {
123  $passed_id = (int) $temp;
124 }
125 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
126  $mailbox = $temp;
127 }
128 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
129  $passed_ent_id = '';
130 }
131 sqgetGlobalVar('key', $key, SQ_COOKIE);
132 sqgetGlobalVar('username', $username, SQ_SESSION);
133 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
134 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
135 
137  $imapPort, 0);
139 
140 $header = parse_viewheader($imapConnection,$passed_id, $passed_ent_id);
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
$id
$id
Definition: move_messages.php:190
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
$mailbox
$mailbox
Definition: options.php:28
$username
global $username
Definition: validate.php:55
sqimap_mailbox_select
sqimap_mailbox_select($imap_stream, $mailbox)
Definition: imap_mailbox.php:238
$uid_support
$uid_support
Definition: config_default.php:643
$mbx_response
$mbx_response
Definition: view_header.php:138
view_header
view_header($header, $mailbox, $color)
Definition: view_header.php:93
sqimap_logout
sqimap_logout($imap_stream)
Definition: imap_general.php:639
$header
$header
Definition: view_header.php:140
echo_template_var
echo_template_var($var, $format_ar=array())
Definition: html.php:155
SQ_GET
const SQ_GET
Definition: global.php:16
$j
for($i=0; $i< $numboxes; $i++) $j
Definition: empty_trash.php:72
SQ_SERVER
const SQ_SERVER
Definition: global.php:20
_
_($str)
Definition: gettext.php:160
$read
$read
Definition: message_details_bottom.php:75
parseEmail
parseEmail(&$body)
Definition: url_parser.php:49
sqimap_run_command
sqimap_run_command($imap_stream, $query, $handle_errors, &$response, &$message, $unique_id=false, $filter=false, $outputstream=false, $no_return=false)
Definition: imap_general.php:58
$imapPort
$imapPort
Definition: config_default.php:210
$color
$color
Definition: load_prefs.php:28
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
SM_PATH
const SM_PATH
Definition: view_header.php:21
parse_viewheader
parse_viewheader($imapConnection, $id, $passed_ent_id)
Definition: view_header.php:30
$imapConnection
$imapConnection
Definition: view_header.php:136