086ec0821fefb7bfd170ee3af4e0742ff76f4571
[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 <HEAD>
17 <SCRIPT LANGUAGE="JavaScript">
18 function DeleteCookie (name) {
19 var exp = new Date();
20 exp.setTime (exp.getTime() - 1);
21 // This cookie is history
22 var cval = GetCookie (name);
23 document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
24 }
25
26 function unSetCookies() {
27 DeleteCookie('username');
28 DeleteCookie('key');
29 DeleteCookie('logged_in');
30 alert(document.cookie);
31 }
32 </SCRIPT>
33 </HEAD>
34 <BODY BGCOLOR=A0B8C8 TEXT="#000000" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE" onUnLoad="unSetCookies()">
35 <FONT FACE="Arial,Helvetica">
36 <?
37 include("../config/config.php");
38 include("../functions/strings.php");
39 include("../functions/imap.php");
40
41 // open a connection on the imap port (143)
42 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
43
44 fputs($imapConnection, "1 list \"\" *\n");
45 $str = imapReadData($imapConnection);
46
47 echo "<FONT FACE=\"Arial,Helvetica\"><B>";
48 echo "<CENTER>$org_name</B><BR>";
49 echo "Folders</CENTER>";
50 echo "</B><BR></FONT>";
51 echo "<code><FONT FACE=\"Arial,Helvetica\">\n";
52 for ($i = 0;$i < count($str); $i++) {
53 $mailbox = Chop($str[$i]);
54 // find the quote at the begining of the mailbox name.
55 // i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name.
56 $mailbox = findMailboxName($mailbox);
57 $periodCount = countCharInString($mailbox, ".");
58
59 // indent the correct number of spaces.
60 for ($j = 0;$j < $periodCount;$j++)
61 echo "&nbsp;&nbsp;";
62
63 $mailboxURL = urlencode($mailbox);
64 echo "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
65 echo readShortMailboxName($mailbox, ".");
66 echo "</FONT></a><br>\n";
67 }
68 echo "</code></FONT>";
69
70 fclose($imapConnection);
71
72 ?>
73 </FONT></BODY></HTML>