patch a security hole in UW
[squirrelmail.git] / src / right_main.php
1 <?php
2 /**
3 ** right_main.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** This is where the mailboxes are listed. This controls most of what
9 ** goes on in SquirrelMail.
10 **
11 **/
12
13 if (!isset($i18n_php))
14 include("../functions/i18n.php");
15
16 session_start();
17
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>";
27 exit;
28 }
29
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");
48 ?>
49 <?php
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
65 // open a connection on the imap port (143)
66 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
67
68 /** If it was a successful login, lets load their preferences **/
69 include("../src/load_prefs.php");
70
71 if (isset($newsort) && $newsort != $sort) {
72 setPref($data_dir, $username, "sort", $newsort);
73 }
74
75 // If the page has been loaded without a specific mailbox,
76 // send them to the inbox
77 if (!isset($mailbox)) {
78 $mailbox = "INBOX";
79 $startMessage = 1;
80 }
81
82 // compensate for the UW vulnerability
83 if ($imap_server_type == "uw" && strstr($mailbox, "../")) {
84 $mailbox = "INBOX";
85 }
86
87 sqimap_mailbox_select($imapConnection, $mailbox);
88 displayPageHeader($color, $mailbox);
89
90 do_hook("right_main_after_header");
91
92 if ($just_logged_in == 1 && strlen(trim($motd)) > 0) {
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";
100 }
101
102 if (isset($newsort)) {
103 $sort = $newsort;
104 session_register("sort");
105 }
106
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. :)
110 if ($use_mailbox_cache && session_is_registered("msgs")) {
111 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
112 } else {
113 if (session_is_registered("msgs"))
114 unset($msgs);
115 if (session_is_registered("msort"))
116 unset($msort);
117 if (session_is_registered("numMessages"))
118 unset($numMessages);
119
120 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
121
122 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
123
124 if (session_is_registered("msgs") && isset($msgs))
125 session_register("msgs");
126 if (session_is_registered("msort") && isset($msort))
127 session_register("msort");
128 session_register("numMessages");
129 }
130
131 do_hook("right_main_bottom");
132 sqimap_logout ($imapConnection);
133 ?>
134 </FONT>
135 </BODY>
136 </HTML>