changed some error messages to be formatted, and actually meaningful
[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 sqimap_mailbox_select($imapConnection, $mailbox);
83 displayPageHeader($color, $mailbox);
84
85 do_hook("right_main_after_header");
86
87 if ($just_logged_in == 1 && strlen(trim($motd)) > 0) {
88 echo "<center><br>\n";
89 echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n";
90 echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n";
91 echo "$motd\n";
92 echo "</td></tr></table>\n";
93 echo "</td></tr></table>\n";
94 echo "</center><br>\n";
95 }
96
97 if (isset($newsort)) {
98 $sort = $newsort;
99 session_register("sort");
100 }
101
102 // Check to see if we can use cache or not. Currently the only time when you wont use it is
103 // when a link on the left hand frame is used. Also check to make sure we actually have the
104 // array in the registered session data. :)
105 if ($use_mailbox_cache && session_is_registered("msgs")) {
106 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
107 } else {
108 if (session_is_registered("msgs"))
109 unset($msgs);
110 if (session_is_registered("msort"))
111 unset($msort);
112 if (session_is_registered("numMessages"))
113 unset($numMessages);
114
115 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
116
117 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
118
119 if (session_is_registered("msgs") && isset($msgs))
120 session_register("msgs");
121 if (session_is_registered("msort") && isset($msort))
122 session_register("msort");
123 session_register("numMessages");
124 }
125
126 do_hook("right_main_bottom");
127 sqimap_logout ($imapConnection);
128 ?>
129 </FONT>
130 </BODY>
131 </HTML>