made more tolerant to malformed from field in message header
[squirrelmail.git] / src / right_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** right_main.php
21c3249f 4 **
3bcede49 5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
21c3249f 8 ** This is where the mailboxes are listed. This controls most of what
9 ** goes on in SquirrelMail.
10 **
245a6892 11 ** $Id$
21c3249f 12 **/
13
ff8a98e7 14 require_once('../src/validate.php');
15 require_once('../functions/imap.php');
16 require_once('../functions/date.php');
17 require_once('../functions/array.php');
18 require_once('../functions/mime.php');
19 require_once('../functions/mailbox_display.php');
20 require_once('../functions/display_messages.php');
dc54c9f2 21
21c3249f 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
21c3249f 37 // open a connection on the imap port (143)
e1469126 38 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21c3249f 39
5c54e435 40 if (isset($newsort) && $newsort != $sort) {
91dc6e4e 41 setPref($data_dir, $username, 'sort', $newsort);
5c54e435 42 }
43
21c3249f 44 // If the page has been loaded without a specific mailbox,
a48fbf9b 45 // send them to the inbox
21c3249f 46 if (!isset($mailbox)) {
91dc6e4e 47 $mailbox = 'INBOX';
e9f8ea4e 48 $startMessage = 1;
21c3249f 49 }
50
cdcaac70 51 // compensate for the UW vulnerability
9d99e49d 52 if ($imap_server_type == 'uw' && (strstr($mailbox, '../') !== false ||
19303888 53 substr($mailbox, 0, 1) == '/')) {
91dc6e4e 54 $mailbox = 'INBOX';
cdcaac70 55 }
56
813eba2f 57 sqimap_mailbox_select($imapConnection, $mailbox);
f8f9bed9 58 displayPageHeader($color, $mailbox);
21c3249f 59
91dc6e4e 60 do_hook('right_main_after_header');
2016e645 61
eaab965a 62 if (isset($note))
63 echo "<CENTER><B>$note</B></CENTER><BR>\n";
64
872fef97 65 if ($just_logged_in == true) {
66 $just_logged_in = false;
2016e645 67
872fef97 68 if (strlen(trim($motd)) > 0) {
2016e645 69 echo "<br><table align=center width=70% cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" .
70 '<tr><td>' .
71 "<table width=100% cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" .
72 "<tr><td align=center>$motd";
73 do_hook('motd');
74 echo '</td></tr>' .
75 '</table>' .
76 '</td></tr></table>';
872fef97 77 }
a37f3771 78 }
79
2016e645 80 if (isset($newsort)) {
81 $sort = $newsort;
82 session_register('sort');
83 }
e452ce9b 84
9f2215a1 85 // Check to see if we can use cache or not. Currently the only time when you wont use it is
86 // when a link on the left hand frame is used. Also check to make sure we actually have the
87 // array in the registered session data. :)
245a6892 88 if (! isset($use_mailbox_cache))
89 $use_mailbox_cache = 0;
91dc6e4e 90 if ($use_mailbox_cache && session_is_registered('msgs')) {
dc54c9f2 91 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
90033b64 92 } else {
91dc6e4e 93 if (session_is_registered('msgs'))
90033b64 94 unset($msgs);
91dc6e4e 95 if (session_is_registered('msort'))
dc54c9f2 96 unset($msort);
2016e645 97 if (session_is_registered('numMessages'))
98 unset($numMessages);
1108e8bb 99
2016e645 100 $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox);
9f2215a1 101
dc54c9f2 102 showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
2016e645 103
91dc6e4e 104 if (session_is_registered('msgs') && isset($msgs))
105 session_register('msgs');
106 if (session_is_registered('msort') && isset($msort))
107 session_register('msort');
108 session_register('numMessages');
90033b64 109 }
21c3249f 110
d53e5562 111 do_hook('right_main_bottom');
813eba2f 112 sqimap_logout ($imapConnection);
21c3249f 113?>
114</FONT>
115</BODY>
eaab965a 116</HTML>