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