fixed bug that didn't display folders with spaces in the name
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** right_main.php
21c3249f 4 **
3bcede49 5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
21c3249f 8 ** This is where the mailboxes are listed. This controls most of what
9 ** goes on in SquirrelMail.
10 **
245a6892 11 ** $Id$
21c3249f 12 **/
13
f740c049 14 include('../src/validate.php');
15 include('../functions/i18n.php');
16 include('../functions/strings.php');
17 include('../config/config.php');
18 include('../functions/imap.php');
19 include('../functions/date.php');
20 include('../functions/page_header.php');
21 include('../functions/array.php');
22 include('../functions/mime.php');
23 include('../functions/mailbox_display.php');
24 include('../functions/display_messages.php');
dc54c9f2 25
44139266 26?>
59177427 27<?php
21c3249f 28 /////////////////////////////////////////////////////////////////////////////////
29 //
30 // incoming variables from URL:
31 // $sort Direction to sort by date
32 // values: 0 - descending order
33 // values: 1 - ascending order
34 // $startMessage Message to start at
35 // $mailbox Full Mailbox name
36 //
37 // incoming from cookie:
38 // $username duh
39 // $key pass
40 //
41 /////////////////////////////////////////////////////////////////////////////////
42
21c3249f 43 // open a connection on the imap port (143)
e1469126 44 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21c3249f 45
f3d17401 46 /** If it was a successful login, lets load their preferences **/
91dc6e4e 47 include('../src/load_prefs.php');
f3d17401 48
5c54e435 49 if (isset($newsort) && $newsort != $sort) {
91dc6e4e 50 setPref($data_dir, $username, 'sort', $newsort);
5c54e435 51 }
52
21c3249f 53 // If the page has been loaded without a specific mailbox,
a48fbf9b 54 // send them to the inbox
21c3249f 55 if (!isset($mailbox)) {
91dc6e4e 56 $mailbox = 'INBOX';
e9f8ea4e 57 $startMessage = 1;
21c3249f 58 }
59
cdcaac70 60 // compensate for the UW vulnerability
9d99e49d 61 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') !== false ||
19303888 62 substr($mailbox, 0, 1) == '/')) {
91dc6e4e 63 $mailbox = 'INBOX';
cdcaac70 64 }
65
813eba2f 66 sqimap_mailbox_select($imapConnection, $mailbox);
f8f9bed9 67 displayPageHeader($color, $mailbox);
21c3249f 68
91dc6e4e 69 do_hook('right_main_after_header');
06ad27a2 70
245a6892 71 if (isset($just_logged_in) && $just_logged_in == 1 &&
72 strlen(trim($motd)) > 0) {
04632dbc 73 echo "<center><br>\n";
74 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
75 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
76 echo "$motd\n";
77 echo "</td></tr></table>\n";
78 echo "</td></tr></table>\n";
79 echo "</center><br>\n";
a37f3771 80 }
81
e452ce9b 82 if (isset($newsort)) {
83 $sort = $newsort;
91dc6e4e 84 session_register('sort');
e452ce9b 85 }
86
9f2215a1 87 // Check to see if we can use cache or not. Currently the only time when you wont use it is
88 // when a link on the left hand frame is used. Also check to make sure we actually have the
89 // array in the registered session data. :)
245a6892 90 if (! isset($use_mailbox_cache))
91 $use_mailbox_cache = 0;
91dc6e4e 92 if ($use_mailbox_cache && session_is_registered('msgs')) {
dc54c9f2 93 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 94 } else {
91dc6e4e 95 if (session_is_registered('msgs'))
90033b64 96 unset($msgs);
91dc6e4e 97 if (session_is_registered('msort'))
dc54c9f2 98 unset($msort);
91dc6e4e 99 if (session_is_registered('numMessages'))
1108e8bb 100 unset($numMessages);
101
102 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
9f2215a1 103
dc54c9f2 104 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 105
91dc6e4e 106 if (session_is_registered('msgs') && isset($msgs))
107 session_register('msgs');
108 if (session_is_registered('msort') && isset($msort))
109 session_register('msort');
110 session_register('numMessages');
90033b64 111 }
21c3249f 112
d53e5562 113 do_hook('right_main_bottom');
813eba2f 114 sqimap_logout ($imapConnection);
21c3249f 115?>
116</FONT>
117</BODY>
118</HTML>