* UW workaround improved, methinks.
[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
441f2d33 14 if (!isset($i18n_php))
91dc6e4e 15 include('../functions/i18n.php');
dc54c9f2 16
2a32fc83 17 session_start();
18
10455998 19 if(!isset($logged_in) || !isset($username) || !isset($key)) {
91dc6e4e 20 include ('../themes/default_theme.php');
21 include ('../functions/display_messages.php');
10455998 22 printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
23 $color[8], $color[4], $color[7], $color[7], $color[7]);
24 plain_error_message(_("You need a valid user and password to access this page!")
91dc6e4e 25 . '<br><a href="../src/login.php">'
10455998 26 . _("Click here to log back in.") . "</a>.", $color);
91dc6e4e 27 echo '</body></html>';
21c3249f 28 exit;
29 }
44139266 30
245a6892 31 if (!isset($strings_php))
91dc6e4e 32 include('../functions/strings.php');
d068c0ec 33 if (!isset($config_php))
91dc6e4e 34 include('../config/config.php');
d068c0ec 35 if (!isset($imap_php))
91dc6e4e 36 include('../functions/imap.php');
d068c0ec 37 if (!isset($date_php))
91dc6e4e 38 include('../functions/date.php');
d068c0ec 39 if (!isset($page_header_php))
91dc6e4e 40 include('../functions/page_header.php');
d068c0ec 41 if (!isset($array_php))
91dc6e4e 42 include('../functions/array.php');
d068c0ec 43 if (!isset($mime_php))
91dc6e4e 44 include('../functions/mime.php');
d068c0ec 45 if (!isset($mailbox_display_php))
91dc6e4e 46 include('../functions/mailbox_display.php');
d068c0ec 47 if (!isset($display_messages_php))
91dc6e4e 48 include('../functions/display_messages.php');
44139266 49?>
59177427 50<?php
21c3249f 51 /////////////////////////////////////////////////////////////////////////////////
52 //
53 // incoming variables from URL:
54 // $sort Direction to sort by date
55 // values: 0 - descending order
56 // values: 1 - ascending order
57 // $startMessage Message to start at
58 // $mailbox Full Mailbox name
59 //
60 // incoming from cookie:
61 // $username duh
62 // $key pass
63 //
64 /////////////////////////////////////////////////////////////////////////////////
65
21c3249f 66 // open a connection on the imap port (143)
e1469126 67 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21c3249f 68
f3d17401 69 /** If it was a successful login, lets load their preferences **/
91dc6e4e 70 include('../src/load_prefs.php');
f3d17401 71
5c54e435 72 if (isset($newsort) && $newsort != $sort) {
91dc6e4e 73 setPref($data_dir, $username, 'sort', $newsort);
5c54e435 74 }
75
21c3249f 76 // If the page has been loaded without a specific mailbox,
a48fbf9b 77 // send them to the inbox
21c3249f 78 if (!isset($mailbox)) {
91dc6e4e 79 $mailbox = 'INBOX';
e9f8ea4e 80 $startMessage = 1;
21c3249f 81 }
82
cdcaac70 83 // compensate for the UW vulnerability
19303888 84 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
85 substr($mailbox, 0, 1) == '/')) {
91dc6e4e 86 $mailbox = 'INBOX';
cdcaac70 87 }
88
813eba2f 89 sqimap_mailbox_select($imapConnection, $mailbox);
f8f9bed9 90 displayPageHeader($color, $mailbox);
21c3249f 91
91dc6e4e 92 do_hook('right_main_after_header');
06ad27a2 93
245a6892 94 if (isset($just_logged_in) && $just_logged_in == 1 &&
95 strlen(trim($motd)) > 0) {
04632dbc 96 echo "<center><br>\n";
97 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
98 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
99 echo "$motd\n";
100 echo "</td></tr></table>\n";
101 echo "</td></tr></table>\n";
102 echo "</center><br>\n";
a37f3771 103 }
104
e452ce9b 105 if (isset($newsort)) {
106 $sort = $newsort;
91dc6e4e 107 session_register('sort');
e452ce9b 108 }
109
9f2215a1 110 // Check to see if we can use cache or not. Currently the only time when you wont use it is
111 // when a link on the left hand frame is used. Also check to make sure we actually have the
112 // array in the registered session data. :)
245a6892 113 if (! isset($use_mailbox_cache))
114 $use_mailbox_cache = 0;
91dc6e4e 115 if ($use_mailbox_cache && session_is_registered('msgs')) {
dc54c9f2 116 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 117 } else {
91dc6e4e 118 if (session_is_registered('msgs'))
90033b64 119 unset($msgs);
91dc6e4e 120 if (session_is_registered('msort'))
dc54c9f2 121 unset($msort);
91dc6e4e 122 if (session_is_registered('numMessages'))
1108e8bb 123 unset($numMessages);
124
125 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
9f2215a1 126
dc54c9f2 127 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 128
91dc6e4e 129 if (session_is_registered('msgs') && isset($msgs))
130 session_register('msgs');
131 if (session_is_registered('msort') && isset($msort))
132 session_register('msort');
133 session_register('numMessages');
90033b64 134 }
21c3249f 135
d53e5562 136 do_hook('right_main_bottom');
813eba2f 137 sqimap_logout ($imapConnection);
21c3249f 138?>
139</FONT>
140</BODY>
141</HTML>