global.php
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
895905c0 2
c57b0888 3/**
4 * right_main.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
c57b0888 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
15require_once('../src/validate.php');
16require_once('../functions/imap.php');
17require_once('../functions/date.php');
18require_once('../functions/array.php');
19require_once('../functions/mime.php');
20require_once('../functions/mailbox_display.php');
21require_once('../functions/display_messages.php');
fab3baa6 22require_once('../functions/html.php');
c57b0888 23
24/***********************************************************
25 * incoming variables from URL: *
26 * $sort Direction to sort by date *
27 * values: 0 - descending order *
28 * values: 1 - ascending order *
29 * $startMessage Message to start at *
30 * $mailbox Full Mailbox name *
31 * *
32 * incoming from cookie: *
33 * $username duh *
34 * $key pass *
35 ***********************************************************/
36
37/* Open a connection on the imap port (143) */
6f223ace 38
c57b0888 39$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40
cf710efe 41global $PG_SHOWNUM;
42if (isset($PG_SHOWALL)) {
43 if ($PG_SHOWALL) {
44 $PG_SHOWNUM=999999;
45 $show_num=$PG_SHOWNUM;
46 session_register('PG_SHOWNUM');
47 }
48 else {
49 session_unregister('PG_SHOWNUM');
50 unset($PG_SHOWNUM);
51 }
52}
53else if( isset( $PG_SHOWNUM ) ) {
bdfb67f8 54 $show_num = $PG_SHOWNUM;
55}
56
c57b0888 57if (isset($newsort) && $newsort != $sort) {
58 setPref($data_dir, $username, 'sort', $newsort);
59}
60
e372ee8c 61
62
63/* If the page has been loaded without a specific mailbox, */
64/* send them to the inbox */
65if (!isset($mailbox)) {
66 $mailbox = 'INBOX';
67 $startMessage = 1;
68}
69
70
71if (!isset($startMessage) || ($startMessage == '')) {
72 $startMessage = 1;
73}
74
75/* compensate for the UW vulnerability. */
76if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
77 substr($mailbox, 0, 1) == '/')) {
78 $mailbox = 'INBOX';
79}
80
7c612fdd 81/* decide if we are thread sorting or not */
82global $allow_thread_sort;
794d59c0 83if ($allow_thread_sort == TRUE) {
7c612fdd 84 if (isset($set_thread)) {
85 if ($set_thread == 1) {
78cc4b12 86 setPref($data_dir, $username, "thread_$mailbox", 1);
7c612fdd 87 $thread_sort_messages = '1';
88 }
89 elseif ($set_thread == 2) {
78cc4b12 90 setPref($data_dir, $username, "thread_$mailbox", 0);
7c612fdd 91 $thread_sort_messages = '0';
92 }
93 }
94 else {
78cc4b12 95 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
7c612fdd 96 }
97}
98else {
99 $thread_sort_messages = 0;
100}
101
e372ee8c 102global $color;
11af81b9 103
104do_hook ("generic_header");
7c612fdd 105
c57b0888 106sqimap_mailbox_select($imapConnection, $mailbox);
6f223ace 107
31b32433 108if (isset($composenew) && $composenew) {
d7f8e6e6 109 $comp_uri = "../src/compose.php?mailbox=". urlencode($mailbox).
11af81b9 110 "&amp;session=$composesession";
111 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
6f223ace 112} else {
113 displayPageHeader($color, $mailbox);
114}
c57b0888 115echo "<br>\n";
c57b0888 116do_hook('right_main_after_header');
c57b0888 117if (isset($note)) {
fab3baa6 118 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
c57b0888 119}
120
121if ($just_logged_in == true) {
122 $just_logged_in = false;
123
124 if (strlen(trim($motd)) > 0) {
fab3baa6 125 echo html_tag( 'table',
126 html_tag( 'tr',
6b4bd11f 127 html_tag( 'td',
fab3baa6 128 html_tag( 'table',
129 html_tag( 'tr',
130 html_tag( 'td', $motd, 'center' )
131 ) ,
132 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
133 )
134 ) ,
135 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
23d6bd09 136 }
c57b0888 137}
138
7c612fdd 139if (isset($newsort)) {
140 $sort = $newsort;
141 session_register('sort');
142}
143
c57b0888 144/*********************************************************************
145 * Check to see if we can use cache or not. Currently the only time *
146 * when you will not use it is when a link on the left hand frame is *
147 * used. Also check to make sure we actually have the array in the *
148 * registered session data. :) *
149 *********************************************************************/
150if (! isset($use_mailbox_cache)) {
151 $use_mailbox_cache = 0;
152}
153
d46fbcf8 154/* There is a problem with registered vars in 4.1 */
88cb1b4d 155/*
ae7c2608 156if( substr( phpversion(), 0, 3 ) == '4.1' ) {
d46fbcf8 157 $use_mailbox_cache = FALSE;
158}
88cb1b4d 159*/
d46fbcf8 160
c57b0888 161if ($use_mailbox_cache && session_is_registered('msgs')) {
162 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
163} else {
164 if (session_is_registered('msgs')) {
165 unset($msgs);
23d6bd09 166 }
167
c57b0888 168 if (session_is_registered('msort')) {
169 unset($msort);
23d6bd09 170 }
a37f3771 171
c57b0888 172 if (session_is_registered('numMessages')) {
173 unset($numMessages);
2016e645 174 }
e452ce9b 175
c57b0888 176 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 177
c57b0888 178 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
179 $startMessage, $sort, $color, $show_num,
180 $use_mailbox_cache);
23d6bd09 181
c57b0888 182 if (session_is_registered('msgs') && isset($msgs)) {
183 session_register('msgs');
b831fe0b 184 $_SESSION['msgs'] = $msgs;
c57b0888 185 }
1108e8bb 186
c57b0888 187 if (session_is_registered('msort') && isset($msort)) {
188 session_register('msort');
b831fe0b 189 $_SESSION['msort'] = $msort;
c57b0888 190 }
9f2215a1 191
c57b0888 192 session_register('numMessages');
b831fe0b 193 $_SESSION['numMessages'] = $numMessages;
c57b0888 194}
c57b0888 195do_hook('right_main_bottom');
196sqimap_logout ($imapConnection);
23d6bd09 197
fab3baa6 198echo '</body></html>';
21c3249f 199
978d53dc 200?>