NFW Daily Email Notification sent every 24 h. disregarding Daylight Saving Time
-
Hi,
It seems that instead of sending daily notification email on midnight (00:00) plugin counts 24 hours, not taking into account day light saving time.
See the function below on the file event_notifications.php:
// ---------------------------------------------------------------------
function nf_daily_report_log() {
if ( date('j') == 1 ) {
$cur_month_log = date('Y-m', strtotime( date('Y-m') .' -1 month') );
} else {
$cur_month_log = date('Y-m');
}
$previous_day = strtotime( date('Y-m-d 00:00:01', strtotime('-1 day') ) );
$logstats = [ 0 => 0, 1 => 0, 2 => 0, 3 => 0, 5 => 0 ];
$files = NinjaFirewall_helpers::nfw_glob(
NFW_LOG_DIR .'/nfwlog', 'firewall_'. $cur_month_log, true, true
);
// Parse each log
foreach( $files as $file ) {
// Stat the file: if it's older than 24 hours, we skip it
$log_stat = stat( $file );
if ( $log_stat['mtime'] < $previous_day ) {
continue;
}
$log_lines = file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
foreach ( $log_lines as $line ) {
if ( preg_match(
'/^\[(\d{10})\]\s+\[.+?\]\s+\[.+?\]\s+\[#\d{7}\]\s+\[\d+\]\s+\[([1235])\]\s+\[/',
$line, $match )
) {
// Fetch last 24 hours only
if ( $match[1] > $previous_day && $match[1] < $previous_day + 86400 ) {
++$logstats[ $match[2] ];
if ( strpos( $line, 'Brute-force attack detected') !== FALSE ) {
++$logstats[0];
}
}
}
}
}
return $logstats;
}
// ---------------------------------------------------------------------Can you please fix this issue?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.