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 | |
bdfb67f8 |
42 | if( isset( $PG_SHOWNUM ) ) { |
43 | $show_num = $PG_SHOWNUM; |
44 | } |
45 | |
c57b0888 |
46 | if (isset($newsort) && $newsort != $sort) { |
47 | setPref($data_dir, $username, 'sort', $newsort); |
48 | } |
49 | |
50 | /* If the page has been loaded without a specific mailbox, */ |
51 | /* send them to the inbox */ |
52 | if (!isset($mailbox)) { |
53 | $mailbox = 'INBOX'; |
54 | $startMessage = 1; |
55 | } |
56 | |
57 | if (!isset($startMessage) || ($startMessage == '')) { |
58 | $startMessage = 1; |
59 | } |
60 | |
61 | /* compensate for the UW vulnerability. */ |
62 | if ($imap_server_type == 'uw' && (strstr($mailbox, '../') || |
63 | substr($mailbox, 0, 1) == '/')) { |
64 | $mailbox = 'INBOX'; |
65 | } |
6f223ace |
66 | global $color; |
67 | |
68 | if( isset($do_hook) && $do_hook ) { |
69 | do_hook ("generic_header"); |
70 | } |
c57b0888 |
71 | |
72 | sqimap_mailbox_select($imapConnection, $mailbox); |
6f223ace |
73 | |
74 | if (isset($composenew)) { |
75 | $width= getPref($username, $data_dir, 'editor_size', 76); |
76 | if ($width < 65) { |
77 | $pix_width = 560; |
78 | } else { |
79 | $width = (.9*$width); |
80 | $pix_width = intval($width).'0'; |
81 | } |
82 | $features = "toolbar=no, width=$pix_width, height=650, scrollbars=yes, resizable=yes target=_blank"; |
83 | $location = 'compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
84 | $onload= "window.open(\"$location\",\"compose_window_$session\", \"$features\");"; |
85 | displayPageHeader($color, $mailbox, $onload); |
86 | } else { |
87 | displayPageHeader($color, $mailbox); |
88 | } |
c57b0888 |
89 | echo "<br>\n"; |
90 | |
91 | do_hook('right_main_after_header'); |
92 | |
93 | if (isset($note)) { |
94 | echo "<CENTER><B>$note</B></CENTER><BR>\n"; |
95 | } |
96 | |
97 | if ($just_logged_in == true) { |
98 | $just_logged_in = false; |
99 | |
100 | if (strlen(trim($motd)) > 0) { |
bd9bbfef |
101 | echo "<br><table align=center width=\"70%\" cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" . |
c57b0888 |
102 | '<tr><td>' . |
bd9bbfef |
103 | "<table width=\"100%\" cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" . |
c57b0888 |
104 | "<tr><td align=center>$motd"; |
105 | do_hook('motd'); |
106 | echo '</td></tr>' . |
107 | '</table>' . |
108 | '</td></tr></table>'; |
23d6bd09 |
109 | } |
c57b0888 |
110 | } |
111 | |
112 | if (isset($newsort)) { |
113 | $sort = $newsort; |
114 | session_register('sort'); |
115 | } |
116 | |
117 | /********************************************************************* |
118 | * Check to see if we can use cache or not. Currently the only time * |
119 | * when you will not use it is when a link on the left hand frame is * |
120 | * used. Also check to make sure we actually have the array in the * |
121 | * registered session data. :) * |
122 | *********************************************************************/ |
123 | if (! isset($use_mailbox_cache)) { |
124 | $use_mailbox_cache = 0; |
125 | } |
126 | |
d46fbcf8 |
127 | /* There is a problem with registered vars in 4.1 */ |
88cb1b4d |
128 | /* |
ae7c2608 |
129 | if( substr( phpversion(), 0, 3 ) == '4.1' ) { |
d46fbcf8 |
130 | $use_mailbox_cache = FALSE; |
131 | } |
88cb1b4d |
132 | */ |
d46fbcf8 |
133 | |
c57b0888 |
134 | if ($use_mailbox_cache && session_is_registered('msgs')) { |
135 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); |
136 | } else { |
137 | if (session_is_registered('msgs')) { |
138 | unset($msgs); |
23d6bd09 |
139 | } |
140 | |
c57b0888 |
141 | if (session_is_registered('msort')) { |
142 | unset($msort); |
23d6bd09 |
143 | } |
a37f3771 |
144 | |
c57b0888 |
145 | if (session_is_registered('numMessages')) { |
146 | unset($numMessages); |
2016e645 |
147 | } |
e452ce9b |
148 | |
c57b0888 |
149 | $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); |
23d6bd09 |
150 | |
c57b0888 |
151 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, |
152 | $startMessage, $sort, $color, $show_num, |
153 | $use_mailbox_cache); |
23d6bd09 |
154 | |
c57b0888 |
155 | if (session_is_registered('msgs') && isset($msgs)) { |
156 | session_register('msgs'); |
b831fe0b |
157 | $_SESSION['msgs'] = $msgs; |
c57b0888 |
158 | } |
1108e8bb |
159 | |
c57b0888 |
160 | if (session_is_registered('msort') && isset($msort)) { |
161 | session_register('msort'); |
b831fe0b |
162 | $_SESSION['msort'] = $msort; |
c57b0888 |
163 | } |
9f2215a1 |
164 | |
c57b0888 |
165 | session_register('numMessages'); |
b831fe0b |
166 | $_SESSION['numMessages'] = $numMessages; |
c57b0888 |
167 | } |
2016e645 |
168 | |
c57b0888 |
169 | do_hook('right_main_bottom'); |
170 | sqimap_logout ($imapConnection); |
23d6bd09 |
171 | |
bd9bbfef |
172 | echo '</BODY></HTML>'; |
21c3249f |
173 | |
b831fe0b |
174 | ?> |