11d09a535e4a2c9c2545c182f48cbe63a1cc0bb5
[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 ** $Id$
12 **/
13
14 if (!isset($i18n_php))
15 include("../functions/i18n.php");
16
17 session_start();
18
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>";
28 exit;
29 }
30
31 if (!isset($strings_php))
32 include("../functions/strings.php");
33 if (!isset($config_php))
34 include("../config/config.php");
35 if (!isset($imap_php))
36 include("../functions/imap.php");
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");
49 ?>
50 <?php
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
66 // open a connection on the imap port (143)
67 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
68
69 /** If it was a successful login, lets load their preferences **/
70 include("../src/load_prefs.php");
71
72 if (isset($newsort) && $newsort != $sort) {
73 setPref($data_dir, $username, "sort", $newsort);
74 }
75
76 // If the page has been loaded without a specific mailbox,
77 // send them to the inbox
78 if (!isset($mailbox)) {
79 $mailbox = "INBOX";
80 $startMessage = 1;
81 }
82
83 // compensate for the UW vulnerability
84 if ($imap_server_type == "uw" && strstr($mailbox, "../")) {
85 $mailbox = "INBOX";
86 }
87
88 sqimap_mailbox_select($imapConnection, $mailbox);
89 displayPageHeader($color, $mailbox);
90
91 do_hook("right_main_after_header");
92
93 if (isset($just_logged_in) && $just_logged_in == 1 &&
94 strlen(trim($motd)) > 0) {
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";
102 }
103
104 if (isset($newsort)) {
105 $sort = $newsort;
106 session_register("sort");
107 }
108
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. :)
112 if (! isset($use_mailbox_cache))
113 $use_mailbox_cache = 0;
114 if ($use_mailbox_cache && session_is_registered("msgs")) {
115 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
116 } else {
117 if (session_is_registered("msgs"))
118 unset($msgs);
119 if (session_is_registered("msort"))
120 unset($msort);
121 if (session_is_registered("numMessages"))
122 unset($numMessages);
123
124 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
125
126 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
127
128 if (session_is_registered("msgs") && isset($msgs))
129 session_register("msgs");
130 if (session_is_registered("msort") && isset($msort))
131 session_register("msort");
132 session_register("numMessages");
133 }
134
135 do_hook("right_main_bottom");
136 sqimap_logout ($imapConnection);
137 ?>
138 </FONT>
139 </BODY>
140 </HTML>