Cleanup work.
[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
54 /* compensate for the UW vulnerability. */
55 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
56 substr($mailbox, 0, 1) == '/')) {
57 $mailbox = 'INBOX';
58 }
59
60 sqimap_mailbox_select($imapConnection, $mailbox);
61 displayPageHeader($color, $mailbox);
62 echo "<br>\n";
63
64 do_hook('right_main_after_header');
65
66 if (isset($note)) {
67 echo "<CENTER><B>$note</B></CENTER><BR>\n";
68 }
69
70 if ($just_logged_in == true) {
71 $just_logged_in = false;
72
73 if (strlen(trim($motd)) > 0) {
74 echo "<br><table align=center width=70% cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" .
75 '<tr><td>' .
76 "<table width=100% cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" .
77 "<tr><td align=center>$motd";
78 do_hook('motd');
79 echo '</td></tr>' .
80 '</table>' .
81 '</td></tr></table>';
82 }
83 }
84
85 if (isset($newsort)) {
86 $sort = $newsort;
87 session_register('sort');
88 }
89
90 /*********************************************************************
91 * Check to see if we can use cache or not. Currently the only time *
92 * when you will not use it is when a link on the left hand frame is *
93 * used. Also check to make sure we actually have the array in the *
94 * registered session data. :) *
95 *********************************************************************/
96 if (! isset($use_mailbox_cache)) {
97 $use_mailbox_cache = 0;
98 }
99
100 if ($use_mailbox_cache && session_is_registered('msgs')) {
101 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
102 } else {
103 if (session_is_registered('msgs')) {
104 unset($msgs);
105 }
106
107 if (session_is_registered('msort')) {
108 unset($msort);
109 }
110
111 if (session_is_registered('numMessages')) {
112 unset($numMessages);
113 }
114
115 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
116
117 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
118 $startMessage, $sort, $color, $show_num,
119 $use_mailbox_cache);
120
121 if (session_is_registered('msgs') && isset($msgs)) {
122 session_register('msgs');
123 }
124
125 if (session_is_registered('msort') && isset($msort)) {
126 session_register('msort');
127 }
128
129 session_register('numMessages');
130 }
131
132 do_hook('right_main_bottom');
133 sqimap_logout ($imapConnection);
134
135 echo '/FONT></BODY></HTML>';
136
137 ?>