Revision: 2050 Author: olavmrk Date: Tue Dec 8 06:16:49 2009 Log: statistics: Handle new year wraparound without year included in log lines.
Merged into 1.5 branch from r2049. http://code.google.com/p/simplesamlphp/source/detail?r=2050 Modified: /branches/simplesamlphp-1.5/docs/simplesamlphp-changelog.txt /branches/simplesamlphp-1.5/modules/statistics/lib/LogParser.php ======================================= --- /branches/simplesamlphp-1.5/docs/simplesamlphp-changelog.txt Mon Dec 7 06:15:13 2009 +++ /branches/simplesamlphp-1.5/docs/simplesamlphp-changelog.txt Tue Dec 8 06:16:49 2009 @@ -8,6 +8,7 @@ Released TBD. + * statistics: Handle new year wraparound. * Dictionary updates. * Fix bridged logout. * Some documentation updates. ======================================= --- /branches/simplesamlphp-1.5/modules/statistics/lib/LogParser.php Mon Aug 17 02:05:29 2009 +++ /branches/simplesamlphp-1.5/modules/statistics/lib/LogParser.php Tue Dec 8 06:16:49 2009 @@ -25,6 +25,21 @@ public function parseEpoch($line) { $epoch = strtotime(substr($line, 0, $this->datelength)); + if ($epoch > time() + 60*60*24*31) { + /* + * More than a month in the future - probably caused by + * the log files missing the year. + * We will therefore subtrackt one year. + */ + $hour = gmdate('H', $epoch); + $minute = gmdate('i', $epoch); + $second = gmdate('s', $epoch); + $month = gmdate('n', $epoch); + $day = gmdate('j', $epoch); + $year = gmdate('Y', $epoch) - 1; + $epoch = gmmktime($hour, $minute, $second, $month, $day, $year); + } + // echo 'debug ' . $line . "\n"; // echo 'debug [' . substr($line, 0, $this->datelength) . '] => [' . $epoch . ']' . "\n"; return $epoch; -- You received this message because you are subscribed to the Google Groups "simpleSAMLphp commits" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/simplesamlphp-commits?hl=en.
