3f6bba8add1da97b841942b086e96f7139d62c4c
[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)) {
19 set_up_language($squirrelmail_language, true);
20 echo _("You must login first.");
21 exit;
22 }
23 if(!isset($username) || !isset($key)) {
24 set_up_language($squirrelmail_language, true);
25 echo _("You need a valid user and password to access this page!");
26 exit;
27 }
28
29 if (!isset($config_php))
30 include("../config/config.php");
31 if (!isset($imap_php))
32 include("../functions/imap.php");
33 if (!isset($strings_php))
34 include("../functions/strings.php");
35 if (!isset($date_php))
36 include("../functions/date.php");
37 if (!isset($page_header_php))
38 include("../functions/page_header.php");
39 if (!isset($array_php))
40 include("../functions/array.php");
41 if (!isset($mime_php))
42 include("../functions/mime.php");
43 if (!isset($mailbox_display_php))
44 include("../functions/mailbox_display.php");
45 if (!isset($display_messages_php))
46 include("../functions/display_messages.php");
47 ?>
48 <?php
49 /////////////////////////////////////////////////////////////////////////////////
50 //
51 // incoming variables from URL:
52 // $sort Direction to sort by date
53 // values: 0 - descending order
54 // values: 1 - ascending order
55 // $startMessage Message to start at
56 // $mailbox Full Mailbox name
57 //
58 // incoming from cookie:
59 // $username duh
60 // $key pass
61 //
62 /////////////////////////////////////////////////////////////////////////////////
63
64 // open a connection on the imap port (143)
65 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
66
67 /** If it was a successful login, lets load their preferences **/
68 include("../src/load_prefs.php");
69
70 if (isset($newsort) && $newsort != $sort) {
71 setPref($data_dir, $username, "sort", $newsort);
72 }
73
74 // If the page has been loaded without a specific mailbox,
75 // send them to the inbox
76 if (!isset($mailbox)) {
77 $mailbox = "INBOX";
78 $startMessage = 1;
79 }
80
81 sqimap_mailbox_select($imapConnection, $mailbox);
82 displayPageHeader($color, $mailbox);
83
84 do_hook("right_main_after_header");
85
86 if ($just_logged_in == 1 && strlen(trim($motd)) > 0) {
87 echo "<center><br>\n";
88 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
89 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
90 echo "$motd\n";
91 echo "</td></tr></table>\n";
92 echo "</td></tr></table>\n";
93 echo "</center><br>\n";
94 }
95
96 if (isset($newsort)) {
97 $sort = $newsort;
98 session_register("sort");
99 }
100
101 // Check to see if we can use cache or not. Currently the only time when you wont use it is
102 // when a link on the left hand frame is used. Also check to make sure we actually have the
103 // array in the registered session data. :)
104 if ($use_mailbox_cache && session_is_registered("msgs")) {
105 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
106 } else {
107 if (session_is_registered("msgs"))
108 unset($msgs);
109 if (session_is_registered("msort"))
110 unset($msort);
111 if (session_is_registered("numMessages"))
112 unset($numMessages);
113
114 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
115
116 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
117
118 if (session_is_registered("msgs") && isset($msgs))
119 session_register("msgs");
120 if (session_is_registered("msort") && isset($msort))
121 session_register("msort");
122 session_register("numMessages");
123 }
124
125 do_hook("right_main_bottom");
126 sqimap_logout ($imapConnection);
127 ?>
128 </FONT>
129 </BODY>
130 </HTML>