| 1 | <?php |
| 2 | /** |
| 3 | ** left_main.php |
| 4 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
| 5 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
| 6 | ** |
| 7 | ** This is the code for the left bar. The left bar shows the folders |
| 8 | ** available, and has cookie information. |
| 9 | ** |
| 10 | **/ |
| 11 | |
| 12 | session_start(); |
| 13 | |
| 14 | if(!isset($username)) { |
| 15 | echo "You need a valid user and password to access this page!"; |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | |
| 20 | if (!isset($config_php)) |
| 21 | include("../config/config.php"); |
| 22 | if (!isset($array_php)) |
| 23 | include("../functions/array.php"); |
| 24 | if (!isset($strings_php)) |
| 25 | include("../functions/strings.php"); |
| 26 | if (!isset($imap_php)) |
| 27 | include("../functions/imap.php"); |
| 28 | if (!isset($page_header_php)) |
| 29 | include("../functions/page_header.php"); |
| 30 | if (!isset($i18n_php)) |
| 31 | include("../functions/i18n.php"); |
| 32 | if (!isset($plugin_php)) |
| 33 | include("../functions/plugin.php"); |
| 34 | |
| 35 | // open a connection on the imap port (143) |
| 36 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output |
| 37 | |
| 38 | /** If it was a successful login, lets load their preferences **/ |
| 39 | include("../src/load_prefs.php"); |
| 40 | |
| 41 | displayHtmlHeader(); |
| 42 | |
| 43 | function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) { |
| 44 | global $folder_prefix, $trash_folder, $sent_folder; |
| 45 | global $color, $move_to_sent, $move_to_trash; |
| 46 | global $unseen_notify, $unseen_type; |
| 47 | |
| 48 | $mailboxURL = urlencode($real_box); |
| 49 | |
| 50 | if ($unseen_notify == 2 && $real_box == "INBOX") { |
| 51 | $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box); |
| 52 | if ($unseen_type == 1 && $unseen > 0) { |
| 53 | $unseen_string = "($unseen)"; |
| 54 | $unseen_found = true; |
| 55 | } else if ($unseen_type == 2) { |
| 56 | $numMessages = sqimap_get_num_messages($imapConnection, $real_box); |
| 57 | $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>"; |
| 58 | $unseen_found = true; |
| 59 | } |
| 60 | } else if ($unseen_notify == 3) { |
| 61 | $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box); |
| 62 | if ($unseen_type == 1 && $unseen > 0) { |
| 63 | $unseen_string = "($unseen)"; |
| 64 | $unseen_found = true; |
| 65 | } else if ($unseen_type == 2) { |
| 66 | $numMessages = sqimap_get_num_messages($imapConnection, $real_box); |
| 67 | $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>"; |
| 68 | $unseen_found = true; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | $line .= "<NOBR>"; |
| 73 | if ($unseen > 0) |
| 74 | $line .= "<B>"; |
| 75 | |
| 76 | $special_color = false; |
| 77 | if ((strtolower($real_box) == "inbox") || |
| 78 | (($real_box == $trash_folder) && ($move_to_trash)) || |
| 79 | (($real_box == $sent_folder) && ($move_to_sent))) |
| 80 | $special_color = true; |
| 81 | |
| 82 | if ($special_color == true) { |
| 83 | $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">"; |
| 84 | $line .= replace_spaces($mailbox); |
| 85 | $line .= "</font></a>"; |
| 86 | } else { |
| 87 | $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
| 88 | $line .= replace_spaces($mailbox); |
| 89 | $line .= "</a>"; |
| 90 | } |
| 91 | |
| 92 | if ($unseen > 0) |
| 93 | $line .= "</B>"; |
| 94 | |
| 95 | if ($unseen_found) { |
| 96 | $line .= " <small>$unseen_string</small>"; |
| 97 | } |
| 98 | |
| 99 | if (($move_to_trash == true) && ($real_box == $trash_folder)) { |
| 100 | $urlMailbox = urlencode($real_box); |
| 101 | $line .= "\n<small>\n"; |
| 102 | $line .= " (<B><A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A></B>)"; |
| 103 | $line .= "\n</small>\n"; |
| 104 | } |
| 105 | $line .= "</NOBR>"; |
| 106 | return $line; |
| 107 | } |
| 108 | |
| 109 | if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) { |
| 110 | echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n"; |
| 111 | echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
| 112 | echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n"; |
| 113 | } |
| 114 | |
| 115 | echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n\n"; |
| 116 | |
| 117 | do_hook("left_main_before"); |
| 118 | |
| 119 | $boxes = sqimap_mailbox_list($imapConnection); |
| 120 | |
| 121 | echo "<CENTER><FONT SIZE=4><B>"; |
| 122 | echo _("Folders") . "</B><BR></FONT>\n\n"; |
| 123 | |
| 124 | echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">"; |
| 125 | echo _("refresh folder list"); |
| 126 | echo "</A>)</small></CENTER><BR>"; |
| 127 | $delimeter = sqimap_get_delimiter($imapConnection); |
| 128 | |
| 129 | for ($i = 0;$i < count($boxes); $i++) { |
| 130 | $line = ""; |
| 131 | $mailbox = $boxes[$i]["formatted"]; |
| 132 | |
| 133 | if ($boxes[$i]["flags"]) { |
| 134 | $noselect = false; |
| 135 | for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) { |
| 136 | if (strtolower($boxes[$i]["flags"][$h]) == "noselect") |
| 137 | $noselect = true; |
| 138 | } |
| 139 | if ($noselect == true) { |
| 140 | $line .= "<FONT COLOR=\"$color[10]\">"; |
| 141 | $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter)); |
| 142 | $line .= "</FONT>"; |
| 143 | } else { |
| 144 | $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]); |
| 145 | } |
| 146 | } else { |
| 147 | $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]); |
| 148 | } |
| 149 | echo "\n$line<BR>\n"; |
| 150 | } |
| 151 | sqimap_logout($imapConnection); |
| 152 | do_hook("left_main_after"); |
| 153 | ?> |
| 154 | </BODY></HTML> |