1 |
c0b6fdde
|
jim-p
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* easyrule.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
8f2f85c3
|
Luiz Otavio O Souza
|
* Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* Originally Sponsored By Anathematic @ pfSense Forums
|
10 |
|
|
* All rights reserved.
|
11 |
fd9ebcd5
|
Stephen Beaver
|
*
|
12 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
13 |
|
|
* you may not use this file except in compliance with the License.
|
14 |
|
|
* You may obtain a copy of the License at
|
15 |
fd9ebcd5
|
Stephen Beaver
|
*
|
16 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
17 |
fd9ebcd5
|
Stephen Beaver
|
*
|
18 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
19 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
20 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
21 |
|
|
* See the License for the specific language governing permissions and
|
22 |
|
|
* limitations under the License.
|
23 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
24 |
c0b6fdde
|
jim-p
|
|
25 |
59c6e218
|
jim-p
|
##|+PRIV
|
26 |
|
|
##|*IDENT=page-firewall-easyrule
|
27 |
5230f468
|
jim-p
|
##|*NAME=Firewall: Easy Rule add/status
|
28 |
59c6e218
|
jim-p
|
##|*DESCR=Allow access to the 'Firewall: Easy Rule' add/status page.
|
29 |
|
|
##|*MATCH=easyrule.php*
|
30 |
|
|
##|-PRIV
|
31 |
|
|
|
32 |
c0b6fdde
|
jim-p
|
require_once("guiconfig.inc");
|
33 |
|
|
require_once("easyrule.inc");
|
34 |
4ec77db3
|
Scott Ullrich
|
require_once("filter.inc");
|
35 |
8f2c6b94
|
Scott Ullrich
|
require_once("shaper.inc");
|
36 |
4ec77db3
|
Scott Ullrich
|
|
37 |
c0b6fdde
|
jim-p
|
$retval = 0;
|
38 |
|
|
$message = "";
|
39 |
0f026089
|
jim-p
|
$confirmed = isset($_POST['confirmed']) && $_POST['confirmed'] == 'true';
|
40 |
c0b6fdde
|
jim-p
|
|
41 |
0f026089
|
jim-p
|
/* $specialsrcdst must be a defined global for functions being called. */
|
42 |
|
|
global $specialsrcdst;
|
43 |
|
|
$specialsrcdst = explode(" ", "any pppoe l2tp openvpn");
|
44 |
|
|
|
45 |
|
|
if ($_POST && $confirmed && isset($_POST['action'])) {
|
46 |
|
|
switch ($_POST['action']) {
|
47 |
c0b6fdde
|
jim-p
|
case 'block':
|
48 |
|
|
/* Check that we have a valid host */
|
49 |
0f026089
|
jim-p
|
$message = easyrule_parse_block($_POST['int'], $_POST['src'], $_POST['ipproto']);
|
50 |
c0b6fdde
|
jim-p
|
break;
|
51 |
|
|
case 'pass':
|
52 |
0f026089
|
jim-p
|
$message = easyrule_parse_pass($_POST['int'], $_POST['proto'], $_POST['src'], $_POST['dst'], $_POST['dstport'], $_POST['ipproto']);
|
53 |
c0b6fdde
|
jim-p
|
break;
|
54 |
0f026089
|
jim-p
|
default:
|
55 |
|
|
$message = gettext("Invalid action specified.");
|
56 |
c0b6fdde
|
jim-p
|
}
|
57 |
|
|
}
|
58 |
|
|
|
59 |
45b4ffc6
|
Phil Davis
|
if (stristr($retval, "error") == true) {
|
60 |
|
|
$message = $retval;
|
61 |
|
|
}
|
62 |
c0b6fdde
|
jim-p
|
|
63 |
0f026089
|
jim-p
|
$pgtitle = array(gettext("Firewall"), gettext("Easy Rule"));
|
64 |
60d87435
|
Phil Davis
|
include("head.inc");
|
65 |
947141fd
|
Phil Davis
|
if ($input_errors) {
|
66 |
01036a9a
|
Stephen Beaver
|
print_input_errors($input_errors);
|
67 |
947141fd
|
Phil Davis
|
}
|
68 |
60d87435
|
Phil Davis
|
?>
|
69 |
0f026089
|
jim-p
|
<form action="easyrule.php" method="post">
|
70 |
|
|
<div class="panel panel-default">
|
71 |
|
|
<div class="panel-heading">
|
72 |
|
|
<h2 class="panel-title">
|
73 |
|
|
<?=gettext("Confirmation Required to Add Easy Rule");?>
|
74 |
|
|
</h2>
|
75 |
|
|
</div>
|
76 |
|
|
<div class="panel-body">
|
77 |
|
|
<div class="content">
|
78 |
60d87435
|
Phil Davis
|
<?php
|
79 |
0f026089
|
jim-p
|
if (!$confirmed && !empty($_REQUEST['action'])) { ?>
|
80 |
cbb82e6b
|
Steve Beaver
|
<?php if ($_REQUEST['action'] == 'block'): ?>
|
81 |
|
|
<b><?=gettext("Rule Type")?>:</b> <?=htmlspecialchars(ucfirst(gettext($_REQUEST['action'])))?>
|
82 |
|
|
<br/><b><?=gettext("Interface")?>:</b> <?=htmlspecialchars(strtoupper($_REQUEST['int']))?>
|
83 |
|
|
<input type="hidden" name="int" value="<?=htmlspecialchars($_REQUEST['int'])?>" />
|
84 |
|
|
<br/><b><?= gettext("Source") ?>:</b> <?=htmlspecialchars($_REQUEST['src'])?>
|
85 |
|
|
<input type="hidden" name="src" value="<?=htmlspecialchars($_REQUEST['src'])?>" />
|
86 |
|
|
<br/><b><?=gettext("IP Protocol")?>:</b> <?=htmlspecialchars(ucfirst($_REQUEST['ipproto']))?>
|
87 |
|
|
<input type="hidden" name="ipproto" value="<?=htmlspecialchars($_REQUEST['ipproto'])?>" />
|
88 |
|
|
<?php elseif ($_REQUEST['action'] == 'pass'): ?>
|
89 |
|
|
<b><?=gettext("Rule Type")?>:</b> <?=htmlspecialchars(ucfirst(gettext($_REQUEST['action'])))?>
|
90 |
|
|
<br/><b><?=gettext("Interface")?>:</b> <?=htmlspecialchars(strtoupper($_REQUEST['int']))?>
|
91 |
|
|
<input type="hidden" name="int" value="<?=htmlspecialchars($_REQUEST['int'])?>" />
|
92 |
|
|
<br/><b><?=gettext("Protocol")?>:</b> <?=htmlspecialchars(strtoupper($_REQUEST['proto']))?>
|
93 |
|
|
<input type="hidden" name="proto" value="<?=htmlspecialchars($_REQUEST['proto'])?>" />
|
94 |
|
|
<br/><b><?=gettext("Source")?>:</b> <?=htmlspecialchars($_REQUEST['src'])?>
|
95 |
|
|
<input type="hidden" name="src" value="<?=htmlspecialchars($_REQUEST['src'])?>" />
|
96 |
|
|
<br/><b><?=gettext("Destination")?>:</b> <?=htmlspecialchars($_REQUEST['dst'])?>
|
97 |
|
|
<input type="hidden" name="dst" value="<?=htmlspecialchars($_REQUEST['dst'])?>" />
|
98 |
|
|
<br/><b><?=gettext("Destination Port")?>:</b> <?=htmlspecialchars($_REQUEST['dstport'])?>
|
99 |
|
|
<input type="hidden" name="dstport" value="<?=htmlspecialchars($_REQUEST['dstport'])?>" />
|
100 |
|
|
<br/><b><?=gettext("IP Protocol")?>:</b> <?=htmlspecialchars(ucfirst($_REQUEST['ipproto']))?>
|
101 |
|
|
<input type="hidden" name="ipproto" value="<?=htmlspecialchars($_REQUEST['ipproto'])?>" />
|
102 |
0f026089
|
jim-p
|
<?php else:
|
103 |
|
|
$message = gettext("Invalid action specified.");
|
104 |
|
|
endif; ?>
|
105 |
|
|
<br/><br/>
|
106 |
|
|
<?php if (empty($message)): ?>
|
107 |
cbb82e6b
|
Steve Beaver
|
<input type="hidden" name="action" value="<?=htmlspecialchars($_REQUEST['action'])?>" />
|
108 |
0f026089
|
jim-p
|
<input type="hidden" name="confirmed" value="true" />
|
109 |
|
|
<button type="submit" class="btn btn-success" name="erconfirm" id="erconfirm" value="<?=gettext("Confirm")?>">
|
110 |
|
|
<i class="fa fa-check icon-embed-btn"></i>
|
111 |
|
|
<?=gettext("Confirm")?>
|
112 |
|
|
</button>
|
113 |
|
|
<?php endif;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
if ($message) {
|
117 |
|
|
print_info_box($message);
|
118 |
|
|
} elseif (empty($_REQUEST['action'])) {
|
119 |
60d87435
|
Phil Davis
|
print_info_box(
|
120 |
|
|
gettext('This is the Easy Rule status page, mainly used to display errors when adding rules.') . ' ' .
|
121 |
af3cc7d6
|
NOYB
|
gettext('There apparently was not an error, and this page was navigated to directly without any instructions for what it should do.') .
|
122 |
60d87435
|
Phil Davis
|
'<br /><br />' .
|
123 |
|
|
gettext('This page is meant to be called from the block/pass buttons on the Firewall Logs page') .
|
124 |
|
|
', <a href="status_logs_filter.php">' . gettext("Status") . ' > ' . gettext('System Logs') . ', ' . gettext('Firewall Tab') . '</a>.<br />');
|
125 |
|
|
}
|
126 |
|
|
?>
|
127 |
0f026089
|
jim-p
|
</div>
|
128 |
|
|
</div>
|
129 |
|
|
</div>
|
130 |
|
|
</form>
|
131 |
01036a9a
|
Stephen Beaver
|
<?php include("foot.inc"); ?>
|