5 * Copyright (c) 1999-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 * This is where the mailboxes are listed. This controls most of what
9 * goes on in SquirrelMail.
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
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');
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 *
40 * incoming from cookie: *
42 * incoming from session: *
45 ***********************************************************/
48 /* lets get the global vars we may need */
49 sqgetGlobalVar('key', $key, SQ_COOKIE
);
50 sqgetGlobalVar('username', $username, SQ_SESSION
);
51 sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION
);
52 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
53 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
55 sqgetGlobalVar('mailbox', $mailbox);
56 sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION
);
57 sqgetGlobalVar('numMessages' , $numMessages, SQ_SESSION
);
58 sqgetGlobalVar('session', $session, SQ_GET
);
59 sqgetGlobalVar('note', $note, SQ_GET
);
60 sqgetGlobalVar('mail_sent', $mail_sent, SQ_GET
);
61 sqgetGlobalVar('use_mailbox_cache', $use_mailbox_cache, SQ_GET
);
63 if ( sqgetGlobalVar('startMessage', $temp) ) {
64 $startMessage = (int) $temp;
66 if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) {
67 $PG_SHOWNUM = (int) $temp;
69 if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET
) ) {
70 $PG_SHOWALL = (int) $temp;
72 if ( sqgetGlobalVar('newsort', $temp, SQ_GET
) ) {
73 $newsort = (int) $temp;
75 if ( sqgetGlobalVar('checkall', $temp, SQ_GET
) ) {
76 $checkall = (int) $temp;
78 if ( sqgetGlobalVar('set_thread', $temp, SQ_GET
) ) {
79 $set_thread = (int) $temp;
81 if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET
) ) {
84 /* end of get globals */
87 /* Open a connection on the imap port (143) */
89 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
91 if (isset($PG_SHOWALL)) {
94 $show_num=$PG_SHOWNUM;
95 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
98 sqsession_unregister('PG_SHOWNUM');
102 else if( isset( $PG_SHOWNUM ) ) {
103 $show_num = $PG_SHOWNUM;
106 if (isset($newsort) ) {
107 if ( $newsort != $sort )
108 setPref($data_dir, $username, 'sort', $newsort);
111 sqsession_register($sort, 'sort');
114 /* If the page has been loaded without a specific mailbox, */
115 /* send them to the inbox */
116 if (!isset($mailbox)) {
122 if (!isset($startMessage) ||
($startMessage == '')) {
126 /* compensate for the UW vulnerability. */
127 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
128 substr($mailbox, 0, 1) == '/')) {
132 /* decide if we are thread sorting or not */
133 if ($allow_thread_sort == TRUE) {
134 if (isset($set_thread)) {
135 if ($set_thread == 1) {
136 setPref($data_dir, $username, "thread_$mailbox", 1);
137 $thread_sort_messages = '1';
139 elseif ($set_thread == 2) {
140 setPref($data_dir, $username, "thread_$mailbox", 0);
141 $thread_sort_messages = '0';
145 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
149 $thread_sort_messages = 0;
152 do_hook ('generic_header');
154 $aMbxResponse = sqimap_mailbox_select($imapConnection, $mailbox);
157 $comp_uri = SM_PATH
. 'src/compose.php?mailbox='. urlencode($mailbox).
159 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
161 displayPageHeader($color, $mailbox);
163 do_hook('right_main_after_header');
165 /* display a message to the user that their mail has been sent */
166 if (isset($mail_sent) && $mail_sent == 'yes') {
167 $note = _("Your Message has been sent.");
170 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
173 if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION
) ) {
174 if ($just_logged_in == true) {
175 $just_logged_in = false;
176 sqsession_register($just_logged_in, 'just_logged_in');
178 if (strlen(trim($motd)) > 0) {
179 echo html_tag( 'table',
184 html_tag( 'td', $motd, 'center' )
186 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
189 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
195 /*********************************************************************
196 * Check to see if we can use cache or not. Currently the only time *
197 * when you will not use it is when a link on the left hand frame is *
198 * used. Also check to make sure we actually have the array in the *
199 * registered session data. :) *
200 *********************************************************************/
201 if (! isset($use_mailbox_cache)) {
202 $use_mailbox_cache = 0;
205 if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
206 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
207 $startMessage, $sort, $color, $show_num,
208 $use_mailbox_cache, '',$aMbxResponse);
210 if (sqsession_is_registered('msgs')) {
214 if (sqsession_is_registered('msort')) {
218 if (sqsession_is_registered('numMessages')) {
222 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
224 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
225 $startMessage, $sort, $color, $show_num,
226 $use_mailbox_cache,'',$aMbxResponse);
228 if (sqsession_is_registered('msgs') && isset($msgs)) {
229 sqsession_register($msgs, 'msgs');
232 if (sqsession_is_registered('msort') && isset($msort)) {
233 sqsession_register($msort, 'msort');
236 sqsession_register($numMessages, 'numMessages');
238 do_hook('right_main_bottom');
239 sqimap_logout ($imapConnection);
241 echo '</body></html>';