Commit 72ab9e21 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) spaces, curly braces etc diag_logs_filter.php

(cherry picked from commit db3601f4)
parent 9e3def1a
...@@ -46,30 +46,36 @@ function easyrule_find_rule_interface($int) { ...@@ -46,30 +46,36 @@ function easyrule_find_rule_interface($int) {
/* Borrowed from firewall_rules.php */ /* Borrowed from firewall_rules.php */
$iflist = get_configured_interface_with_descr(false, true); $iflist = get_configured_interface_with_descr(false, true);
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") {
$iflist['pptp'] = "PPTP VPN"; $iflist['pptp'] = "PPTP VPN";
}
if (isset($config['pppoe']['mode']) && $config['pppoe']['mode'] == "server") if (isset($config['pppoe']['mode']) && $config['pppoe']['mode'] == "server") {
$iflist['pppoe'] = "PPPoE VPN"; $iflist['pppoe'] = "PPPoE VPN";
}
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") {
$iflist['l2tp'] = "L2TP VPN"; $iflist['l2tp'] = "L2TP VPN";
}
/* add ipsec interfaces */ /* add ipsec interfaces */
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])){ if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])){
$iflist["enc0"] = "IPSEC"; $iflist["enc0"] = "IPSEC";
} }
if (isset($iflist[$int])) if (isset($iflist[$int])) {
return $int; return $int;
}
foreach ($iflist as $if => $ifd) { foreach ($iflist as $if => $ifd) {
if (strtolower($int) == strtolower($ifd)) if (strtolower($int) == strtolower($ifd)) {
return $if; return $if;
} }
}
if (substr($int, 0, 4) == "ovpn") if (substr($int, 0, 4) == "ovpn") {
return "openvpn"; return "openvpn";
}
return false; return false;
} }
...@@ -84,12 +90,14 @@ function easyrule_block_rule_exists($int = 'wan', $ipproto = "inet") { ...@@ -84,12 +90,14 @@ function easyrule_block_rule_exists($int = 'wan', $ipproto = "inet") {
/* Search through the rules for one referencing our alias */ /* Search through the rules for one referencing our alias */
foreach ($config['filter']['rule'] as $rule) { foreach ($config['filter']['rule'] as $rule) {
if (!is_array($rule) || !is_array($rule['source'])) if (!is_array($rule) || !is_array($rule['source'])) {
continue; continue;
}
$checkproto = isset($rule['ipprotocol']) ? $rule['ipprotocol'] : "inet"; $checkproto = isset($rule['ipprotocol']) ? $rule['ipprotocol'] : "inet";
if ($rule['source']['address'] == $blockaliasname . strtoupper($int) && ($rule['interface'] == $int) && ($checkproto == $ipproto)) if ($rule['source']['address'] == $blockaliasname . strtoupper($int) && ($rule['interface'] == $int) && ($checkproto == $ipproto)) {
return true; return true;
} }
}
return false; return false;
} }
...@@ -98,12 +106,14 @@ function easyrule_block_rule_create($int = 'wan', $ipproto = "inet") { ...@@ -98,12 +106,14 @@ function easyrule_block_rule_create($int = 'wan', $ipproto = "inet") {
$blockaliasname = 'EasyRuleBlockHosts'; $blockaliasname = 'EasyRuleBlockHosts';
/* If the alias doesn't exist, exit. /* If the alias doesn't exist, exit.
* Can't create an empty alias, and we don't know a host */ * Can't create an empty alias, and we don't know a host */
if (easyrule_block_alias_getid($int) === false) if (easyrule_block_alias_getid($int) === false) {
return false; return false;
}
/* If the rule already exists, no need to do it again */ /* If the rule already exists, no need to do it again */
if (easyrule_block_rule_exists($int, $ipproto)) if (easyrule_block_rule_exists($int, $ipproto)) {
return true; return true;
}
/* No rules, start a new array */ /* No rules, start a new array */
if (!is_array($config['filter']['rule'])) { if (!is_array($config['filter']['rule'])) {
...@@ -153,8 +163,9 @@ function easyrule_block_alias_add($host, $int = 'wan') { ...@@ -153,8 +163,9 @@ function easyrule_block_alias_add($host, $int = 'wan') {
$blockaliasname = 'EasyRuleBlockHosts'; $blockaliasname = 'EasyRuleBlockHosts';
/* If the host isn't a valid IP address, bail */ /* If the host isn't a valid IP address, bail */
$host = trim($host, "[]"); $host = trim($host, "[]");
if (!is_ipaddr($host) && !is_subnet($host)) if (!is_ipaddr($host) && !is_subnet($host)) {
return false; return false;
}
/* If there are no aliases, start an array */ /* If there are no aliases, start an array */
if (!isset($config['aliases']) || !is_array($config['aliases'])) { if (!isset($config['aliases']) || !is_array($config['aliases'])) {
...@@ -167,8 +178,9 @@ function easyrule_block_alias_add($host, $int = 'wan') { ...@@ -167,8 +178,9 @@ function easyrule_block_alias_add($host, $int = 'wan') {
/* Try to get the ID if the alias already exists */ /* Try to get the ID if the alias already exists */
$id = easyrule_block_alias_getid($int); $id = easyrule_block_alias_getid($int);
if ($id === false) if ($id === false) {
unset($id); unset($id);
}
$alias = array(); $alias = array();
if (is_subnet($host)) { if (is_subnet($host)) {
...@@ -183,8 +195,9 @@ function easyrule_block_alias_add($host, $int = 'wan') { ...@@ -183,8 +195,9 @@ function easyrule_block_alias_add($host, $int = 'wan') {
if (isset($id) && $a_aliases[$id]) { if (isset($id) && $a_aliases[$id]) {
/* Make sure this IP isn't already in the list. */ /* Make sure this IP isn't already in the list. */
if (in_array($host.'/'.$mask, explode(" ", $a_aliases[$id]['address']))) if (in_array($host.'/'.$mask, explode(" ", $a_aliases[$id]['address']))) {
return true; return true;
}
/* Since the alias already exists, just add to it. */ /* Since the alias already exists, just add to it. */
$alias['name'] = $a_aliases[$id]['name']; $alias['name'] = $a_aliases[$id]['name'];
$alias['type'] = $a_aliases[$id]['type']; $alias['type'] = $a_aliases[$id]['type'];
...@@ -203,10 +216,11 @@ function easyrule_block_alias_add($host, $int = 'wan') { ...@@ -203,10 +216,11 @@ function easyrule_block_alias_add($host, $int = 'wan') {
} }
/* Replace the old alias if needed, otherwise tack it on the end */ /* Replace the old alias if needed, otherwise tack it on the end */
if (isset($id) && $a_aliases[$id]) if (isset($id) && $a_aliases[$id]) {
$a_aliases[$id] = $alias; $a_aliases[$id] = $alias;
else } else {
$a_aliases[] = $alias; $a_aliases[] = $alias;
}
// Sort list // Sort list
$a_aliases = msort($a_aliases, "name"); $a_aliases = msort($a_aliases, "name");
...@@ -218,8 +232,9 @@ function easyrule_block_host_add($host, $int = 'wan', $ipproto = "inet") { ...@@ -218,8 +232,9 @@ function easyrule_block_host_add($host, $int = 'wan', $ipproto = "inet") {
global $retval; global $retval;
/* Bail if the supplied host is not a valid IP address */ /* Bail if the supplied host is not a valid IP address */
$host = trim($host, "[]"); $host = trim($host, "[]");
if (!is_ipaddr($host) && !is_subnet($host)) if (!is_ipaddr($host) && !is_subnet($host)) {
return false; return false;
}
/* Flag whether or not we need to reload the filter */ /* Flag whether or not we need to reload the filter */
$dirty = false; $dirty = false;
...@@ -273,18 +288,21 @@ function easyrule_pass_rule_add($int, $proto, $srchost, $dsthost, $dstport, $ipp ...@@ -273,18 +288,21 @@ function easyrule_pass_rule_add($int, $proto, $srchost, $dsthost, $dstport, $ipp
$filterent['ipprotocol'] = $ipproto; $filterent['ipprotocol'] = $ipproto;
$filterent['descr'] = gettext("Easy Rule: Passed from Firewall Log View"); $filterent['descr'] = gettext("Easy Rule: Passed from Firewall Log View");
if ($proto != "any") if ($proto != "any") {
$filterent['protocol'] = $proto; $filterent['protocol'] = $proto;
else } else {
unset($filterent['protocol']); unset($filterent['protocol']);
}
/* Default to only allow echo requests, since that's what most people want and /* Default to only allow echo requests, since that's what most people want and
* it should be a safe choice. */ * it should be a safe choice. */
if ($proto == "icmp") if ($proto == "icmp") {
$filterent['icmptype'] = 'echoreq'; $filterent['icmptype'] = 'echoreq';
}
if ((strtolower($proto) == "icmp6") || (strtolower($proto) == "icmpv6")) if ((strtolower($proto) == "icmp6") || (strtolower($proto) == "icmpv6")) {
$filterent['protocol'] = "icmp"; $filterent['protocol'] = "icmp";
}
if (is_subnet($srchost)) { if (is_subnet($srchost)) {
list($srchost, $srcmask) = explode("/", $srchost); list($srchost, $srcmask) = explode("/", $srchost);
...@@ -384,8 +402,9 @@ function easyrule_parse_pass($int, $proto, $src, $dst, $dstport = 0, $ipproto = ...@@ -384,8 +402,9 @@ function easyrule_parse_pass($int, $proto, $src, $dst, $dstport = 0, $ipproto =
********************************************************************************************************************/ ********************************************************************************************************************/
function get_port_with_service($port, $proto) { function get_port_with_service($port, $proto) {
if (!$port) if (!$port) {
return ''; return '';
}
$service = getservbyport($port, $proto); $service = getservbyport($port, $proto);
$portstr = ""; $portstr = "";
...@@ -400,24 +419,26 @@ function get_port_with_service($port, $proto) { ...@@ -400,24 +419,26 @@ function get_port_with_service($port, $proto) {
function find_rule_by_number($rulenum, $type = 'block') function find_rule_by_number($rulenum, $type = 'block')
{ {
/* Passing arbitrary input to grep could be a Very Bad Thing(tm) */ /* Passing arbitrary input to grep could be a Very Bad Thing(tm) */
if (!is_numeric($rulenum) || !in_array($type, array('pass', 'block', 'match', 'rdr'))) if (!is_numeric($rulenum) || !in_array($type, array('pass', 'block', 'match', 'rdr'))) {
return; return;
}
$lookup_pattern = "^@{$rulenum}[[:space:]]{$type}[[:space:]].*[[:space:]]log[[:space:]]"; $lookup_pattern = "^@{$rulenum}[[:space:]]{$type}[[:space:]].*[[:space:]]log[[:space:]]";
/* At the moment, miniupnpd is the only thing I know of that /* At the moment, miniupnpd is the only thing I know of that
generates logging rdr rules */ generates logging rdr rules */
unset($buffer); unset($buffer);
if ($type == "rdr") if ($type == "rdr") {
$_gb = exec("/sbin/pfctl -vvPsn -a \"miniupnpd\" | /usr/bin/egrep " . escapeshellarg("^@{$rulenum}"), $buffer); $_gb = exec("/sbin/pfctl -vvPsn -a \"miniupnpd\" | /usr/bin/egrep " . escapeshellarg("^@{$rulenum}"), $buffer);
else { } else {
if (file_exists('/tmp/rules.debug')) { if (file_exists('/tmp/rules.debug')) {
$_gb = exec('/sbin/pfctl -vvPnf /tmp/rules.debug 2>/dev/null | /usr/bin/egrep ' . escapeshellarg($lookup_pattern), $buffer); $_gb = exec('/sbin/pfctl -vvPnf /tmp/rules.debug 2>/dev/null | /usr/bin/egrep ' . escapeshellarg($lookup_pattern), $buffer);
} else { } else {
$_gb = exec('/sbin/pfctl -vvPsr | /usr/bin/egrep ' . escapeshellarg($lookup_pattern), $buffer); $_gb = exec('/sbin/pfctl -vvPsr | /usr/bin/egrep ' . escapeshellarg($lookup_pattern), $buffer);
} }
} }
if (is_array($buffer)) if (is_array($buffer)) {
return $buffer[0]; return $buffer[0];
}
return ""; return "";
} }
...@@ -493,17 +514,16 @@ if (isset($_POST['resolve'])) { ...@@ -493,17 +514,16 @@ if (isset($_POST['resolve'])) {
$ip = strtolower($_POST['resolve']); $ip = strtolower($_POST['resolve']);
$res = (is_ipaddr($ip) ? gethostbyaddr($ip) : ''); $res = (is_ipaddr($ip) ? gethostbyaddr($ip) : '');
if ($res && $res != $ip) if ($res && $res != $ip) {
$response = array('resolve_ip' => $ip, 'resolve_text' => $res); $response = array('resolve_ip' => $ip, 'resolve_text' => $res);
else } else {
$response = array('resolve_ip' => $ip, 'resolve_text' => gettext("Cannot resolve")); $response = array('resolve_ip' => $ip, 'resolve_text' => gettext("Cannot resolve"));
}
echo json_encode(str_replace("\\","\\\\", $response)); // single escape chars can break JSON decode echo json_encode(str_replace("\\","\\\\", $response)); // single escape chars can break JSON decode
exit; exit;
} }
if (isset($_POST['easyrule'])) { if (isset($_POST['easyrule'])) {
$response = array("status"=>"unknown") ; $response = array("status"=>"unknown") ;
switch ($_POST['easyrule']) { switch ($_POST['easyrule']) {
case 'block': case 'block':
...@@ -516,7 +536,6 @@ if (isset($_POST['easyrule'])) { ...@@ -516,7 +536,6 @@ if (isset($_POST['easyrule'])) {
break; break;
} }
echo json_encode(str_replace("\\","\\\\", $response)); echo json_encode(str_replace("\\","\\\\", $response));
exit; exit;
} }
...@@ -524,15 +543,17 @@ if (isset($_POST['easyrule'])) { ...@@ -524,15 +543,17 @@ if (isset($_POST['easyrule'])) {
function getGETPOSTsettingvalue($settingname, $default) function getGETPOSTsettingvalue($settingname, $default)
{ {
$settingvalue = $default; $settingvalue = $default;
if(isset($_GET[$settingname])) if (isset($_GET[$settingname])) {
$settingvalue = $_GET[$settingname]; $settingvalue = $_GET[$settingname];
if(isset($_POST[$settingname])) }
if (isset($_POST[$settingname])) {
$settingvalue = $_POST[$settingname]; $settingvalue = $_POST[$settingname];
}
return $settingvalue; return $settingvalue;
} }
$rulenum = getGETPOSTsettingvalue('getrulenum', null); $rulenum = getGETPOSTsettingvalue('getrulenum', null);
if($rulenum) { if ($rulenum) {
list($rulenum, $type) = explode(',', $rulenum); list($rulenum, $type) = explode(',', $rulenum);
$rule = find_rule_by_number($rulenum, $type); $rule = find_rule_by_number($rulenum, $type);
echo gettext("The rule that triggered this action is") . ":\n\n{$rule}"; echo gettext("The rule that triggered this action is") . ":\n\n{$rule}";
...@@ -590,30 +611,23 @@ if (isset($_POST['clear'])) { ...@@ -590,30 +611,23 @@ if (isset($_POST['clear'])) {
} }
include("head.inc"); include("head.inc");
?> ?>
<script src="/javascript/filter_log.js" type="text/javascript"></script>
<body> <body>
<script src="/javascript/filter_log.js" type="text/javascript"></script>
<?php include("fbegin.inc"); ?> <?php include("fbegin.inc"); ?>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
<form id="filterlogentries" name="filterlogentries" action="diag_logs_filter.php" method="post"> <form id="filterlogentries" name="filterlogentries" action="diag_logs_filter.php" method="post">
<?php <?php
$Include_Act = explode(",", str_replace(" ", ",", $filterfieldsarray['act'])); $Include_Act = explode(",", str_replace(" ", ",", $filterfieldsarray['act']));
if ($filterfieldsarray['interface'] == "All") $interface = ""; if ($filterfieldsarray['interface'] == "All") $interface = "";
?> ?>
<div class="table-responsive widgetconfigdiv" id="filterlogentries_show"> <div class="table-responsive" id="filterlogentries_show">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
...@@ -632,11 +646,21 @@ include("head.inc"); ...@@ -632,11 +646,21 @@ include("head.inc");
<input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) echo "checked=\"checked\""; ?> />&nbsp;&nbsp;Pass <input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) echo "checked=\"checked\""; ?> />&nbsp;&nbsp;Pass
</label> </label>
</td> </td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Time') ?>" id="filterlogentries_time" name="filterlogentries_time" value="<?= $filterfieldsarray['time'] ?>"></td> <td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Source IP Address') ?>" id="filterlogentries_sourceipaddress" name="filterlogentries_sourceipaddress" value="<?= $filterfieldsarray['srcip'] ?>"></td> <input type="text" class="form-control" placeholder="<?= gettext('Time') ?>" id="filterlogentries_time" name="filterlogentries_time" value="<?= $filterfieldsarray['time'] ?>">
<td><input type="text" class="form-control" placeholder="<?= gettext('Source Port') ?>" id="filterlogentries_sourceport" name="filterlogentries_sourceport" value="<?= $filterfieldsarray['srcport'] ?>"></td> </td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Protocol') ?>" id="filterlogentries_protocol" name="filterlogentries_protocol" value="<?= $filterfieldsarray['proto'] ?>"></td> <td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Quantity') ?>" id="filterlogentries_qty" name="filterlogentries_qty" value="<?= $filterlogentries_qty ?>"></td> <input type="text" class="form-control" placeholder="<?= gettext('Source IP Address') ?>" id="filterlogentries_sourceipaddress" name="filterlogentries_sourceipaddress" value="<?= $filterfieldsarray['srcip'] ?>">
</td>
<td>
<input type="text" class="form-control" placeholder="<?= gettext('Source Port') ?>" id="filterlogentries_sourceport" name="filterlogentries_sourceport" value="<?= $filterfieldsarray['srcport'] ?>">
</td>
<td>
<input type="text" class="form-control" placeholder="<?= gettext('Protocol') ?>" id="filterlogentries_protocol" name="filterlogentries_protocol" value="<?= $filterfieldsarray['proto'] ?>">
</td>
<td>
<input type="text" class="form-control" placeholder="<?= gettext('Quantity') ?>" id="filterlogentries_qty" name="filterlogentries_qty" value="<?= $filterlogentries_qty ?>">
</td>
</tr> </tr>
<tr> <tr>
<td> <td>
...@@ -644,10 +668,18 @@ include("head.inc"); ...@@ -644,10 +668,18 @@ include("head.inc");
<input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) echo "checked=\"checked\""; ?> /> &nbsp;&nbsp;Block <input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) echo "checked=\"checked\""; ?> /> &nbsp;&nbsp;Block
</label> </label>
</td> </td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Interface') ?>" id="filterlogentries_interfaces" name="filterlogentries_interfaces" value="<?= $filterfieldsarray['interface'] ?>"></td> <td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Destination IP Address') ?>" id="filterlogentries_destinationipaddress" name="filterlogentries_destinationipaddress" value="<?= $filterfieldsarray['dstip'] ?>"></td> <input type="text" class="form-control" placeholder="<?= gettext('Interface') ?>" id="filterlogentries_interfaces" name="filterlogentries_interfaces" value="<?= $filterfieldsarray['interface'] ?>">
<td><input type="text" class="form-control" placeholder="<?= gettext('Destination Port') ?>" id="filterlogentries_destinationport" name="filterlogentries_destinationport" value="<?= $filterfieldsarray['dstport'] ?>"></td> </td>
<td><input type="text" class="form-control" placeholder="<?= gettext('Protocol Flags') ?>" id="filterlogentries_protocolflags" name="filterlogentries_protocolflags" value="<?= $filterfieldsarray['tcpflags'] ?>"></td> <td>
<input type="text" class="form-control" placeholder="<?= gettext('Destination IP Address') ?>" id="filterlogentries_destinationipaddress" name="filterlogentries_destinationipaddress" value="<?= $filterfieldsarray['dstip'] ?>">
</td>
<td>
<input type="text" class="form-control" placeholder="<?= gettext('Destination Port') ?>" id="filterlogentries_destinationport" name="filterlogentries_destinationport" value="<?= $filterfieldsarray['dstport'] ?>">
</td>
<td>
<input type="text" class="form-control" placeholder="<?= gettext('Protocol Flags') ?>" id="filterlogentries_protocolflags" name="filterlogentries_protocolflags" value="<?= $filterfieldsarray['tcpflags'] ?>">
</td>
<td> <td>
<select class="form-control" id="filterlogentries_version" name="filterlogentries_version"> <select class="form-control" id="filterlogentries_version" name="filterlogentries_version">
<?php <?php
...@@ -662,7 +694,7 @@ include("head.inc"); ...@@ -662,7 +694,7 @@ include("head.inc");
</tr> </tr>
<tr> <tr>
<td colspan="6"> <td colspan="6">
<span class="vexpl"><a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP Flags</a>: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, W - CWR</span> <span><a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP Flags</a>: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, W - CWR</span>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -676,59 +708,59 @@ include("head.inc"); ...@@ -676,59 +708,59 @@ include("head.inc");
</tbody> </tbody>
</table> </table>
</div> </div>
</form> </form>
</div> </div>
</section> </section>
<section class="col-xs-12"> <section class="col-xs-12">
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sort"> <table class="table table-striped">
<?php
<?php
$iflist = get_configured_interface_with_descr(false, true); $iflist = get_configured_interface_with_descr(false, true);
if (isset($iflist[$interfacefilter])) if (isset($iflist[$interfacefilter])) {
$interfacefilter = $iflist[$interfacefilter]; $interfacefilter = $iflist[$interfacefilter];
if (isset($filtersubmit)) }
if (isset($filtersubmit)) {
$filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100, $filterfieldsarray); $filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100, $filterfieldsarray);
else } else {
$filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100, $filtertext, $interfacefilter); $filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100, $filtertext, $interfacefilter);
}
?> ?>
<tr> <tr>
<td colspan="<?=isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions']==="1"?7:6?>" class="listtopic"> <td colspan="<?=isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions']==="1"?7:6?>">
<strong> <strong>
<?php if ( (!$filtertext) && (!$filterfieldsarray) ) <?php
if ( (!$filtertext) && (!$filterfieldsarray) ) {
printf(gettext("Last %s firewall log entries."),count($filterlog)); printf(gettext("Last %s firewall log entries."),count($filterlog));
else } else {
echo sprintf(gettext('Showing %s matching log entries (maximum is %s).'), count($filterlog), $nentries);?> echo sprintf(gettext('Showing %s matching log entries (maximum is %s).'), count($filterlog), $nentries);
}?>
</strong> </strong>
</td> </td>
</tr> </tr>
<tr class="sortableHeaderRowIdentifier"> <tr>
<td width="50" class="listhdrr"><?=gettext("Act");?></td> <td width="50"><?=gettext("Act");?></td>
<td class="listhdrr"><?=gettext("Time");?></td> <td><?=gettext("Time");?></td>
<td class="listhdrr"><?=gettext("If");?></td> <td><?=gettext("If");?></td>
<?php if (isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions'] === "1"):?> <?php if (isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions'] === "1"):?>
<td width="10%" class="listhdrr"><?=gettext("Rule");?></td> <td width="10%"><?=gettext("Rule");?></td>
<?php endif;?> <?php endif;?>
<td class="listhdrr"><?=gettext("Source");?></td> <td><?=gettext("Source");?></td>
<td class="listhdrr"><?=gettext("Destination");?></td> <td><?=gettext("Destination");?></td>
<td class="listhdrr"><?=gettext("Proto");?></td> <td><?=gettext("Proto");?></td>
</tr> </tr>
<?php <?php
if (isset($config['syslog']['filterdescriptions'])) if (isset($config['syslog']['filterdescriptions'])) {
buffer_rules_load(); buffer_rules_load();
}
$rowIndex = 0; $rowIndex = 0;
foreach ($filterlog as $filterent): foreach ($filterlog as $filterent):
$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
$rowIndex++;?> $rowIndex++;?>
<tr class="<?=$evenRowClass?>"> <tr class="<?=$evenRowClass?>">
<td class="listMRlr nowrap" align="center" sorttable_customkey="<?=$filterent['act']?>"> <td>
<a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);" title="<?php echo $filterent['act'];?>"><span class="glyphicon glyphicon-<?php switch ($filterent['act']) { <a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);" title="<?php echo $filterent['act'];?>">
<span class="glyphicon glyphicon-<?php switch ($filterent['act']) {
case 'pass': case 'pass':
echo "play"; /* icon triangle */ echo "play"; /* icon triangle */
break; break;
...@@ -740,18 +772,23 @@ include("head.inc"); ...@@ -740,18 +772,23 @@ include("head.inc");
default: default:
echo 'remove'; /* a x*/ echo 'remove'; /* a x*/
break; break;
} }?>">
?>"></span></a></td> </span>
<?php if (isset($filterent['count'])) echo $filterent['count'];?></a></center></td> </a>
<td class="listMRr nowrap"><?php echo htmlspecialchars($filterent['time']);?></td> </td>
<td class="listMRr nowrap"> <td><?php echo htmlspecialchars($filterent['time']);?></td>
<?php if ($filterent['direction'] == "out"): ?> <td>
<?php
if ($filterent['direction'] == "out"): ?>
<span class="glyphicon glyphicon-cloud-download" alt="<?= gettext('Direction=OUT') ?>" title="<?= gettext('Direction=OUT') ?>"></span> <span class="glyphicon glyphicon-cloud-download" alt="<?= gettext('Direction=OUT') ?>" title="<?= gettext('Direction=OUT') ?>"></span>
<?php endif; ?> <?php
<?php echo htmlspecialchars($filterent['interface']);?></td> endif; ?>
<?php <?=htmlspecialchars($filterent['interface']);?>
if (isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions'] === "1") </td>
<?php
if (isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions'] === "1") {
echo("<td class=\"listMRr nowrap\">".find_rule_by_number_buffer($filterent['rulenum'],$filterent['act'])."</td>"); echo("<td class=\"listMRr nowrap\">".find_rule_by_number_buffer($filterent['rulenum'],$filterent['act'])."</td>");
}
$int = strtolower($filterent['interface']); $int = strtolower($filterent['interface']);
$proto = strtolower($filterent['proto']); $proto = strtolower($filterent['proto']);
...@@ -762,60 +799,63 @@ include("head.inc"); ...@@ -762,60 +799,63 @@ include("head.inc");
} else { } else {
$ipproto = "inet"; $ipproto = "inet";
} }
if (!isset($filterent['srcport'])) $filterent['srcport'] = null ; if (!isset($filterent['srcport'])) {
$filterent['srcport'] = null ;
}
$srcstr = $filterent['srcip'] . get_port_with_service($filterent['srcport'], $proto); $srcstr = $filterent['srcip'] . get_port_with_service($filterent['srcport'], $proto);
$src_htmlclass = str_replace(array('.', ':'), '-', $filterent['srcip']); $src_htmlclass = str_replace(array('.', ':'), '-', $filterent['srcip']);
if (!isset($filterent['dstport'])) $filterent['dstport'] = null ; if (!isset($filterent['dstport'])) {
$filterent['dstport'] = null ;
}
$dststr = $filterent['dstip'] . get_port_with_service($filterent['dstport'], $proto); $dststr = $filterent['dstip'] . get_port_with_service($filterent['dstport'], $proto);
$dst_htmlclass = str_replace(array('.', ':'), '-', $filterent['dstip']); $dst_htmlclass = str_replace(array('.', ':'), '-', $filterent['dstip']);
?> ?>
<td class="listMRr nowrap"> <td>
<span onclick="javascript:resolve_with_ajax('<?php echo "{$filterent['srcip']}"; ?>');" title="<?=gettext("Click to resolve");?>" class="ICON-<?= $src_htmlclass; ?>" alt="Icon Reverse Resolve with DNS"><span class="btn btn-default btn-xs glyphicon glyphicon-info-sign"></span></span> <span onclick="javascript:resolve_with_ajax('<?php echo "{$filterent['srcip']}"; ?>');" title="<?=gettext("Click to resolve");?>" class="ICON-<?= $src_htmlclass; ?>" alt="Icon Reverse Resolve with DNS"><span class="btn btn-default btn-xs glyphicon glyphicon-info-sign"></span></span>
<a title="<?=gettext("Easy Rule: Add to Block List");?>" href="#blockEasy" class="btn btn-danger btn-xs easy_block"> <a title="<?=gettext("Easy Rule: Add to Block List");?>" href="#blockEasy" class="btn btn-danger btn-xs easy_block">
<input type="hidden" value="<?= $filterent['srcip']; ?>" id="srcip"/> <input type="hidden" value="<?= $filterent['srcip']; ?>" class="srcip"/>
<input type="hidden" value="<?= $int;?>" id="intf"/> <input type="hidden" value="<?= $int;?>" class="intf"/>
<input type="hidden" value="<?= $ipproto;?>" id="ipproto"/> <input type="hidden" value="<?= $ipproto;?>" class="ipproto"/>
<span class="glyphicon glyphicon-remove" alt="Icon Easy Rule: Add to Block List"></span></a> <span class="glyphicon glyphicon-remove" alt="Icon Easy Rule: Add to Block List"></span></a>
<?php echo $srcstr . '<span class="RESOLVE-' . $src_htmlclass . '"></span>';?> <?php echo $srcstr . '<span class="RESOLVE-' . $src_htmlclass . '"></span>';?>
</td> </td>
<td class="listMRr nowrap"> <td>
<span onclick="javascript:resolve_with_ajax('<?php echo "{$filterent['dstip']}"; ?>');" title="<?=gettext("Click to resolve");?>" class="ICON-<?= $dst_htmlclass; ?>" alt="Icon Reverse Resolve with DNS"><span class="btn btn-default btn-xs glyphicon glyphicon-info-sign"></span></span> <span onclick="javascript:resolve_with_ajax('<?php echo "{$filterent['dstip']}"; ?>');" title="<?=gettext("Click to resolve");?>" class="ICON-<?= $dst_htmlclass; ?>" alt="Icon Reverse Resolve with DNS"><span class="btn btn-default btn-xs glyphicon glyphicon-info-sign"></span></span>
<a title="<?=gettext("Easy Rule: Pass this traffic");?>" href="#blockEasy" class="btn btn-success btn-xs easy_pass"> <a title="<?=gettext("Easy Rule: Pass this traffic");?>" href="#blockEasy" class="btn btn-success btn-xs easy_pass">
<input type="hidden" value="<?= $filterent['srcip']; ?>" id="srcip"/> <input type="hidden" value="<?= $filterent['srcip']; ?>" class="srcip"/>
<input type="hidden" value="<?= $filterent['dstip']; ?>" id="dstip"/> <input type="hidden" value="<?= $filterent['dstip']; ?>" class="dstip"/>
<input type="hidden" value="<?= $filterent['dstport']; ?>" id="dstport"/> <input type="hidden" value="<?= $filterent['dstport']; ?>" class="dstport"/>
<input type="hidden" value="<?= $int;?>" id="intf"/> <input type="hidden" value="<?= $int;?>" class="intf"/>
<input type="hidden" value="<?= $proto;?>" id="proto"/> <input type="hidden" value="<?= $proto;?>" class="proto"/>
<input type="hidden" value="<?= $ipproto;?>" id="ipproto"/> <input type="hidden" value="<?= $ipproto;?>" class="ipproto"/>
<span class="glyphicon glyphicon-play" alt="<?= gettext('Icon Easy Rule: Pass this traffic') ?>"></span></a> <span class="glyphicon glyphicon-play" alt="<?= gettext('Icon Easy Rule: Pass this traffic') ?>"></span></a>
<?php echo $dststr . '<span class="RESOLVE-' . $dst_htmlclass . '"></span>';?> <?php echo $dststr . '<span class="RESOLVE-' . $dst_htmlclass . '"></span>';?>
</td> </td>
<?php <?php
if ($filterent['proto'] == "TCP") if ($filterent['proto'] == "TCP") {
$filterent['proto'] .= ":{$filterent['tcpflags']}"; $filterent['proto'] .= ":{$filterent['tcpflags']}";
?> }?>
<td class="listMRr nowrap"><?php echo htmlspecialchars($filterent['proto']);?></td> <td>
<?php echo htmlspecialchars($filterent['proto']);?>
</td>
</tr> </tr>
<?php if (isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions'] === "2"):?> <?php
if (isset($config['syslog']['filterdescriptions']) && $config['syslog']['filterdescriptions'] === "2"):?>
<tr class="<?=$evenRowClass?>"> <tr class="<?=$evenRowClass?>">
<td colspan="2" class="listMRDescriptionL listMRlr" /> <td colspan="2"></td>
<td colspan="4" class="listMRDescriptionR listMRr nowrap"><?=find_rule_by_number_buffer($filterent['rulenum'],$filterent['act']);?></td> <td colspan="4"><?=find_rule_by_number_buffer($filterent['rulenum'],$filterent['act']);?></td>
</tr> </tr>
<?php endif; <?php
endif;
endforeach; endforeach;
buffer_rules_clear(); ?> buffer_rules_clear(); ?>
</table> </table>
</div> </div>
</td>
</tr>
</table>
</div> </div>
</section> </section>
</div> </div>
</div> </div>
</section> </section>
<!-- AJAXY STUFF --> <!-- AJAXY STUFF -->
...@@ -830,9 +870,9 @@ $( document ).ready(function() { ...@@ -830,9 +870,9 @@ $( document ).ready(function() {
dataType: 'json', dataType: 'json',
data: { data: {
easyrule:'block', easyrule:'block',
srcip:$(this).find('#srcip').val(), srcip:$(this).find('.srcip').val(),
ipproto:$(this).find('#ipproto').val(), ipproto:$(this).find('.ipproto').val(),
intf:$(this).find('#intf').val() intf:$(this).find('.intf').val()
}, },
complete: function(data,status) { complete: function(data,status) {
alert("<?= gettext('added block rule') ?>"); alert("<?= gettext('added block rule') ?>");
...@@ -849,12 +889,12 @@ $( document ).ready(function() { ...@@ -849,12 +889,12 @@ $( document ).ready(function() {
dataType: 'json', dataType: 'json',
data: { data: {
easyrule:'pass', easyrule:'pass',
srcip:$(this).find('#srcip').val(), srcip:$(this).find('.srcip').val(),
dstip:$(this).find('#dstip').val(), dstip:$(this).find('.dstip').val(),
dstport:$(this).find('#dstport').val(), dstport:$(this).find('.dstport').val(),
proto:$(this).find('#proto').val(), proto:$(this).find('.proto').val(),
ipproto:$(this).find('#ipproto').val(), ipproto:$(this).find('.ipproto').val(),
intf:$(this).find('#intf').val() intf:$(this).find('.intf').val()
}, },
complete: function(data,status) { complete: function(data,status) {
alert("<?= gettext('added pass rule') ?>"); alert("<?= gettext('added pass rule') ?>");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment