Rewrote imap functions
[squirrelmail.git] / src / right_main.php
1 <?
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 if(!isset($logged_in)) {
11 echo _("You must ");
12 echo "<a href=\"login.php\">";
13 echo _("login");
14 echo "</a>";
15 echo _(" first.");
16 exit;
17 }
18 if(!isset($username) || !isset($key)) {
19 echo _("You need a valid user and password to access this page!");
20 exit;
21 }
22 ?>
23 <HTML>
24 <FONT FACE="Arial,Helvetica">
25 <?
26 include("../config/config.php");
27 include("../functions/imap.php");
28 include("../functions/strings.php");
29 include("../functions/date.php");
30 include("../functions/page_header.php");
31 include("../functions/array.php");
32 include("../functions/mailbox_display.php");
33 include("../functions/display_messages.php");
34
35 /////////////////////////////////////////////////////////////////////////////////
36 //
37 // incoming variables from URL:
38 // $sort Direction to sort by date
39 // values: 0 - descending order
40 // values: 1 - ascending order
41 // $startMessage Message to start at
42 // $mailbox Full Mailbox name
43 //
44 // incoming from cookie:
45 // $username duh
46 // $key pass
47 //
48 /////////////////////////////////////////////////////////////////////////////////
49
50 // open a connection on the imap port (143)
51 $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
52
53 /** If it was a successful login, lets load their preferences **/
54 include("../src/load_prefs.php");
55 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
56 echo "<FONT FACE=\"Arial,Helvetica\">";
57
58 // If the page has been loaded without a specific mailbox,
59 // just show a page of general info.
60 if (!isset($mailbox)) {
61 displayPageHeader($color, "None");
62 general_info($motd, $org_logo, $version, $org_name, $color);
63 echo "</BODY></HTML>";
64 exit;
65 }
66
67 sqimap_mailbox_select($imapConnection, $mailbox);
68 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
69 displayPageHeader($color, $mailbox);
70
71 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color);
72
73 // close the connection
74 sqimap_logout ($imapConnection);
75 ?>
76 </FONT>
77 </BODY>
78 </HTML>