8470069f43f3eed1b6d14d03f1ab29b23de304a8
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
. 'include/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: *
38 * incoming from session: *
41 ***********************************************************/
44 /* lets get the global vars we may need */
45 $username = $_SESSION['username'];
46 $key = $_COOKIE['key'];
47 $onetimepad = $_SESSION['onetimepad'];
48 $base_uri = $_SESSION['base_uri'];
49 $delimiter = $_SESSION['delimiter'];
51 if (isset($_GET['startMessage'])) {
52 $startMessage = $_GET['startMessage'];
53 } elseif (isset($_POST['startMessage'])) {
54 $startMessage = $_POST['startMessage'];
56 if (isset($_GET['mailbox'])) {
57 $mailbox = $_GET['mailbox'];
58 } else if (isset($_POST['mailbox'])) {
59 $mailbox = $_POST['mailbox'];
61 if (isset($_GET['PG_SHOWNUM'])) {
62 $PG_SHOWNUM = $_GET['PG_SHOWNUM'];
64 elseif (isset($_SESSION['PG_SHOWNUM'])) {
65 $PG_SHOWNUM = $_SESSION['PG_SHOWNUM'];
67 if (isset($_GET['PG_SHOWALL'])) {
68 $PG_SHOWALL = $_GET['PG_SHOWALL'];
70 if (isset($_GET['newsort'])) {
71 $newsort = $_GET['newsort'];
73 if (isset($_GET['checkall'])) {
74 $checkall = $_GET['checkall'];
76 if (isset($_GET['set_thread'])) {
77 $set_thread = $_GET['set_thread'];
79 if (isset($_SESSION['lastTargetMailbox'])) {
80 $lastTargetMailbox =$_SESSION['lastTargetMailbox'];
83 /* end of get globals */
86 /* Open a connection on the imap port (143) */
88 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
90 if (isset($PG_SHOWALL)) {
93 $show_num=$PG_SHOWNUM;
94 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
97 sqsession_unregister('PG_SHOWNUM');
101 else if( isset( $PG_SHOWNUM ) ) {
102 $show_num = $PG_SHOWNUM;
105 if (isset($newsort) && $newsort != $sort) {
106 setPref($data_dir, $username, 'sort', $newsort);
111 /* If the page has been loaded without a specific mailbox, */
112 /* send them to the inbox */
113 if (!isset($mailbox)) {
119 if (!isset($startMessage) ||
($startMessage == '')) {
123 /* compensate for the UW vulnerability. */
124 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
125 substr($mailbox, 0, 1) == '/')) {
129 /* decide if we are thread sorting or not */
130 if ($allow_thread_sort == TRUE) {
131 if (isset($set_thread)) {
132 if ($set_thread == 1) {
133 setPref($data_dir, $username, "thread_$mailbox", 1);
134 $thread_sort_messages = '1';
136 elseif ($set_thread == 2) {
137 setPref($data_dir, $username, "thread_$mailbox", 0);
138 $thread_sort_messages = '0';
142 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
146 $thread_sort_messages = 0;
149 do_hook ('generic_header');
151 sqimap_mailbox_select($imapConnection, $mailbox);
153 if (isset($composenew) && $composenew) {
154 $comp_uri = '../src/compose.php?mailbox='. urlencode($mailbox).
155 "&session=$composesession";
156 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
158 displayPageHeader($color, $mailbox);
160 do_hook('right_main_after_header');
162 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
165 if (isset($_SESSION['just_logged_in'])) {
166 $just_logged_in = $_SESSION['just_logged_in'];
167 if ($just_logged_in == true) {
168 $just_logged_in = false;
170 if (strlen(trim($motd)) > 0) {
171 echo html_tag( 'table',
176 html_tag( 'td', $motd, 'center' )
178 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
181 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
186 if (isset($newsort)) {
188 sqsession_register($sort, 'sort');
191 /*********************************************************************
192 * Check to see if we can use cache or not. Currently the only time *
193 * when you will not use it is when a link on the left hand frame is *
194 * used. Also check to make sure we actually have the array in the *
195 * registered session data. :) *
196 *********************************************************************/
197 if (! isset($use_mailbox_cache)) {
198 $use_mailbox_cache = 0;
201 if ($use_mailbox_cache && session_is_registered('msgs')) {
202 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
204 if (session_is_registered('msgs')) {
208 if (session_is_registered('msort')) {
212 if (session_is_registered('numMessages')) {
216 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
218 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
219 $startMessage, $sort, $color, $show_num,
222 if (session_is_registered('msgs') && isset($msgs)) {
223 sqsession_register($msgs, 'msgs');
224 $_SESSION['msgs'] = $msgs;
227 if (session_is_registered('msort') && isset($msort)) {
228 sqsession_register($msort, 'msort');
229 $_SESSION['msort'] = $msort;
232 sqsession_register($numMessages, 'numMessages');
233 $_SESSION['numMessages'] = $numMessages;
235 do_hook('right_main_bottom');
236 sqimap_logout ($imapConnection);
238 echo '</body></html>';