more warnings removed
[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))
15 include("../functions/i18n.php");
dc54c9f2 16
2a32fc83 17 session_start();
18
10455998 19 if(!isset($logged_in) || !isset($username) || !isset($key)) {
20 include ("../themes/default_theme.php");
21 include ("../functions/display_messages.php");
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!")
25 . "<br><a href=\"../src/login.php\">"
26 . _("Click here to log back in.") . "</a>.", $color);
27 echo "</body></html>";
21c3249f 28 exit;
29 }
44139266 30
245a6892 31 if (!isset($strings_php))
32 include("../functions/strings.php");
d068c0ec 33 if (!isset($config_php))
34 include("../config/config.php");
35 if (!isset($imap_php))
36 include("../functions/imap.php");
d068c0ec 37 if (!isset($date_php))
38 include("../functions/date.php");
39 if (!isset($page_header_php))
40 include("../functions/page_header.php");
41 if (!isset($array_php))
42 include("../functions/array.php");
43 if (!isset($mime_php))
44 include("../functions/mime.php");
45 if (!isset($mailbox_display_php))
46 include("../functions/mailbox_display.php");
47 if (!isset($display_messages_php))
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 **/
70 include("../src/load_prefs.php");
f3d17401 71
5c54e435 72 if (isset($newsort) && $newsort != $sort) {
73 setPref($data_dir, $username, "sort", $newsort);
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)) {
e9f8ea4e 79 $mailbox = "INBOX";
e9f8ea4e 80 $startMessage = 1;
21c3249f 81 }
82
cdcaac70 83 // compensate for the UW vulnerability
84 if ($imap_server_type == "uw" && strstr($mailbox, "../")) {
85 $mailbox = "INBOX";
86 }
87
813eba2f 88 sqimap_mailbox_select($imapConnection, $mailbox);
f8f9bed9 89 displayPageHeader($color, $mailbox);
21c3249f 90
06ad27a2 91 do_hook("right_main_after_header");
92
245a6892 93 if (isset($just_logged_in) && $just_logged_in == 1 &&
94 strlen(trim($motd)) > 0) {
04632dbc 95 echo "<center><br>\n";
96 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
97 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
98 echo "$motd\n";
99 echo "</td></tr></table>\n";
100 echo "</td></tr></table>\n";
101 echo "</center><br>\n";
a37f3771 102 }
103
e452ce9b 104 if (isset($newsort)) {
105 $sort = $newsort;
106 session_register("sort");
107 }
108
9f2215a1 109 // Check to see if we can use cache or not. Currently the only time when you wont use it is
110 // when a link on the left hand frame is used. Also check to make sure we actually have the
111 // array in the registered session data. :)
245a6892 112 if (! isset($use_mailbox_cache))
113 $use_mailbox_cache = 0;
90033b64 114 if ($use_mailbox_cache && session_is_registered("msgs")) {
dc54c9f2 115 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 116 } else {
117 if (session_is_registered("msgs"))
118 unset($msgs);
dc54c9f2 119 if (session_is_registered("msort"))
120 unset($msort);
1108e8bb 121 if (session_is_registered("numMessages"))
122 unset($numMessages);
123
124 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
9f2215a1 125
dc54c9f2 126 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 127
128 if (session_is_registered("msgs") && isset($msgs))
129 session_register("msgs");
dc54c9f2 130 if (session_is_registered("msort") && isset($msort))
131 session_register("msort");
1108e8bb 132 session_register("numMessages");
90033b64 133 }
21c3249f 134
06ad27a2 135 do_hook("right_main_bottom");
813eba2f 136 sqimap_logout ($imapConnection);
21c3249f 137?>
138</FONT>
139</BODY>
140</HTML>