21c3249f |
1 | <? |
2 | /** |
a09387f4 |
3 | ** left_main.php |
21c3249f |
4 | ** |
5 | ** This is the code for the left bar. The left bar shows the folders |
6 | ** available, and has cookie information. |
7 | ** |
8 | **/ |
9 | |
10 | if(!isset($username)) { |
11 | echo "You need a valid user and password to access this page!"; |
12 | exit; |
13 | } |
14 | ?> |
15 | <HTML> |
21c3249f |
16 | <? |
d068c0ec |
17 | if (!isset($config_php)) |
18 | include("../config/config.php"); |
19 | if (!isset($array_php)) |
20 | include("../functions/array.php"); |
21 | if (!isset($strings_php)) |
22 | include("../functions/strings.php"); |
23 | if (!isset($imap_php)) |
24 | include("../functions/imap.php"); |
21c3249f |
25 | |
91f999f6 |
26 | function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) { |
d92b6f31 |
27 | require ("../config/config.php"); |
28 | |
4c34dac5 |
29 | $mailboxURL = urlencode($real_box); |
813eba2f |
30 | sqimap_mailbox_select ($imapConnection, $real_box); |
31 | $unseen = sqimap_unseen_messages($imapConnection, $numUnseen); |
d92b6f31 |
32 | |
97be2168 |
33 | echo "<NOBR>"; |
d92b6f31 |
34 | if ($unseen) |
35 | $line .= "<B>"; |
36 | |
7ce342dc |
37 | $special_color = false; |
38 | for ($i = 0; $i < count($special_folders); $i++) { |
f16d469a |
39 | if (($special_folders[$i] == $real_box) && ($use_special_folder_color == true)) |
7ce342dc |
40 | $special_color = true; |
41 | } |
42 | |
43 | if ($special_color == true) { |
aae41ae9 |
44 | $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">"; |
813eba2f |
45 | $line .= replace_spaces($mailbox); |
7ce342dc |
46 | $line .= "</font></a>"; |
47 | } else { |
aae41ae9 |
48 | $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
813eba2f |
49 | $line .= replace_spaces($mailbox); |
7ce342dc |
50 | $line .= "</font></a>"; |
d92b6f31 |
51 | } |
7ce342dc |
52 | |
53 | if ($unseen) |
54 | $line .= "</B>"; |
55 | |
d92b6f31 |
56 | if ($numUnseen > 0) { |
aae41ae9 |
57 | $line .= " <small>($numUnseen)</small>"; |
7ce342dc |
58 | } |
59 | |
0ab89329 |
60 | if (($move_to_trash == true) && (trim($real_box) == $trash_folder)) { |
61 | $urlMailbox = urlencode($real_box); |
aae41ae9 |
62 | $line .= "<small>"; |
b6def0e7 |
63 | $line .= " (<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">"._("purge")."</A></B>)"; |
aae41ae9 |
64 | $line .= "</small></a>\n"; |
d92b6f31 |
65 | } |
97be2168 |
66 | |
67 | echo "</NOBR>"; |
d92b6f31 |
68 | return $line; |
69 | } |
70 | |
21c3249f |
71 | // open a connection on the imap port (143) |
813eba2f |
72 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, 10); // the 10 is to hide the output |
21c3249f |
73 | |
f3d17401 |
74 | /** If it was a successful login, lets load their preferences **/ |
75 | include("../src/load_prefs.php"); |
4c34dac5 |
76 | if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) { |
aff57ea5 |
77 | echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">"; |
78 | echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">"; |
469eb37b |
79 | echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">"; |
80 | } |
813eba2f |
81 | |
f3d17401 |
82 | echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">"; |
f3d17401 |
83 | |
813eba2f |
84 | $boxes = sqimap_mailbox_list($imapConnection); |
21c3249f |
85 | |
aae41ae9 |
86 | echo "<FONT SIZE=4><B><CENTER>"; |
813eba2f |
87 | echo _("Folders") . "</B><BR></FONT>"; |
97afcee9 |
88 | |
aae41ae9 |
89 | echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">"; |
ad6f805c |
90 | echo _("refresh folder list"); |
aae41ae9 |
91 | echo "</A>)</small></CENTER><BR>"; |
813eba2f |
92 | $delimeter = sqimap_get_delimiter($imapConnection); |
4c34dac5 |
93 | |
7ce342dc |
94 | for ($i = 0;$i < count($boxes); $i++) { |
d92b6f31 |
95 | $line = ""; |
813eba2f |
96 | $mailbox = $boxes[$i]["formatted"]; |
d92b6f31 |
97 | |
813eba2f |
98 | if ($boxes[$i]["flags"]) { |
7ce342dc |
99 | $noselect = false; |
813eba2f |
100 | for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) { |
101 | if (strtolower($boxes[$i]["flags"][$h]) == "noselect") |
7ce342dc |
102 | $noselect = true; |
d92b6f31 |
103 | } |
7ce342dc |
104 | if ($noselect == true) { |
aae41ae9 |
105 | $line .= "<FONT COLOR=\"$color[10]\">"; |
813eba2f |
106 | $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter)); |
aae41ae9 |
107 | $line .= "</FONT>"; |
7ce342dc |
108 | } else { |
813eba2f |
109 | $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash); |
d92b6f31 |
110 | } |
7ce342dc |
111 | } else { |
813eba2f |
112 | $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash); |
d92b6f31 |
113 | } |
7ce342dc |
114 | echo "$line<BR>"; |
d92b6f31 |
115 | } |
116 | |
21c3249f |
117 | |
118 | fclose($imapConnection); |
119 | |
120 | ?> |
aae41ae9 |
121 | </BODY></HTML> |