ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LogParser.php
Go to the documentation of this file.
1<?php
2/*
3 * @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
4 * @package SimpleSAMLphp
5 */
7{
11 private $datestart;
12
16 private $datelength;
17
21 private $offset;
22
31 {
32 $this->datestart = $datestart;
33 $this->datelength = $datelength;
34 $this->offset = $offset;
35 }
36
37
43 public function parseEpoch($line)
44 {
45 $epoch = strtotime(substr($line, 0, $this->datelength));
46 if ($epoch > time() + 2678400) { // 60 * 60 *24 * 31 = 2678400
47 /*
48 * More than a month in the future - probably caused by
49 * the log files missing the year.
50 * We will therefore subtrackt one year.
51 */
52 $hour = gmdate('H', $epoch);
53 $minute = gmdate('i', $epoch);
54 $second = gmdate('s', $epoch);
55 $month = gmdate('n', $epoch);
56 $day = gmdate('j', $epoch);
57 $year = gmdate('Y', $epoch) - 1;
58 $epoch = gmmktime($hour, $minute, $second, $month, $day, $year);
59 }
60 return $epoch;
61 }
62
63
69 public function parseContent($line)
70 {
71 $contentstr = substr($line, $this->offset);
72 $content = explode(' ', $contentstr);
73 return $content;
74 }
75}
An exception for terminatinating execution or to throw for unit testing.
__construct($datestart, $datelength, $offset)
Constructor.
Definition: LogParser.php:30