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

Documentation generated on Sat, 07 Oct 2006 16:33:18 +0300 by phpDocumentor 1.3.0RC6