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