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