21c3249f |
1 | <? |
2 | /** |
3 | ** left_main.php3 |
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.php3"); |
491b3750 |
38 | include("../functions/strings.php3"); |
39 | include("../functions/imap.php3"); |
21c3249f |
40 | |
41 | // ***************************************** |
42 | // Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX |
43 | // ***************************************** |
44 | function findMailboxName($mailbox) { |
45 | // start at -2 so that we skip the initial quote at the end of the mailbox name |
46 | $i = -2; |
47 | $char = substr($mailbox, $i, 1); |
48 | while ($char != "\"") { |
49 | $i--; |
50 | $temp .= $char; |
51 | $char = substr($mailbox, $i, 1); |
52 | } |
53 | return strrev($temp); |
54 | } |
55 | |
56 | // open a connection on the imap port (143) |
57 | $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString); |
58 | if (!$imapConnection) { |
59 | echo "Error connecting to IMAP Server.<br>"; |
60 | echo "$errorNumber : $errorString<br>"; |
61 | exit; |
62 | } |
63 | $serverInfo = fgets($imapConnection, 256); |
64 | |
65 | fputs($imapConnection, "1 login $username $key\n"); |
66 | $read = fgets($imapConnection, 1024); |
67 | |
68 | fputs($imapConnection, "1 list \"\" *\n"); |
69 | $str = imapReadData($imapConnection); |
70 | |
71 | echo "<FONT FACE=\"Arial,Helvetica\"><B>"; |
72 | echo "<CENTER>$org_name</B><BR>"; |
73 | echo "Folders</CENTER>"; |
74 | echo "</B><BR></FONT>"; |
75 | echo "<code><FONT FACE=\"Arial,Helvetica\">\n"; |
76 | for ($i = 0;$i < count($str); $i++) { |
77 | $mailbox = Chop($str[$i]); |
78 | // find the quote at the begining of the mailbox name. |
79 | // i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name. |
80 | $mailbox = findMailboxName($mailbox); |
81 | $periodCount = countCharInString($mailbox, "."); |
82 | |
83 | // indent the correct number of spaces. |
84 | for ($j = 0;$j < $periodCount;$j++) |
85 | echo " "; |
86 | |
87 | $mailboxURL = urlencode($mailbox); |
926da13e |
88 | echo "<a href=\"right_main.php3?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">"; |
21c3249f |
89 | echo readShortMailboxName($mailbox, "."); |
90 | echo "</FONT></a><br>\n"; |
91 | } |
92 | echo "</code></FONT>"; |
93 | |
94 | fclose($imapConnection); |
95 | |
96 | ?> |
97 | </FONT></BODY></HTML> |