fix for unidentified reply-to header lines.
[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: *
c57b0888 37 * $key pass *
a32985a5 38 * incoming from session: *
39 * $username duh *
40 * *
c57b0888 41 ***********************************************************/
42
a32985a5 43
44/* lets get the global vars we may need */
45$username = $_SESSION['username'];
46$key = $_COOKIE['key'];
47$onetimepad = $_SESSION['onetimepad'];
48$base_uri = $_SESSION['base_uri'];
49$delimiter = $_SESSION['delimiter'];
50
51if (isset($_GET['startMessage'])) {
52 $startMessage = $_GET['startMessage'];
cd9a4fd3 53} elseif (isset($_POST['startMessage'])) {
54 $startMessage = $_POST['startMessage'];
a32985a5 55}
56if (isset($_GET['mailbox'])) {
57 $mailbox = $_GET['mailbox'];
cd9a4fd3 58} else if (isset($_POST['mailbox'])) {
59 $mailbox = $_POST['mailbox'];
a32985a5 60}
61if (isset($_GET['PG_SHOWNUM'])) {
62 $PG_SHOWNUM = $_GET['PG_SHOWNUM'];
63}
64elseif (isset($_SESSION['PG_SHOWNUM'])) {
65 $PG_SHOWNUM = $_SESSION['PG_SHOWNUM'];
66}
67if (isset($_GET['PG_SHOWALL'])) {
68 $PG_SHOWALL = $_GET['PG_SHOWALL'];
69}
70if (isset($_GET['newsort'])) {
71 $newsort = $_GET['newsort'];
72}
8cc72ada 73if (isset($_GET['composenew'])) {
74 $composenew = $_GET['composenew'];
75} else {
76 $composenew = false;
77}
78
a32985a5 79if (isset($_GET['checkall'])) {
80 $checkall = $_GET['checkall'];
81}
82if (isset($_GET['set_thread'])) {
83 $set_thread = $_GET['set_thread'];
84}
85if (isset($_SESSION['lastTargetMailbox'])) {
86 $lastTargetMailbox =$_SESSION['lastTargetMailbox'];
87}
88
8cc72ada 89if (isset($_GET['session'])) {
90 $session = $_GET['session'];
91}
92
93
a32985a5 94/* end of get globals */
95
96
c57b0888 97/* Open a connection on the imap port (143) */
6f223ace 98
c57b0888 99$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
100
cf710efe 101if (isset($PG_SHOWALL)) {
102 if ($PG_SHOWALL) {
103 $PG_SHOWNUM=999999;
104 $show_num=$PG_SHOWNUM;
a32985a5 105 sqsession_register($PG_SHOWNUM, 'PG_SHOWNUM');
cf710efe 106 }
107 else {
a32985a5 108 sqsession_unregister('PG_SHOWNUM');
cf710efe 109 unset($PG_SHOWNUM);
110 }
111}
112else if( isset( $PG_SHOWNUM ) ) {
bdfb67f8 113 $show_num = $PG_SHOWNUM;
114}
115
c57b0888 116if (isset($newsort) && $newsort != $sort) {
117 setPref($data_dir, $username, 'sort', $newsort);
118}
119
e372ee8c 120
121
122/* If the page has been loaded without a specific mailbox, */
123/* send them to the inbox */
124if (!isset($mailbox)) {
125 $mailbox = 'INBOX';
126 $startMessage = 1;
127}
128
129
130if (!isset($startMessage) || ($startMessage == '')) {
131 $startMessage = 1;
132}
133
134/* compensate for the UW vulnerability. */
135if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
136 substr($mailbox, 0, 1) == '/')) {
137 $mailbox = 'INBOX';
138}
139
7c612fdd 140/* decide if we are thread sorting or not */
794d59c0 141if ($allow_thread_sort == TRUE) {
7c612fdd 142 if (isset($set_thread)) {
143 if ($set_thread == 1) {
78cc4b12 144 setPref($data_dir, $username, "thread_$mailbox", 1);
7c612fdd 145 $thread_sort_messages = '1';
146 }
147 elseif ($set_thread == 2) {
78cc4b12 148 setPref($data_dir, $username, "thread_$mailbox", 0);
7c612fdd 149 $thread_sort_messages = '0';
150 }
151 }
152 else {
78cc4b12 153 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
7c612fdd 154 }
155}
156else {
157 $thread_sort_messages = 0;
158}
159
a32985a5 160do_hook ('generic_header');
7c612fdd 161
c57b0888 162sqimap_mailbox_select($imapConnection, $mailbox);
6f223ace 163
8cc72ada 164if ($composenew) {
165 $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox).
0cb19b37 166 "&session=$session";
11af81b9 167 displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);
6f223ace 168} else {
169 displayPageHeader($color, $mailbox);
170}
c57b0888 171do_hook('right_main_after_header');
c57b0888 172if (isset($note)) {
fab3baa6 173 echo html_tag( 'div', '<b>' . $note .'</b>', 'center' ) . "<br>\n";
c57b0888 174}
175
a32985a5 176if (isset($_SESSION['just_logged_in'])) {
177 $just_logged_in = $_SESSION['just_logged_in'];
178 if ($just_logged_in == true) {
179 $just_logged_in = false;
180
181 if (strlen(trim($motd)) > 0) {
182 echo html_tag( 'table',
183 html_tag( 'tr',
184 html_tag( 'td',
185 html_tag( 'table',
186 html_tag( 'tr',
187 html_tag( 'td', $motd, 'center' )
188 ) ,
189 '', $color[4], 'width="100%" cellpadding="5" cellspacing="1" border="0"' )
190 )
191 ) ,
192 'center', $color[9], 'width="70%" cellpadding="0" cellspacing="3" border="0"' );
193 }
23d6bd09 194 }
c57b0888 195}
196
7c612fdd 197if (isset($newsort)) {
198 $sort = $newsort;
a32985a5 199 sqsession_register($sort, 'sort');
7c612fdd 200}
201
c57b0888 202/*********************************************************************
203 * Check to see if we can use cache or not. Currently the only time *
204 * when you will not use it is when a link on the left hand frame is *
205 * used. Also check to make sure we actually have the array in the *
206 * registered session data. :) *
207 *********************************************************************/
208if (! isset($use_mailbox_cache)) {
209 $use_mailbox_cache = 0;
210}
211
d7c82551 212if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
c57b0888 213 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
214} else {
d7c82551 215 if (sqsession_is_registered('msgs')) {
c57b0888 216 unset($msgs);
23d6bd09 217 }
218
d7c82551 219 if (sqsession_is_registered('msort')) {
c57b0888 220 unset($msort);
23d6bd09 221 }
a37f3771 222
d7c82551 223 if (sqsession_is_registered('numMessages')) {
c57b0888 224 unset($numMessages);
2016e645 225 }
e452ce9b 226
c57b0888 227 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 228
c57b0888 229 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
230 $startMessage, $sort, $color, $show_num,
231 $use_mailbox_cache);
23d6bd09 232
d7c82551 233 if (sqsession_is_registered('msgs') && isset($msgs)) {
a32985a5 234 sqsession_register($msgs, 'msgs');
b831fe0b 235 $_SESSION['msgs'] = $msgs;
c57b0888 236 }
1108e8bb 237
d7c82551 238 if (sqsession_is_registered('msort') && isset($msort)) {
a32985a5 239 sqsession_register($msort, 'msort');
b831fe0b 240 $_SESSION['msort'] = $msort;
c57b0888 241 }
9f2215a1 242
a32985a5 243 sqsession_register($numMessages, 'numMessages');
b831fe0b 244 $_SESSION['numMessages'] = $numMessages;
c57b0888 245}
c57b0888 246do_hook('right_main_bottom');
247sqimap_logout ($imapConnection);
23d6bd09 248
fab3baa6 249echo '</body></html>';
21c3249f 250
978d53dc 251?>