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