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