Next/Previous are working a bit better
[squirrelmail.git] / src / right_main.php3
CommitLineData
21c3249f 1<?
2 /**
3 ** right_main.php3
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 <a href=\"login.php3\">login</a> first.";
12 exit;
13 }
14 if(!isset($username) || !isset($key)) {
15 echo "You need a valid user and password to access this page!";
16 exit;
17 }
18?>
19<HTML>
20<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
21<FONT FACE="Arial,Helvetica">
22<?
23 include("../config/config.php3");
491b3750 24 include("../functions/imap.php3");
25 include("../functions/strings.php3");
26 include("../functions/date.php3");
27 include("../functions/page_header.php3");
28 include("../functions/array.php3");
29 include("../functions/mailbox.php3");
30 include("../functions/mailbox_display.php3");
31 include("../functions/display_messages.php3");
21c3249f 32
33 /////////////////////////////////////////////////////////////////////////////////
34 //
35 // incoming variables from URL:
36 // $sort Direction to sort by date
37 // values: 0 - descending order
38 // values: 1 - ascending order
39 // $startMessage Message to start at
40 // $mailbox Full Mailbox name
41 //
42 // incoming from cookie:
43 // $username duh
44 // $key pass
45 //
46 /////////////////////////////////////////////////////////////////////////////////
47
48
49 // open a connection on the imap port (143)
50 $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
51 if (!$imapConnection) {
52 echo "Error connecting to IMAP Server.<br>";
53 echo "$errorNumber : $errorString<br>";
54 exit;
55 }
56 $serverInfo = fgets($imapConnection, 256);
57
58 // login
59 fputs($imapConnection, "1 login $username $key\n");
60 $read = fgets($imapConnection, 1024);
61 if (strpos($read, "NO")) {
62 error_username_password_incorrect();
63 exit;
64 }
65
66 // If the page has been loaded without a specific mailbox,
67 // just show a page of general info.
68 if (!isset($mailbox)) {
69 displayPageHeader("None");
70 general_info($motd, $org_logo, $version, $org_name);
71 exit;
72 }
73
74
75 // switch to the mailbox, and get the number of messages in it.
76 selectMailbox($imapConnection, $mailbox, $numMessages);
54a8ae32 77// $numMessages = $numMessages - 1; // I did this so it's 0 based like the message array
21c3249f 78
79 // make a URL safe $mailbox for use in the links
80 $urlMailbox = urlencode($mailbox);
21c3249f 81
926da13e 82 // Display the header at the top of the page
83 displayPageHeader($mailbox);
21c3249f 84
926da13e 85 // Get the list of messages for this mailbox
926da13e 86 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort);
21c3249f 87
926da13e 88 // close the connection
21c3249f 89 fclose($imapConnection);
90?>
91</FONT>
92</BODY>
93</HTML>