Skip to content

Commit

Permalink
Requests count rolled back
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergull committed Sep 8, 2023
1 parent 50733e1 commit e529667
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions inc/spbc-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ function spbc_get_brief_data_for_firewalls($current_fw_data, $current_bfp_data,

// get new records of all types
$new_log_data = array();
$fw_data_query = 'SELECT entry_timestamp as ts, status, requests' .
$fw_data_query = 'SELECT entry_timestamp as ts, status' .
' FROM ' . SPBC_TBL_FIREWALL_LOG
// exclude too old
. ' WHERE entry_timestamp > (UNIX_TIMESTAMP() - ' . ($days_limit * 3600 * 24) . ') AND'
Expand Down Expand Up @@ -623,18 +623,18 @@ function spbc_get_brief_data_for_firewalls($current_fw_data, $current_bfp_data,
// collect new events counters by type
foreach ($new_log_data as $_entry => $value) {
// skip wrong records
if (!isset($value['status'], $value['ts'], $value['requests'])) {
if (!isset($value['status'], $value['ts'])) {
continue;
}

$day = date('Y-m-d', (int)$value['ts']);

if ($value['status'] === 'DENY_BY_BFP') {
$count = in_array($day, array_keys($new_bfp_data)) ? $new_bfp_data[$day]['count'] + (int)$value['requests'] : (int)$value['requests'];
$count = in_array($day, array_keys($new_bfp_data)) ? $new_bfp_data[$day]['count'] + 1 : 1;
$new_bfp_data[$day] = array('day' => $day,
'count' => $count);
} else {
$count = in_array($day, array_keys($new_fw_data)) ? $new_fw_data[$day]['count'] + (int)$value['requests'] : (int)$value['requests'];
$count = in_array($day, array_keys($new_fw_data)) ? $new_fw_data[$day]['count'] + 1 : 1;
$new_fw_data[$day] = array('day' => $day,
'count' => $count);
}
Expand Down

0 comments on commit e529667

Please sign in to comment.