7223cacf8a9f1cf3ae42d778247080076a9466cd
6 * Copyright (c) 1999-2003 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
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/global.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/date.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: *
38 * incoming from session: *
41 ***********************************************************/
44 /* lets get the global vars we may need */
45 sqgetGlobalVar('key', $key, SQ_COOKIE
);
46 sqgetGlobalVar('username', $username, SQ_SESSION
);
47 sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION
);
48 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
49 sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION
);
51 sqgetGlobalVar('mailbox', $mailbox);
52 sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION
);
53 sqgetGlobalVar('numMessages' , $numMessages, SQ_SESSION
);
54 sqgetGlobalVar('session', $session, SQ_GET
);
55 sqgetGlobalVar('note', $note, SQ_GET
);
56 sqgetGlobalVar('mail_sent', $mail_sent, SQ_GET
);
57 sqgetGlobalVar('use_mailbox_cache', $use_mailbox_cache, SQ_GET
);
59 if ( sqgetGlobalVar('startMessage', $temp) ) {
60 $startMessage = (int) $temp;
62 if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) {
63 $PG_SHOWNUM = (int) $temp;
65 if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET
) ) {
66 $PG_SHOWALL = (int) $temp;
68 if ( sqgetGlobalVar('newsort', $temp, SQ_GET
) ) {
69 $newsort = (int) $temp;
71 if ( sqgetGlobalVar('checkall', $temp, SQ_GET
) ) {
72 $checkall = (int) $temp;
74 if ( sqgetGlobalVar('set_thread', $temp, SQ_GET
) ) {
75 $set_thread = (int) $temp;
77 if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET
) ) {
80 /* end of get globals */
83 /* Open a connection on the imap port (143) */
85 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
87 if (isset($PG_SHOWALL)) {
90 $show_num=$PG_SHOWNUM;
91 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
94 sqsession_unregister('PG_SHOWNUM');
98 else if( isset( $PG_SHOWNUM ) ) {
99 $show_num = $PG_SHOWNUM;
102 if (isset($newsort) && $newsort != $sort) {
103 setPref($data_dir, $username, 'sort', $newsort);
108 /* If the page has been loaded without a specific mailbox, */
109 /* send them to the inbox */
110 if (!isset($mailbox)) {
116 if (!isset($startMessage) ||
($startMessage == '')) {
120 /* compensate for the UW vulnerability. */
121 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
122 substr($mailbox, 0, 1) == '/')) {
126 /* decide if we are thread sorting or not */
127 if ($allow_thread_sort == TRUE) {
128 if (isset($set_thread)) {
129 if ($set_thread == 1) {
130 setPref($data_dir, $username, "thread_$mailbox", 1);
131 $thread_sort_messages = '1';
133 elseif ($set_thread == 2) {
134 setPref($data_dir, $username, "thread_$mailbox", 0);
135 $thread_sort_messages = '0';
139 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
143 $thread_sort_messages = 0;
146 do_hook ('generic_header');
148 sqimap_mailbox_select($imapConnection, $mailbox);
151 $comp_uri = SM_PATH
. 'src/compose.php?mailbox='. urlencode($mailbox).
153 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
155 displayPageHeader($color, $mailbox);
157 do_hook('right_main_after_header');
159 /* display a message to the user that their mail has been sent */
160 if (isset($mail_sent) && $mail_sent == 'yes') {
161 $note = _("Your Message has been sent.");
164 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
167 if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION
) ) {
168 if ($just_logged_in == true) {
169 $just_logged_in = false;
170 sqsession_register($just_logged_in, 'just_logged_in');
172 if (strlen(trim($motd)) > 0) {
173 echo html_tag( 'table',
178 html_tag( 'td', $motd, 'center' )
180 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
183 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
188 if (isset($newsort)) {
190 sqsession_register($sort, 'sort');
193 /*********************************************************************
194 * Check to see if we can use cache or not. Currently the only time *
195 * when you will not use it is when a link on the left hand frame is *
196 * used. Also check to make sure we actually have the array in the *
197 * registered session data. :) *
198 *********************************************************************/
199 if (! isset($use_mailbox_cache)) {
200 $use_mailbox_cache = 0;
203 if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
204 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
206 if (sqsession_is_registered('msgs')) {
210 if (sqsession_is_registered('msort')) {
214 if (sqsession_is_registered('numMessages')) {
218 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
220 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
221 $startMessage, $sort, $color, $show_num,
224 if (sqsession_is_registered('msgs') && isset($msgs)) {
225 sqsession_register($msgs, 'msgs');
226 //$_SESSION['msgs'] = $msgs;
229 if (sqsession_is_registered('msort') && isset($msort)) {
230 sqsession_register($msort, 'msort');
231 //$_SESSION['msort'] = $msort;
234 sqsession_register($numMessages, 'numMessages');
235 //$_SESSION['numMessages'] = $numMessages;
237 do_hook('right_main_bottom');
238 sqimap_logout ($imapConnection);
240 echo '</body></html>';