Jopoy C. Solano wrote:

ah, yung sa akin yung raw form. ito yung sample na laman, sorry medyo
mahaba :) ... pero kung titingnan mo, ang liit lang nung body



try the working PHP code below. i've made it simple and easy to grasp especially
for non-PHP programers. maybe from here, you can port it to Perl or C. =)



HTH






--------------------------------------- start of code ----------------------------------------------

<?php
        $filename="jopoy.txt";                             // filename
        $file = fopen ($filename,"r");                     // opens a file
        $string = fread($file,filesize($filename));  // dumps the file content to a 
string

        // split the string into lines
        $arr = explode("\n", $string);                                

        // let's read the file contents line by line.
        for ($x=0; $x<=count($arr); $x++)
        {
                $line = $arr[$x];

// extracts the 1st 5 char in a line to ease // the matching of the ff words: // ">From" -- marks the start of a new message
// "Date:" -- marks the Date header.
// "From:" -- marks the From header.
$header = substr($line, 0, 5);
// print if the line is either a Date or From header.
if ($header == "Date:" || $header =="From:")
{
echo htmlspecialchars("$line")."<br>";
}


                // if a line is empty (after reading the headers),
                // it is most likely to be the start of the msg body.
                if($line=="")
                {
                        $body=TRUE;
                }

// if a line begins with a ">From", then it is most likely // to be the end of the msg body &/or start of the new msg.
if($header==">From")
{
$body=FALSE;
echo "================================================= <br>";
}

// print while the $body is true.
if($body==TRUE)
{
echo "$line <br>";
}
}

?>



--------------------------------------- end of code ----------------------------------------------


--------------------------------------- start of jopoy.txt ---------------------------------------

From MAILER-DAEMON Wed Sep 10 16:02:42 2003
Date: 10 Sep 2003 16:02:42 +0800
From: Mail System Internal Data <[EMAIL PROTECTED]>
Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
Message-ID: <[EMAIL PROTECTED]>
X-IMAP: 1063095784 0000000007
Status: RO

This text is part of the internal format of your mail folder, and is not
a real message.  It is created automatically by the mail system software.
If deleted, important folder data will be lost, and it will be re-created
with the data reset to initial values.

From [EMAIL PROTECTED] Tue Sep 9 15:44:57 2003
Return-Path: <[EMAIL PROTECTED]>
Delivered-To: [EMAIL PROTECTED]
Received: from localhost (localhost.localdomain [127.0.0.1])
       by mx1.ubaguio.edu (Postfix) with ESMTP id 340243806C
       for <[EMAIL PROTECTED]>; Tue,  9 Sep 2003 15:44:57 +0800 (PHT)
Received: from ubaguio.edu (unknown [210.23.201.157])
       by mx1.ubaguio.edu (Postfix) with SMTP id B185C3805D
       for <[EMAIL PROTECTED]>; Tue,  9 Sep 2003 15:44:55 +0800 (PHT)
Received: from 210.23.201.148 (proxying for 127.0.0.1)
       (SquirrelMail authenticated user jigz)
       by webmail.ubaguio.edu with HTTP;
       Tue, 9 Sep 2003 14:51:26 +0800 (PHT)
Message-ID: <[EMAIL PROTECTED]>
Date: Tue, 9 Sep 2003 14:51:26 +0800 (PHT)
Subject: jigz report_9/6/03
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
X-Priority: 3
Importance: Normal
X-Mailer: SquirrelMail (version 1.2.11)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: by AMaViS 0.3.12
Status: RO
X-Status:
X-Keywords:
X-UID: 2



1311: changed table orientation for network cabling.


----------------------- University of Baguio General Luna Road Baguio City Philippines 2600 Phone: +63(74)442-3540 Fax: +63(74)442-3071 http://www.ubaguio.edu



--------------------------------------- end of jopoy.txt -----------------------------------------


--------------------------------------- output ---------------------------------------------------



================================================= Date: 10 Sep 2003 16:02:42 +0800 From: Mail System Internal Data <[EMAIL PROTECTED]>

This text is part of the internal format of your mail folder, and is not
a real message. It is created automatically by the mail system software.
If deleted, important folder data will be lost, and it will be re-created
with the data reset to initial values.

=================================================
Date: Tue, 9 Sep 2003 14:51:26 +0800 (PHT)
From: <[EMAIL PROTECTED]>



1311: changed table orientation for network cabling.


----------------------- University of Baguio General Luna Road Baguio City Philippines 2600 Phone: +63(74)442-3540 Fax: +63(74)442-3071 http://www.ubaguio.edu


=================================================


--------------------------------------- output ---------------------------------------------------



--
Philippine Linux Users' Group (PLUG) Mailing List
[EMAIL PROTECTED] (#PLUG @ irc.free.net.ph)
Official Website: http://plug.linux.org.ph
Searchable Archives: http://marc.free.net.ph
.
To leave, go to http://lists.q-linux.com/mailman/listinfo/plug
.
Are you a Linux newbie? To join the newbie list, go to
http://lists.q-linux.com/mailman/listinfo/ph-linux-newbie

Reply via email to