}
$GLOBALS["col"] = $col; // Column or Columns as an array
$GLOBALS["dir"] = $dir; // Direction, a positive number for ascending a negative for descending
-
- function comp2($a,$b,$i = 0) {
+
+ usort($ary,comp2);
+ return $ary;
+ }
+
+ function comp2($a,$b,$i = 0) {
global $col;
global $dir;
$c = count($col) -1;
}
return $r;
}
-
- usort($ary,comp2);
- return $ary;
- }
?>
if ($handle_errors == true) {
if ($response == "NO") {
- echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>: Could not complete request.</B> </FONT><BR><FONT COLOR=CC0000> <B>Reason given:</B> $message</FONT><BR><BR>";
+ echo "<BR><B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>: Could not complete request.</B> </FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000> <B>Reason given:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
exit;
} else if ($response == "BAD") {
- echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>: Bad or malformed request.</B></FONT><BR><FONT COLOR=CC0000> <B>Server responded:</B> $message</FONT><BR><BR>";
+ echo "<BR><B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>: Bad or malformed request.</B></FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000> <B>Server responded:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
exit;
}
}
$data = imapReadData($imapConnection, "1", false, $response, $message);
if ($response == "NO") {
- echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>: Could not complete request.</B> </FONT><BR><FONT COLOR=CC0000> <B>Reason given:</B> $message</FONT><BR><BR>";
- echo "Possible solutions:<BR><LI>You may need to specify that the folder is a subfolder of INBOX</LI>";
+ echo "<BR><B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>: Could not complete request.</B> </FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000> <B>Reason given:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
+ echo "<FONT FACE=\"Arial,Helvetica\">Possible solutions:<BR><LI>You may need to specify that the folder is a subfolder of INBOX</LI>";
+ echo "<LI>Try renaming the folder to something different.</LI>";
exit;
} else if ($response == "BAD") {
- echo "<B><FONT COLOR=FF0000>ERROR</FONT><FONT COLOR=CC0000>: Bad or malformed request.</B></FONT><BR><FONT COLOR=CC0000> <B>Server responded:</B> $message</FONT><BR><BR>";
+ echo "<B><FONT FACE=\"Arial,Helvetica\" COLOR=FF0000>ERROR</FONT FACE=\"Arial,Helvetica\"><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000>: Bad or malformed request.</B></FONT FACE=\"Arial,Helvetica\"><BR><FONT FACE=\"Arial,Helvetica\" COLOR=CC0000> <B>Server responded:</B> $message</FONT FACE=\"Arial,Helvetica\"><BR><BR>";
exit;
}
}
}
/** Sends back two arrays, boxesFormatted and boxesUnformatted **/
- function getFolderList($imapConnection, &$boxesFormatted, &$boxesUnformatted, &$boxesRaw) {
+ function getFolderList($imapConnection, &$boxes) {
+ require ("../config/config.php");
+
fputs($imapConnection, "1 list \"\" *\n");
$str = imapReadData($imapConnection, "1", true, $response, $message);
$dm = findMailboxDelimeter($imapConnection);
+ $g = 0;
for ($i = 0;$i < count($str); $i++) {
$mailbox = chop($str[$i]);
- $boxesRaw[$i] = $mailbox;
+ if (substr(findMailboxName($mailbox), 0, 1) != ".") {
+ $boxes[$g]["RAW"] = $mailbox;
- $mailbox = findMailboxName($mailbox);
- $periodCount = countCharInString($mailbox, $dm);
+ $mailbox = findMailboxName($mailbox);
+ $periodCount = countCharInString($mailbox, $dm);
- // indent the correct number of spaces.
- for ($j = 0;$j < $periodCount;$j++)
- $boxesFormatted[$i] = "$boxesFormatted[$i] ";
+ // indent the correct number of spaces.
+ for ($j = 0;$j < $periodCount;$j++)
+ $boxes[$g]["FORMATTED"] = $boxes[$g]["FORMATTED"] . " ";
- $boxesFormatted[$i] = $boxesFormatted[$i] . readShortMailboxName($mailbox, $dm);
- $boxesUnformatted[$i] = $mailbox;
+ $boxes[$g]["FORMATTED"] = $boxes[$g]["FORMATTED"] . readShortMailboxName($mailbox, $dm);
+ $boxes[$g]["UNFORMATTED"] = $mailbox;
+ $boxes[$g]["ID"] = $g;
+ $g++;
+ }
}
+
+ $original = $boxes;
+
+ for ($i = 0; $i < count($original); $i++) {
+ $boxes[$i]["UNFORMATTED"] = strtolower($boxes[$i]["UNFORMATTED"]);
+ }
+
+ $boxes = ary_sort($boxes, "UNFORMATTED", 1);
+
+ for ($i = 0; $i < count($original); $i++) {
+ for ($j = 0; $j < count($original); $j++) {
+ if ($boxes[$i]["ID"] == $original[$j]["ID"]) {
+ $boxes[$i]["UNFORMATTED"] = $original[$j]["UNFORMATTED"];
+ $boxes[$i]["FORMATTED"] = $original[$j]["FORMATTED"];
+ $boxes[$i]["RAW"] = $original[$j]["RAW"];
+ }
+ }
+ }
+
+ for ($i = 0; $i < count($boxes); $i++) {
+ if ($boxes[$i]["UNFORMATTED"] == $special_folders[0]) {
+ $boxesnew[0]["FORMATTED"] = $boxes[$i]["FORMATTED"];
+ $boxesnew[0]["UNFORMATTED"] = trim($boxes[$i]["UNFORMATTED"]);
+ $boxesnew[0]["RAW"] = trim($boxes[$i]["RAW"]);
+ $boxes[$i]["USED"] = true;
+ }
+ }
+ if ($list_special_folders_first == true) {
+ for ($i = 0; $i < count($boxes); $i++) {
+ for ($j = 1; $j < count($special_folders); $j++) {
+ if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($special_folders[$j])) == $special_folders[$j]) {
+ $pos = count($boxesnew);
+ $boxesnew[$pos]["FORMATTED"] = $boxes[$i]["FORMATTED"];
+ $boxesnew[$pos]["RAW"] = trim($boxes[$i]["RAW"]);
+ $boxesnew[$pos]["UNFORMATTED"] = trim($boxes[$i]["UNFORMATTED"]);
+ $boxes[$i]["USED"] = true;
+ }
+ }
+ }
+ }
+ for ($i = 0; $i < count($boxes); $i++) {
+ if (($boxes[$i]["UNFORMATTED"] != $special_folders[0]) &&
+ ($boxes[$i]["UNFORMATTED"] != ".mailboxlist") &&
+ ($boxes[$i]["USED"] == false)) {
+ $pos = count($boxesnew);
+ $boxesnew[$pos]["FORMATTED"] = $boxes[$i]["FORMATTED"];
+ $boxesnew[$pos]["RAW"] = trim($boxes[$i]["RAW"]);
+ $boxesnew[$pos]["UNFORMATTED"] = trim($boxes[$i]["UNFORMATTED"]);
+ $boxes[$i]["USED"] = true;
+ }
+ }
+
+ $boxes = $boxesnew;
}
function deleteMessages($imapConnection, $a, $b, $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox) {
while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
if (substr($read, 0, 5) == "From:") {
- $read = ereg_replace("<", "EMAILSTART--", $read);
- $read = ereg_replace(">", "--EMAILEND", $read);
+ $read = encodeEmailAddr("$read");
$from[$pos] = substr($read, 5, strlen($read) - 6);
}
else if (substr($read, 0, 5) == "Date:") {
}
}
+ function encodeEmailAddr($string) {
+ $string = ereg_replace("<", "EMAILSTART--", $string);
+ $string = ereg_replace(">", "--EMAILEND", $string);
+ return $string;
+ }
+
function setMessageFlag($imapConnection, $i, $q, $flag) {
fputs($imapConnection, "messageStore STORE $i:$q +FLAGS (\\$flag)\n");
}
** This function loops through a group of messages in the mailbox and shows them
**/
function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
- require ("../config/config.php");
+ include ("../config/config.php");
if (1 <= $numMessages) {
getMessageHeaders($imapConnection, 1, $numMessages, $from, $subject, $date);
}
}
-// $j = 0;
-// while ($j < $numMessages) {
-// $sub = $msgs[$j]["SUBJECT"];
-// $id = $msgs[$j]["ID"];
-// echo "$id -- $sub<BR>";
-// $j++;
-// }
-//exit;
-
if ($startMessage + 24 < $numMessages) {
$endMessage = $startMessage + 24;
} else {
echo "<TR><TD BGCOLOR=\"$color[0]\">";
echo "\n\n\n<FORM name=messageList method=post action=\"move_messages.php?msg=$msg&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage\">";
- echo "<TABLE BGCOLOR=\"$color[0]\">\n";
+ echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0>\n";
echo " <TR>\n";
- echo " <TD WIDTH=30% ALIGN=LEFT>\n";
- echo " <NOBR><FONT FACE=\"Arial,Helvetica\" SIZE=2><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"Move to:\">\n";
- echo " <SELECT NAME=\"targetMailbox\">\n";
- getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
+ echo " <TD WIDTH=60% ALIGN=LEFT>\n";
+ echo " <NOBR><FONT FACE=\"Arial,Helvetica\"><SMALL>Move selected to: </SMALL></FONT>";
+ echo " <TT><SMALL><SELECT NAME=\"targetMailbox\">";
+
+ getFolderList($imapConnection, $boxes);
+ for ($i = 0; $i < count($boxes); $i++) {
$use_folder = true;
for ($p = 0; $p < count($special_folders); $p++) {
- // don't allow moving messages to any special folder EXCEPT for INBOX.
- if (($boxesUnformatted[$i] == $special_folders[$p]) && ($boxesUnformatted[$i] != "INBOX")) {
+ if ($boxes[$i]["UNFORMATTED"] == $special_folders[0]) {
+ $use_folder = true;
+ } else if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
$use_folder = false;
- } else if (substr($boxesUnformatted[$i], 0, strlen($trash_folder)) == $trash_folder) {
+ } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
$use_folder = false;
}
}
- if ($use_folder == true)
- echo " <OPTION VALUE=\"$boxesUnformatted[$i]\">$boxesUnformatted[$i]\n";
+ if ($use_folder == true) {
+ $box = $boxes[$i]["UNFORMATTED"];
+ $box2 = $boxes[$i]["FORMATTED"];
+ echo " <OPTION VALUE=\"$box\">$box2\n";
+ }
}
- echo " </SELECT></NOBR></FONT>\n";
+ echo " </SELECT></SMALL></TT>";
+ echo " <FONT FACE=\"Arial,Helvetica\"><SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"Move\"></SMALL></FONT></NOBR>\n";
echo " </TD>\n";
- echo " <TD WIDTH=70% ALIGN=RIGHT>\n";
- echo " <NOBR><FONT FACE=\"Arial,Helvetica\" SIZE=2><INPUT TYPE=SUBMIT VALUE=\"Delete\"> checked messages</FONT></NOBR>\n";
+ echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
+ echo " <NOBR><FONT FACE=\"Arial,Helvetica\"><SMALL><INPUT TYPE=SUBMIT VALUE=\"Delete\"> checked messages</SMALL></FONT></NOBR>\n";
echo " </TD>";
echo " </TR>\n";
echo "<TR><TD BGCOLOR=\"$color[0]\">";
echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[4]\">";
echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
- echo " <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
+ echo " <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B> </B></FONT></TD>";
/** FROM HEADER **/
echo " <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT>";
if ($sort == 2)
/** SUBJECT HEADER **/
echo " <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT>\n";
if ($sort == 4)
- echo " <A HREF=\"right_main.php?sort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
+ echo " <A HREF=\"right_main.php?sort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
else if ($sort == 5)
echo " <A HREF=\"right_main.php?sort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
else
fputs($smtpConnection, "Cc: <$cc_list>\n"); // Who the CCs are
}
fputs($smtpConnection, "X-Mailer: SquirrelMail (version $version)\n"); // Identify SquirrelMail
+ fputs($smtpConnection, "Reply-To: $from\n");
+ fputs($smtpConnection, "MIME-Version: 1.0\n");
+ fputs($smtpConnection, "Content-Type: text/plain; charset=us-ascii\n");
fputs($smtpConnection, "$body\n"); // send the body of the message
fputs($smtpConnection, ".\n"); // end the DATA part
<?
+
//*************************************************************************
// Count the number of occurances of $needle are in $haystack.
//*************************************************************************
}
return $to_line;
}
+
+ /* SquirrelMail version number -- DO NOT CHANGE */
+ $version = "0.1.2";
?>
}
}
+ // Add some decoding information
+ $send_to = encodeEmailAddr($send_to);
+ // parses the field and returns only the email address
+ $send_to = decodeEmailAddr($send_to);
+
+ $send_to = strtolower($send_to);
$send_to = ereg_replace("\"", "", $send_to);
$send_to = stripslashes($send_to);
sendMessage($smtpServerAddress, $smtpPort, $username, $domain, $passed_to, $passed_cc, $passed_bcc, $passed_subject, $passed_body, $version);
- echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=right_main.php\">";
+ if ($auto_forwarding == true)
+ echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=right_main.php\">";
echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
displayPageHeader($color, "None");
include("../functions/page_header.php");
include("../functions/display_messages.php");
include("../functions/imap.php");
+ include("../functions/array.php");
$imapConnection = loginToImapServer($username, $key, $imapServerAddress);
- getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+ getFolderList($imapConnection, $boxes);
$mailbox = $trash_folder;
fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
$data = imapReadData($imapConnection , "1", false, $response, $message);
while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
- if (($boxesUnformatted[$i] == $mailbox) ||
- (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
- removeFolder($imapConnection, "$boxesUnformatted[$i]");
+ for ($i = 0; $i < count($boxes); $i++) {
+ if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+ (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+ removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
}
}
fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
include("../functions/page_header.php");
include("../functions/imap.php");
include("../functions/mailbox.php");
+ include("../functions/array.php");
echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
echo "</TABLE>\n";
$imapConnection = loginToImapServer($username, $key, $imapServerAddress);
- getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+ getFolderList($imapConnection, $boxes);
/** DELETING FOLDERS **/
echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Delete Folder</B></FONT></TD></TR>";
echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
- echo "<SELECT NAME=mailbox><FONT FACE=\"Arial,Helvetica\">\n";
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
+ echo "<TT><SELECT NAME=mailbox>\n";
+ for ($i = 0; $i < count($boxes); $i++) {
$use_folder = true;
for ($p = 0; $p < count($special_folders); $p++) {
- if ($boxesUnformatted[$i] == $special_folders[$p]) {
+ if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
$use_folder = false;
- } else if (substr($boxesUnformatted[$i], 0, strlen($trash_folder)) == $trash_folder) {
+ } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
$use_folder = false;
}
}
-
- if ($use_folder == true)
- echo "<OPTION>$boxesUnformatted[$i]\n";
+ if ($use_folder == true) {
+ $box = $boxes[$i]["UNFORMATTED"];
+ $box2 = $boxes[$i]["FORMATTED"];
+ echo " <OPTION VALUE=\"$box\">$box2\n";
+ }
}
- echo "</SELECT>\n";
- echo "<INPUT TYPE=SUBMIT VALUE=Delete>\n";
+
+ echo "</SELECT></TT>\n";
+ echo "<FONT FACE=\"Arial,Helvetica\"><INPUT TYPE=SUBMIT VALUE=Delete></FONT>\n";
echo "</FORM><BR></TD></TR><BR>\n";
/** CREATING FOLDERS **/
echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
echo "<FORM ACTION=folders_create.php METHOD=POST>\n";
echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
- echo " as a subfolder of<BR>";
- echo "<SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
+ echo "<FONT FACE=\"Arial,Helvetica\">as a subfolder of</FONT><BR>";
+ echo "<TT><SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
if ($default_sub_of_inbox == false)
echo "<OPTION SELECTED>[ None ]\n";
else
echo "<OPTION>[ None ]\n";
- for ($i = 0;$i < count($boxesUnformatted); $i++) {
- if (($boxesUnformatted[$i] == $special_folders[0]) && ($default_sub_of_inbox == true))
- echo "<OPTION SELECTED>$boxesUnformatted[$i]\n";
- else
- echo "<OPTION>$boxesUnformatted[$i]\n";
+ for ($i = 0; $i < count($boxes); $i++) {
+ if (($boxes[$i]["UNFORMATTED"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
+ $box = $boxes[$i]["UNFORMATTED"];
+ $box2 = $boxes[$i]["FORMATTED"];
+ echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
+ } else {
+ $box = $boxes[$i]["UNFORMATTED"];
+ $box2 = $boxes[$i]["FORMATTED"];
+ echo "<OPTION VALUE=\"$box\">$box2\n";
+ }
}
- echo "</SELECT><BR>\n";
- echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
+ echo "</SELECT></TT><BR>\n";
+ echo "<FONT FACE=\"Arial,Helvetica\">";
+ if ($show_contain_subfolders_option)
+ echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"><FONT FACE=\"Arial,Helvetica\"> Let this folder contain subfolders</FONT><BR>";
+ echo "<INPUT TYPE=SUBMIT VALUE=Create></FONT>\n";
echo "</FORM><BR></TD></TR><BR>\n";
/** RENAMING FOLDERS **/
echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Rename a Folder</B></FONT></TD></TR>";
echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
echo "<FORM ACTION=folders_rename_getname.php METHOD=POST>\n";
- echo "<SELECT NAME=old><FONT FACE=\"Arial,Helvetica\">\n";
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
+ echo "<TT><SELECT NAME=old><FONT FACE=\"Arial,Helvetica\">\n";
+ for ($i = 0; $i < count($boxes); $i++) {
$use_folder = true;
for ($p = 0; $p < count($special_folders); $p++) {
- if ($boxesUnformatted[$i] == $special_folders[$p]) {
+ if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) {
+ $use_folder = false;
+ } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) {
$use_folder = false;
}
}
- if ($use_folder == true)
- echo " <OPTION>$boxesUnformatted[$i]\n";
+ if ($use_folder == true) {
+ $box = $boxes[$i]["UNFORMATTED"];
+ $box2 = $boxes[$i]["FORMATTED"];
+ echo " <OPTION VALUE=\"$box\">$box2\n";
+ }
}
- echo "</SELECT>\n";
- echo "<INPUT TYPE=SUBMIT VALUE=\"Rename\">\n";
+ echo "</SELECT></TT>\n";
+ echo "<FONT FACE=\"Arial,Helvetica\"><INPUT TYPE=SUBMIT VALUE=\"Rename\"></FONT>\n";
echo "</FORM></TD></TR></TABLE><BR>\n";
?>
include("../functions/strings.php");
include("../functions/page_header.php");
include("../functions/imap.php");
+ include("../functions/display_messages.php");
echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+ displayPageHeader($color, "None");
+
$imapConnection = loginToImapServer($username, $key, $imapServerAddress);
$dm = findMailboxDelimeter($imapConnection);
+
+ if (strpos($folder_name, "\"") || strpos($folder_name, ".") ||
+ strpos($folder_name, "/") || strpos($folder_name, "\\") ||
+ strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
+ plain_error_message("Illegal folder name. Please select a different name.<BR><A HREF=\"../src/folders.php\">Click here to go back</A>.", $color);
+ exit;
+ }
+
+ if ($contain_subs == true)
+ $folder_name = "$folder_name$dm";
+
if (trim($subfolder) == "[ None ]") {
createFolder($imapConnection, "$folder_name");
} else {
include("../functions/page_header.php");
include("../functions/imap.php");
include("../functions/mailbox.php");
+ include("../functions/array.php");
echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
$imapConnection = loginToImapServer($username, $key, $imapServerAddress);
- getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
+ getFolderList($imapConnection, $boxes);
$dm = findMailboxDelimeter($imapConnection);
/** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
- if ($boxesUnformatted[$i] == $trash_folder)
- $tmp_trash_folder = $boxesRaw[$i];
+ for ($i = 0; $i < count($boxes[$i]["UNFORMATTED"]); $i++) {
+ if ($boxes[$i]["UNFORMATTED"] == $trash_folder)
+ $tmp_trash_folder = $boxes[$i]["RAW"];
}
$tmpflags = getMailboxFlags($tmp_trash_folder);
/** Lets start removing the folders and messages **/
if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
/** Creates the subfolders under $trash_folder **/
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
- if (($boxesUnformatted[$i] == $mailbox) ||
- (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
- $folderWithoutINBOX = getFolderNameMinusINBOX($boxesUnformatted[$i], $dm);
- $flags = getMailboxFlags($boxesRaw[$i]);
+ for ($i = 0; $i < count($boxes); $i++) {
+ if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+ (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+ $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"], $dm);
+ $flags = getMailboxFlags($boxes[$i]["RAW"]);
for ($b = 0; $b < count($flags); $b++) {
$type = $flags[$b];
}
createFolder($imapConnection, "$trash_folder" . $dm . "$folderWithoutINBOX", $type);
}
}
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
- if (($boxesUnformatted[$i] == $mailbox) ||
- (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
- selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages);
- $folder = getFolderNameMinusINBOX($boxesUnformatted[$i]);
+ for ($i = 0; $i < count($boxes); $i++) {
+ if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+ (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+ selectMailbox($imapConnection, $boxes[$i]["UNFORMATTED"], $numMessages);
+ $folder = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"]);
if ($numMessages > 0)
$success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder" . $dm . "$folder");
$success = true;
if ($success == true)
- removeFolder($imapConnection, "$boxesUnformatted[$i]");
+ removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
}
}
} else { /** if they do NOT wish to move messages to the trash (or cannot)**/
fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
$data = imapReadData($imapConnection , "1", false, $response, $message);
while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
- for ($i = 0; $i < count($boxesUnformatted); $i++) {
- if (($boxesUnformatted[$i] == $mailbox) ||
- (substr($boxesUnformatted[$i], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
- removeFolder($imapConnection, "$boxesUnformatted[$i]");
+ for ($i = 0; $i < count($boxes); $i++) {
+ if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
+ (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
+ removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
}
}
fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
$imapConnection = loginToImapServer($username, $key, $imapServerAddress);
selectMailbox($imapConnection, $old, $numMessages);
- getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
$dm = findMailboxDelimeter($imapConnection);
if (strpos($old, $dm)) {
if ($unseen)
$line .= "<B>";
- $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
- $line .= readShortMailboxName($mailbox, $delimeter);
- if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
- $urlMailbox = urlencode($mailbox);
- $line .= "</A> (<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
+ $special_color = false;
+ for ($i = 0; $i < count($special_folders); $i++) {
+ if (($special_folders[$i] == $mailbox) && ($use_special_folder_color == true))
+ $special_color = true;
+ }
+
+ if ($special_color == true) {
+ $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\" COLOR=\"$color[11]\">";
+ $line .= readShortMailboxName($mailbox, $delimeter);
+ $line .= "</font></a>";
+ } else {
+ $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
+ $line .= readShortMailboxName($mailbox, $delimeter);
+ $line .= "</font></a>";
}
- $line .= "</FONT></a>\n";
+
+ if ($unseen)
+ $line .= "</B>";
+
if ($numUnseen > 0) {
- $line .= "</B> </FONT><FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
+ $line .= " <FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
+ }
+
+ if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
+ $urlMailbox = urlencode($mailbox);
+ $line .= "<FONT FACE=\"Arial,Helvetica\" SIZE=2>";
+ $line .= " (<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
+ $line .= "</FONT></a>\n";
}
return $line;
}
// open a connection on the imap port (143)
$imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
- fputs($imapConnection, "1 list \"\" *\n");
- $str = imapReadData($imapConnection, "1", true, $response, $message);
+ getFolderList($imapConnection, $boxes);
echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
echo "Folders</B><BR></FONT>";
echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>";
echo "<FONT FACE=\"Arial,Helvetica\">\n";
$delimeter = findMailboxDelimeter($imapConnection);
- for ($i = 0;$i < count($str); $i++) {
- $mailbox = Chop($str[$i]);
- $boxFlags = getMailboxFlags($mailbox);
- $mailbox = findMailboxName($mailbox);
+ for ($i = 0;$i < count($boxes); $i++) {
+ $mailbox = $boxes[$i]["UNFORMATTED"];
+ $boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
$boxCount = countCharInString($mailbox, $delimeter);
$line .= " ";
if (trim($boxFlags[0]) != "") {
+ $noselect = false;
for ($h = 0; $h < count($boxFlags); $h++) {
- if (strtolower($boxFlags[$h]) == "noselect") {
- $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
- $line .= readShortMailboxName($mailbox, $delimeter);
- $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
- } else {
- $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
- }
- }
- } else {
- $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
- }
- $folder_list[$i]["FORMATTED"] = trim($line);
- $folder_list[$i]["PLAIN"] = trim($mailbox);
- $folder_list[$i]["ID"] = $i;
- }
-
- /** Alphebetize the folders */
- $original = $folder_list;
-
- for ($i = 0; $i < count($original); $i++) {
- $folder_list[$i]["PLAIN"] = strtolower($folder_list[$i]["PLAIN"]);
- }
-
- $folder_list = ary_sort($folder_list, "PLAIN", 1);
-
- for ($i = 0; $i < count($original); $i++) {
- for ($j = 0; $j < count($original); $j++) {
- if ($folder_list[$i]["ID"] == $original[$j]["ID"]) {
- $folder_list[$i]["PLAIN"] = $original[$j]["PLAIN"];
- $folder_list[$i]["FORMATTED"] = $original[$j]["FORMATTED"];
+ if (strtolower($boxFlags[$h]) == "noselect")
+ $noselect = true;
}
- }
- }
- /** If it is the inbox, list it first **/
- for ($i = 0; $i < count($folder_list); $i++) {
- if ($folder_list[$i]["PLAIN"] == $special_folders[0]) {
- echo "<FONT FACE=\"Arial,Helvetica\">";
- echo trim($folder_list[$i]["FORMATTED"]);
- echo "</FONT><BR>";
- $folder_list[$i]["USED"] = true;
- }
- }
- /** Now the other special folders **/
- if ($list_special_folders_first == true) {
- for ($i = 0; $i < count($folder_list); $i++) {
- for ($j = 1; $j < count($special_folders); $j++) {
- if (substr($folder_list[$i]["PLAIN"], 0, strlen($special_folders[$j])) == $special_folders[$j]) {
- echo "<FONT FACE=\"Arial,Helvetica\">";
- echo trim($folder_list[$i]["FORMATTED"]);
- echo "</FONT><BR>";
- $folder_list[$i]["USED"] = true;
- }
+ if ($noselect == true) {
+ $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
+ $line .= readShortMailboxName($mailbox, $delimeter);
+ $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
+ } else {
+ $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
}
+ } else {
+ $line .= formatMailboxName($imapConnection, $mailbox, $delimeter);
}
- }
- /** Then list all the other ones (not equal to INBOX) **/
- /** NOTE: .mailboxlist is a netscape thing.. just ignore it **/
- for ($i = 0; $i < count($folder_list); $i++) {
- if (($folder_list[$i]["PLAIN"] != $special_folders[0]) &&
- ($folder_list[$i]["PLAIN"] != ".mailboxlist") &&
- ($folder_list[$i]["USED"] == false)) {
- echo "<FONT FACE=\"Arial,Helvetica\">";
- echo trim($folder_list[$i]["FORMATTED"]);
- echo "</FONT><BR>";
- }
+ echo "$line<BR>";
}
echo "</FONT>";
<HTML>
<?
include("../config/config.php");
+ include("../functions/strings.php");
echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
echo "<FORM ACTION=webmail.php METHOD=\"POST\" NAME=f>\n";
// loop because we never increment j. so check to see if msg[0] is set or not to fix this.
while ($j < count($msg)) {
if ($msg[$i]) {
- echo "MSG: $msg[$i]<BR>";
deleteMessages($imapConnection, $msg[$i], $msg[$i], $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
$j++;
}
}
messages_deleted_message($mailbox, $sort, $startMessage, $color);
} else {
- echo "<BR><BR><CENTER>No messages selected.</CENTER>";
+ error_message("No messages were selected.", $mailbox, $sort, $startMessage, $color);
}
} else { // Move messages
displayPageHeader($color, $mailbox);
?>
<HTML><HEAD>
<TITLE>
-OM-USA WebMail
+<?
+ include ("../config/config.php");
+ echo "$org_title";
+?>
</TITLE>
<FRAMESET COLS="200, *" NORESIZE BORDER=0>