summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/firewall_rules.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www/firewall_rules.php')
-rw-r--r--src/usr/local/www/firewall_rules.php194
1 files changed, 163 insertions, 31 deletions
diff --git a/src/usr/local/www/firewall_rules.php b/src/usr/local/www/firewall_rules.php
index 615f3bc..1d32e65 100644
--- a/src/usr/local/www/firewall_rules.php
+++ b/src/usr/local/www/firewall_rules.php
@@ -120,26 +120,26 @@ foreach ($ifdescs as $ifent => $ifdesc) {
if ($config['l2tp']['mode'] == "server") {
if (have_ruleint_access("l2tp")) {
- $iflist['l2tp'] = "L2TP VPN";
+ $iflist['l2tp'] = gettext("L2TP VPN");
}
}
if (is_array($config['pppoes']['pppoe'])) {
foreach ($config['pppoes']['pppoe'] as $pppoes) {
if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe")) {
- $iflist['pppoe'] = "PPPoE Server";
+ $iflist['pppoe'] = gettext("PPPoE Server");
}
}
}
/* add ipsec interfaces */
if (ipsec_enabled() && have_ruleint_access("enc0")) {
- $iflist["enc0"] = "IPsec";
+ $iflist["enc0"] = gettext("IPsec");
}
/* add openvpn/tun interfaces */
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) {
- $iflist["openvpn"] = "OpenVPN";
+ $iflist["openvpn"] = gettext("OpenVPN");
}
if (!$if || !isset($iflist[$if])) {
@@ -155,6 +155,7 @@ if (!$if || !isset($iflist[$if])) {
}
if ($_POST) {
+
$pconfig = $_POST;
if ($_POST['apply']) {
@@ -233,6 +234,16 @@ if (isset($_POST['del_x'])) {
}
$a_filter = $a_filter_new;
+
+ $config['filter']['separator'][strtolower($if)] = "";
+
+ if ($_POST['separator']) {
+ $idx = 0;
+ foreach ($_POST['separator'] as $separator) {
+ $config['filter']['separator'][strtolower($separator['if'])]['sep' . $idx++] = $separator;
+ }
+ }
+
if (write_config()) {
mark_subsystem_dirty('filter');
}
@@ -297,8 +308,8 @@ display_top_tabs($tab_array);
<?php
// Show the anti-lockout rule if it's enabled, and we are on LAN with an if count > 1, or WAN with an if count of 1.
if (!isset($config['system']['webgui']['noantilockout']) &&
- (((count($config['interfaces']) > 1) && ($if == 'lan')) ||
- ((count($config['interfaces']) == 1) && ($if == 'wan')))):
+ (((count($config['interfaces']) > 1) && ($if == 'lan')) ||
+ ((count($config['interfaces']) == 1) && ($if == 'wan')))):
$alports = implode('<br />', filter_get_antilockout_ports(true));
?>
<tr id="antilockout">
@@ -359,6 +370,16 @@ display_top_tabs($tab_array);
<tbody class="user-entries">
<?php
$nrules = 0;
+$seps = 0;
+
+// There can be a separator before any rules are listed
+if ($config['filter']['separator'][strtolower($if)]['sep0']['row'][0] == "fr-1") {
+ print('<tr class="ui-sortable-handle separator">' .
+ '<td bgcolor="#cce5ff" colspan="11">' . '<font color="#002699">' . $config['filter']['separator'][strtolower($if)]['sep0']['text'] . '</font></td>' .
+ '<td bgcolor="#cce5ff"><a href="#"><i class="fa fa-trash no-confirm sepdel" title="delete this separator"></i></a></td>' .
+ '</tr>' . "\n");
+}
+
for ($i = 0; isset($a_filter[$i]); $i++):
$filterent = $a_filter[$i];
@@ -367,6 +388,7 @@ for ($i = 0; isset($a_filter[$i]); $i++):
} else {
$display = "";
}
+
?>
<tr id="fr<?=$nrules;?>" <?=$display?> onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
<td >
@@ -517,7 +539,7 @@ for ($i = 0; isset($a_filter[$i]); $i++):
#FIXME
$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
$schedule_span_begin = '<a href="/firewall_schedule_edit.php?id=' . $idx . '" data-toggle="popover" data-trigger="hover focus" title="' . $schedule['name'] . '" data-content="' .
- $sched_caption_escaped . '" data-html="true">';
+ $sched_caption_escaped . '" data-html="true">';
$schedule_span_end = "";
}
}
@@ -528,7 +550,7 @@ for ($i = 0; isset($a_filter[$i]); $i++):
$image = "";
if (!isset($filterent['disabled'])) {
if ($schedstatus) {
- if ($iconfn == "block" || $iconfn == "reject") {
+ if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
$image = "times-circle";
$dispcolor = "text-danger";
$alttext = gettext("Traffic matching this rule is currently being denied");
@@ -539,13 +561,13 @@ for ($i = 0; isset($a_filter[$i]); $i++):
}
$printicon = true;
} else if ($filterent['sched']) {
- if ($iconfn == "block" || $iconfn == "reject") {
+ if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
$image = "times-circle";
} else {
- $image = "times-circle";
+ $image = "play-circle";
}
$alttext = gettext("This rule is not currently active because its period has expired");
- $dispcolor = "text-danger";
+ $dispcolor = "text-warning";
$printicon = true;
}
}
@@ -572,7 +594,7 @@ for ($i = 0; isset($a_filter[$i]); $i++):
echo strtoupper($filterent['protocol']);
if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
- echo ' <span style="cursor: help;" title="ICMP type: ' .
+ echo ' <span style="cursor: help;" title="' . gettext('ICMP type') . ': ' .
($filterent['ipprotocol'] == "inet6" ? $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']]) .
'"><u>';
echo $filterent['icmptype'];
@@ -584,25 +606,25 @@ for ($i = 0; isset($a_filter[$i]); $i++):
</td>
<td>
<?php if (isset($alias['src'])): ?>
- <a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
+ <a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
<?php endif; ?>
<?=htmlspecialchars(pprint_address($filterent['source']))?>
</td>
<td>
<?php if (isset($alias['srcport'])): ?>
- <a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
+ <a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
<?php endif; ?>
<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
</td>
<td>
<?php if (isset($alias['dst'])): ?>
- <a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
+ <a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
<?php endif; ?>
<?=htmlspecialchars(pprint_address($filterent['destination']))?>
</td>
<td>
<?php if (isset($alias['dstport'])): ?>
- <a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
+ <a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
<?php endif; ?>
<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
</td>
@@ -653,6 +675,18 @@ for ($i = 0; isset($a_filter[$i]); $i++):
</td>
</tr>
<?php
+ if (isset($config['filter']['separator'][strtolower($if)]['sep0'])) {
+ foreach ($config['filter']['separator'][strtolower($if)] as $rulesep) {
+ if ($rulesep['row']['0'] == "fr" . $nrules) {
+ $cellcolor = $rulesep['color'];
+ print('<tr class="ui-sortable-handle separator">' .
+ '<td class="' . $cellcolor . '" colspan="11">' . '<font class="' . $cellcolor . '">' . $rulesep['text'] . '</font></td>' .
+ '<td class="' . $cellcolor . '"><a href="#"><i class="fa fa-trash no-confirm sepdel" title="delete this separator"></i></a></td>' .
+ '</tr>' . "\n");
+ }
+ }
+ }
+
$nrules++;
endfor;
?>
@@ -745,37 +779,135 @@ events.push(function() {
// Check all of the rule checkboxes so that their values are posted
$('#order-store').click(function () {
- $('[id^=frc]').prop('checked', true);
+ $('[id^=frc]').prop('checked', true);
+
+ // Save the separator bar configuration
+ save_separators();
});
- // Separator bar stuff
+ // Separator bar stuff ------------------------------------------------------------------------
+
+ // Globals
+ gColor = 'bg-info';
+ newSeperator = false;
+
$("#addsep").prop('type' ,'button');
- $("#addsep").click(function() {
- alert("This feature is not yet complete. (Nothing is saved)\nIncluded for review only.");
- $('#ruletable > tbody:last').append('<tr>' +
- '<td bgcolor="#cce5ff" colspan="10"><input id="newsep" placeholder="<?=gettext("Enter a description, Save, then drag to final location.")?>" class="col-md-12" type="text"></input></td>' +
- '<td bgcolor="#cce5ff" colspan="2"><button class="btn btn-default btn-sm" id="btnnewsep"><?=gettext("Save")?></button></td>' +
- '</tr>');
+ $("#addsep").click(function() {
+ if (newSeperator) {
+ return(false);
+ }
+
+ gColor = 'bg-info';
+ // Inset a temporary bar in which the user can enter some optional text
+ $('#ruletable > tbody:last').append('<tr>' +
+ '<td class="' + gColor + '" colspan="10"><input id="newsep" placeholder="<?=gettext("Enter a description, Save, then drag to final location.")?>" class="col-md-12" type="text"></input></td>' +
+ '<td class="' + gColor + '" colspan="2"><button class="btn btn-default btn-sm" id="btnnewsep"><?=gettext("Save")?></button>' +
+ '<button class="btn btn-default btn-sm" id="btncncsep"><?=gettext("Cancel")?></button>' +
+ '&nbsp;&nbsp;&nbsp;&nbsp;' +
+ '&nbsp;&nbsp;<a href="#" id="sepclrblue" value="bg-info"><i class="fa fa-circle text-info"></i></a>' +
+ '&nbsp;&nbsp;<a href="#" id="sepclrred" value="bg-danger"><i class="fa fa-circle text-danger"></i></a>' +
+ '&nbsp;&nbsp;<a href="#" id="sepclrgreen" value="bg-success"><i class="fa fa-circle text-success"></i></a>' +
+ '&nbsp;&nbsp;<a href="#" id="sepclrorange" value="bg-warning"><i class="fa fa-circle text-warning"></i></a>' +
+ '</td></tr>');
+
+ $('#newsep').focus();
+ newSeperator = true;
$("#btnnewsep").prop('type' ,'button');
+ handle_colors();
+
+ // Remove the temporary separator bar and replace it with the final version containing the
+ // user's text and a delete icon
$("#btnnewsep").click(function() {
- var septext = $('#newsep').val();
+ var septext = escapeHtml($('#newsep').val());
$('#ruletable > tbody:last >tr:last').remove();
- $('#ruletable > tbody:last').append('<tr class="ui-sortable-handle">' +
- '<td bgcolor="#cce5ff" colspan="11">' + '<font color="#002699">' + septext + '</font></td>' +
- '<td bgcolor="#cce5ff"><a href="#"><i class="fa fa-trash"></i></a></td>' +
- '</tr>');
+ $('#ruletable > tbody:last').append('<tr class="ui-sortable-handle separator">' +
+ '<td class="' + gColor + '" colspan="11">' + '<font class="' + gColor + '">' + septext + '</font></td>' +
+ '<td class="' + gColor + '"><a href="#"><i class="fa fa-trash sepdel"></i></a>' +
+ '</tr>');
+
+ $('#order-store').removeAttr('disabled');
+ newSeperator = false;
});
- });
+ // Cancel button
+ $('#btncncsep').click(function(e) {
+ e.preventDefault();
+ $(this).parents('tr').remove();
+ newSeperator = false;
+ });
+ });
+
+ // Delete a separator row
$(function(){
- $('table').on('click','tr a',function(e){
+ $('table').on('click','tr a .sepdel',function(e){
e.preventDefault();
$(this).parents('tr').remove();
+ $('#order-store').removeAttr('disabled');
});
});
+
+ // Compose an inout array containing the row # and text for each separator
+ function save_separators() {
+ var seprow = 0;
+ var sepinput;
+ var sepnum = 0;
+
+ $('#ruletable > tbody > tr').each(function() {
+ if ($(this).hasClass('separator')) {
+ seprow = $(this).prev('tr').attr("id");
+ if (seprow == undefined) {
+ seprow = "fr-1";
+ }
+
+ sepinput = '<input type="hidden" name="separator[' + sepnum + '][row]" value="' + seprow + '"></input>';
+ $('form').append(sepinput);
+ sepinput = '<input type="hidden" name="separator[' + sepnum + '][text]" value="' + $(this).find('td').text() + '"></input>';
+ $('form').append(sepinput);
+ sepinput = '<input type="hidden" name="separator[' + sepnum + '][color]" value="' + $(this).find('td').prop('class') + '"></input>';
+ $('form').append(sepinput);
+ sepinput = '<input type="hidden" name="separator[' + sepnum + '][if]" value="<?=strtolower($if)?>"></input>';
+ $('form').append(sepinput);
+ sepnum++;
+ }
+
+ if ($(this).parent('tbody').hasClass('user-entries')) {
+ seprow++;
+ }
+ });
+ }
+
+ function handle_colors() {
+ $('[id^=sepclr]').prop("type", "button");
+
+ $('[id^=sepclr]').click(function () {
+ var color = $(this).attr('value');
+ // Clear all the color classes
+ $(this).parent('td').prop('class', '');
+ $(this).parent('td').prev('td').prop('class', '');
+ // Install our new color class
+ $(this).parent('td').addClass(color);
+ $(this).parent('td').prev('td').addClass(color);
+ // Set the global color
+ gColor = color;
+ });
+ }
+
+ //JS equivalent to PHP htmlspecialchars()
+ function escapeHtml(text) {
+ var map = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#039;'
+ };
+
+ return text.replace(/[&<>"']/g, function(m) { return map[m]; });
+ }
+ // --------------------------------------------------------------------------------------------
});
//]]>
</script>
OpenPOWER on IntegriCloud