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