From 2eeb9e1762988e5654310af910c4b1fb1253ebdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Mon, 23 Feb 2009 13:33:52 +0000 Subject: [PATCH] Bug fixes in statistics git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1304 44740490-163a-0410-bde0-09ae8108e29a --- modules/statistics/lib/Aggregator.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php index 964de2f65..2c3be7c49 100644 --- a/modules/statistics/lib/Aggregator.php +++ b/modules/statistics/lib/Aggregator.php @@ -67,7 +67,7 @@ class sspmod_statistics_Aggregator { // Parse log, and extract epoch time and rest of content. $epoch = $logparser->parseEpoch($logline); $content = $logparser->parseContent($logline); - $action = $content[4]; + $action = $content[5]; if ($debug) { echo("----------------------------------------\n"); @@ -81,11 +81,11 @@ class sspmod_statistics_Aggregator { // Iterate all the statrules from config. foreach ($this->statrules AS $rulename => $rule) { - #echo 'Comparing action: [' . $rule['action'] . '] with [' . $action . ']'; + // echo 'Comparing action: [' . $rule['action'] . '] with [' . $action . ']' . "\n"; $timeslot = $datehandler->toSlot($epoch, $rule['slot']); $fileslot = $datehandler->toSlot($epoch, $rule['fileslot']); //print_r($content); - if (isset($rule['action']) && ($action !== $rule['action'])) continue; + if (!isset($rule['action']) && ($action !== $rule['action'])) continue; $difcol = $content[$rule['col']]; // echo '[...' . $difcol . '...]'; @@ -94,6 +94,7 @@ class sspmod_statistics_Aggregator { $results[$rulename][$fileslot][$timeslot]['_']++; $results[$rulename][$fileslot][$timeslot][$difcol]++; + } } return $results; @@ -102,6 +103,8 @@ class sspmod_statistics_Aggregator { public function store($results) { + $datehandler = new sspmod_statistics_DateHandler($this->offset); + // Iterate the first level of results, which is per rule, as defined in the config. foreach ($results AS $rulename => $ruleresults) { @@ -121,7 +124,7 @@ class sspmod_statistics_Aggregator { } // store file - file_put_contents($statdir . '/' . $rulename . '-' . $fileno . '.stat', serialize($filledresult), LOCK_EX ); + file_put_contents($this->statdir . '/' . $rulename . '-' . $fileno . '.stat', serialize($filledresult), LOCK_EX ); } } -- GitLab