Browse Source

Next/previous is working a bit better

Luke Ehresman 26 năm trước cách đây
mục cha
commit
b847b72497
4 tập tin đã thay đổi với 22 bổ sung27 xóa
  1. 9 9
      functions/date.php3
  2. 4 4
      functions/mailbox.php3
  3. 8 13
      functions/mailbox_display.php3
  4. 1 1
      src/right_main.php3

+ 9 - 9
functions/date.php3

@@ -141,7 +141,7 @@
    }
 
    function getTimeStamp($dateParts) {
-      if (eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp)) {
+//      if (eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp)) {
          $d[0] = getHour($dateParts[4]);
          $d[1] = getMinute($dateParts[4]);
          $d[2] = getSecond($dateParts[4]);
@@ -149,13 +149,13 @@
          $d[4] = getDayOfMonth($dateParts[1]);
          $d[5] = getYear($dateParts[3]);
          return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
-      }
-      $d[0] = getHour($dateParts[3]);
-      $d[1] = getMinute($dateParts[3]);
-      $d[2] = getSecond($dateParts[3]);
-      $d[3] = getMonthNum($dateParts[1]);
-      $d[4] = getDayOfMonth($dateParts[0]);
-      $d[5] = getYear($dateParts[2]);
-      return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
+//      }
+//      $d[0] = getHour($dateParts[3]);
+//      $d[1] = getMinute($dateParts[3]);
+//      $d[2] = getSecond($dateParts[3]);
+//      $d[3] = getMonthNum($dateParts[1]);
+//      $d[4] = getDayOfMonth($dateParts[0]);
+//      $d[5] = getYear($dateParts[2]);
+//      return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
    }
 ?>

+ 4 - 4
functions/mailbox.php3

@@ -58,10 +58,10 @@
             $read = substr($read, strpos($read, "FLAGS")+6, strlen($read));
             $read = trim($read);
             $flags = explode(" ", $read);;
-            $i = 0;
-            while ($i < count($flags)) {
-               $flags[$i] = substr($flags[$i], 1, strlen($flags[$i]));
-               $i++;
+            $s = 0;
+            while ($s < count($flags)) {
+               $flags[$s] = substr($flags[$s], 1, strlen($flags[$s]));
+               $s++;
             }
          } else {
             $flags[0] = "None";

+ 8 - 13
functions/mailbox_display.php3

@@ -7,10 +7,7 @@
     **
     **/
 
-   function printMessageInfo($imapConnection, $i, $from, $subject, $date, $answered, $seen) {
-//      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
-      $dateParts = explode(" ", trim($date));
-      $dateString = getDateString($dateParts);  // this will reformat the date string into a good format for us.
+   function printMessageInfo($imapConnection, $i, $from, $subject, $dateString, $answered, $seen) {
       $senderName = getSenderName($from);
       if (strlen(Chop($subject)) == 0)
          $subject = "(no subject)";
@@ -34,18 +31,17 @@
     ** This function loops through a group of messages in the mailbox and shows them
     **/
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
-      $i = 1;
+      $i = 0;
       $j = 1;
       while ($j <= $numMessages) {
          getMessageHeaders($imapConnection, $j, $from, $subject, $date);
          getMessageFlags($imapConnection, $j, $flags);
 
-         echo "$date --";
-         $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date)));
+         $messages[$i]["TIME_STAMP"] = getTimeStamp(explode(" ", trim($date)));
+         $messages[$i]["DATE_STRING"] = getDateString(explode(" ", trim($date)));
          $messages[$i]["ID"] = $j;
          $messages[$i]["FROM"] = $from;
          $messages[$i]["SUBJECT"] = $subject;
-//         echo "$messages[$i][\"DATE\"]<BR>";
 
          $messages[$i]["FLAG_DELETED"] = false;
          $messages[$i]["FLAG_ANSWERED"] = false;
@@ -71,10 +67,9 @@
       $numMessages = $i;
 
       if ($sort == 0)
-         $msgs = ary_sort($messages, "DATE", -1);
+         $msgs = ary_sort($messages, "TIME_STAMP", -1);
       else
-         $msgs = ary_sort($messages, "DATE", 1);
-
+         $msgs = ary_sort($messages, "TIME_STAMP", 1);
 
       if ($startMessage + 24 < $numMessages) {
          $nextGroup = $startMessage + 24 + 1; // +1 to go to beginning of next group
@@ -118,8 +113,8 @@
       echo "</TR>";
 
       // loop through and display the info for each message.
-      for ($i = $startMessage;$i <= $endMessage; $i++) {
-         printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]);
+      for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) {
+         printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]);
       }
 
       echo "</TABLE>\n";

+ 1 - 1
src/right_main.php3

@@ -74,7 +74,7 @@
 
    // switch to the mailbox, and get the number of messages in it.
    selectMailbox($imapConnection, $mailbox, $numMessages);
-   $numMessages = $numMessages - 1;  // I did this so it's 0 based like the message array
+//   $numMessages = $numMessages - 1;  // I did this so it's 0 based like the message array
 
    // make a URL safe $mailbox for use in the links
    $urlMailbox = urlencode($mailbox);