fixed bugs with cache
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** right_main.php
21c3249f 4 **
5 ** This is where the mailboxes are listed. This controls most of what
6 ** goes on in SquirrelMail.
7 **
8 **/
9
dc54c9f2 10
2a32fc83 11 session_start();
12
21c3249f 13 if(!isset($logged_in)) {
138f26f6 14 echo _("You must login first.");
21c3249f 15 exit;
16 }
17 if(!isset($username) || !isset($key)) {
b581fa60 18 echo _("You need a valid user and password to access this page!");
21c3249f 19 exit;
20 }
44139266 21
d068c0ec 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");
44139266 40?>
41<HTML>
42<FONT FACE="Arial,Helvetica">
59177427 43<?php
21c3249f 44 /////////////////////////////////////////////////////////////////////////////////
45 //
46 // incoming variables from URL:
47 // $sort Direction to sort by date
48 // values: 0 - descending order
49 // values: 1 - ascending order
50 // $startMessage Message to start at
51 // $mailbox Full Mailbox name
52 //
53 // incoming from cookie:
54 // $username duh
55 // $key pass
56 //
57 /////////////////////////////////////////////////////////////////////////////////
58
21c3249f 59 // open a connection on the imap port (143)
e1469126 60 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21c3249f 61
f3d17401 62 /** If it was a successful login, lets load their preferences **/
63 include("../src/load_prefs.php");
f3d17401 64 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
f3d17401 65
21c3249f 66 // If the page has been loaded without a specific mailbox,
67 // just show a page of general info.
68 if (!isset($mailbox)) {
f8f9bed9 69 displayPageHeader($color, "None");
70 general_info($motd, $org_logo, $version, $org_name, $color);
aa32c5e4 71 echo "</BODY></HTML>";
21c3249f 72 exit;
73 }
74
813eba2f 75 sqimap_mailbox_select($imapConnection, $mailbox);
f8f9bed9 76 displayPageHeader($color, $mailbox);
21c3249f 77
e452ce9b 78 if (isset($newsort)) {
79 $sort = $newsort;
80 session_register("sort");
81 }
82
9f2215a1 83 // Check to see if we can use cache or not. Currently the only time when you wont use it is
84 // when a link on the left hand frame is used. Also check to make sure we actually have the
85 // array in the registered session data. :)
90033b64 86 if ($use_mailbox_cache && session_is_registered("msgs")) {
dc54c9f2 87 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 88 } else {
89 if (session_is_registered("msgs"))
90 unset($msgs);
dc54c9f2 91 if (session_is_registered("msort"))
92 unset($msort);
1108e8bb 93 if (session_is_registered("numMessages"))
94 unset($numMessages);
95
96 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
9f2215a1 97
dc54c9f2 98 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 99
100 if (session_is_registered("msgs") && isset($msgs))
101 session_register("msgs");
dc54c9f2 102 if (session_is_registered("msort") && isset($msort))
103 session_register("msort");
1108e8bb 104 session_register("numMessages");
90033b64 105 }
21c3249f 106
926da13e 107 // close the connection
813eba2f 108 sqimap_logout ($imapConnection);
21c3249f 109?>
110</FONT>
111</BODY>
112</HTML>