*** empty log message ***
[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) */
39$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40
bdfb67f8 41if( isset( $PG_SHOWNUM ) ) {
42 $show_num = $PG_SHOWNUM;
43}
44
c57b0888 45if (isset($newsort) && $newsort != $sort) {
46 setPref($data_dir, $username, 'sort', $newsort);
47}
48
49/* If the page has been loaded without a specific mailbox, */
50/* send them to the inbox */
51if (!isset($mailbox)) {
52 $mailbox = 'INBOX';
53 $startMessage = 1;
54}
55
56if (!isset($startMessage) || ($startMessage == '')) {
57 $startMessage = 1;
58}
59
60/* compensate for the UW vulnerability. */
61if ($imap_server_type == 'uw' && (strstr($mailbox, '../') ||
62 substr($mailbox, 0, 1) == '/')) {
63 $mailbox = 'INBOX';
64}
65
66sqimap_mailbox_select($imapConnection, $mailbox);
5e7f6ef6 67if( strtolower( $mailbox ) == 'inbox' ) {
68 displayPageHeader($color, _("INBOX"));
69} else {
70 displayPageHeader($color, $mailbox);
71}
c57b0888 72echo "<br>\n";
73
74do_hook('right_main_after_header');
75
76if (isset($note)) {
77 echo "<CENTER><B>$note</B></CENTER><BR>\n";
78}
79
80if ($just_logged_in == true) {
81 $just_logged_in = false;
82
83 if (strlen(trim($motd)) > 0) {
bd9bbfef 84 echo "<br><table align=center width=\"70%\" cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" .
c57b0888 85 '<tr><td>' .
bd9bbfef 86 "<table width=\"100%\" cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" .
c57b0888 87 "<tr><td align=center>$motd";
88 do_hook('motd');
89 echo '</td></tr>' .
90 '</table>' .
91 '</td></tr></table>';
23d6bd09 92 }
c57b0888 93}
94
95if (isset($newsort)) {
96 $sort = $newsort;
97 session_register('sort');
98}
99
100/*********************************************************************
101 * Check to see if we can use cache or not. Currently the only time *
102 * when you will not use it is when a link on the left hand frame is *
103 * used. Also check to make sure we actually have the array in the *
104 * registered session data. :) *
105 *********************************************************************/
106if (! isset($use_mailbox_cache)) {
107 $use_mailbox_cache = 0;
108}
109
d46fbcf8 110/* There is a problem with registered vars in 4.1 */
88cb1b4d 111/*
ae7c2608 112if( substr( phpversion(), 0, 3 ) == '4.1' ) {
d46fbcf8 113 $use_mailbox_cache = FALSE;
114}
88cb1b4d 115*/
d46fbcf8 116
c57b0888 117if ($use_mailbox_cache && session_is_registered('msgs')) {
118 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
119} else {
120 if (session_is_registered('msgs')) {
121 unset($msgs);
23d6bd09 122 }
123
c57b0888 124 if (session_is_registered('msort')) {
125 unset($msort);
23d6bd09 126 }
a37f3771 127
c57b0888 128 if (session_is_registered('numMessages')) {
129 unset($numMessages);
2016e645 130 }
e452ce9b 131
c57b0888 132 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
23d6bd09 133
c57b0888 134 showMessagesForMailbox($imapConnection, $mailbox, $numMessages,
135 $startMessage, $sort, $color, $show_num,
136 $use_mailbox_cache);
23d6bd09 137
c57b0888 138 if (session_is_registered('msgs') && isset($msgs)) {
139 session_register('msgs');
140 }
1108e8bb 141
c57b0888 142 if (session_is_registered('msort') && isset($msort)) {
143 session_register('msort');
144 }
9f2215a1 145
c57b0888 146 session_register('numMessages');
147}
2016e645 148
c57b0888 149do_hook('right_main_bottom');
150sqimap_logout ($imapConnection);
23d6bd09 151
bd9bbfef 152echo '</BODY></HTML>';
21c3249f 153
5e7f6ef6 154?>