Fixed login crash
[squirrelmail.git] / src / right_main.php
1 <?php
2
3 /**
4 ** right_main.php
5 **
6 ** Copyright (c) 1999-2001 The Squirrelmail Development Team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 **
9 ** This is where the mailboxes are listed. This controls most of what
10 ** goes on in SquirrelMail.
11 **
12 ** $Id$
13 **/
14
15 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/date.php');
18 require_once('../functions/array.php');
19 require_once('../functions/mime.php');
20 require_once('../functions/mailbox_display.php');
21 require_once('../functions/display_messages.php');
22
23 /***********************************************************
24 * incoming variables from URL: *
25 * $sort Direction to sort by date *
26 * values: 0 - descending order *
27 * values: 1 - ascending order *
28 * $startMessage Message to start at *
29 * $mailbox Full Mailbox name *
30 * *
31 * incoming from cookie: *
32 * $username duh *
33 * $key pass *
34 ***********************************************************/
35
36 /* Open a connection on the imap port (143) */
37 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
38
39 if (isset($newsort) && $newsort != $sort) {
40 setPref($data_dir, $username, 'sort', $newsort);
41 }
42
43 /* If the page has been loaded without a specific mailbox, */
44 /* send them to the inbox */
45 if (!isset($mailbox)) {
46 $mailbox = 'INBOX';
47 $startMessage = 1;
48 }
49
50 if (! isset($startMessage) || $startMessage == '')
51 $startMessage = 1;
52
53 /* compensate for the UW vulnerability. */
54 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
55 substr($mailbox, 0, 1) == '/')) {
56 $mailbox = 'INBOX';
57 }
58
59 sqimap_mailbox_select($imapConnection, $mailbox);
60 displayPageHeader($color, $mailbox);
61 echo "<br>\n";
62
63 do_hook('right_main_after_header');
64
65 if (isset($note)) {
66 echo "<CENTER><B>$note</B></CENTER><BR>\n";
67 }
68
69 if ($just_logged_in == true) {
70 $just_logged_in = false;
71
72 if (strlen(trim($motd)) > 0) {
73 echo "<br><table align=center width=70% cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" .
74 '<tr><td>' .
75 "<table width=100% cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" .
76 "<tr><td align=center>$motd";
77 do_hook('motd');
78 echo '</td></tr>' .
79 '</table>' .
80 '</td></tr></table>';
81 }
82 }
83
84 if (isset($newsort)) {
85 $sort = $newsort;
86 session_register('sort');
87 }
88
89 /*********************************************************************
90 * Check to see if we can use cache or not. Currently the only time *
91 * when you will not use it is when a link on the left hand frame is *
92 * used. Also check to make sure we actually have the array in the *
93 * registered session data. :) *
94 *********************************************************************/
95 if (! isset($use_mailbox_cache)) {
96 $use_mailbox_cache = 0;
97 }
98
99 if ($use_mailbox_cache && session_is_registered('msgs')) {
100 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
101 } else {
102 if (session_is_registered('msgs')) {
103 unset($msgs);
104 }
105
106 if (session_is_registered('msort')) {
107 unset($msort);
108 }
109
110 if (session_is_registered('numMessages')) {
111 unset($numMessages);
112 }
113
114 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
115
116 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
117 $startMessage, $sort, $color, $show_num,
118 $use_mailbox_cache);
119
120 if (session_is_registered('msgs') && isset($msgs)) {
121 session_register('msgs');
122 }
123
124 if (session_is_registered('msort') && isset($msort)) {
125 session_register('msort');
126 }
127
128 session_register('numMessages');
129 }
130
131 do_hook('right_main_bottom');
132 sqimap_logout ($imapConnection);
133 ?>
134 </FONT>
135 </BODY>
136 </HTML>