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