Skip to content

Commit

Permalink
hitcount - codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelloc authored and Charlie Root committed Sep 11, 2015
1 parent 8020b94 commit 68150d1
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/etc/inc/rule_count.inc
@@ -1,24 +1,23 @@
<?php
$rules_count_array=array();
$rules_count_array = array();
exec("/sbin/pfctl -vvsr | /usr/bin/grep -A1 ' label '",$cnt_pfctl);
if (!empty($cnt_pfctl)) {
foreach($cnt_pfctl as $line) {
if (preg_match('/@(\d+)\W\d+.*label "(USER_RULE: |)(.*)"/',$line,$m1)){
$cr=$m1[3];
$rl=$m1[2].$m1[3];
$rid=$m1[1];
foreach ($cnt_pfctl as $line) {
if (preg_match('/@(\d+)\W\d+.*label "(USER_RULE: |)(.*)"/',$line,$m1)) {
$cr = $m1[3];
$rl = $m1[2].$m1[3];
$rid = $m1[1];
continue;
}
if ($cr != "" && preg_match("/Evaluations:\s+(\d+)\s+Packets:\s+(\d+)\s+Bytes:\s+(\d+)\s+States:\s+(\d+)\s+/",$line,$m2)){
if (isset($rules_count_array[$cr][Packets])){
if ($cr != "" && preg_match("/Evaluations:\s+(\d+)\s+Packets:\s+(\d+)\s+Bytes:\s+(\d+)\s+States:\s+(\d+)\s+/",$line,$m2)) {
if (isset($rules_count_array[$cr][Packets])) {
$rules_count_array[$cr]['Packets'] += $m2[2];
$rules_count_array[$cr]['Evaluations'] += $m2[1];
$rules_count_array[$cr]['Bytes'] += $m2[3];
$rules_count_array[$cr]['States'] += $m2[4];
$rules_count_array[$cr]['RuleId'] .= "|$rid";
}else {

$rules_count_array[$cr]=array('Evaluations'=>$m2[1],'Packets'=>$m2[2],'Bytes'=>$m2[3],'States'=>$m2[4],'Label'=>$rl,'RuleId'=>$rid);
} else {
$rules_count_array[$cr]=array('Evaluations'=>$m2[1],'Packets'=>$m2[2],'Bytes'=>$m2[3],'States'=>$m2[4],'Label'=>$rl,'RuleId'=>$rid);
}
}
}
Expand Down

0 comments on commit 68150d1

Please sign in to comment.