Little bit of tidying up
[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);
76b684a5 48 $sort = $newsort;
49 session_register('sort');
c57b0888 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
59if (!isset($startMessage) || ($startMessage == '')) {
60 $startMessage = 1;
61}
62
63/* compensate for the UW vulnerability. */
64if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
65 substr($mailbox, 0, 1) == '/')) {
66 $mailbox = 'INBOX';
67}
76b684a5 68global $color;
6f223ace 69
76b684a5 70if( isset($do_hook) && $do_hook ) {
71 do_hook ("generic_header");
72}
c57b0888 73
74sqimap_mailbox_select($imapConnection, $mailbox);
6f223ace 75
76if (isset($composenew)) {
77 $width= getPref($username, $data_dir, 'editor_size', 76);
78 if ($width < 65) {
79 $pix_width = 560;
80 } else {
81 $width = (.9*$width);
82 $pix_width = intval($width).'0';
83 }
84 $features = "toolbar=no, width=$pix_width, height=650, scrollbars=yes, resizable=yes target=_blank";
85 $location = 'compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session";
86 $onload= "window.open(\"$location\",\"compose_window_$session\", \"$features\");";
87 displayPageHeader($color, $mailbox, $onload);
88} else {
89 displayPageHeader($color, $mailbox);
90}
c57b0888 91echo "<br>\n";
92
93do_hook('right_main_after_header');
94
95if (isset($note)) {
96 echo "<CENTER><B>$note</B></CENTER><BR>\n";
97}
98
99if ($just_logged_in == true) {
100 $just_logged_in = false;
101
102 if (strlen(trim($motd)) > 0) {
bd9bbfef 103 echo "<br><table align=center width=\"70%\" cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" .
c57b0888 104 '<tr><td>' .
bd9bbfef 105 "<table width=\"100%\" cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" .
c57b0888 106 "<tr><td align=center>$motd";
107 do_hook('motd');
108 echo '</td></tr>' .
109 '</table>' .
110 '</td></tr></table>';
23d6bd09 111 }
c57b0888 112}
113
c57b0888 114/*********************************************************************
115 * Check to see if we can use cache or not. Currently the only time *
116 * when you will not use it is when a link on the left hand frame is *
117 * used. Also check to make sure we actually have the array in the *
118 * registered session data. :) *
119 *********************************************************************/
120if (! isset($use_mailbox_cache)) {
121 $use_mailbox_cache = 0;
122}
123
d46fbcf8 124/* There is a problem with registered vars in 4.1 */
88cb1b4d 125/*
ae7c2608 126if( substr( phpversion(), 0, 3 ) == '4.1' ) {
d46fbcf8 127 $use_mailbox_cache = FALSE;
128}
88cb1b4d 129*/
d46fbcf8 130
c57b0888 131if ($use_mailbox_cache && session_is_registered('msgs')) {
132 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
133} else {
134 if (session_is_registered('msgs')) {
135 unset($msgs);
23d6bd09 136 }
137
c57b0888 138 if (session_is_registered('msort')) {
139 unset($msort);
23d6bd09 140 }
a37f3771 141
c57b0888 142 if (session_is_registered('numMessages')) {
143 unset($numMessages);
2016e645 144 }
e452ce9b 145
c57b0888 146 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 147
c57b0888 148 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
149 $startMessage, $sort, $color, $show_num,
150 $use_mailbox_cache);
23d6bd09 151
c57b0888 152 if (session_is_registered('msgs') && isset($msgs)) {
153 session_register('msgs');
b831fe0b 154 $_SESSION['msgs'] = $msgs;
c57b0888 155 }
1108e8bb 156
c57b0888 157 if (session_is_registered('msort') && isset($msort)) {
158 session_register('msort');
b831fe0b 159 $_SESSION['msort'] = $msort;
c57b0888 160 }
9f2215a1 161
c57b0888 162 session_register('numMessages');
b831fe0b 163 $_SESSION['numMessages'] = $numMessages;
c57b0888 164}
2016e645 165
c57b0888 166do_hook('right_main_bottom');
167sqimap_logout ($imapConnection);
23d6bd09 168
bd9bbfef 169echo '</BODY></HTML>';
21c3249f 170
b831fe0b 171?>