59177427 |
1 | <?php |
895905c0 |
2 | |
c57b0888 |
3 | /** |
4 | * right_main.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 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. */ |
16 | define('SM_PATH','../'); |
17 | |
18 | /* SquirrelMail required files. */ |
08185f2a |
19 | require_once(SM_PATH . 'include/validate.php'); |
86725763 |
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'); |
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 */ |
45 | $username = $_SESSION['username']; |
46 | $key = $_COOKIE['key']; |
47 | $onetimepad = $_SESSION['onetimepad']; |
48 | $base_uri = $_SESSION['base_uri']; |
49 | $delimiter = $_SESSION['delimiter']; |
50 | |
51 | if (isset($_GET['startMessage'])) { |
52 | $startMessage = $_GET['startMessage']; |
cd9a4fd3 |
53 | } elseif (isset($_POST['startMessage'])) { |
54 | $startMessage = $_POST['startMessage']; |
a32985a5 |
55 | } |
56 | if (isset($_GET['mailbox'])) { |
57 | $mailbox = $_GET['mailbox']; |
cd9a4fd3 |
58 | } else if (isset($_POST['mailbox'])) { |
59 | $mailbox = $_POST['mailbox']; |
a32985a5 |
60 | } |
61 | if (isset($_GET['PG_SHOWNUM'])) { |
62 | $PG_SHOWNUM = $_GET['PG_SHOWNUM']; |
63 | } |
64 | elseif (isset($_SESSION['PG_SHOWNUM'])) { |
65 | $PG_SHOWNUM = $_SESSION['PG_SHOWNUM']; |
66 | } |
67 | if (isset($_GET['PG_SHOWALL'])) { |
68 | $PG_SHOWALL = $_GET['PG_SHOWALL']; |
69 | } |
70 | if (isset($_GET['newsort'])) { |
71 | $newsort = $_GET['newsort']; |
72 | } |
73 | if (isset($_GET['checkall'])) { |
74 | $checkall = $_GET['checkall']; |
75 | } |
76 | if (isset($_GET['set_thread'])) { |
77 | $set_thread = $_GET['set_thread']; |
78 | } |
79 | if (isset($_SESSION['lastTargetMailbox'])) { |
80 | $lastTargetMailbox =$_SESSION['lastTargetMailbox']; |
81 | } |
82 | |
83 | /* end of get globals */ |
84 | |
85 | |
c57b0888 |
86 | /* Open a connection on the imap port (143) */ |
6f223ace |
87 | |
c57b0888 |
88 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
89 | |
cf710efe |
90 | if (isset($PG_SHOWALL)) { |
91 | if ($PG_SHOWALL) { |
92 | $PG_SHOWNUM=999999; |
93 | $show_num=$PG_SHOWNUM; |
a32985a5 |
94 | sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM'); |
cf710efe |
95 | } |
96 | else { |
a32985a5 |
97 | sqsession_unregister('PG_SHOWNUM'); |
cf710efe |
98 | unset($PG_SHOWNUM); |
99 | } |
100 | } |
101 | else if( isset( $PG_SHOWNUM ) ) { |
bdfb67f8 |
102 | $show_num = $PG_SHOWNUM; |
103 | } |
104 | |
c57b0888 |
105 | if (isset($newsort) && $newsort != $sort) { |
106 | setPref($data_dir, $username, 'sort', $newsort); |
107 | } |
108 | |
e372ee8c |
109 | |
110 | |
111 | /* If the page has been loaded without a specific mailbox, */ |
112 | /* send them to the inbox */ |
113 | if (!isset($mailbox)) { |
114 | $mailbox = 'INBOX'; |
115 | $startMessage = 1; |
116 | } |
117 | |
118 | |
119 | if (!isset($startMessage) || ($startMessage == '')) { |
120 | $startMessage = 1; |
121 | } |
122 | |
123 | /* compensate for the UW vulnerability. */ |
124 | if ($imap_server_type == 'uw' && (strstr($mailbox, '../') || |
125 | substr($mailbox, 0, 1) == '/')) { |
126 | $mailbox = 'INBOX'; |
127 | } |
128 | |
7c612fdd |
129 | /* decide if we are thread sorting or not */ |
794d59c0 |
130 | if ($allow_thread_sort == TRUE) { |
7c612fdd |
131 | if (isset($set_thread)) { |
132 | if ($set_thread == 1) { |
78cc4b12 |
133 | setPref($data_dir, $username, "thread_$mailbox", 1); |
7c612fdd |
134 | $thread_sort_messages = '1'; |
135 | } |
136 | elseif ($set_thread == 2) { |
78cc4b12 |
137 | setPref($data_dir, $username, "thread_$mailbox", 0); |
7c612fdd |
138 | $thread_sort_messages = '0'; |
139 | } |
140 | } |
141 | else { |
78cc4b12 |
142 | $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox"); |
7c612fdd |
143 | } |
144 | } |
145 | else { |
146 | $thread_sort_messages = 0; |
147 | } |
148 | |
a32985a5 |
149 | do_hook ('generic_header'); |
7c612fdd |
150 | |
c57b0888 |
151 | sqimap_mailbox_select($imapConnection, $mailbox); |
6f223ace |
152 | |
31b32433 |
153 | if (isset($composenew) && $composenew) { |
a32985a5 |
154 | $comp_uri = '../src/compose.php?mailbox='. urlencode($mailbox). |
11af81b9 |
155 | "&session=$composesession"; |
156 | displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false); |
6f223ace |
157 | } else { |
158 | displayPageHeader($color, $mailbox); |
159 | } |
c57b0888 |
160 | do_hook('right_main_after_header'); |
c57b0888 |
161 | if (isset($note)) { |
fab3baa6 |
162 | echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n"; |
c57b0888 |
163 | } |
164 | |
a32985a5 |
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; |
169 | |
170 | if (strlen(trim($motd)) > 0) { |
171 | echo html_tag( 'table', |
172 | html_tag( 'tr', |
173 | html_tag( 'td', |
174 | html_tag( 'table', |
175 | html_tag( 'tr', |
176 | html_tag( 'td', $motd, 'center' ) |
177 | ) , |
178 | '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' ) |
179 | ) |
180 | ) , |
181 | 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' ); |
182 | } |
23d6bd09 |
183 | } |
c57b0888 |
184 | } |
185 | |
7c612fdd |
186 | if (isset($newsort)) { |
187 | $sort = $newsort; |
a32985a5 |
188 | sqsession_register($sort, 'sort'); |
7c612fdd |
189 | } |
190 | |
c57b0888 |
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; |
199 | } |
200 | |
d7c82551 |
201 | if ($use_mailbox_cache && sqsession_is_registered('msgs')) { |
c57b0888 |
202 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); |
203 | } else { |
d7c82551 |
204 | if (sqsession_is_registered('msgs')) { |
c57b0888 |
205 | unset($msgs); |
23d6bd09 |
206 | } |
207 | |
d7c82551 |
208 | if (sqsession_is_registered('msort')) { |
c57b0888 |
209 | unset($msort); |
23d6bd09 |
210 | } |
a37f3771 |
211 | |
d7c82551 |
212 | if (sqsession_is_registered('numMessages')) { |
c57b0888 |
213 | unset($numMessages); |
2016e645 |
214 | } |
e452ce9b |
215 | |
c57b0888 |
216 | $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); |
23d6bd09 |
217 | |
c57b0888 |
218 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, |
219 | $startMessage, $sort, $color, $show_num, |
220 | $use_mailbox_cache); |
23d6bd09 |
221 | |
d7c82551 |
222 | if (sqsession_is_registered('msgs') && isset($msgs)) { |
a32985a5 |
223 | sqsession_register($msgs, 'msgs'); |
b831fe0b |
224 | $_SESSION['msgs'] = $msgs; |
c57b0888 |
225 | } |
1108e8bb |
226 | |
d7c82551 |
227 | if (sqsession_is_registered('msort') && isset($msort)) { |
a32985a5 |
228 | sqsession_register($msort, 'msort'); |
b831fe0b |
229 | $_SESSION['msort'] = $msort; |
c57b0888 |
230 | } |
9f2215a1 |
231 | |
a32985a5 |
232 | sqsession_register($numMessages, 'numMessages'); |
b831fe0b |
233 | $_SESSION['numMessages'] = $numMessages; |
c57b0888 |
234 | } |
c57b0888 |
235 | do_hook('right_main_bottom'); |
236 | sqimap_logout ($imapConnection); |
23d6bd09 |
237 | |
fab3baa6 |
238 | echo '</body></html>'; |
21c3249f |
239 | |
978d53dc |
240 | ?> |