|
@@ -363,51 +363,63 @@
|
|
|
return $line;
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- $start = strpos(strtolower($line), "http://");
|
|
|
- $text = substr($line, $start, strlen($line));
|
|
|
- $linktext = substr($link, 0, $end);
|
|
|
- $link = trim(ereg_replace("<BR>", "", $linktext));
|
|
|
-
|
|
|
+ function getMessageHeadersTo($imapConnection, $i, &$to) {
|
|
|
+ $pos = 0;
|
|
|
+ fputs($imapConnection, "messageFetch FETCH $i:$i RFC822.HEADER.LINES (To)\n");
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
|
|
|
-// $line = str_replace($text, "<A HREF=\"$link\" TARGET=_top>$link</A>", $line);
|
|
|
-*/
|
|
|
+ $firstline = true;
|
|
|
+ while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
|
|
|
+ if ($firstline == true) {
|
|
|
+ $firstline = false;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ } else if (strlen(trim($read)) <= 1) {
|
|
|
+ $firstline = false;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ } else if ($read == ")") {
|
|
|
+ $firstline = false;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ } else {
|
|
|
+ $firstline = false;
|
|
|
+ $read = ereg_replace("<", "<", $read);
|
|
|
+ $read = ereg_replace(">", ">", $read);
|
|
|
+ if (strlen(trim($read)) != 0)
|
|
|
+ $to[$pos] = substr($read, 3, strlen($read));
|
|
|
|
|
|
- function getMessageHeadersTo($imapConnection, $start, $end, &$to) {
|
|
|
- $rel_start = $start;
|
|
|
- if (($start > $end) || ($start < 1)) {
|
|
|
- echo "Error in message header fetching. Start message: $start, End message: $end<BR>";
|
|
|
- exit;
|
|
|
+ $pos++;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ function getMessageHeadersCc($imapConnection, $i, &$cc) {
|
|
|
$pos = 0;
|
|
|
- while ($rel_start <= $end) {
|
|
|
- if ($end - $rel_start > 50) {
|
|
|
- $rel_end = $rel_start + 49;
|
|
|
- } else {
|
|
|
- $rel_end = $end;
|
|
|
- }
|
|
|
- fputs($imapConnection, "messageFetch FETCH $rel_start:$rel_end RFC822.HEADER.LINES (To)\n");
|
|
|
- $read = fgets($imapConnection, 1024);
|
|
|
+ fputs($imapConnection, "messageFetch FETCH $i:$i RFC822.HEADER.LINES (Cc)\n");
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
|
|
|
- while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
|
|
|
- if (substr($read, 0, 3) == "To:") {
|
|
|
- $read = ereg_replace("<", "<", $read);
|
|
|
- $read = ereg_replace(">", ">", $read);
|
|
|
- $to[$pos] = substr($read, 3, strlen($read));
|
|
|
- if (strlen(Chop($to[$pos])) == 0)
|
|
|
- $to[$pos] = "Unknown Recipients";
|
|
|
- }
|
|
|
- else if (substr($read, 0, 1) == ")") {
|
|
|
- if ($subject[$pos] == "")
|
|
|
- $subject[$pos] = "Unknown Recipients";
|
|
|
- $pos++;
|
|
|
- }
|
|
|
+ $firstline = true;
|
|
|
+ while ((strlen(trim($read)) > 0) && (substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
|
|
|
+ if ($firstline == true) {
|
|
|
+ $firstline = false;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ } else if (strlen(trim($read)) <= 1) {
|
|
|
+ $firstline = false;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ } else if ($read == ")") {
|
|
|
+ $firstline = false;
|
|
|
+ $read = fgets($imapConnection, 1024);
|
|
|
+ } else {
|
|
|
+ $read = ereg_replace("<", "<", $read);
|
|
|
+ $read = ereg_replace(">", ">", $read);
|
|
|
+ if (strlen(trim($read)) != 0)
|
|
|
+ $cc[$pos] = substr($read, 3, strlen($read));
|
|
|
|
|
|
+ $pos++;
|
|
|
$read = fgets($imapConnection, 1024);
|
|
|
}
|
|
|
- $rel_start = $rel_start + 50;
|
|
|
}
|
|
|
+ $read = fgets($imapConnection, 1024); // get rid of the last line
|
|
|
}
|
|
|
|
|
|
+
|
|
|
?>
|