Source for file right_main.php

Documentation is available at right_main.php

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

Documentation generated on 2020年1月13日 04:25:14 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /