59177427 |
1 | <?php |
c57b0888 |
2 | /** |
3 | * right_main.php |
4 | * |
82d304a0 |
5 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
c57b0888 |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This is where the mailboxes are listed. This controls most of what |
9 | * goes on in SquirrelMail. |
10 | * |
11 | * $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
c57b0888 |
13 | */ |
14 | |
8f6f9ba5 |
15 | /** Path for SquirrelMail required files. */ |
86725763 |
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'); |
c97f4825 |
27 | require_once(SM_PATH . 'functions/plugin.php'); |
c57b0888 |
28 | |
29 | /*********************************************************** |
30 | * incoming variables from URL: * |
31 | * $sort Direction to sort by date * |
32 | * values: 0 - descending order * |
33 | * values: 1 - ascending order * |
34 | * $startMessage Message to start at * |
35 | * $mailbox Full Mailbox name * |
36 | * * |
37 | * incoming from cookie: * |
c57b0888 |
38 | * $key pass * |
a32985a5 |
39 | * incoming from session: * |
40 | * $username duh * |
41 | * * |
c57b0888 |
42 | ***********************************************************/ |
43 | |
a32985a5 |
44 | |
45 | /* lets get the global vars we may need */ |
1e12d1ff |
46 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
47 | sqgetGlobalVar('username', $username, SQ_SESSION); |
48 | sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); |
49 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
50 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
51 | |
52 | sqgetGlobalVar('mailbox', $mailbox); |
53 | sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION); |
d7048dd4 |
54 | sqgetGlobalVar('numMessages' , $numMessages, SQ_SESSION); |
1e12d1ff |
55 | sqgetGlobalVar('session', $session, SQ_GET); |
56 | sqgetGlobalVar('note', $note, SQ_GET); |
2ffeb7c5 |
57 | sqgetGlobalVar('mail_sent', $mail_sent, SQ_GET); |
d7048dd4 |
58 | sqgetGlobalVar('use_mailbox_cache', $use_mailbox_cache, SQ_GET); |
1e12d1ff |
59 | |
60 | if ( sqgetGlobalVar('startMessage', $temp) ) { |
61 | $startMessage = (int) $temp; |
a32985a5 |
62 | } |
1e12d1ff |
63 | if ( sqgetGlobalVar('PG_SHOWNUM', $temp) ) { |
64 | $PG_SHOWNUM = (int) $temp; |
a32985a5 |
65 | } |
1e12d1ff |
66 | if ( sqgetGlobalVar('PG_SHOWALL', $temp, SQ_GET) ) { |
67 | $PG_SHOWALL = (int) $temp; |
a32985a5 |
68 | } |
1e12d1ff |
69 | if ( sqgetGlobalVar('newsort', $temp, SQ_GET) ) { |
70 | $newsort = (int) $temp; |
a32985a5 |
71 | } |
1e12d1ff |
72 | if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) { |
73 | $checkall = (int) $temp; |
a32985a5 |
74 | } |
1e12d1ff |
75 | if ( sqgetGlobalVar('set_thread', $temp, SQ_GET) ) { |
76 | $set_thread = (int) $temp; |
a32985a5 |
77 | } |
1e12d1ff |
78 | if ( !sqgetGlobalVar('composenew', $composenew, SQ_GET) ) { |
8cc72ada |
79 | $composenew = false; |
80 | } |
a32985a5 |
81 | /* end of get globals */ |
82 | |
83 | |
c57b0888 |
84 | /* Open a connection on the imap port (143) */ |
6f223ace |
85 | |
c57b0888 |
86 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
87 | |
cf710efe |
88 | if (isset($PG_SHOWALL)) { |
89 | if ($PG_SHOWALL) { |
90 | $PG_SHOWNUM=999999; |
91 | $show_num=$PG_SHOWNUM; |
a32985a5 |
92 | sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM'); |
cf710efe |
93 | } |
94 | else { |
a32985a5 |
95 | sqsession_unregister('PG_SHOWNUM'); |
cf710efe |
96 | unset($PG_SHOWNUM); |
97 | } |
98 | } |
99 | else if( isset( $PG_SHOWNUM ) ) { |
bdfb67f8 |
100 | $show_num = $PG_SHOWNUM; |
101 | } |
102 | |
94a4ea53 |
103 | if (isset($newsort) ) { |
104 | if ( $newsort != $sort ) |
105 | setPref($data_dir, $username, 'sort', $newsort); |
e372ee8c |
106 | |
94a4ea53 |
107 | $sort = $newsort; |
108 | sqsession_register($sort, 'sort'); |
109 | } |
e372ee8c |
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); |
c97f4825 |
134 | $thread_sort_messages = '1'; |
7c612fdd |
135 | } |
136 | elseif ($set_thread == 2) { |
78cc4b12 |
137 | setPref($data_dir, $username, "thread_$mailbox", 0); |
c97f4825 |
138 | $thread_sort_messages = '0'; |
7c612fdd |
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; |
c97f4825 |
147 | } |
7c612fdd |
148 | |
a32985a5 |
149 | do_hook ('generic_header'); |
7c612fdd |
150 | |
c57b0888 |
151 | sqimap_mailbox_select($imapConnection, $mailbox); |
6f223ace |
152 | |
8cc72ada |
153 | if ($composenew) { |
154 | $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox). |
c97f4825 |
155 | "&session=$session"; |
11af81b9 |
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'); |
2ffeb7c5 |
161 | |
162 | /* display a message to the user that their mail has been sent */ |
163 | if (isset($mail_sent) && $mail_sent == 'yes') { |
164 | $note = _("Your Message has been sent."); |
165 | } |
c57b0888 |
166 | if (isset($note)) { |
fab3baa6 |
167 | echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n"; |
c57b0888 |
168 | } |
169 | |
f38b7cf0 |
170 | if ( sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION) ) { |
a32985a5 |
171 | if ($just_logged_in == true) { |
172 | $just_logged_in = false; |
dd2a2e15 |
173 | sqsession_register($just_logged_in, 'just_logged_in'); |
a32985a5 |
174 | |
175 | if (strlen(trim($motd)) > 0) { |
176 | echo html_tag( 'table', |
177 | html_tag( 'tr', |
c97f4825 |
178 | html_tag( 'td', |
a32985a5 |
179 | html_tag( 'table', |
180 | html_tag( 'tr', |
181 | html_tag( 'td', $motd, 'center' ) |
182 | ) , |
183 | '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' ) |
184 | ) |
185 | ) , |
186 | 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' ); |
187 | } |
23d6bd09 |
188 | } |
c57b0888 |
189 | } |
190 | |
7c612fdd |
191 | |
c57b0888 |
192 | /********************************************************************* |
193 | * Check to see if we can use cache or not. Currently the only time * |
194 | * when you will not use it is when a link on the left hand frame is * |
195 | * used. Also check to make sure we actually have the array in the * |
196 | * registered session data. :) * |
197 | *********************************************************************/ |
198 | if (! isset($use_mailbox_cache)) { |
199 | $use_mailbox_cache = 0; |
200 | } |
201 | |
d7c82551 |
202 | if ($use_mailbox_cache && sqsession_is_registered('msgs')) { |
c57b0888 |
203 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); |
204 | } else { |
d7c82551 |
205 | if (sqsession_is_registered('msgs')) { |
c57b0888 |
206 | unset($msgs); |
23d6bd09 |
207 | } |
208 | |
d7c82551 |
209 | if (sqsession_is_registered('msort')) { |
c57b0888 |
210 | unset($msort); |
23d6bd09 |
211 | } |
a37f3771 |
212 | |
d7c82551 |
213 | if (sqsession_is_registered('numMessages')) { |
c57b0888 |
214 | unset($numMessages); |
2016e645 |
215 | } |
e452ce9b |
216 | |
c57b0888 |
217 | $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); |
23d6bd09 |
218 | |
c97f4825 |
219 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, |
c57b0888 |
220 | $startMessage, $sort, $color, $show_num, |
221 | $use_mailbox_cache); |
23d6bd09 |
222 | |
d7c82551 |
223 | if (sqsession_is_registered('msgs') && isset($msgs)) { |
a32985a5 |
224 | sqsession_register($msgs, 'msgs'); |
d7048dd4 |
225 | //$_SESSION['msgs'] = $msgs; |
c57b0888 |
226 | } |
1108e8bb |
227 | |
d7c82551 |
228 | if (sqsession_is_registered('msort') && isset($msort)) { |
a32985a5 |
229 | sqsession_register($msort, 'msort'); |
d7048dd4 |
230 | //$_SESSION['msort'] = $msort; |
c57b0888 |
231 | } |
9f2215a1 |
232 | |
a32985a5 |
233 | sqsession_register($numMessages, 'numMessages'); |
d7048dd4 |
234 | //$_SESSION['numMessages'] = $numMessages; |
c57b0888 |
235 | } |
c57b0888 |
236 | do_hook('right_main_bottom'); |
237 | sqimap_logout ($imapConnection); |
23d6bd09 |
238 | |
dcc1cc82 |
239 | echo '</body></html>'; |
240 | |
241 | ?> |