updated mime support
[squirrelmail.git] / src / left_main.php
CommitLineData
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");
de80e95e 21 include("../functions/mailbox.php");
21c3249f 22
d92b6f31 23 function formatMailboxName($imapConnection, $mailbox, $delimeter) {
24 require ("../config/config.php");
25
26 $mailboxURL = urlencode($mailbox);
27 selectMailbox($imapConnection, $mailbox, $numNessages);
28 $unseen = unseenMessages($imapConnection, $numUnseen);
29
30 if ($unseen)
31 $line .= "<B>";
32
7ce342dc 33 $special_color = false;
34 for ($i = 0; $i < count($special_folders); $i++) {
35 if (($special_folders[$i] == $mailbox) && ($use_special_folder_color == true))
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]\">";
41 $line .= readShortMailboxName($mailbox, $delimeter);
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\">";
45 $line .= readShortMailboxName($mailbox, $delimeter);
46 $line .= "</font></a>";
d92b6f31 47 }
7ce342dc 48
49 if ($unseen)
50 $line .= "</B>";
51
d92b6f31 52 if ($numUnseen > 0) {
7ce342dc 53 $line .= "&nbsp;<FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
54 }
55
56 if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
57 $urlMailbox = urlencode($mailbox);
58 $line .= "<FONT FACE=\"Arial,Helvetica\" SIZE=2>";
59 $line .= "&nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
60 $line .= "</FONT></a>\n";
d92b6f31 61 }
62 return $line;
63 }
64
f8f9bed9 65 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
66 echo "<FONT FACE=\"Arial,Helvetica\">";
21c3249f 67 // open a connection on the imap port (143)
d92b6f31 68 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
21c3249f 69
7ce342dc 70 getFolderList($imapConnection, $boxes);
21c3249f 71
d92b6f31 72 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
ff89ac8a 73 echo "Folders</B><BR></FONT>";
97afcee9 74
d92b6f31 75 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>";
ff89ac8a 76 echo "<FONT FACE=\"Arial,Helvetica\">\n";
d92b6f31 77 $delimeter = findMailboxDelimeter($imapConnection);
7ce342dc 78 for ($i = 0;$i < count($boxes); $i++) {
79 $mailbox = $boxes[$i]["UNFORMATTED"];
80 $boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
de80e95e 81
d92b6f31 82 $boxCount = countCharInString($mailbox, $delimeter);
83
84 $line = "";
21c3249f 85 // indent the correct number of spaces.
d92b6f31 86 for ($j = 0;$j < $boxCount;$j++)
87 $line .= "&nbsp;&nbsp;";
88
89 if (trim($boxFlags[0]) != "") {
7ce342dc 90 $noselect = false;
d92b6f31 91 for ($h = 0; $h < count($boxFlags); $h++) {
7ce342dc 92 if (strtolower($boxFlags[$h]) == "noselect")
93 $noselect = true;
d92b6f31 94 }
d92b6f31 95
7ce342dc 96 if ($noselect == true) {
97 $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
98 $line .= readShortMailboxName($mailbox, $delimeter);
99 $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
100 } else {
101 $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
d92b6f31 102 }
7ce342dc 103 } else {
104 $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
d92b6f31 105 }
7ce342dc 106 echo "$line<BR>";
d92b6f31 107 }
108
ff89ac8a 109 echo "</FONT>";
21c3249f 110
111 fclose($imapConnection);
112
113?>
114</FONT></BODY></HTML>