Added html_top and html_bottom hooks to read_body for compression plugin
[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 the page has been loaded without a specific mailbox,
71 // send them to the inbox
72 if (!isset($mailbox)) {
73 $mailbox = "INBOX";
74 $sort = $newsort = 0;
75 $startMessage = 1;
76 }
77
78 sqimap_mailbox_select($imapConnection, $mailbox);
79 displayPageHeader($color, $mailbox);
80
81 do_hook("right_main_after_header");
82
83 if ($just_logged_in == 1 && strlen(trim($motd)) > 0) {
84 echo "<center><br>\n";
85 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
86 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
87 echo "$motd\n";
88 echo "</td></tr></table>\n";
89 echo "</td></tr></table>\n";
90 echo "</center><br>\n";
91 }
92
93 if (isset($newsort)) {
94 $sort = $newsort;
95 session_register("sort");
96 }
97
98 // Check to see if we can use cache or not. Currently the only time when you wont use it is
99 // when a link on the left hand frame is used. Also check to make sure we actually have the
100 // array in the registered session data. :)
101 if ($use_mailbox_cache && session_is_registered("msgs")) {
102 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
103 } else {
104 if (session_is_registered("msgs"))
105 unset($msgs);
106 if (session_is_registered("msort"))
107 unset($msort);
108 if (session_is_registered("numMessages"))
109 unset($numMessages);
110
111 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
112
113 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
114
115 if (session_is_registered("msgs") && isset($msgs))
116 session_register("msgs");
117 if (session_is_registered("msort") && isset($msort))
118 session_register("msort");
119 session_register("numMessages");
120 }
121
122 do_hook("right_main_bottom");
123 // close the connection
124 sqimap_mailbox_close($imapConnection);
125 sqimap_logout ($imapConnection);
126 ?>
127 </FONT>
128 </BODY>
129 </HTML>