Monil Chheda wrote:

Hi,

I have a problem in grabbing data from a file.

I need to fetch data from raw log files and display it
in a proper tabular manner.

The log file contains:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AWSTATS DATA FILE 5.0 (build 1.345)
# If you remove this file, all statistics for date
2002-12 will be lost/reset.
# Position (offset in bytes) in this file of beginning
of each section
# for direct I/O access. If you made changes somewhere
in this file, you
# should also remove completely the MAP section
(AWStats will rewrite it
# at next update).
BEGIN_MAP 23
POS_GENERAL 1602 POS_PAGEREFS 4060 POS_SEARCHWORDS 5537 POS_KEYWORDS 5769 POS_ERRORS 5916 POS_SIDER_404 6040 POS_EMAILSENDER POS_EMAILRECEIVER END_MAP


BEGIN_GENERAL 8
LastLine 20030101041055
FirstTime 20021201004812
LastTime 20021231204118
LastUpdate 20030101044540 392 0 391 0 1
TotalVisits 279 TotalUnique 221 MonthHostsKnown 0 MonthHostsUnknown 258 END_GENERAL


~~~~~~~~~~~~~~~~~~~~~~~~~~

I need the contents between BEGIN_MAP and END_MAP to
be displayed on the browser.
But I need each word seperate in a tabular form. For
Example on the browser it should display:

LOG DETAILS             No.Of.Results.
POS_SEARCHWORDS                 5537
POS_KEYWORDS                    5769

------------------------------------------

I am using the following script: But it doesnot work.
Kindly help me.

<?php

if(!($myfile = fopen("test.txt","r")))
{
        echo "File $myfile could not be opened";
        exit;
}
else
{
        echo "$myfile Opened";
        exit;
}

while ($line = fgets($myfile))
{
        if(eregi("^\s*BEGIN_KEYWORDS", $line)) {

$display=true;
continue;
       }



if(eregi("^\s*END_KEYWORDS", $line)) {

$display=false;
continue; // optionaly break
       }

if($display && eregi('^\s*([a-z]+)\s+([0-9]+)',$line,$m)) {
   echo "<tr><td>$m[1]</td><td>$m[2]</td></tr>\n";
}

}

?>


Thank you.


Best Regards,
Monil Chheda
============================
+91-22-5699 1887
+91-22-2820 4125
+09821405705
http://www.eliteral.com
http://order.eliteral.com
http://domains.eliteral.com
http://services.eliteral.com
============================

=====
Best Regards,
Monil Chheda(INDIA)
http://domains.eliteral.com
===========================
===========================

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to