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