Added minimum GNU License
[squirrelmail.git] / src / left_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** left_main.php
ef870322 4 ** Copyright (c) 1999-2000 The SquirrelMail development team
5 ** Licensed under the GNU GPL. For full terms see the file COPYING.
21c3249f 6 **
7 ** This is the code for the left bar. The left bar shows the folders
8 ** available, and has cookie information.
9 **
10 **/
11
2a32fc83 12 session_start();
13
21c3249f 14 if(!isset($username)) {
15 echo "You need a valid user and password to access this page!";
16 exit;
17 }
142499d4 18
207dff25 19
d068c0ec 20 if (!isset($config_php))
21 include("../config/config.php");
22 if (!isset($array_php))
23 include("../functions/array.php");
24 if (!isset($strings_php))
25 include("../functions/strings.php");
26 if (!isset($imap_php))
27 include("../functions/imap.php");
142499d4 28 if (!isset($page_header_php))
29 include("../functions/page_header.php");
9c1852ff 30 if (!isset($i18n_php))
31 include("../functions/i18n.php");
32
142499d4 33
2a833d72 34 displayHtmlHeader();
21c3249f 35
d1941f35 36 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) {
1e0628fb 37 global $folder_prefix, $trash_folder, $sent_folder;
38 global $color, $move_to_sent, $move_to_trash;
d92b6f31 39
4c34dac5 40 $mailboxURL = urlencode($real_box);
4bbba0d8 41 if($real_box=="INBOX") {
42 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
43 }
d92b6f31 44
1d4fe45e 45 $line .= "<NOBR>";
d1941f35 46 if ($unseen > 0)
d92b6f31 47 $line .= "<B>";
48
7ce342dc 49 $special_color = false;
1e0628fb 50 if ((strtolower($real_box) == "inbox") ||
51 (($real_box == $trash_folder) && ($move_to_trash)) ||
52 (($real_box == $sent_folder) && ($move_to_sent)))
53 $special_color = true;
7ce342dc 54
55 if ($special_color == true) {
9f2215a1 56 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">";
813eba2f 57 $line .= replace_spaces($mailbox);
7ce342dc 58 $line .= "</font></a>";
59 } else {
9f2215a1 60 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
813eba2f 61 $line .= replace_spaces($mailbox);
1d4fe45e 62 $line .= "</a>";
d92b6f31 63 }
7ce342dc 64
d1941f35 65 if ($unseen > 0)
7ce342dc 66 $line .= "</B>";
67
d1941f35 68 if ($unseen > 0) {
69 $line .= "&nbsp;<small>($unseen)</small>";
7ce342dc 70 }
71
1e0628fb 72 if (($move_to_trash == true) && ($real_box == $trash_folder)) {
0ab89329 73 $urlMailbox = urlencode($real_box);
1d4fe45e 74 $line .= "\n<small>\n";
75 $line .= " &nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">"._("purge")."</A></B>)";
76 $line .= "\n</small>\n";
d92b6f31 77 }
1d4fe45e 78 $line .= "</NOBR>";
d92b6f31 79 return $line;
80 }
81
21c3249f 82 // open a connection on the imap port (143)
e1469126 83 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
21c3249f 84
f3d17401 85 /** If it was a successful login, lets load their preferences **/
86 include("../src/load_prefs.php");
9c1852ff 87
4c34dac5 88 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
1d4fe45e 89 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n";
90 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
91 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
469eb37b 92 }
813eba2f 93
1d4fe45e 94 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n\n";
f3d17401 95
813eba2f 96 $boxes = sqimap_mailbox_list($imapConnection);
21c3249f 97
1d4fe45e 98 echo "<CENTER><FONT SIZE=4><B>";
99 echo _("Folders") . "</B><BR></FONT>\n\n";
97afcee9 100
9f2215a1 101 echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
ad6f805c 102 echo _("refresh folder list");
aae41ae9 103 echo "</A>)</small></CENTER><BR>";
813eba2f 104 $delimeter = sqimap_get_delimiter($imapConnection);
4c34dac5 105
7ce342dc 106 for ($i = 0;$i < count($boxes); $i++) {
d92b6f31 107 $line = "";
813eba2f 108 $mailbox = $boxes[$i]["formatted"];
d92b6f31 109
813eba2f 110 if ($boxes[$i]["flags"]) {
7ce342dc 111 $noselect = false;
813eba2f 112 for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
113 if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
7ce342dc 114 $noselect = true;
d92b6f31 115 }
7ce342dc 116 if ($noselect == true) {
aae41ae9 117 $line .= "<FONT COLOR=\"$color[10]\">";
813eba2f 118 $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter));
aae41ae9 119 $line .= "</FONT>";
7ce342dc 120 } else {
d1941f35 121 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
d92b6f31 122 }
7ce342dc 123 } else {
d1941f35 124 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
d92b6f31 125 }
1d4fe45e 126 echo "\n$line<BR>\n";
d92b6f31 127 }
128
21c3249f 129
130 fclose($imapConnection);
b9d121d2 131
21c3249f 132?>
aae41ae9 133</BODY></HTML>