浏览代码

optomizations

Luke Ehresman 25 年之前
父节点
当前提交
62b919ff99
共有 2 个文件被更改,包括 13 次插入17 次删除
  1. 2 0
      functions/imap_general.php
  2. 11 17
      functions/imap_messages.php

+ 2 - 0
functions/imap_general.php

@@ -14,12 +14,14 @@
       global $color;
       global $color;
 
 
       $read = fgets ($imap_stream, 1024);
       $read = fgets ($imap_stream, 1024);
+//		echo "<small><tt><font color=cc0000>$read</font></tt></small><br>";
       $counter = 0;
       $counter = 0;
       while ((substr($read, 0, strlen("$pre OK")) != "$pre OK") &&
       while ((substr($read, 0, strlen("$pre OK")) != "$pre OK") &&
              (substr($read, 0, strlen("$pre BAD")) != "$pre BAD") &&
              (substr($read, 0, strlen("$pre BAD")) != "$pre BAD") &&
              (substr($read, 0, strlen("$pre NO")) != "$pre NO")) {
              (substr($read, 0, strlen("$pre NO")) != "$pre NO")) {
          $data[$counter] = $read;
          $data[$counter] = $read;
          $read = fgets ($imap_stream, 1024);
          $read = fgets ($imap_stream, 1024);
+//			echo "<small><tt><font color=cc0000>$read</font></tt></small><br>";
          $counter++;
          $counter++;
       }       
       }       
       if (substr($read, 0, strlen("$pre OK")) == "$pre OK") {
       if (substr($read, 0, strlen("$pre OK")) == "$pre OK") {

+ 11 - 17
functions/imap_messages.php

@@ -33,33 +33,27 @@
    function sqimap_messages_flag ($imap_stream, $start, $end, $flag) {
    function sqimap_messages_flag ($imap_stream, $start, $end, $flag) {
       fputs ($imap_stream, "a001 STORE $start:$end +FLAGS (\\$flag)\r\n");
       fputs ($imap_stream, "a001 STORE $start:$end +FLAGS (\\$flag)\r\n");
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
-      
    }
    }
 
 
    /******************************************************************************
    /******************************************************************************
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
     ******************************************************************************/
-   function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date, $sent) {
+   function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date) {
       //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n");
       //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n");
-      fputs ($imap_stream, "a001 FETCH $id RFC822.HEADER\r\n");
+      //fputs ($imap_stream, "a001 FETCH $id RFC822.HEADER\r\n");
+      fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date From Subject)]\r\n");
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
 
 
       $subject = _("(no subject)");
       $subject = _("(no subject)");
       $from = _("Unknown Sender");
       $from = _("Unknown Sender");
       for ($i = 0; $i < count($read); $i++) {
       for ($i = 0; $i < count($read); $i++) {
-			if ($sent == true) {
-	         if (strtolower(substr($read[$i], 0, 3)) == "to:")
-   	         $from = sqimap_find_displayable_name(substr($read[$i], 3));
-			} else {
-	         if (strtolower(substr($read[$i], 0, 5)) == "from:")
-   	         $from = sqimap_find_displayable_name(substr($read[$i], 5));
-			}
-
-			if (strtolower(substr($read[$i], 0, 5)) == "date:") {
+         if (eregi ("^from:", $read[$i])) {
+            $from = sqimap_find_displayable_name(substr($read[$i], 5));
+         } else if (eregi ("^date:", $read[$i])) {
             $date = substr($read[$i], 5);
             $date = substr($read[$i], 5);
-         } else if (strtolower(substr($read[$i], 0, 8)) == "subject:") {
-            $subject = htmlspecialchars(substr($read[$i], 8));
-            if (strlen(trim($subject)) == 0)
+         } else if (eregi ("^subject:", $read[$i])) {
+            $subject = htmlspecialchars(eregi_replace ("^subject: ", "", $read[$i]));
+            if (strlen($subject) == 0)
                $subject = _("(no subject)");
                $subject = _("(no subject)");
          }
          }
       }
       }
@@ -247,7 +241,7 @@
             $pos = 0;
             $pos = 0;
             $header["CC"][$pos] = trim(substr($read[$i], 4));
             $header["CC"][$pos] = trim(substr($read[$i], 4));
             $i++;
             $i++;
-				while (((substr($read[$i], 0, 1) == "\t") || (substr($read[$i], 0, 1) == " ")) && (trim($read[$i]) != "")) {
+            while ((substr($read[$i], 0, 1) == " ") && (trim($read[$i]) != "")) {
                $pos++;
                $pos++;
                $header["CC"][$pos] = trim($read[$i]);
                $header["CC"][$pos] = trim($read[$i]);
                $i++;
                $i++;
@@ -258,7 +252,7 @@
             $pos = 0;
             $pos = 0;
             $header["TO"][$pos] = trim(substr($read[$i], 4));
             $header["TO"][$pos] = trim(substr($read[$i], 4));
             $i++;
             $i++;
-				while (((substr($read[$i], 0, 1) == "\t") || (substr($read[$i], 0, 1) == " ")) && (trim($read[$i]) != "")) {
+            while ((substr($read[$i], 0, 1) == " ")  && (trim($read[$i]) != "")){
                $pos++;
                $pos++;
                $header["TO"][$pos] = trim($read[$i]);
                $header["TO"][$pos] = trim($read[$i]);
                $i++;
                $i++;