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> |
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> |
ff89ac8a |
34 | <BODY BGCOLOR=A0B8C8 TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" onUnLoad="unSetCookies()"> |
21c3249f |
35 | <FONT FACE="Arial,Helvetica"> |
36 | <? |
a09387f4 |
37 | include("../config/config.php"); |
38 | include("../functions/strings.php"); |
39 | include("../functions/imap.php"); |
de80e95e |
40 | include("../functions/mailbox.php"); |
21c3249f |
41 | |
21c3249f |
42 | // open a connection on the imap port (143) |
2aa12d5e |
43 | $imapConnection = loginToImapServer($username, $key, $imapServerAddress); |
21c3249f |
44 | |
45 | fputs($imapConnection, "1 list \"\" *\n"); |
46 | $str = imapReadData($imapConnection); |
47 | |
ff89ac8a |
48 | echo "<FONT FACE=\"Arial,Helvetica\" COLOR=000000 SIZE=4><B><CENTER>"; |
49 | echo "Folders</B><BR></FONT>"; |
50 | echo "<FONT FACE=\"Arial,Helvetica\" COLOR=000000 SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>"; |
51 | echo "<FONT FACE=\"Arial,Helvetica\">\n"; |
21c3249f |
52 | for ($i = 0;$i < count($str); $i++) { |
53 | $mailbox = Chop($str[$i]); |
de80e95e |
54 | $mailbox = findMailboxName($mailbox); |
55 | |
21c3249f |
56 | // find the quote at the begining of the mailbox name. |
57 | // i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name. |
21c3249f |
58 | $periodCount = countCharInString($mailbox, "."); |
59 | |
60 | // indent the correct number of spaces. |
61 | for ($j = 0;$j < $periodCount;$j++) |
62 | echo " "; |
63 | |
64 | $mailboxURL = urlencode($mailbox); |
ff89ac8a |
65 | selectMailbox($imapConnection, $mailbox, $numNessages); |
66 | $unseen = unseenMessages($imapConnection, $numUnseen); |
67 | if ($unseen) |
68 | echo "<B>"; |
a09387f4 |
69 | echo "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">"; |
21c3249f |
70 | echo readShortMailboxName($mailbox, "."); |
8eea5dd3 |
71 | if (($move_to_trash == true) && ($mailbox == $trash_folder)) { |
72 | $urlMailbox = urlencode($mailbox); |
e2370222 |
73 | echo "</A> (<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)"; |
8eea5dd3 |
74 | } |
ff89ac8a |
75 | echo "</FONT></a>\n"; |
76 | if ($numUnseen > 0) { |
77 | echo "</B> </FONT><FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>"; |
78 | } |
79 | echo "<BR>\n"; |
21c3249f |
80 | } |
ff89ac8a |
81 | echo "</FONT>"; |
21c3249f |
82 | |
83 | fclose($imapConnection); |
84 | |
85 | ?> |
86 | </FONT></BODY></HTML> |