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