| 1 | <?php |
| 2 | /** |
| 3 | ** right_main.php |
| 4 | ** |
| 5 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
| 6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | ** |
| 8 | ** This is where the mailboxes are listed. This controls most of what |
| 9 | ** goes on in SquirrelMail. |
| 10 | ** |
| 11 | ** $Id$ |
| 12 | **/ |
| 13 | |
| 14 | include('../src/validate.php'); |
| 15 | include('../functions/imap.php'); |
| 16 | include('../functions/date.php'); |
| 17 | include('../functions/page_header.php'); |
| 18 | include('../functions/array.php'); |
| 19 | include('../functions/mime.php'); |
| 20 | include('../functions/mailbox_display.php'); |
| 21 | include('../functions/display_messages.php'); |
| 22 | |
| 23 | ?> |
| 24 | <?php |
| 25 | ///////////////////////////////////////////////////////////////////////////////// |
| 26 | // |
| 27 | // incoming variables from URL: |
| 28 | // $sort Direction to sort by date |
| 29 | // values: 0 - descending order |
| 30 | // values: 1 - ascending order |
| 31 | // $startMessage Message to start at |
| 32 | // $mailbox Full Mailbox name |
| 33 | // |
| 34 | // incoming from cookie: |
| 35 | // $username duh |
| 36 | // $key pass |
| 37 | // |
| 38 | ///////////////////////////////////////////////////////////////////////////////// |
| 39 | |
| 40 | // open a connection on the imap port (143) |
| 41 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
| 42 | |
| 43 | /** If it was a successful login, lets load their preferences **/ |
| 44 | include('../src/load_prefs.php'); |
| 45 | |
| 46 | if (isset($newsort) && $newsort != $sort) { |
| 47 | setPref($data_dir, $username, 'sort', $newsort); |
| 48 | } |
| 49 | |
| 50 | // If the page has been loaded without a specific mailbox, |
| 51 | // send them to the inbox |
| 52 | if (!isset($mailbox)) { |
| 53 | $mailbox = 'INBOX'; |
| 54 | $startMessage = 1; |
| 55 | } |
| 56 | |
| 57 | // compensate for the UW vulnerability |
| 58 | if ($imap_server_type == 'uw' && (strstr($mailbox, '../') !== false || |
| 59 | substr($mailbox, 0, 1) == '/')) { |
| 60 | $mailbox = 'INBOX'; |
| 61 | } |
| 62 | |
| 63 | sqimap_mailbox_select($imapConnection, $mailbox); |
| 64 | displayPageHeader($color, $mailbox); |
| 65 | |
| 66 | do_hook('right_main_after_header'); |
| 67 | |
| 68 | if (isset($just_logged_in) && $just_logged_in == 1 && |
| 69 | strlen(trim($motd)) > 0) { |
| 70 | echo "<center><br>\n"; |
| 71 | echo "<table width=70% cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=\"$color[9]\">\n"; |
| 72 | echo "<table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor=\"$color[4]\">\n"; |
| 73 | echo "$motd\n"; |
| 74 | echo "</td></tr></table>\n"; |
| 75 | echo "</td></tr></table>\n"; |
| 76 | echo "</center><br>\n"; |
| 77 | } |
| 78 | |
| 79 | if (isset($newsort)) { |
| 80 | $sort = $newsort; |
| 81 | session_register('sort'); |
| 82 | } |
| 83 | |
| 84 | // Check to see if we can use cache or not. Currently the only time when you wont use it is |
| 85 | // when a link on the left hand frame is used. Also check to make sure we actually have the |
| 86 | // array in the registered session data. :) |
| 87 | if (! isset($use_mailbox_cache)) |
| 88 | $use_mailbox_cache = 0; |
| 89 | if ($use_mailbox_cache && session_is_registered('msgs')) { |
| 90 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); |
| 91 | } else { |
| 92 | if (session_is_registered('msgs')) |
| 93 | unset($msgs); |
| 94 | if (session_is_registered('msort')) |
| 95 | unset($msort); |
| 96 | if (session_is_registered('numMessages')) |
| 97 | unset($numMessages); |
| 98 | |
| 99 | $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); |
| 100 | |
| 101 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); |
| 102 | |
| 103 | if (session_is_registered('msgs') && isset($msgs)) |
| 104 | session_register('msgs'); |
| 105 | if (session_is_registered('msort') && isset($msort)) |
| 106 | session_register('msort'); |
| 107 | session_register('numMessages'); |
| 108 | } |
| 109 | |
| 110 | do_hook('right_main_bottom'); |
| 111 | sqimap_logout ($imapConnection); |
| 112 | ?> |
| 113 | </FONT> |
| 114 | </BODY> |
| 115 | </HTML> |