Fixed mailparser ignoring last day of year
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
This commit is contained in:
@@ -249,21 +249,17 @@ class MailLogParser {
|
|||||||
* @param int traffic
|
* @param int traffic
|
||||||
*/
|
*/
|
||||||
private function _addDomainTraffic($domain, $traffic, $timestamp) {
|
private function _addDomainTraffic($domain, $traffic, $timestamp) {
|
||||||
if ($timestamp < ($this->startTime + 60 * 60 * 24)) {
|
$date = date("Y-m-d", $timestamp);
|
||||||
// Only add traffic if it's not in the future!
|
if (in_array($domain, $this->myDomains)) {
|
||||||
$date = date("Y-m-d", $timestamp);
|
if (array_key_exists($domain, $this->domainTraffic) && array_key_exists($date, $this->domainTraffic[$domain])) {
|
||||||
if (in_array($domain, $this->myDomains)) {
|
$this->domainTraffic[$domain][$date] += (int)$traffic;
|
||||||
if (array_key_exists($domain, $this->domainTraffic) && array_key_exists($date, $this->domainTraffic[$domain])) {
|
} else {
|
||||||
$this->domainTraffic[$domain][$date] += (int)$traffic;
|
if (!array_key_exists($domain, $this->domainTraffic)) {
|
||||||
} else {
|
$this->domainTraffic[$domain] = array();
|
||||||
if (!array_key_exists($domain, $this->domainTraffic)) {
|
|
||||||
$this->domainTraffic[$domain] = array();
|
|
||||||
}
|
|
||||||
$this->domainTraffic[$domain][$date] = (int)$traffic;
|
|
||||||
}
|
}
|
||||||
|
$this->domainTraffic[$domain][$date] = (int)$traffic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -274,7 +270,12 @@ class MailLogParser {
|
|||||||
*/
|
*/
|
||||||
private function _getLogTimestamp($line) {
|
private function _getLogTimestamp($line) {
|
||||||
if (preg_match("/((?:[A-Z]{3}\s{1,2}\d{1,2}|\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2})/i", $line, $matches)) {
|
if (preg_match("/((?:[A-Z]{3}\s{1,2}\d{1,2}|\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2})/i", $line, $matches)) {
|
||||||
return strtotime($matches[1]);
|
$timestamp = strtotime($matches[1]);
|
||||||
|
if ($timestamp > ($this->startTime + 60 * 60 * 24)) {
|
||||||
|
return strtotime($matches[1] . " -1 year");
|
||||||
|
} else {
|
||||||
|
return strtotime($matches[1]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user