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('use_mailbox_cache', $use_mailbox_cache, SQ_GET
);
58 if ( sqgetGlobalVar('startMessage', $temp) ) {
59 $startMessage = (int) $temp;
61 if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) {
62 $PG_SHOWNUM = (int) $temp;
64 if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET
) ) {
65 $PG_SHOWALL = (int) $temp;
67 if ( sqgetGlobalVar('newsort', $temp, SQ_GET
) ) {
68 $newsort = (int) $temp;
70 if ( sqgetGlobalVar('checkall', $temp, SQ_GET
) ) {
71 $checkall = (int) $temp;
73 if ( sqgetGlobalVar('set_thread', $temp, SQ_GET
) ) {
74 $set_thread = (int) $temp;
76 if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET
) ) {
79 /* end of get globals */
82 /* Open a connection on the imap port (143) */
84 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
86 if (isset($PG_SHOWALL)) {
89 $show_num=$PG_SHOWNUM;
90 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
93 sqsession_unregister('PG_SHOWNUM');
97 else if( isset( $PG_SHOWNUM ) ) {
98 $show_num = $PG_SHOWNUM;
101 if (isset($newsort) && $newsort != $sort) {
102 setPref($data_dir, $username, 'sort', $newsort);
107 /* If the page has been loaded without a specific mailbox, */
108 /* send them to the inbox */
109 if (!isset($mailbox)) {
115 if (!isset($startMessage) ||
($startMessage == '')) {
119 /* compensate for the UW vulnerability. */
120 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
121 substr($mailbox, 0, 1) == '/')) {
125 /* decide if we are thread sorting or not */
126 if ($allow_thread_sort == TRUE) {
127 if (isset($set_thread)) {
128 if ($set_thread == 1) {
129 setPref($data_dir, $username, "thread_$mailbox", 1);
130 $thread_sort_messages = '1';
132 elseif ($set_thread == 2) {
133 setPref($data_dir, $username, "thread_$mailbox", 0);
134 $thread_sort_messages = '0';
138 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
142 $thread_sort_messages = 0;
145 do_hook ('generic_header');
147 sqimap_mailbox_select($imapConnection, $mailbox);
150 $comp_uri = SM_PATH
. 'src/compose.php?mailbox='. urlencode($mailbox).
152 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
154 displayPageHeader($color, $mailbox);
156 do_hook('right_main_after_header');
158 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
161 if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION
) ) {
162 if ($just_logged_in == true) {
163 $just_logged_in = false;
164 sqsession_register($just_logged_in, 'just_logged_in');
166 if (strlen(trim($motd)) > 0) {
167 echo html_tag( 'table',
172 html_tag( 'td', $motd, 'center' )
174 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
177 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
182 if (isset($newsort)) {
184 sqsession_register($sort, 'sort');
187 /*********************************************************************
188 * Check to see if we can use cache or not. Currently the only time *
189 * when you will not use it is when a link on the left hand frame is *
190 * used. Also check to make sure we actually have the array in the *
191 * registered session data. :) *
192 *********************************************************************/
193 if (! isset($use_mailbox_cache)) {
194 $use_mailbox_cache = 0;
197 if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
198 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
200 if (sqsession_is_registered('msgs')) {
204 if (sqsession_is_registered('msort')) {
208 if (sqsession_is_registered('numMessages')) {
212 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
214 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
215 $startMessage, $sort, $color, $show_num,
218 if (sqsession_is_registered('msgs') && isset($msgs)) {
219 sqsession_register($msgs, 'msgs');
220 //$_SESSION['msgs'] = $msgs;
223 if (sqsession_is_registered('msort') && isset($msort)) {
224 sqsession_register($msort, 'msort');
225 //$_SESSION['msort'] = $msort;
228 sqsession_register($numMessages, 'numMessages');
229 //$_SESSION['numMessages'] = $numMessages;
231 do_hook('right_main_bottom');
232 sqimap_logout ($imapConnection);
234 echo '</body></html>';