cvs: pear /Mail_Mbox mbox.php mbox_test.php
| From: | Roberto Bert� | Date: | Mon, 30 Dec 2002 16:26:47 +0000 |
| Subject: | cvs: pear /Mail_Mbox mbox.php mbox_test.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8003@lists.php.net to get a copy of this message | ||
darkelder Mon Dec 30 11:26:47 2002 EDT
Modified files:
/pear/Mail_Mbox mbox.php mbox_test.php
Log:
current development version
Index: pear/Mail_Mbox/mbox.php
diff -u pear/Mail_Mbox/mbox.php:1.5 pear/Mail_Mbox/mbox.php:1.6
--- pear/Mail_Mbox/mbox.php:1.5 Mon Dec 30 11:25:19 2002
+++ pear/Mail_Mbox/mbox.php Mon Dec 30 11:26:44 2002
@@ -16,7 +16,7 @@
// | Authors: Roberto Berto <darkelder.php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: mbox.php,v 1.5 2002/12/30 16:25:19 darkelder Exp $
+// $Id: mbox.php,v 1.6 2002/12/30 16:26:44 darkelder Exp $
require_once "PEAR.php";
@@ -536,51 +536,50 @@
while (feof($this->_resources[$resourceId]["fresource"]) != true) {
// getting char by char
- $c = fgetc($this->_resources[$resourceId]["fresource"]);
- $lineThis .= $c;
- // each \n we will check things
- if ($c === "\n") {
- // checking if start with From
- if (substr($lineThis, 0, 5) === "From ") {
- // this line byte count is last line more 1 byte
- $bytesStart = $bytesEnd + 1;
- // last line byte count is this line bytes minus this line length
- $bytesEnd = $bytes - strlen($lineThis);
- // we will check messages after they end
- if ($bytesStart != 1) {
- if ($this->debug) {
- printf("#################### from byte %08d to byte %08d
################### <br />", $bytesStart, $bytesEnd);
- }
-
- // setting new message points
- $messagesCount = $this->size($resourceId);
- $this->_resources[$resourceId]["messages"][$messagesCount][0]
= $bytesStart;
- $this->_resources[$resourceId]["messages"][$messagesCount][1]
= $bytesEnd;
+ $lineThis = fgets($this->_resources[$resourceId]["fresource"]);
+ if (feof($this->_resources[$resourceId]["fresource"])) {
+ break;
+ }
+ $bytes += strlen($lineThis);
+ // checking if start with From
+ if (substr($lineThis, 0, 5) === "From ") {
+ // this line byte count is last line more 1 byte
+ $bytesStart = $bytesEnd + 1;
+ // last line byte count is this line bytes minus this line length
+ $bytesEnd = $bytes - strlen($lineThis);
+ // we will check messages after they end
+ if ($bytesStart != 1) {
+ if ($this->debug) {
+ printf("#################### from byte %08d to byte %08d
################### <br />", $bytesStart, $bytesEnd);
}
- }
- // increasing number of lines (doesn't matter)
- if ($this->debug) {
- $lines++;
- }
-
- // last line is this line
- $lineLast = $lineThis;
-
- // this line is blank now
- unset($lineThis);
- if ($this->debug) {
- printf("%08d:%08d %s<br/>", $lines, $bytes, $lineLast);
+ // setting new message points
+ $messagesCount = $this->size($resourceId);
+ $this->_resources[$resourceId]["messages"][$messagesCount][0] =
$bytesStart;
+ $this->_resources[$resourceId]["messages"][$messagesCount][1] =
$bytesEnd;
}
}
- $bytes++;
+
+ // increasing number of lines (doesn't matter)
+ if ($this->debug) {
+ $lines++;
+ }
+
+ // last line is this line
+ $lineLast = $lineThis;
+
+ // this line is blank now
+ unset($lineThis);
+ if ($this->debug) {
+ printf("%08d:%08d %s<br/>", $lines, $bytes, $lineLast);
+ }
}
// last message must be made here - again same things -
// this line byte count is last line more 1 byte
$bytesStart = $bytesEnd + 1;
- // last line byte count is this line bytes minus this line length
- $bytesEnd = $bytes - strlen($lineThis) - 2;
+ // last line byte count is this line bytes minus this line length and the blank line from
Mbox format
+ $bytesEnd = $bytes - strlen($lineThis) - 1;
// we will check messages after they end
$messagesCount = $this->size($resourceId);
Index: pear/Mail_Mbox/mbox_test.php
diff -u pear/Mail_Mbox/mbox_test.php:1.3 pear/Mail_Mbox/mbox_test.php:1.4
--- pear/Mail_Mbox/mbox_test.php:1.3 Mon Dec 30 11:22:53 2002
+++ pear/Mail_Mbox/mbox_test.php Mon Dec 30 11:26:46 2002
@@ -16,19 +16,19 @@
// | Authors: Roberto Berto <darkelder.php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: mbox_test.php,v 1.3 2002/12/30 16:22:53 darkelder Exp $
+// $Id: mbox_test.php,v 1.4 2002/12/30 16:26:46 darkelder Exp $
// some random content
$content = <<<EOF
From Foo@example.com Fri Dec 27 14:31:10 2002
Return-Path:
-Received: from [unix socket] by campos.example.com (LMTP); Fri, 27 Dec
+Received: from [unix socket] by campos.terra.com.br (LMTP); Fri, 27 Dec
2002 14:31:10 -0200 (BRST)
Date: Fri, 27 Dec 2002 14:31:21 -0500
Message-Id: <200212271931.gBRJVL012289@example.com>
-Received: from pcp128525pcs.foo.example.com (
- pcp128525pcs.example.com [99.99.99.99]) by/
- serjolen6com.example.com (v64.19) with ESMTP id
+Received: from pcp128525pcs.medfrd01.nj.comcast.net (
+ pcp128525pcs.medfrd01.nj.comcast.net [68.45.42.4]) by
+ serjolen6com.siteprotect.net (v64.19) with ESMTP id
MAILRELAYINZA98-3601058302; Fri, 08 Nov 2002 06:39:05 -0500
From: "Foo@example.com"
To: fool@example.com
@@ -40,7 +40,7 @@
// starting mbox
require_once "mbox.php";
- $mbox = new Mail_Mbox();
+ $mbox =& new Mail_Mbox();
// uncomment to see lots of things
#$mbox->debug = true;
@@ -54,7 +54,7 @@
// deleting a message (uncomment to test)
- #$res1 = $mbox->remove($mid,0);
+ $res1 = $mbox->remove($mid,0);
if (PEAR::isError($res1))
{
print $res1->getMessage();
@@ -65,7 +65,7 @@
// changing a message (uncomment to test)
- #$res2 = $mbox->update($mid,0,$content);
+ $res2 = $mbox->update($mid,0,$content);
if (PEAR::isError($res2))
{
print $res2->getMessage();
@@ -88,12 +88,12 @@
printf("Message: %08d<pre>",$x);
$thisMessage = $mbox->get($mid,$x);
print $thisMessage;
- print "<hr />";
+ print "<hr>";
$decode = new Mail_mimeDecode($thisMessage, "\r\n");
$structure = $decode->decode();
print_r($structure);
- print "</pre><hr /><hr /><hr />";
+ print "</pre><hr><hr><hr>";
}