@@ -45,7 +45,7 @@ public function aggregate($debug = FALSE) {
4545
4646
4747 $ file = fopen ($ this ->inputfile , 'r ' );
48- $ logfile = file ($ this ->inputfile , FILE_IGNORE_NEW_LINES );
48+ # $logfile = file($this->inputfile, FILE_IGNORE_NEW_LINES );
4949
5050
5151 $ logparser = new sspmod_statistics_LogParser (
@@ -57,18 +57,27 @@ public function aggregate($debug = FALSE) {
5757
5858 $ i = 0 ;
5959 // Parse through log file, line by line
60- foreach ($ logfile AS $ logline ) {
61-
60+ while (!feof ($ file )) {
61+
62+ $ logline = fgets ($ file , 4096 );
63+
6264 // Continue if STAT is not found on line.
6365 if (!preg_match ('/STAT/ ' , $ logline )) continue ;
6466 $ i ++;
6567
6668 // Parse log, and extract epoch time and rest of content.
6769 $ epoch = $ logparser ->parseEpoch ($ logline );
6870 $ content = $ logparser ->parseContent ($ logline );
69- $ action = $ content [5 ];
71+ $ action = trim ($ content [5 ]);
72+
73+ if (($ i % 10000 ) == 0 ) {
74+ echo ("Read line " . $ i . "\n" );
75+ }
76+
7077
7178 if ($ debug ) {
79+
80+
7281 echo ("---------------------------------------- \n" );
7382 echo ('Log line: ' . $ logline . "\n" );
7483 echo ('Date parse [ ' . substr ($ logline , 0 , $ this ->statconfig ->getValue ('datelength ' , 15 )) . '] to [ ' . date (DATE_RFC822 , $ epoch ) . '] ' . "\n" );
@@ -88,7 +97,7 @@ public function aggregate($debug = FALSE) {
8897 if (isset ($ rule ['action ' ]) && ($ action !== $ rule ['action ' ])) continue ;
8998
9099
91- $ difcol = $ content [$ rule ['col ' ]]; // echo '[...' . $difcol . '...]';
100+ $ difcol = trim ( $ content [$ rule ['col ' ]]) ; // echo '[...' . $difcol . '...]';
92101
93102 if (!isset ($ results [$ rulename ][$ fileslot ][$ timeslot ]['_ ' ])) $ results [$ rulename ][$ fileslot ][$ timeslot ]['_ ' ] = 0 ;
94103 if (!isset ($ results [$ rulename ][$ fileslot ][$ timeslot ][$ difcol ])) $ results [$ rulename ][$ fileslot ][$ timeslot ][$ difcol ] = 0 ;
0 commit comments