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