Source for file view_text.php

Documentation is available at view_text.php

  1. <?php
  2.  
  3. /**
  4.  * view_text.php -- Displays the main frameset
  5.  *
  6.  * Who knows what this file does. Whoever PUT IT HERE DID NOT PUT
  7.  * A SINGLE FREAKING COMMENT IN! Whoever is responsible for this,
  8.  * be very ashamed.
  9.  *
  10.  * @copyright 1999-2020 The SquirrelMail Project Team
  11.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  12.  * @version $Id: view_text.php 14840 2020-01-07 07:42:38Z pdontthink $
  13.  * @package squirrelmail
  14.  */
  15.  
  16. /** This is the view_text page */
  17. define('PAGE_NAME''view_text');
  18.  
  19. /**
  20.  * Path for SquirrelMail required files.
  21.  * @ignore
  22.  */
  23. define('SM_PATH','../');
  24.  
  25. /* SquirrelMail required files. */
  26. require_once(SM_PATH 'include/validate.php');
  27. require_once(SM_PATH 'functions/global.php');
  28. require_once(SM_PATH 'functions/imap.php');
  29. require_once(SM_PATH 'functions/mime.php');
  30. require_once(SM_PATH 'functions/html.php');
  31.  
  32. sqgetGlobalVar('key',        $key,          SQ_COOKIE);
  33. sqgetGlobalVar('username',   $username,     SQ_SESSION);
  34. sqgetGlobalVar('onetimepad'$onetimepad,   SQ_SESSION);
  35. sqgetGlobalVar('delimiter',  $delimiter,    SQ_SESSION);
  36. sqgetGlobalVar('QUERY_STRING'$QUERY_STRINGSQ_SERVER);
  37. sqgetGlobalVar('messages'$messages,       SQ_SESSION);
  38. sqgetGlobalVar('passed_id'$passed_idSQ_GET);
  39.  
  40. if sqgetGlobalVar('mailbox'$tempSQ_GET) ) {
  41.   $mailbox $temp;
  42. }
  43. if !sqgetGlobalVar('ent_id'$ent_idSQ_GET) ) {
  44.   $ent_id '';
  45. }
  46. if !sqgetGlobalVar('passed_ent_id'$passed_ent_idSQ_GET) ) {
  47.   $passed_ent_id '';
  48.  
  49.  
  50.  
  51. global $imap_stream_options// in case not defined in config
  52. $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  53. $mbx_response sqimap_mailbox_select($imapConnection$mailbox);
  54.  
  55. // were we using a reference here just to save memory?
  56. // problem is that below if $passed_ent_id is given,
  57. // the message cache now points to that entity and not
  58. // the original message (corrupts the cache)
  59. //
  60. //$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
  61. //
  62. $message $messages[$mbx_response['UIDVALIDITY']][$passed_id];
  63. $message_ent $message->getEntity($ent_id);
  64. if ($passed_ent_id{
  65.     $message &$message->getEntity($passed_ent_id);
  66. }
  67. $header   $message_ent->header;
  68. $type0    $header->type0;
  69. $type1    $header->type1;
  70. $charset  $header->getParameter('charset');
  71. $encoding strtolower($header->encoding);
  72.  
  73. $msg_url   'read_body.php?' $QUERY_STRING;
  74. $msg_url   set_url_var($msg_url'ent_id'0);
  75. $dwnld_url '../src/download.php?' $QUERY_STRING '&amp;absolute_dl=true';
  76. $unsafe_url 'view_text.php?' $QUERY_STRING;
  77. $unsafe_url set_url_var($unsafe_url'view_unsafe_images'1);
  78.  
  79. $body mime_fetch_body($imapConnection$passed_id$ent_id);
  80. $body decodeBody($body$encoding);
  81.  
  82. if (isset($languages[$squirrelmail_language]['XTRA_CODE']&&
  83.     function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
  84.     if (mb_detect_encoding($body!= 'ASCII'{
  85.         $body $languages[$squirrelmail_language]['XTRA_CODE']('decode'$body);
  86.     }
  87. }
  88.  
  89. if ($type1 == 'html' || (isset($override_type1&&  $override_type1 == 'html')) {
  90.     $ishtml TRUE;
  91.     // html attachment with character set information
  92.     if (empty($charset))
  93.         $body charset_decode($charset,$body,false,true);
  94.     $body magicHTML$body$passed_id$message$mailbox);
  95. else {
  96.     $ishtml FALSE;
  97.     translateText($body$wrap_at$charset);
  98. }
  99.  
  100. displayPageHeader($color'None');
  101. ?>
  102. <br /><table width="100%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]?>">
  103. <b><center>
  104. <?php
  105. echo _("Viewing a text attachment"' - ' .
  106.     '<a href="'.$msg_url.'">' _("View message"'</a>';
  107. ?>
  108. </b></td><tr><tr><td><center>
  109. <?php
  110. if $ishtml {
  111.     echo '<a href="' $unsafe_url '" style="white-space: nowrap;">' _("View Unsafe Images"'</a>&nbsp;| ';
  112. }
  113. echo '<a href="' $dwnld_url '" style="white-space: nowrap;">' _("Download this as a file"'</a>';
  114. ?>
  115. </center><br />
  116. </center></b>
  117. </td></tr></table>
  118. <table width="98%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]?>">
  119. <tr><td bgcolor="<?php echo $color[4]?>"><tt>
  120. <?php echo $body?>
  121. </tt></td></tr></table>
  122. </body></html>

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