Just fixing a bug I ran across where attachments was an empty array.
[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');
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
3392dc86 36$bob = getHashedFile($username, $data_dir, "username.pref");
37
c57b0888 38/* Open a connection on the imap port (143) */
6f223ace 39
c57b0888 40$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
41
bdfb67f8 42if( isset( $PG_SHOWNUM ) ) {
43 $show_num = $PG_SHOWNUM;
44}
45
c57b0888 46if (isset($newsort) && $newsort != $sort) {
47 setPref($data_dir, $username, 'sort', $newsort);
48}
49
e372ee8c 50
51
52/* If the page has been loaded without a specific mailbox, */
53/* send them to the inbox */
54if (!isset($mailbox)) {
55 $mailbox = 'INBOX';
56 $startMessage = 1;
57}
58
59
60if (!isset($startMessage) || ($startMessage == '')) {
61 $startMessage = 1;
62}
63
64/* compensate for the UW vulnerability. */
65if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
66 substr($mailbox, 0, 1) == '/')) {
67 $mailbox = 'INBOX';
68}
69
7c612fdd 70/* decide if we are thread sorting or not */
71global $allow_thread_sort;
72if ($allow_thread_sort == TRUE) {
73 if (isset($set_thread)) {
74 if ($set_thread == 1) {
78cc4b12 75 setPref($data_dir, $username, "thread_$mailbox", 1);
7c612fdd 76 $thread_sort_messages = '1';
77 }
78 elseif ($set_thread == 2) {
78cc4b12 79 setPref($data_dir, $username, "thread_$mailbox", 0);
7c612fdd 80 $thread_sort_messages = '0';
81 }
82 }
83 else {
78cc4b12 84 $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox");
7c612fdd 85 }
86}
87else {
88 $thread_sort_messages = 0;
89}
90
e372ee8c 91global $color;
92if( isset($do_hook) && $do_hook ) {
93 do_hook ("generic_header");
c57b0888 94}
7c612fdd 95
c57b0888 96sqimap_mailbox_select($imapConnection, $mailbox);
6f223ace 97
98if (isset($composenew)) {
99 $width= getPref($username, $data_dir, 'editor_size', 76);
100 if ($width < 65) {
101 $pix_width = 560;
102 } else {
103 $width = (.9*$width);
104 $pix_width = intval($width).'0';
105 }
106 $features = "toolbar=no, width=$pix_width, height=650, scrollbars=yes, resizable=yes target=_blank";
107 $location = 'compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
108 $onload= "window.open(\"$location\",\"compose_window_$session\", \"$features\");";
109 displayPageHeader($color, $mailbox, $onload);
110} else {
111 displayPageHeader($color, $mailbox);
112}
c57b0888 113echo "<br>\n";
114
115do_hook('right_main_after_header');
c57b0888 116if (isset($note)) {
117 echo "<CENTER><B>$note</B></CENTER><BR>\n";
118}
119
120if ($just_logged_in == true) {
121 $just_logged_in = false;
122
123 if (strlen(trim($motd)) > 0) {
bd9bbfef 124 echo "<br><table align=center width=\"70%\" cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" .
c57b0888 125 '<tr><td>' .
bd9bbfef 126 "<table width=\"100%\" cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" .
c57b0888 127 "<tr><td align=center>$motd";
128 do_hook('motd');
129 echo '</td></tr>' .
130 '</table>' .
131 '</td></tr></table>';
23d6bd09 132 }
c57b0888 133}
134
7c612fdd 135if (isset($newsort)) {
136 $sort = $newsort;
137 session_register('sort');
138}
139
c57b0888 140/*********************************************************************
141 * Check to see if we can use cache or not. Currently the only time *
142 * when you will not use it is when a link on the left hand frame is *
143 * used. Also check to make sure we actually have the array in the *
144 * registered session data. :) *
145 *********************************************************************/
146if (! isset($use_mailbox_cache)) {
147 $use_mailbox_cache = 0;
148}
149
d46fbcf8 150/* There is a problem with registered vars in 4.1 */
88cb1b4d 151/*
ae7c2608 152if( substr( phpversion(), 0, 3 ) == '4.1' ) {
d46fbcf8 153 $use_mailbox_cache = FALSE;
154}
88cb1b4d 155*/
d46fbcf8 156
c57b0888 157if ($use_mailbox_cache && session_is_registered('msgs')) {
158 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
159} else {
160 if (session_is_registered('msgs')) {
161 unset($msgs);
23d6bd09 162 }
163
c57b0888 164 if (session_is_registered('msort')) {
165 unset($msort);
23d6bd09 166 }
a37f3771 167
c57b0888 168 if (session_is_registered('numMessages')) {
169 unset($numMessages);
2016e645 170 }
e452ce9b 171
c57b0888 172 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 173
c57b0888 174 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
175 $startMessage, $sort, $color, $show_num,
176 $use_mailbox_cache);
23d6bd09 177
c57b0888 178 if (session_is_registered('msgs') && isset($msgs)) {
179 session_register('msgs');
b831fe0b 180 $_SESSION['msgs'] = $msgs;
c57b0888 181 }
1108e8bb 182
c57b0888 183 if (session_is_registered('msort') && isset($msort)) {
184 session_register('msort');
b831fe0b 185 $_SESSION['msort'] = $msort;
c57b0888 186 }
9f2215a1 187
c57b0888 188 session_register('numMessages');
b831fe0b 189 $_SESSION['numMessages'] = $numMessages;
c57b0888 190}
c57b0888 191do_hook('right_main_bottom');
192sqimap_logout ($imapConnection);
23d6bd09 193
bd9bbfef 194echo '</BODY></HTML>';
21c3249f 195
b831fe0b 196?>