\n"; if ($seen == false) { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; echo " $subject\n"; } else { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; echo " $subject\n"; } echo "\n"; } /** ** This function loops through a group of messages in the mailbox and shows them **/ function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) { include("../config/config.php"); if (1 <= $numMessages) { getMessageHeaders($imapConnection, 1, $numMessages, $from, $subject, $date); } $j = 0; while ($j < $numMessages) { // echo "$numMessages -- $j -- $subject[$j]
"; $date[$j] = ereg_replace(" ", " ", $date[$j]); $tmpdate = explode(" ", trim($date[$j])); $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate); $messages[$j]["DATE_STRING"] = getDateString($tmpdate); $messages[$j]["ID"] = $j+1; $messages[$j]["FROM"] = getSenderName($from[$j]); $messages[$j]["SUBJECT"] = $subject[$j]; $messages[$j]["FLAG_DELETED"] = false; $messages[$j]["FLAG_ANSWERED"] = false; $messages[$j]["FLAG_SEEN"] = false; $num = 0; getMessageFlags($imapConnection, $j+1, $flags); while ($num < count($flags)) { if ($flags[$num] == "Deleted") { $messages[$j]["FLAG_DELETED"] = true; } else if ($flags[$num] == "Answered") { $messages[$j]["FLAG_ANSWERED"] = true; } else if ($flags[$num] == "Seen") { $messages[$j]["FLAG_SEEN"] = true; } $num++; } $j++; } /** Find and remove the ones that are deleted */ $i = 0; $j = 0; while ($j < $numMessages) { if ($messages[$j]["FLAG_DELETED"] == true) { $j++; continue; } $msgs[$i]["TIME_STAMP"] = $messages[$j]["TIME_STAMP"]; $msgs[$i]["DATE_STRING"] = $messages[$j]["DATE_STRING"]; $msgs[$i]["ID"] = $messages[$j]["ID"]; $msgs[$i]["FROM"] = $messages[$j]["FROM"]; $msgs[$i]["SUBJECT"] = $messages[$j]["SUBJECT"]; $msgs[$i]["FLAG_DELETED"] = $messages[$j]["FLAG_DELETED"]; $msgs[$i]["FLAG_ANSWERED"] = $messages[$j]["FLAG_ANSWERED"]; $msgs[$i]["FLAG_SEEN"] = $messages[$j]["FLAG_SEEN"]; $i++; $j++; } $numMessages = $i; // There's gotta be messages in the array for it to sort them. if ($numMessages > 0) { /** 0 = Date (up) 4 = Subject (up) ** 1 = Date (dn) 5 = Subject (dn) ** 2 = Name (up) ** 3 = Name (dn) **/ if ($sort == 0) $msgs = ary_sort($msgs, "TIME_STAMP", -1); else if ($sort == 1) $msgs = ary_sort($msgs, "TIME_STAMP", 1); else { $original = $msgs; $i = 0; while ($i < count($msgs)) { $msgs[$i]["FROM"] = strtolower($msgs[$i]["FROM"]); $msgs[$i]["SUBJECT"] = strtolower($msgs[$i]["SUBJECT"]); $i++; } if ($sort == 2) $msgs = ary_sort($msgs, "FROM", -1); else if ($sort == 3) $msgs = ary_sort($msgs, "FROM", 1); else if ($sort == 4) $msgs = ary_sort($msgs, "SUBJECT", -1); else if ($sort == 5) $msgs = ary_sort($msgs, "SUBJECT", 1); else $msgs = ary_sort($msgs, "TIME_STAMP", -1); $i = 0; while ($i < count($msgs)) { $j = 0; while ($j < count($original)) { if ($msgs[$i]["ID"] == $original[$j]["ID"]) { $msgs[$i]["FROM"] = $original[$j]["FROM"]; $msgs[$i]["SUBJECT"] = $original[$j]["SUBJECT"]; } $j++; } $i++; } } } // $j = 0; // while ($j < $numMessages) { // $sub = $msgs[$j]["SUBJECT"]; // $id = $msgs[$j]["ID"]; // echo "$id -- $sub
"; // $j++; // } //exit; if ($startMessage + 24 < $numMessages) { $endMessage = $startMessage + 24; } else { $endMessage = $numMessages; } $nextGroup = $startMessage + 25; $prevGroup = $startMessage - 25; $urlMailbox = urlencode($mailbox); /** This is the beginning of the message list table. It wraps around all messages */ echo ""; if ($startMessage < $endMessage) { echo "\n"; } else if ($startMessage == $endMessage) { echo "\n"; } echo "\n"; /** The delete and move options */ echo ""; echo "
"; echo "
Viewing messages $startMessage to $endMessage ($numMessages total)
\n"; echo "
"; echo "
Viewing message $startMessage ($numMessages total)
\n"; echo "
"; if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; echo "Next\n"; } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; echo "Next\n"; } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { echo "Previous\n"; echo "Next\n"; } echo "
"; echo "\n\n\n
"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo " \n"; if (($move_to_trash == true) && ($mailbox == $trash_folder)) echo ""; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "  checked messages\n"; echo "
            Empty Trash
\n\n\n"; echo "
"; echo ""; echo ""; echo " "; /** FROM HEADER **/ echo " \n"; else if ($sort == 3) echo " \n"; else echo " \n"; /** DATE HEADER **/ echo " \n"; else if ($sort == 1) echo " \n"; else echo " \n"; /** SUBJECT HEADER **/ echo " \n"; else if ($sort == 5) echo " \n"; else echo " \n"; echo ""; // loop through and display the info for each message. $t = 0; // $t is used for the checkbox number if ($numMessages == 0) { // if there's no messages in this folder echo ""; } 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"], $mailbox, $sort, $startMessage); } 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"], $mailbox, $sort, $startMessage); $t++; } } echo "
NumFrom"; if ($sort == 2) echo " Date"; if ($sort == 0) echo " Subject\n"; if ($sort == 4) echo "

THIS FOLDER IS EMPTY
 
"; echo "
\n"; echo "\n"; echo ""; if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; echo "Next\n"; } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { echo "Previous\n"; echo "Next\n"; } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { echo "Previous\n"; echo "Next\n"; } echo ""; /** End of message-list table */ } ?>