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