Source for file right_main.php

Documentation is available at right_main.php

  1. <?php
  2.  
  3. /**
  4.  * right_main.php
  5.  *
  6.  * This is where the mailboxes are listed. This controls most of what
  7.  * goes on in SquirrelMail.
  8.  *
  9.  * @copyright 1999-2020 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: right_main.php 14840 2020-01-07 07:42:38Z pdontthink $
  12.  * @package squirrelmail
  13.  */
  14.  
  15. /** This is the right_main page */
  16. define('PAGE_NAME''right_main');
  17.  
  18. /**
  19.  * Path for SquirrelMail required files.
  20.  * @ignore
  21.  */
  22. define('SM_PATH','../');
  23.  
  24. /* SquirrelMail required files. */
  25. require_once(SM_PATH 'include/validate.php');
  26. require_once(SM_PATH 'functions/imap.php');
  27. require_once(SM_PATH 'functions/date.php');
  28. require_once(SM_PATH 'functions/mime.php');
  29. require_once(SM_PATH 'functions/mailbox_display.php');
  30. require_once(SM_PATH 'functions/display_messages.php');
  31. require_once(SM_PATH 'functions/html.php');
  32.  
  33. /***********************************************************
  34.  * incoming variables from URL:                            *
  35.  *   $sort             Direction to sort by date           *
  36.  *                        values:  0  -  descending order  *
  37.  *                        values:  1  -  ascending order   *
  38.  *   $startMessage     Message to start at                 *
  39.  *    $mailbox          Full Mailbox name                  *
  40.  *                                                         *
  41.  * incoming from cookie:                                   *
  42.  *    $key              pass                               *
  43.  * incoming from session:                                  *
  44.  *    $username         duh                                *
  45.  *                                                         *
  46.  ***********************************************************/
  47.  
  48. // Disable Browser Caching //
  49. header('Cache-Control: no-cache, no-store, must-revalidate');
  50. header('Pragma: no-cache');
  51. header('Expires: Sat, 1 Jan 2000 00:00:00 GMT');
  52.  
  53.  
  54. /* lets get the global vars we may need */
  55. sqgetGlobalVar('key',       $key,           SQ_COOKIE);
  56. sqgetGlobalVar('username',  $username,      SQ_SESSION);
  57. sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
  58. sqgetGlobalVar('delimiter'$delimiter,     SQ_SESSION);
  59. sqgetGlobalVar('base_uri',  $base_uri,      SQ_SESSION);
  60.  
  61. sqgetGlobalVar('mailbox',   $mailbox);
  62. sqgetGlobalVar('lastTargetMailbox'$lastTargetMailboxSQ_SESSION);
  63. sqgetGlobalVar('numMessages'      $numMessages,       SQ_SESSION);
  64. sqgetGlobalVar('session',           $session,           SQ_GET);
  65. sqgetGlobalVar('note',              $note,              SQ_GET);
  66. sqgetGlobalVar('use_mailbox_cache'$use_mailbox_cacheSQ_GET);
  67.  
  68. if sqgetGlobalVar('startMessage'$temp) ) {
  69.     $startMessage = (int) $temp;
  70. }
  71. if sqgetGlobalVar('PG_SHOWNUM'$temp) ) {
  72.   $PG_SHOWNUM = (int) $temp;
  73. }
  74. if sqgetGlobalVar('PG_SHOWALL'$tempSQ_GET) ) {
  75.   $PG_SHOWALL = (int) $temp;
  76. }
  77. if sqgetGlobalVar('newsort'$tempSQ_GET) ) {
  78.   $newsort = (int) $temp;
  79. }
  80. if !sqgetGlobalVar('preselected'$preselectedSQ_GET|| !is_array($preselected)) {
  81.   $preselected array();
  82. else {
  83.   $preselected array_keys($preselected);
  84. }
  85. if sqgetGlobalVar('checkall'$tempSQ_GET) ) {
  86.   $checkall = (int) $temp;
  87. }
  88. if sqgetGlobalVar('set_thread'$tempSQ_GET) ) {
  89.   $set_thread = (int) $temp;
  90. }
  91. if !sqgetGlobalVar('composenew'$composenewSQ_GET) ) {
  92.     $composenew false;
  93. }
  94. /* end of get globals */
  95.  
  96. /* Open a connection on the imap port (143) */
  97.  
  98. global $imap_stream_options// in case not defined in config
  99. $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  100.  
  101. if (isset($PG_SHOWALL)) {
  102.     if ($PG_SHOWALL{
  103.        $PG_SHOWNUM=999999;
  104.        $show_num=$PG_SHOWNUM;
  105.        sqsession_register($PG_SHOWNUM'PG_SHOWNUM');
  106.     }
  107.     else {
  108.        sqsession_unregister('PG_SHOWNUM');
  109.        unset($PG_SHOWNUM);
  110.     }
  111. }
  112. else ifisset$PG_SHOWNUM ) ) {
  113.     $show_num $PG_SHOWNUM;
  114. }
  115.  
  116. if (!isset($show_num|| empty($show_num|| ($show_num == 0)) {
  117.     setPref($data_dir$username'show_num' 15);
  118.     $show_num 15;
  119. }
  120.  
  121. if (isset($newsort&& $newsort != $sort{
  122.     setPref($data_dir$username'sort'$newsort);
  123. }
  124.  
  125.  
  126.  
  127. /* If the page has been loaded without a specific mailbox, */
  128. /* send them to the inbox                                  */
  129. if (!isset($mailbox)) {
  130.     $mailbox 'INBOX';
  131.     $startMessage 1;
  132. }
  133.  
  134.  
  135. if (!isset($startMessage|| ($startMessage == '')) {
  136.     $startMessage 1;
  137. }
  138.  
  139. /* decide if we are thread sorting or not */
  140. if (!empty($allow_thread_sort&& ($allow_thread_sort == TRUE)) {
  141.     if (isset($set_thread)) {
  142.         if ($set_thread == 1{
  143.             setPref($data_dir$username"thread_$mailbox"1);
  144.             $thread_sort_messages '1';
  145.         }
  146.         elseif ($set_thread == 2)  {
  147.             setPref($data_dir$username"thread_$mailbox"0);
  148.             $thread_sort_messages '0';
  149.         }
  150.     }
  151.     else {
  152.         $thread_sort_messages getPref($data_dir$username"thread_$mailbox");
  153.     }
  154. }
  155. else {
  156.     $thread_sort_messages 0;
  157. }
  158.  
  159. sqimap_mailbox_select($imapConnection$mailbox);
  160.  
  161. // the preg_match() is a fix for Dovecot wherein UIDs can be bigger than
  162. // normal integers - this isn't in 1.4 yet, but when adding new code, why not...
  163. if (sqgetGlobalVar('unread_passed_id'$unread_passed_idSQ_GET)
  164.  && preg_match('/^[0-9]+$/'$unread_passed_id)) {
  165.     sqimap_toggle_flag($imapConnection$unread_passed_id'\\Seen'falsetrue);
  166. }
  167.  
  168. if ($composenew{
  169.     $comp_uri SM_PATH 'src/compose.php?mailbox='urlencode($mailbox).
  170.         "&session=" .urlencode($session);
  171.     displayPageHeader($color$mailbox"comp_in_new('$comp_uri');"false);
  172. else {
  173.     displayPageHeader($color$mailbox);
  174. }
  175.  
  176. do_hook('right_main_after_header');
  177. if (isset($note)) {
  178.     echo html_tag'div''<b>' sm_encode_html_special_chars($note.'</b>''center' "<br />\n";
  179. }
  180.  
  181. if sqgetGlobalVar('just_logged_in'$just_logged_inSQ_SESSION) ) {
  182.     if ($just_logged_in == true{
  183.         $just_logged_in false;
  184.         sqsession_register($just_logged_in'just_logged_in');
  185.  
  186.         if (strlen(trim($motd)) 0{
  187.             echo html_tag'table',
  188.                         html_tag'tr',
  189.                             html_tag'td',
  190.                                 html_tag'table',
  191.                                     html_tag'tr',
  192.                                         html_tag'td'$motd'center' )
  193.                                     ,
  194.                                 ''$color[4]'width="100%" cellpadding="5" cellspacing="1" border="0"' )
  195.                              )
  196.                         ,
  197.                     'center'$color[9]'width="70%" cellpadding="0" cellspacing="3" border="0"' );
  198.         }
  199.     }
  200. }
  201.  
  202. if (isset($newsort)) {
  203.     $sort $newsort;
  204.     sqsession_register($sort'sort');
  205. }
  206.  
  207. /*********************************************************************
  208.  * Check to see if we can use cache or not. Currently the only time  *
  209.  * when you will not use it is when a link on the left hand frame is *
  210.  * used. Also check to make sure we actually have the array in the   *
  211.  * registered session data.  :)                                      *
  212.  *********************************************************************/
  213. if (isset($use_mailbox_cache)) {
  214.     $use_mailbox_cache 0;
  215. }
  216.  
  217.  
  218. if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
  219.     showMessagesForMailbox($imapConnection$mailbox$numMessages$startMessage$sort$color$show_num$use_mailbox_cache);
  220. else {
  221.     if (sqsession_is_registered('msgs')) {
  222.         unset($msgs);
  223.     }
  224.  
  225.     if (sqsession_is_registered('msort')) {
  226.         unset($msort);
  227.     }
  228.  
  229.     if (sqsession_is_registered('numMessages')) {
  230.         unset($numMessages);
  231.     }
  232.  
  233.     $numMessages sqimap_get_num_messages ($imapConnection$mailbox);
  234.  
  235.     // set 8th argument to false in order to make sure that cache is not used.
  236.     showMessagesForMailbox($imapConnection$mailbox$numMessages,
  237.                            $startMessage$sort$color$show_num,
  238.                            false);
  239.  
  240.     if (sqsession_is_registered('msgs'&& isset($msgs)) {
  241.         sqsession_register($msgs'msgs');
  242.     }
  243.  
  244.     if (sqsession_is_registered('msort'&& isset($msort)) {
  245.         sqsession_register($msort'msort');
  246.     }
  247.  
  248.     sqsession_register($numMessages'numMessages');
  249. }
  250. do_hook('right_main_bottom');
  251. sqimap_logout ($imapConnection);
  252.  
  253. echo '</body></html>';

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