6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This is where the mailboxes are listed. This controls most of what
10 * goes on in SquirrelMail.
15 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/date.php');
18 require_once('../functions/array.php');
19 require_once('../functions/mime.php');
20 require_once('../functions/mailbox_display.php');
21 require_once('../functions/display_messages.php');
22 require_once('../functions/html.php');
24 /***********************************************************
25 * incoming variables from URL: *
26 * $sort Direction to sort by date *
27 * values: 0 - descending order *
28 * values: 1 - ascending order *
29 * $startMessage Message to start at *
30 * $mailbox Full Mailbox name *
32 * incoming from cookie: *
35 ***********************************************************/
37 /* Open a connection on the imap port (143) */
39 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
42 if (isset($PG_SHOWALL)) {
45 $show_num=$PG_SHOWNUM;
46 session_register('PG_SHOWNUM');
49 session_unregister('PG_SHOWNUM');
53 else if( isset( $PG_SHOWNUM ) ) {
54 $show_num = $PG_SHOWNUM;
57 if (isset($newsort) && $newsort != $sort) {
58 setPref($data_dir, $username, 'sort', $newsort);
63 /* If the page has been loaded without a specific mailbox, */
64 /* send them to the inbox */
65 if (!isset($mailbox)) {
71 if (!isset($startMessage) ||
($startMessage == '')) {
75 /* compensate for the UW vulnerability. */
76 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
77 substr($mailbox, 0, 1) == '/')) {
81 /* decide if we are thread sorting or not */
82 global $allow_thread_sort;
83 if ($allow_thread_sort == TRUE) {
84 if (isset($set_thread)) {
85 if ($set_thread == 1) {
86 setPref($data_dir, $username, "thread_$mailbox", 1);
87 $thread_sort_messages = '1';
89 elseif ($set_thread == 2) {
90 setPref($data_dir, $username, "thread_$mailbox", 0);
91 $thread_sort_messages = '0';
95 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
99 $thread_sort_messages = 0;
104 do_hook ("generic_header");
106 sqimap_mailbox_select($imapConnection, $mailbox);
108 if (isset($composenew) && $composenew) {
109 $comp_uri = "../src/compose.php?mailbox=". urlencode($mailbox).
110 "&session=$composesession";
111 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
113 displayPageHeader($color, $mailbox);
115 do_hook('right_main_after_header');
117 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
120 if ($just_logged_in == true) {
121 $just_logged_in = false;
123 if (strlen(trim($motd)) > 0) {
124 echo html_tag( 'table',
129 html_tag( 'td', $motd, 'center' )
131 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
134 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
138 if (isset($newsort)) {
140 session_register('sort');
143 /*********************************************************************
144 * Check to see if we can use cache or not. Currently the only time *
145 * when you will not use it is when a link on the left hand frame is *
146 * used. Also check to make sure we actually have the array in the *
147 * registered session data. :) *
148 *********************************************************************/
149 if (! isset($use_mailbox_cache)) {
150 $use_mailbox_cache = 0;
153 /* There is a problem with registered vars in 4.1 */
155 if( substr( phpversion(), 0, 3 ) == '4.1' ) {
156 $use_mailbox_cache = FALSE;
160 if ($use_mailbox_cache && session_is_registered('msgs')) {
161 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
163 if (session_is_registered('msgs')) {
167 if (session_is_registered('msort')) {
171 if (session_is_registered('numMessages')) {
175 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
177 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
178 $startMessage, $sort, $color, $show_num,
181 if (session_is_registered('msgs') && isset($msgs)) {
182 session_register('msgs');
183 $_SESSION['msgs'] = $msgs;
186 if (session_is_registered('msort') && isset($msort)) {
187 session_register('msort');
188 $_SESSION['msort'] = $msort;
191 session_register('numMessages');
192 $_SESSION['numMessages'] = $numMessages;
194 do_hook('right_main_bottom');
195 sqimap_logout ($imapConnection);
197 echo '</body></html>';