r2l
[squirrelmail.git] / src / right_main.php
... / ...
CommitLineData
1<?php
2
3/**
4 * right_main.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
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
15require_once('../src/validate.php');
16require_once('../functions/imap.php');
17require_once('../functions/date.php');
18require_once('../functions/array.php');
19require_once('../functions/mime.php');
20require_once('../functions/mailbox_display.php');
21require_once('../functions/display_messages.php');
22require_once('../functions/html.php');
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
37$bob = getHashedFile($username, $data_dir, "username.pref");
38
39/* Open a connection on the imap port (143) */
40
41$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
42
43global $PG_SHOWNUM;
44if (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}
55else if( isset( $PG_SHOWNUM ) ) {
56 $show_num = $PG_SHOWNUM;
57}
58
59if (isset($newsort) && $newsort != $sort) {
60 setPref($data_dir, $username, 'sort', $newsort);
61}
62
63
64
65/* If the page has been loaded without a specific mailbox, */
66/* send them to the inbox */
67if (!isset($mailbox)) {
68 $mailbox = 'INBOX';
69 $startMessage = 1;
70}
71
72
73if (!isset($startMessage) || ($startMessage == '')) {
74 $startMessage = 1;
75}
76
77/* compensate for the UW vulnerability. */
78if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
79 substr($mailbox, 0, 1) == '/')) {
80 $mailbox = 'INBOX';
81}
82
83/* decide if we are thread sorting or not */
84global $allow_thread_sort;
85if ($allow_thread_sort == TRUE) {
86 if (isset($set_thread)) {
87 if ($set_thread == 1) {
88 setPref($data_dir, $username, "thread_$mailbox", 1);
89 $thread_sort_messages = '1';
90 }
91 elseif ($set_thread == 2) {
92 setPref($data_dir, $username, "thread_$mailbox", 0);
93 $thread_sort_messages = '0';
94 }
95 }
96 else {
97 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
98 }
99}
100else {
101 $thread_sort_messages = 0;
102}
103
104global $color;
105if( isset($do_hook) && $do_hook ) {
106 do_hook ("generic_header");
107}
108
109sqimap_mailbox_select($imapConnection, $mailbox);
110
111if (isset($composenew) && $composenew) {
112 $comp_uri = "../src/compose.php?mailbox=". urlencode($mailbox).
113 "&amp;session=$composesession&amp;attachedmessages=true&amp";
114
115 displayPageHeader($color, $mailbox, "comp_in_new(false,'$comp_uri');", false);
116} else {
117 displayPageHeader($color, $mailbox);
118}
119echo "<br>\n";
120
121do_hook('right_main_after_header');
122if (isset($note)) {
123 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
124}
125
126if ($just_logged_in == true) {
127 $just_logged_in = false;
128
129 if (strlen(trim($motd)) > 0) {
130 echo html_tag( 'table',
131 html_tag( 'tr',
132 html_tag( 'td',
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"' );
141 }
142}
143
144if (isset($newsort)) {
145 $sort = $newsort;
146 session_register('sort');
147}
148
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 *********************************************************************/
155if (! isset($use_mailbox_cache)) {
156 $use_mailbox_cache = 0;
157}
158
159/* There is a problem with registered vars in 4.1 */
160/*
161if( substr( phpversion(), 0, 3 ) == '4.1' ) {
162 $use_mailbox_cache = FALSE;
163}
164*/
165
166if ($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);
171 }
172
173 if (session_is_registered('msort')) {
174 unset($msort);
175 }
176
177 if (session_is_registered('numMessages')) {
178 unset($numMessages);
179 }
180
181 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
182
183 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
184 $startMessage, $sort, $color, $show_num,
185 $use_mailbox_cache);
186
187 if (session_is_registered('msgs') && isset($msgs)) {
188 session_register('msgs');
189 $_SESSION['msgs'] = $msgs;
190 }
191
192 if (session_is_registered('msort') && isset($msort)) {
193 session_register('msort');
194 $_SESSION['msort'] = $msort;
195 }
196
197 session_register('numMessages');
198 $_SESSION['numMessages'] = $numMessages;
199}
200do_hook('right_main_bottom');
201sqimap_logout ($imapConnection);
202
203echo '</body></html>';
204
205?>