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