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