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