Jump to content

Text (log) file parse


razta

Recommended Posts

Hello,

Im wanting to read a text file and then return the output in a loop until the EOF is reached.

 

Here is the text file in question (PHPIDS log file):

"local/unknown",2009-08-04T13:10:58+01:00,52,"xss csrf id rfe lfi sqli","REQUEST.name=%3Cscript%3Ealert%28%27xss%27%29%3B%3C%2Fscript%3E GET.name=%3Cscript%3Ealert%28%27xss%27%29%3B%3C%2Fscript%3E","%2Fdvwa%2Fvulnerabilities%2Fxss%2F%3Fname%3D%253Cscript%253Ealert%2528%2527xss%2527%2529%253B%253C%252Fscript%253E","127.0.0.1"
"local/unknown",2009-08-04T13:35:24+01:00,12,"sqli id lfi","REQUEST.name=%27 GET.name=%27","%2Fdvwa%2Fvulnerabilities%2Fxss%2F%3Fname%3D%2527","127.0.0.1"

 

And here is where I have got up to so far:


function readLog(){
$Lines = file(PHPIDS_LOG.txt);
$LineCount = count($Lines);
$Data = array();
$i = 0;

// Loop through each line
foreach($Lines as $Value)
{
$Data[$i] = explode(",", $Value);
// Increase the line index
$i++;
}

return $Data[0][1];
}

 

What im struggleing with is returning the $Data variable within a loop. Here is an example of how I wish the output to look:

Unknown: local/unknown
Date: 2009-08-04
Time: 13:10:58+01:00
[...]
<hr>
Unknown: local/unknown
Date: 2009-08-04
Time: 13:10:58+01:00
[...]

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/169516-text-log-file-parse/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.