73 {
75
76 if (!is_dir($this->statdir)) {
77 throw new Exception('Statistics module: output dir do not exists [' . $this->statdir . ']');
78 }
79
80 if (!file_exists($this->inputfile)) {
81 throw new Exception('Statistics module: input file do not exists [' . $this->inputfile . ']');
82 }
83
84 $file = fopen($this->inputfile, 'r');
85
86 if ($file === false) {
87 throw new Exception('Statistics module: unable to open file [' . $this->inputfile . ']');
88 }
89
91 $this->statconfig->getValue('datestart', 0), $this->statconfig->getValue('datelength', 15), $this->statconfig->getValue('offsetspan', 44)
92 );
93 $datehandler = array(
96 );
97
98 $notBefore = 0;
99 $lastRead = 0;
100 $lastlinehash = '-';
101
102 if (isset($this->metadata)) {
103 $notBefore = $this->metadata['notBefore'];
104 $lastlinehash = $this->metadata['lastlinehash'];
105 }
106
107 $lastlogline = 'sdfsdf';
108 $lastlineflip = false;
110
112
113 while (!feof($file)) {
114 $logline = fgets($file, 4096);
115
116
117 if (!preg_match('/STAT/', $logline)) {
118 continue;
119 }
120
122 $lastlogline = $logline;
123
124
125 $epoch = $logparser->parseEpoch($logline);
126 $content = $logparser->parseContent($logline);
128
129 if ($this->fromcmdline && (
$i % 10000) == 0) {
130 echo(
"Read line " .
$i .
"\n");
131 }
132
134 echo("----------------------------------------\n");
135 echo('Log line: ' . $logline . "\n");
136 echo('Date parse [' . substr($logline, 0, $this->statconfig->getValue('datelength', 15)) . '] to [' . date(DATE_RFC822, $epoch) . ']' . "\n");
137 echo htmlentities(print_r($content, true));
140 }
141 }
142
143 if ($epoch > $lastRead) {
144 $lastRead = $epoch;
145 }
146
147 if ($epoch === $notBefore) {
148 if (!$lastlineflip) {
149 if (sha1($logline) === $lastlinehash) {
150 $lastlineflip = true;
151 }
152 continue;
153 }
154 }
155
156 if ($epoch < $notBefore) {
157 continue;
158 }
159
160
161 foreach ($this->statrules as $rulename =>
$rule) {
163
164 if (array_key_exists(
'type',
$rule)) {
166 }
167
168 if (
$type !==
'aggregate') {
169 continue;
170 }
171
172 foreach ($this->timeres as $tres => $tresconfig ) {
173 $dh = 'default';
174 if (isset($tresconfig['customDateHandler'])) {
175 $dh = $tresconfig['customDateHandler'];
176 }
177
178 $timeslot = $datehandler['default']->toSlot($epoch, $tresconfig['slot']);
179 $fileslot = $datehandler[$dh]->toSlot($epoch, $tresconfig[
'fileslot']);
180
182 continue;
183 }
184
186
189 }
192 }
193
196 }
197 }
198 }
199 $this->metadata['notBefore'] = $lastRead;
200 $this->metadata['lastline'] = $lastlogline;
201 $this->metadata['lastlinehash'] = sha1($lastlogline);
203 }
static getDifCol($content, $colrule)