From 05207a68b0446f5da0e2e0aa86e9edbe85a40ada Mon Sep 17 00:00:00 2001 From: lkehresman Date: Thu, 2 Dec 1999 22:51:58 +0000 Subject: [PATCH] Major update -- Added mail reading, and many many many bug fixes git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@48 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mailbox.php | 80 ++++++++++++++++++++++++++++++---- functions/mailbox_display.php | 16 +++---- images/sort_none.gif | Bin 0 -> 328 bytes src/move_messages.php | 48 ++++++++++---------- 4 files changed, 103 insertions(+), 41 deletions(-) create mode 100644 images/sort_none.gif diff --git a/functions/mailbox.php b/functions/mailbox.php index 45dbbb7a..d4159f5e 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -35,6 +35,9 @@ exit; } + $from_pos = 0; + $date_pos = 0; + $subj_pos = 0; while ($rel_start <= $end) { if ($end - $rel_start > 50) { $rel_end = $rel_start + 50; @@ -44,27 +47,26 @@ fputs($imapConnection, "messageFetch FETCH $rel_start:$rel_end RFC822.HEADER.LINES (From Subject Date)\n"); $read = fgets($imapConnection, 1024); - $from_num = $rel_start - 1; - $date_num = $rel_start - 1; - $subj_num = $rel_start - 1; 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); - $from[$from_num] = substr($read, 5, strlen($read) - 6); - $from_num++; + $from[$from_pos] = substr($read, 5, strlen($read) - 6); + $from_pos++; } else if (substr($read, 0, 5) == "Date:") { $read = ereg_replace("<", "<", $read); $read = ereg_replace(">", ">", $read); - $date[$date_num] = substr($read, 5, strlen($read) - 6); - $date_num++; + $date[$date_pos] = substr($read, 5, strlen($read) - 6); + $date_pos++; } else if (substr($read, 0, 8) == "Subject:") { $read = ereg_replace("<", "<", $read); $read = ereg_replace(">", ">", $read); - $subject[$subj_num] = substr($read, 8, strlen($read) - 9); - $subj_num++; + $subject[$subj_pos] = substr($read, 8, strlen($read) - 9); + if (strlen(Chop($subject[$subj_pos])) == 0) + $subject[$subj_pos] = "(no subject)"; + $subj_pos++; } $read = fgets($imapConnection, 1024); } @@ -193,4 +195,64 @@ return $box; } + + function fetchBody($imapConnection, $id) { + fputs($imapConnection, "messageFetch FETCH $id:$id BODY[TEXT]\n"); + $count = 0; + $read[$count] = fgets($imapConnection, 1024); + while ((substr($read[$count], 0, 15) != "messageFetch OK") && (substr($read[$count], 0, 16) != "messageFetch BAD")) { + $count++; + $read[$count] = fgets($imapConnection, 1024); + } + + $count = 0; + $useHTML= false; + while ($count < count($read)) { + $read[$count] = "^^$read[$count]"; + if (strpos($read[$count], "") == true) { + $useHTML = true; + } else if (strpos(strtolower($read[$count]), ">") == 2) { + $read[$count] = substr($read[$count], 2, strlen($read[$count])); + $read[$count] = "$read[$count]\n"; + } else if (strpos(trim(str_replace(" ", "", $read[$count])), ">") == 2) { + $read[$count] = substr($read[$count], 2, strlen($read[$count])); + $read[$count] = "$read[$count]\n"; + } else { + $read[$count] = substr($read[$count], 2, strlen($read[$count])); + $read[$count] = "$read[$count]\n"; + } + + if (strpos(strtolower($read[$count]), "http://") != false) { + $start = strpos(strtolower($read[$count]), "http://"); + $link = substr($read[$count], $start, strlen($read[$count])); + + if (strpos($link, " ")) + $end = strpos($link, " "); + else if (strpos($link, "<")) + $end = strpos($link, "<"); + else + $end = strlen($link); + + $link = substr($link, 0, $end); + + $read[$count] = str_replace($link, "$link", $read[$count]); + } + } + $count++; + } + + return $read; + } ?> diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 46211690..645ec00a 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -8,22 +8,20 @@ ** **/ - function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen) { + function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox) { $senderName = getSenderName($from); - if (strlen(Chop($subject)) == 0) - $subject = "(no subject)"; - + $urlMailbox = urlencode($mailbox); echo "\n"; if ($seen == false) { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; - echo " $subject\n"; + echo " $subject\n"; } else { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; - echo " $subject\n"; + echo " $subject\n"; } echo "\n"; } @@ -177,7 +175,7 @@ /** The delete and move options */ echo ""; - echo "
"; + echo ""; echo ""; echo ""; if (($move_to_trash == true) && ($mailbox == $trash_folder)) @@ -220,10 +218,10 @@ echo "

THIS FOLDER IS EMPTY
 
"; } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different. $i = $startMessage - 1; - printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]); + printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox); } else { for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) { - printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]); + printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox); $t++; } } diff --git a/images/sort_none.gif b/images/sort_none.gif new file mode 100644 index 0000000000000000000000000000000000000000..0cef65cdd5ef5eedb551f4193f739550d9cdfca2 GIT binary patch literal 328 zcmV-O0k{4~Nk%w1VGIBY0Hpu`0001YcXxe#eS?F8iHV7ikB^m=m7ANJp`oFtr>Cv0 zt$TZWfq{XDh=`7kj+B&?nwpxRprEFvrmU>2va+&(fPjXEhK!7ilarH~nVFxTpQWXx ztE;QAv9Y(ew}pj;i;Ihqk&%~|m!6)Uq@<*(s;aQCu(r0gyu7@Mii(hskd~H~oSdAZ zqN1p%sIRZDwY9aoySu@`!Lzfoy1Kf+z`(}F#<;k+zP`T2#l_3Z%e}q5!^6YL$;r^r z(A(SFA^r|cVPs_>cWHEJAV*0}PyiwM1OW;FKL9KM0000C015yA22;QvU`Q+q1A+me zU^pNWis6FMa6BLp$%HbjST2~1X2a=th96K!G$NHuC)6;dTCrNL7c3?lGM!K}G&MFu aS6N#(I5|2)Vq|7JJUu=DLPeNAK>$0}U!WBL literal 0 HcmV?d00001 diff --git a/src/move_messages.php b/src/move_messages.php index 0dc83b96..8fcc2e51 100644 --- a/src/move_messages.php +++ b/src/move_messages.php @@ -4,39 +4,41 @@ include("../functions/strings.php"); include("../functions/page_header.php"); include("../functions/display_messages.php"); + include("../functions/imap.php"); - $imapConnection = loginToImapServer($username, $key); + echo ""; + $imapConnection = loginToImapServer($username, $key, $imapServerAddress); // switch to the mailbox, and get the number of messages in it. selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress); - // Marks the selected messages ad 'Deleted' - $j = 0; - $i = 0; - - while ($j < count($msg)) { - if ($msg[$i]) { - /** check if they would like to move it to the trash folder or not */ - if ($move_to_trash == true) { - $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $trash_folder); - if ($success == true) - setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted"); - } else { - setMessageFlag($imapConnection, $msg[$i], "Deleted"); + if (strtolower($move_or_delete) == "delete selected messages") { + // Marks the selected messages ad 'Deleted' + $j = 0; + $i = 0; + while ($j < count($msg)) { + if ($msg[$i]) { + /** check if they would like to move it to the trash folder or not */ + if ($move_to_trash == true) { + $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $trash_folder); + if ($success == true) + setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted"); + } else { + setMessageFlag($imapConnection, $msg[$i], "Deleted"); + } + $j++; } - $j++; + $i++; } - $i++; + if ($auto_expunge == true) + expungeBox($imapConnection, $mailbox, $numMessages); + displayPageHeader($mailbox); + messages_deleted_message($mailbox, $sort, $startMessage); + } else { + echo "Move"; } - if ($auto_expunge == true) - expungeBox($imapConnection, $mailbox, $numMessages); - // Log out this session fputs($imapConnection, "1 logout"); - echo ""; - displayPageHeader($mailbox); - - messages_deleted_message($mailbox, $sort, $startMessage); ?> -- 2.25.1