7b7ec043a66d59175e1a7d9f9e476b01b75ac8bd
[squirrelmail.git] / src / folders.php
1 <HTML><BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
2 <?
3 include("../config/config.php");
4 include("../functions/strings.php");
5 include("../functions/page_header.php");
6 include("../functions/imap.php");
7 include("../functions/mailbox.php");
8
9 displayPageHeader("None");
10
11 echo "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
12 echo " <TR><TD BGCOLOR=DCDCDC ALIGN=CENTER>\n";
13 echo " <FONT FACE=\"Arial,Helvetica\">Folders</FONT>\n";
14 echo " </TD></TR>\n";
15 echo "</TABLE>\n";
16
17 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
18
19 fputs($imapConnection, "1 list \"\" *\n");
20 $str = imapReadData($imapConnection);
21
22 for ($i = 0;$i < count($str); $i++) {
23 $mailbox = Chop($str[$i]);
24 // find the quote at the begining of the mailbox name.
25 // i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name.
26 $mailbox = findMailboxName($mailbox);
27 $periodCount = countCharInString($mailbox, ".");
28
29 // indent the correct number of spaces.
30 for ($j = 0;$j < $periodCount;$j++)
31 $boxes[$i] = "$boxes[$i]&nbsp;&nbsp;&nbsp;";
32
33 $boxes[$i] = $boxes[$i] . readShortMailboxName($mailbox, ".");
34 $long_name_boxes[$i] = $mailbox;
35 }
36
37 /** DELETING FOLDERS **/
38
39 echo "<FORM ACTION=folders_delete.php METHOD=POST>\n";
40 echo "<SELECT NAME=mailbox><FONT FACE=\"Arial,Helvetica\">\n";
41 for ($i = 0; $i < count($str); $i++) {
42 $thisbox = Chop($str[$i]);
43 $thisbox = findMailboxName($thisbox);
44 $use_folder = true;
45 for ($p = 0; $p < count($special_folders); $p++) {
46 if ($special_folders[$p] == $long_name_boxes[$i])
47 $use_folder = false;
48 }
49 if ($use_folder == true)
50 echo " <OPTION>$thisbox\n";
51 }
52 echo "</SELECT>\n";
53 echo "<INPUT TYPE=SUBMIT VALUE=Delete>\n";
54 echo "</FORM><BR>\n";
55
56 /** CREATING FOLDERS **/
57 echo "<FORM ACTION=folders_create.php METHOD=POST>\n";
58 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name>\n";
59 echo "&nbsp;&nbsp;as a subfolder of&nbsp;&nbsp;";
60 echo "<SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
61 for ($i = 0;$i < count($str); $i++) {
62 $thisbox = Chop($str[$i]);
63 $thisbox = findMailboxName($thisbox);
64 $thisbox = getFolderNameMinusINBOX($thisbox);
65 echo "<OPTION>$thisbox\n";
66 }
67 echo "</SELECT>\n";
68 echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
69 echo "</FORM><BR>\n";
70
71 /** RENAMING FOLDERS **/
72 echo "<FORM ACTION=folders_rename.php METHOD=POST>\n";
73 echo "<SELECT NAME=folder_list><FONT FACE=\"Arial,Helvetica\">\n";
74 for ($i = 0; $i < count($str); $i++) {
75 $use_folder = true;
76 for ($p = 0; $p < count($special_folders); $p++) {
77 if ($special_folders[$p] == $long_name_boxes[$i])
78 $use_folder = false;
79 }
80 if ($use_folder == true)
81 echo " <OPTION>$boxes[$i]\n";
82 }
83 echo "</SELECT>\n";
84 echo "<INPUT TYPE=TEXT SIZE=25 NAME=new_folder_name>\n";
85 echo "<INPUT TYPE=SUBMIT VALUE=Rename>\n";
86 echo "</FORM><BR>\n";
87
88 ?>
89 </BODY></HTML>