ZeufLinux - 2015-03-09 09:08:42 -
In reply to message 1 from Sukhjinder
Same here...
I had to modify the script.
Here is the first stone :
$file = 'test.log' ; // your CLF file
$badRows = 0 ;
$lignes = file ($file) ;
foreach ($lignes as $ligne) {
preg_match ("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) (\".*?\") (\".*?\")$/", $ligne, $logs) ;
if (isset($logs[0])) { // check that it formated OK
$formated_log['ip'] = $logs[1];
$formated_log['identity'] = $logs[2];
$formated_log['user'] = $logs[3];
$formated_log['date'] = $logs[4];
$formated_log['time'] = $logs[5];
$formated_log['timezone'] = $logs[6];
$formated_log['method'] = $logs[7];
$formated_log['path'] = $logs[8];
$formated_log['protocal'] = $logs[9];
$formated_log['status'] = $logs[10];
$formated_log['bytes'] = $logs[11];
$formated_log['referer'] = $logs[12];
$formated_log['agent'] = $logs[13];
$parsed_line = $formated_log; // return the array of info
}
else {
$badRows++ ;
}
echo '<pre>' ;
print_r ( $parsed_line ) ;
}