aadcc70e8f12f7eae553240e0baf6122c22de7e7
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 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'src/validate.php');
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/date.php');
22 require_once(SM_PATH
. 'functions/array.php');
23 require_once(SM_PATH
. 'functions/mime.php');
24 require_once(SM_PATH
. 'functions/mailbox_display.php');
25 require_once(SM_PATH
. 'functions/display_messages.php');
26 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 *
36 * incoming from cookie: *
39 ***********************************************************/
41 /* Open a connection on the imap port (143) */
43 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
46 if (isset($PG_SHOWALL)) {
49 $show_num=$PG_SHOWNUM;
50 session_register('PG_SHOWNUM');
53 session_unregister('PG_SHOWNUM');
57 else if( isset( $PG_SHOWNUM ) ) {
58 $show_num = $PG_SHOWNUM;
61 if (isset($newsort) && $newsort != $sort) {
62 setPref($data_dir, $username, 'sort', $newsort);
67 /* If the page has been loaded without a specific mailbox, */
68 /* send them to the inbox */
69 if (!isset($mailbox)) {
75 if (!isset($startMessage) ||
($startMessage == '')) {
79 /* compensate for the UW vulnerability. */
80 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
81 substr($mailbox, 0, 1) == '/')) {
85 /* decide if we are thread sorting or not */
86 global $allow_thread_sort;
87 if ($allow_thread_sort == TRUE) {
88 if (isset($set_thread)) {
89 if ($set_thread == 1) {
90 setPref($data_dir, $username, "thread_$mailbox", 1);
91 $thread_sort_messages = '1';
93 elseif ($set_thread == 2) {
94 setPref($data_dir, $username, "thread_$mailbox", 0);
95 $thread_sort_messages = '0';
99 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
103 $thread_sort_messages = 0;
108 do_hook ("generic_header");
110 sqimap_mailbox_select($imapConnection, $mailbox);
112 if (isset($composenew) && $composenew) {
113 $comp_uri = "../src/compose.php?mailbox=". urlencode($mailbox).
114 "&session=$composesession";
115 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
117 displayPageHeader($color, $mailbox);
119 do_hook('right_main_after_header');
121 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
124 if ($just_logged_in == true) {
125 $just_logged_in = false;
127 if (strlen(trim($motd)) > 0) {
128 echo html_tag( 'table',
133 html_tag( 'td', $motd, 'center' )
135 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
138 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
142 if (isset($newsort)) {
144 session_register('sort');
147 /*********************************************************************
148 * Check to see if we can use cache or not. Currently the only time *
149 * when you will not use it is when a link on the left hand frame is *
150 * used. Also check to make sure we actually have the array in the *
151 * registered session data. :) *
152 *********************************************************************/
153 if (! isset($use_mailbox_cache)) {
154 $use_mailbox_cache = 0;
157 /* There is a problem with registered vars in 4.1 */
159 if( substr( phpversion(), 0, 3 ) == '4.1' ) {
160 $use_mailbox_cache = FALSE;
164 if ($use_mailbox_cache && session_is_registered('msgs')) {
165 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
167 if (session_is_registered('msgs')) {
171 if (session_is_registered('msort')) {
175 if (session_is_registered('numMessages')) {
179 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
181 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
182 $startMessage, $sort, $color, $show_num,
185 if (session_is_registered('msgs') && isset($msgs)) {
186 session_register('msgs');
187 $_SESSION['msgs'] = $msgs;
190 if (session_is_registered('msort') && isset($msort)) {
191 session_register('msort');
192 $_SESSION['msort'] = $msort;
195 session_register('numMessages');
196 $_SESSION['numMessages'] = $numMessages;
198 do_hook('right_main_bottom');
199 sqimap_logout ($imapConnection);
201 echo '</body></html>';