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-2012 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: right_main.php 14345 2012-12-09 11:58:17Z kink $
  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. $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0);
  99.  
  100. if (isset($PG_SHOWALL)) {
  101.     if ($PG_SHOWALL{
  102.        $PG_SHOWNUM=999999;
  103.        $show_num=$PG_SHOWNUM;
  104.        sqsession_register($PG_SHOWNUM'PG_SHOWNUM');
  105.     }
  106.     else {
  107.        sqsession_unregister('PG_SHOWNUM');
  108.        unset($PG_SHOWNUM);
  109.     }
  110. }
  111. else ifisset$PG_SHOWNUM ) ) {
  112.     $show_num $PG_SHOWNUM;
  113. }
  114.  
  115. if (!isset($show_num|| empty($show_num|| ($show_num == 0)) {
  116.     setPref($data_dir$username'show_num' 15);
  117.     $show_num 15;
  118. }
  119.  
  120. if (isset($newsort&& $newsort != $sort{
  121.     setPref($data_dir$username'sort'$newsort);
  122. }
  123.  
  124.  
  125.  
  126. /* If the page has been loaded without a specific mailbox, */
  127. /* send them to the inbox                                  */
  128. if (!isset($mailbox)) {
  129.     $mailbox 'INBOX';
  130.     $startMessage 1;
  131. }
  132.  
  133.  
  134. if (!isset($startMessage|| ($startMessage == '')) {
  135.     $startMessage 1;
  136. }
  137.  
  138. /* decide if we are thread sorting or not */
  139. if (!empty($allow_thread_sort&& ($allow_thread_sort == TRUE)) {
  140.     if (isset($set_thread)) {
  141.         if ($set_thread == 1{
  142.             setPref($data_dir$username"thread_$mailbox"1);
  143.             $thread_sort_messages '1';
  144.         }
  145.         elseif ($set_thread == 2)  {
  146.             setPref($data_dir$username"thread_$mailbox"0);
  147.             $thread_sort_messages '0';
  148.         }
  149.     }
  150.     else {
  151.         $thread_sort_messages getPref($data_dir$username"thread_$mailbox");
  152.     }
  153. }
  154. else {
  155.     $thread_sort_messages 0;
  156. }
  157.  
  158. sqimap_mailbox_select($imapConnection$mailbox);
  159.  
  160. // the preg_match() is a fix for Dovecot wherein UIDs can be bigger than
  161. // normal integers - this isn't in 1.4 yet, but when adding new code, why not...
  162. if (sqgetGlobalVar('unread_passed_id'$unread_passed_idSQ_GET)
  163.  && preg_match('/^[0-9]+$/'$unread_passed_id)) {
  164.     sqimap_toggle_flag($imapConnection$unread_passed_id'\\Seen'falsetrue);
  165. }
  166.  
  167. if ($composenew{
  168.     $comp_uri SM_PATH 'src/compose.php?mailbox='urlencode($mailbox).
  169.         "&session=" .urlencode($session);
  170.     displayPageHeader($color$mailbox"comp_in_new('$comp_uri');"false);
  171. else {
  172.     displayPageHeader($color$mailbox);
  173. }
  174.  
  175. do_hook('right_main_after_header');
  176. if (isset($note)) {
  177.     echo html_tag'div''<b>' sm_encode_html_special_chars($note.'</b>''center' "<br />\n";
  178. }
  179.  
  180. if sqgetGlobalVar('just_logged_in'$just_logged_inSQ_SESSION) ) {
  181.     if ($just_logged_in == true{
  182.         $just_logged_in false;
  183.         sqsession_register($just_logged_in'just_logged_in');
  184.  
  185.         if (strlen(trim($motd)) 0{
  186.             echo html_tag'table',
  187.                         html_tag'tr',
  188.                             html_tag'td',
  189.                                 html_tag'table',
  190.                                     html_tag'tr',
  191.                                         html_tag'td'$motd'center' )
  192.                                     ,
  193.                                 ''$color[4]'width="100%" cellpadding="5" cellspacing="1" border="0"' )
  194.                              )
  195.                         ,
  196.                     'center'$color[9]'width="70%" cellpadding="0" cellspacing="3" border="0"' );
  197.         }
  198.     }
  199. }
  200.  
  201. if (isset($newsort)) {
  202.     $sort $newsort;
  203.     sqsession_register($sort'sort');
  204. }
  205.  
  206. /*********************************************************************
  207.  * Check to see if we can use cache or not. Currently the only time  *
  208.  * when you will not use it is when a link on the left hand frame is *
  209.  * used. Also check to make sure we actually have the array in the   *
  210.  * registered session data.  :)                                      *
  211.  *********************************************************************/
  212. if (isset($use_mailbox_cache)) {
  213.     $use_mailbox_cache 0;
  214. }
  215.  
  216.  
  217. if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
  218.     showMessagesForMailbox($imapConnection$mailbox$numMessages$startMessage$sort$color$show_num$use_mailbox_cache);
  219. else {
  220.     if (sqsession_is_registered('msgs')) {
  221.         unset($msgs);
  222.     }
  223.  
  224.     if (sqsession_is_registered('msort')) {
  225.         unset($msort);
  226.     }
  227.  
  228.     if (sqsession_is_registered('numMessages')) {
  229.         unset($numMessages);
  230.     }
  231.  
  232.     $numMessages sqimap_get_num_messages ($imapConnection$mailbox);
  233.  
  234.     // set 8th argument to false in order to make sure that cache is not used.
  235.     showMessagesForMailbox($imapConnection$mailbox$numMessages,
  236.                            $startMessage$sort$color$show_num,
  237.                            false);
  238.  
  239.     if (sqsession_is_registered('msgs'&& isset($msgs)) {
  240.         sqsession_register($msgs'msgs');
  241.     }
  242.  
  243.     if (sqsession_is_registered('msort'&& isset($msort)) {
  244.         sqsession_register($msort'msort');
  245.     }
  246.  
  247.     sqsession_register($numMessages'numMessages');
  248. }
  249. do_hook('right_main_bottom');
  250. sqimap_logout ($imapConnection);
  251.  
  252. echo '</body></html>';

Documentation generated on Sun, 19 May 2013 04:22:52 +0200 by phpDocumentor 1.4.3