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