PHP Classes
elePHPant
Icontem

white screen

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Apache log parser  >  All threads  >  white screen  >  (Un) Subscribe thread alerts  
Subject:white screen
Summary:the script is not printing anthing.
Messages:2
Author:Sukhjinder
Date:2012-12-12 07:57:39
 

  1. white screen   Reply   Report abuse  
Picture of Sukhjinder Sukhjinder - 2012-12-12 07:57:39
I run this script on my server it is not printing an array.

  2. Re: white screen   Reply   Report abuse  
Picture of ZeufLinux 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 ) ;
}