Revision: 2049
Author: olavmrk
Date: Tue Dec 8 06:14:49 2009
Log: statistics: Handle new year wraparound without year included in log
lines.
http://code.google.com/p/simplesamlphp/source/detail?r=2049
Modified:
/trunk/modules/statistics/lib/LogParser.php
=======================================
--- /trunk/modules/statistics/lib/LogParser.php Mon Aug 17 02:05:29 2009
+++ /trunk/modules/statistics/lib/LogParser.php Tue Dec 8 06:14: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.