| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * right_main.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2002 The SquirrelMail Project 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 | |
| 15 | require_once('../src/validate.php'); |
| 16 | require_once('../functions/imap.php'); |
| 17 | require_once('../functions/date.php'); |
| 18 | require_once('../functions/array.php'); |
| 19 | require_once('../functions/mime.php'); |
| 20 | require_once('../functions/mailbox_display.php'); |
| 21 | require_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 | $bob = getHashedFile($username, $data_dir, "username.pref"); |
| 37 | |
| 38 | /* Open a connection on the imap port (143) */ |
| 39 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
| 40 | |
| 41 | if( isset( $PG_SHOWNUM ) ) { |
| 42 | $show_num = $PG_SHOWNUM; |
| 43 | } |
| 44 | |
| 45 | if (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 */ |
| 51 | if (!isset($mailbox)) { |
| 52 | $mailbox = 'INBOX'; |
| 53 | $startMessage = 1; |
| 54 | } |
| 55 | |
| 56 | if (!isset($startMessage) || ($startMessage == '')) { |
| 57 | $startMessage = 1; |
| 58 | } |
| 59 | |
| 60 | /* compensate for the UW vulnerability. */ |
| 61 | if ($imap_server_type == 'uw' && (strstr($mailbox, '../') || |
| 62 | substr($mailbox, 0, 1) == '/')) { |
| 63 | $mailbox = 'INBOX'; |
| 64 | } |
| 65 | |
| 66 | sqimap_mailbox_select($imapConnection, $mailbox); |
| 67 | displayPageHeader($color, $mailbox); |
| 68 | echo "<br>\n"; |
| 69 | |
| 70 | do_hook('right_main_after_header'); |
| 71 | |
| 72 | if (isset($note)) { |
| 73 | echo "<CENTER><B>$note</B></CENTER><BR>\n"; |
| 74 | } |
| 75 | |
| 76 | if ($just_logged_in == true) { |
| 77 | $just_logged_in = false; |
| 78 | |
| 79 | if (strlen(trim($motd)) > 0) { |
| 80 | echo "<br><table align=center width=\"70%\" cellpadding=0 cellspacing=3 border=0 bgcolor=\"$color[9]\">" . |
| 81 | '<tr><td>' . |
| 82 | "<table width=\"100%\" cellpadding=5 cellspacing=1 border=0 bgcolor=\"$color[4]\">" . |
| 83 | "<tr><td align=center>$motd"; |
| 84 | do_hook('motd'); |
| 85 | echo '</td></tr>' . |
| 86 | '</table>' . |
| 87 | '</td></tr></table>'; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if (isset($newsort)) { |
| 92 | $sort = $newsort; |
| 93 | session_register('sort'); |
| 94 | } |
| 95 | |
| 96 | /********************************************************************* |
| 97 | * Check to see if we can use cache or not. Currently the only time * |
| 98 | * when you will not use it is when a link on the left hand frame is * |
| 99 | * used. Also check to make sure we actually have the array in the * |
| 100 | * registered session data. :) * |
| 101 | *********************************************************************/ |
| 102 | if (! isset($use_mailbox_cache)) { |
| 103 | $use_mailbox_cache = 0; |
| 104 | } |
| 105 | |
| 106 | /* There is a problem with registered vars in 4.1 */ |
| 107 | /* |
| 108 | if( substr( phpversion(), 0, 3 ) == '4.1' ) { |
| 109 | $use_mailbox_cache = FALSE; |
| 110 | } |
| 111 | */ |
| 112 | |
| 113 | if ($use_mailbox_cache && session_is_registered('msgs')) { |
| 114 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache); |
| 115 | } else { |
| 116 | if (session_is_registered('msgs')) { |
| 117 | unset($msgs); |
| 118 | } |
| 119 | |
| 120 | if (session_is_registered('msort')) { |
| 121 | unset($msort); |
| 122 | } |
| 123 | |
| 124 | if (session_is_registered('numMessages')) { |
| 125 | unset($numMessages); |
| 126 | } |
| 127 | |
| 128 | $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); |
| 129 | |
| 130 | showMessagesForMailbox($imapConnection, $mailbox, $numMessages, |
| 131 | $startMessage, $sort, $color, $show_num, |
| 132 | $use_mailbox_cache); |
| 133 | |
| 134 | if (session_is_registered('msgs') && isset($msgs)) { |
| 135 | session_register('msgs'); |
| 136 | $_SESSION['msgs'] = $msgs; |
| 137 | } |
| 138 | |
| 139 | if (session_is_registered('msort') && isset($msort)) { |
| 140 | session_register('msort'); |
| 141 | $_SESSION['msort'] = $msort; |
| 142 | } |
| 143 | |
| 144 | session_register('numMessages'); |
| 145 | $_SESSION['numMessages'] = $numMessages; |
| 146 | } |
| 147 | |
| 148 | do_hook('right_main_bottom'); |
| 149 | sqimap_logout ($imapConnection); |
| 150 | |
| 151 | echo '</BODY></HTML>'; |
| 152 | |
| 153 | ?> |