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