Fixed some mistakes.
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
895905c0 2
c57b0888 3/**
4 * right_main.php
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
c57b0888 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This is where the mailboxes are listed. This controls most of what
10 * goes on in SquirrelMail.
11 *
12 * $Id$
13 */
14
86725763 15/* Path for SquirrelMail required files. */
16define('SM_PATH','../');
17
18/* SquirrelMail required files. */
08185f2a 19require_once(SM_PATH . 'include/validate.php');
8650e9e1 20require_once(SM_PATH . 'functions/global.php');
86725763 21require_once(SM_PATH . 'functions/imap.php');
22require_once(SM_PATH . 'functions/date.php');
86725763 23require_once(SM_PATH . 'functions/mime.php');
24require_once(SM_PATH . 'functions/mailbox_display.php');
25require_once(SM_PATH . 'functions/display_messages.php');
26require_once(SM_PATH . 'functions/html.php');
c57b0888 27
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 *
35 * *
36 * incoming from cookie: *
c57b0888 37 * $key pass *
a32985a5 38 * incoming from session: *
39 * $username duh *
40 * *
c57b0888 41 ***********************************************************/
42
a32985a5 43
44/* lets get the global vars we may need */
1e12d1ff 45sqgetGlobalVar('key', $key, SQ_COOKIE);
46sqgetGlobalVar('username', $username, SQ_SESSION);
47sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
48sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
49sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
50
51sqgetGlobalVar('mailbox', $mailbox);
52sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION);
d7048dd4 53sqgetGlobalVar('numMessages' , $numMessages, SQ_SESSION);
1e12d1ff 54sqgetGlobalVar('session', $session, SQ_GET);
55sqgetGlobalVar('note', $note, SQ_GET);
d7048dd4 56sqgetGlobalVar('use_mailbox_cache', $use_mailbox_cache, SQ_GET);
1e12d1ff 57
58if ( sqgetGlobalVar('startMessage', $temp) ) {
59 $startMessage = (int) $temp;
a32985a5 60}
1e12d1ff 61if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) {
62 $PG_SHOWNUM = (int) $temp;
a32985a5 63}
1e12d1ff 64if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET) ) {
65 $PG_SHOWALL = (int) $temp;
a32985a5 66}
1e12d1ff 67if ( sqgetGlobalVar('newsort', $temp, SQ_GET) ) {
68 $newsort = (int) $temp;
a32985a5 69}
1e12d1ff 70if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) {
71 $checkall = (int) $temp;
a32985a5 72}
1e12d1ff 73if ( sqgetGlobalVar('set_thread', $temp, SQ_GET) ) {
74 $set_thread = (int) $temp;
a32985a5 75}
1e12d1ff 76if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET) ) {
8cc72ada 77 $composenew = false;
78}
a32985a5 79/* end of get globals */
80
81
c57b0888 82/* Open a connection on the imap port (143) */
6f223ace 83
c57b0888 84$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
85
cf710efe 86if (isset($PG_SHOWALL)) {
87 if ($PG_SHOWALL) {
88 $PG_SHOWNUM=999999;
89 $show_num=$PG_SHOWNUM;
a32985a5 90 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
cf710efe 91 }
92 else {
a32985a5 93 sqsession_unregister('PG_SHOWNUM');
cf710efe 94 unset($PG_SHOWNUM);
95 }
96}
97else if( isset( $PG_SHOWNUM ) ) {
bdfb67f8 98 $show_num = $PG_SHOWNUM;
99}
100
c57b0888 101if (isset($newsort) && $newsort != $sort) {
102 setPref($data_dir, $username, 'sort', $newsort);
103}
104
e372ee8c 105
106
107/* If the page has been loaded without a specific mailbox, */
108/* send them to the inbox */
109if (!isset($mailbox)) {
110 $mailbox = 'INBOX';
111 $startMessage = 1;
112}
113
114
115if (!isset($startMessage) || ($startMessage == '')) {
116 $startMessage = 1;
117}
118
119/* compensate for the UW vulnerability. */
120if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
121 substr($mailbox, 0, 1) == '/')) {
122 $mailbox = 'INBOX';
123}
124
7c612fdd 125/* decide if we are thread sorting or not */
794d59c0 126if ($allow_thread_sort == TRUE) {
7c612fdd 127 if (isset($set_thread)) {
128 if ($set_thread == 1) {
78cc4b12 129 setPref($data_dir, $username, "thread_$mailbox", 1);
7c612fdd 130 $thread_sort_messages = '1';
131 }
132 elseif ($set_thread == 2) {
78cc4b12 133 setPref($data_dir, $username, "thread_$mailbox", 0);
7c612fdd 134 $thread_sort_messages = '0';
135 }
136 }
137 else {
78cc4b12 138 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
7c612fdd 139 }
140}
141else {
142 $thread_sort_messages = 0;
143}
144
a32985a5 145do_hook ('generic_header');
7c612fdd 146
c57b0888 147sqimap_mailbox_select($imapConnection, $mailbox);
6f223ace 148
8cc72ada 149if ($composenew) {
150 $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox).
0cb19b37 151 "&session=$session";
11af81b9 152 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
6f223ace 153} else {
154 displayPageHeader($color, $mailbox);
155}
c57b0888 156do_hook('right_main_after_header');
c57b0888 157if (isset($note)) {
fab3baa6 158 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
c57b0888 159}
160
f38b7cf0 161if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION) ) {
a32985a5 162 if ($just_logged_in == true) {
163 $just_logged_in = false;
164
165 if (strlen(trim($motd)) > 0) {
166 echo html_tag( 'table',
167 html_tag( 'tr',
168 html_tag( 'td',
169 html_tag( 'table',
170 html_tag( 'tr',
171 html_tag( 'td', $motd, 'center' )
172 ) ,
173 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
174 )
175 ) ,
176 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
177 }
23d6bd09 178 }
c57b0888 179}
180
7c612fdd 181if (isset($newsort)) {
182 $sort = $newsort;
a32985a5 183 sqsession_register($sort, 'sort');
7c612fdd 184}
185
c57b0888 186/*********************************************************************
187 * Check to see if we can use cache or not. Currently the only time *
188 * when you will not use it is when a link on the left hand frame is *
189 * used. Also check to make sure we actually have the array in the *
190 * registered session data. :) *
191 *********************************************************************/
192if (! isset($use_mailbox_cache)) {
193 $use_mailbox_cache = 0;
194}
195
d7c82551 196if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
c57b0888 197 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
198} else {
d7c82551 199 if (sqsession_is_registered('msgs')) {
c57b0888 200 unset($msgs);
23d6bd09 201 }
202
d7c82551 203 if (sqsession_is_registered('msort')) {
c57b0888 204 unset($msort);
23d6bd09 205 }
a37f3771 206
d7c82551 207 if (sqsession_is_registered('numMessages')) {
c57b0888 208 unset($numMessages);
2016e645 209 }
e452ce9b 210
c57b0888 211 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 212
c57b0888 213 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
214 $startMessage, $sort, $color, $show_num,
215 $use_mailbox_cache);
23d6bd09 216
d7c82551 217 if (sqsession_is_registered('msgs') && isset($msgs)) {
a32985a5 218 sqsession_register($msgs, 'msgs');
d7048dd4 219 //$_SESSION['msgs'] = $msgs;
c57b0888 220 }
1108e8bb 221
d7c82551 222 if (sqsession_is_registered('msort') && isset($msort)) {
a32985a5 223 sqsession_register($msort, 'msort');
d7048dd4 224 //$_SESSION['msort'] = $msort;
c57b0888 225 }
9f2215a1 226
a32985a5 227 sqsession_register($numMessages, 'numMessages');
d7048dd4 228 //$_SESSION['numMessages'] = $numMessages;
c57b0888 229}
c57b0888 230do_hook('right_main_bottom');
231sqimap_logout ($imapConnection);
23d6bd09 232
fab3baa6 233echo '</body></html>';
21c3249f 234
978d53dc 235?>