Source for file view_header.php

Documentation is available at view_header.php

  1. <?php
  2. /**
  3. * view_header.php
  4. *
  5. * This is the code to view the message header.
  6. *
  7. * @copyright 1999-2020 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id: view_header.php 14845 2020年01月07日 08:09:34Z pdontthink $
  10. * @package squirrelmail
  11. */
  12. /** This is the view_header page */
  13. define ('PAGE_NAME', 'view_header');
  14. /**
  15. * Include the SquirrelMail initialization file.
  16. */
  17. require('../include/init.php');
  18. /* SquirrelMail required files. */
  19. require_once(SM_PATH . 'functions/imap.php');
  20. require_once(SM_PATH . 'functions/url_parser.php');
  21. /**
  22. * Extract message headers
  23. *
  24. * @param resource $imapConnection
  25. * @param string $id Message ID
  26. * @param string $passed_ent_id Nested/attached/embedded message ID (if any)
  27. *
  28. * @return array List of all message headers, where each
  29. * element is a sub-array that contains two
  30. * elements: header name and header value
  31. * (in that order) where the header value is
  32. * HTML-formatted, ready for display in browser
  33. *
  34. */
  35. function parse_viewheader ($imapConnection, $id, $passed_ent_id) {
  36. $header_output = array();
  37. $second = array();
  38. $first = array();
  39. if (!$passed_ent_id) {
  40. $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]",
  41. true, $a, $b, TRUE);
  42. } else {
  43. $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
  44. $read=sqimap_run_command ($imapConnection, $query,
  45. true, $a, $b, TRUE);
  46. }
  47. $cnum = 0;
  48. for ($i=1; $i < count ($read); $i++) {
  49. $line = sm_encode_html_special_chars ($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. for ($i=0; $i < count ($second); $i = $j) {
  73. $f = (isset($first[$i]) ? $first[$i] : '');
  74. $s = (isset($second[$i]) ? nl2br ($second[$i]) : '');
  75. $j = $i + 1;
  76. while (($first[$j] == '') && ($j < count ($first))) {
  77. $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' . nl2br ($second[$j]);
  78. $j++;
  79. }
  80. $lowf=strtolower ($f);
  81. /* do not mark these headers as emailaddresses */
  82. if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') {
  83. parseEmail ($s);
  84. }
  85. if ($f) {
  86. $header_output[] = array($f,$s);
  87. }
  88. }
  89. sqimap_logout ($imapConnection);
  90. return $header_output;
  91. }
  92. /* get global vars */
  93. sqgetGlobalVar ('passed_id', $passed_id, SQ_GET , NULL, SQ_TYPE_BIGINT );
  94. if ( sqgetGlobalVar ('mailbox', $temp, SQ_GET ) ) {
  95. $mailbox = $temp;
  96. }
  97. if ( !sqgetGlobalVar ('passed_ent_id', $passed_ent_id, SQ_GET ) ) {
  98. $passed_ent_id = '';
  99. }
  100. sqgetGlobalVar ('delimiter', $delimiter, SQ_SESSION );
  101. global $imap_stream_options; // in case not defined in config
  102. $imapConnection = sqimap_login ($username, false, $imapServerAddress,
  103. $imapPort, 0, $imap_stream_options);
  104. $mbx_response = sqimap_mailbox_select ($imapConnection, $mailbox, false, false, true);
  105. $header = parse_viewheader ($imapConnection,$passed_id, $passed_ent_id);
  106. $aTemplateHeaders = array();
  107. foreach ($header as $h) {
  108. $aTemplateHeaders[] = array (
  109. 'Header' => $h[0],
  110. 'Value' => $h[1]
  111. );
  112. }
  113. sqgetGlobalVar ('QUERY_STRING', $queryStr, SQ_SERVER );
  114. $ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr;
  115. displayPageHeader ( $color, $mailbox );
  116. $oTemplate->assign('view_message_href', $ret_addr);
  117. $oTemplate->assign('headers', $aTemplateHeaders);
  118. $oTemplate->display('view_header.tpl');
  119. $oTemplate->display('footer.tpl');

Documentation generated on 2020年1月13日 04:23:45 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /