Source for file view_header.php

Documentation is available at 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 1999-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: view_header.php 14840 2020-01-07 07:42:38Z pdontthink $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /** This is the view_header page */
  15. define('PAGE_NAME''view_header');
  16.  
  17. /**
  18.  * Path for SquirrelMail required files.
  19.  * @ignore
  20.  */
  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. /**
  31.   * Extract message headers
  32.   *
  33.   * @param resource $imapConnection 
  34.   * @param string $id Message ID
  35.   * @param string $passed_ent_id Nested/attached/embedded message ID (if any)
  36.   *
  37.   * @return array List of all message headers, where each
  38.   *                element is a sub-array that contains two
  39.   *                elements: header name and header value
  40.   *                (in that order) where the header value is
  41.   *                HTML-formatted, ready for display in browser
  42.   *
  43.   */
  44. function parse_viewheader($imapConnection$id$passed_ent_id{
  45.     global $uid_support;
  46.  
  47.     $header_full array();
  48.     $header_output array();
  49.     $second array();
  50.     $first array();
  51.  
  52.     if (!$passed_ent_id{
  53.         $read=sqimap_run_command ($imapConnection"FETCH $id BODY[HEADER]"
  54.                               true$a$b$uid_support);
  55.     else {
  56.         $query "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
  57.         $read=sqimap_run_command ($imapConnection$query
  58.                               true$a$b$uid_support);
  59.     }    
  60.     $cnum 0;
  61.  
  62.     for ($i=1$i count($read)$i++{
  63.         $line sm_encode_html_special_chars($read[$i]);
  64.         switch (true{
  65.             case (preg_match('/^&gt;/i'$line)):
  66.                 $second[$i$line;
  67.                 $first[$i'&nbsp;';
  68.                 $cnum++;
  69.                 break;
  70. // 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
  71.             case (preg_match('/^[ |\t]/'$line)):
  72.                 $second[$i$line;
  73.                 $first[$i'';
  74.                 break;
  75.             case (preg_match('/^([^:]+):(.+)/'$line$regs)):
  76.                 $first[$i$regs[1':';
  77.                 $second[$i$regs[2];
  78.                 $cnum++;
  79.                 break;
  80.             default:
  81.                 $second[$itrim($line);
  82.                 $first[$i'';
  83.                 break;
  84.         }
  85.     }
  86.  
  87.     for ($i=0$i count($second)$i $j{
  88.         $f (isset($first[$i]$first[$i'');
  89.         $s (isset($second[$i]nl2br($second[$i]'')
  90.         $j $i 1;
  91.         while (($first[$j== ''&& ($j count($first))) {
  92.             $s .= '&nbsp;&nbsp;&nbsp;&nbsp;' nl2br($second[$j]);
  93.             $j++;
  94.         }
  95.         $lowf=strtolower($f);
  96.         /* do not mark these headers as emailaddresses */
  97.         if($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:'{
  98.             parseEmail($s);
  99.         }
  100.         if ($f{
  101.             $header_output[array($f,$s);
  102.         }
  103.     }
  104.     return $header_output;
  105. }
  106.  
  107. function view_header($header$mailbox$color{
  108.     sqgetGlobalVar('QUERY_STRING'$queryStrSQ_SERVER);
  109.     $ret_addr SM_PATH 'src/read_body.php?'.$queryStr;
  110.  
  111.     displayPageHeader($color$mailbox);
  112.  
  113.     echo '<br />' .
  114.          '<table width="100%" cellpadding="2" cellspacing="0" border="0" '.
  115.             'align="center">' "\n" .
  116.          '<tr><td bgcolor="'.$color[9].'" width="100%" align="center"><b>'.
  117.          _("Viewing Full Header"'</b> - '.
  118.          '<a href="'
  119.     echo_template_var($ret_addr);
  120.     echo '">' ._("View message""</a></b></td></tr></table>\n";
  121.  
  122.     echo_template_var($header
  123.         array(
  124.             '<table width="99%" cellpadding="2" cellspacing="0" border="0" '.
  125.                 "align=center>\n".'<tr><td>',
  126.             '<nobr><tt><b>',
  127.             '</b>',
  128.             '</tt></nobr>',
  129.             '</td></tr></table>'."\n" 
  130.          )
  131.     );
  132.     do_hook('view_header_bottom');
  133.     echo '</body></html>';
  134. }
  135.  
  136. /* get global vars */
  137. if sqgetGlobalVar('passed_id'$tempSQ_GET) ) {
  138.   $passed_id = (int) $temp;
  139. }
  140. if sqgetGlobalVar('mailbox'$tempSQ_GET) ) {
  141.   $mailbox $temp;
  142. }
  143. if !sqgetGlobalVar('passed_ent_id'$passed_ent_idSQ_GET) ) {
  144.   $passed_ent_id '';
  145. sqgetGlobalVar('key',        $key,          SQ_COOKIE);
  146. sqgetGlobalVar('username',   $username,     SQ_SESSION);
  147. sqgetGlobalVar('onetimepad'$onetimepad,   SQ_SESSION);
  148. sqgetGlobalVar('delimiter',  $delimiter,    SQ_SESSION);
  149.  
  150. global $imap_stream_options// in case not defined in config
  151. $imapConnection sqimap_login($username$key$imapServerAddress,
  152.                                $imapPort0$imap_stream_options);
  153. $mbx_response sqimap_mailbox_select($imapConnection$mailboxfalsefalsetrue);
  154.  
  155. $header parse_viewheader($imapConnection,$passed_id$passed_ent_id)
  156. view_header($header$mailbox$color);
  157. sqimap_logout($imapConnection);

Documentation generated on Mon, 13 Jan 2020 04:25:25 +0100 by phpDocumentor 1.4.3