f8a2afab |
1 | <? |
2 | if(!isset($username)) { |
3 | echo "You need a valid user and password to access this page!"; |
4 | exit; |
5 | } |
6 | ?> |
7 | <HTML> |
8 | <HEAD> |
9 | <SCRIPT LANGUAGE="JavaScript"> |
10 | function DeleteCookie (name) { |
11 | var exp = new Date(); |
12 | exp.setTime (exp.getTime() - 1); |
13 | // This cookie is history |
14 | var cval = GetCookie (name); |
15 | document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); |
16 | } |
17 | |
18 | function unSetCookies() { |
19 | DeleteCookie('username'); |
20 | DeleteCookie('key'); |
21 | DeleteCookie('logged_in'); |
22 | alert(document.cookie); |
23 | } |
24 | </SCRIPT> |
25 | </HEAD> |
26 | <BODY BGCOLOR=A0B8C8 TEXT="#000000" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE" onUnLoad="unSetCookies()"> |
27 | <FONT FACE="Arial,Helvetica"> |
28 | <? |
29 | include("config/config.php3"); |
30 | include("functions/strings.php3"); |
31 | include("functions/imap.php3"); |
32 | |
33 | // ***************************************** |
34 | // Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX |
35 | // ***************************************** |
36 | function findMailboxName($mailbox) { |
37 | // start at -2 so that we skip the initial quote at the end of the mailbox name |
38 | $i = -2; |
39 | $char = substr($mailbox, $i, 1); |
40 | while ($char != "\"") { |
41 | $i--; |
42 | $temp .= $char; |
43 | $char = substr($mailbox, $i, 1); |
44 | } |
45 | return strrev($temp); |
46 | } |
47 | |
48 | // open a connection on the imap port (143) |
49 | $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString); |
50 | if (!$imapConnection) { |
51 | echo "Error connecting to IMAP Server.<br>"; |
52 | echo "$errorNumber : $errorString<br>"; |
53 | exit; |
54 | } |
55 | $serverInfo = fgets($imapConnection, 256); |
56 | |
57 | fputs($imapConnection, "1 login $username $key\n"); |
58 | $read = fgets($imapConnection, 1024); |
59 | |
60 | fputs($imapConnection, "1 list \"\" *\n"); |
61 | $str = imapReadData($imapConnection); |
62 | |
63 | echo "<FONT FACE=\"Arial,Helvetica\"><B>"; |
64 | echo "<CENTER>$org_name</B><BR>"; |
65 | echo "Folders</CENTER>"; |
66 | echo "</B><BR></FONT>"; |
67 | echo "<code><FONT FACE=\"Arial,Helvetica\">\n"; |
68 | for ($i = 0;$i < count($str); $i++) { |
69 | $mailbox = Chop($str[$i]); |
70 | // find the quote at the begining of the mailbox name. |
71 | // i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name. |
72 | $mailbox = findMailboxName($mailbox); |
73 | $periodCount = countCharInString($mailbox, "."); |
74 | |
75 | // indent the correct number of spaces. |
76 | for ($j = 0;$j < $periodCount;$j++) |
77 | echo " "; |
78 | |
79 | $mailboxURL = urlencode($mailbox); |
80 | echo "<a href=\"mailboxMessageList.php3?sort=0&startMessage=0&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">"; |
81 | echo readShortMailboxName($mailbox, "."); |
82 | echo "</FONT></a><br>\n"; |
83 | } |
84 | echo "</code></FONT>"; |
85 | |
86 | fclose($imapConnection); |
87 | |
88 | ?> |
89 | </FONT></BODY></HTML> |