Project

General

Profile

Download (5.25 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * easyrule.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9
 * Originally Sponsored By Anathematic @ pfSense Forums
10
 * All rights reserved.
11
 *
12
 * 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
 *
16
 * http://www.apache.org/licenses/LICENSE-2.0
17
 *
18
 * 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
 */
24

    
25
##|+PRIV
26
##|*IDENT=page-firewall-easyrule
27
##|*NAME=Firewall: EasyRule add/status
28
##|*DESCR=Allow access to the 'Firewall: EasyRule' add/status page.
29
##|*MATCH=easyrule.php*
30
##|-PRIV
31

    
32
require_once("guiconfig.inc");
33
require_once("easyrule.inc");
34
require_once("filter.inc");
35
require_once("shaper.inc");
36

    
37
$retval = 0;
38
$message = "";
39
$confirmed = isset($_POST['confirmed']) && $_POST['confirmed'] == 'true';
40

    
41
if ($_POST && $confirmed && isset($_POST['action'])) {
42
	switch ($_POST['action']) {
43
		case 'block':
44
			/* Check that we have a valid host */
45
			$message = easyrule_parse_block($_POST['int'], $_POST['src'], $_POST['ipproto']);
46
			break;
47
		case 'pass':
48
			$message = easyrule_parse_pass($_POST['int'], $_POST['proto'], $_POST['src'], $_POST['dst'], $_POST['dstport'], $_POST['ipproto']);
49
			break;
50
		default:
51
			$message = gettext("Invalid action specified.");
52
	}
53
}
54

    
55
if (stristr($retval, "error") == true) {
56
	$message = $retval;
57
}
58

    
59
$pgtitle = array(gettext("Firewall"), gettext("EasyRule"));
60
include("head.inc");
61
if ($input_errors) {
62
	print_input_errors($input_errors);
63
}
64
?>
65
<form action="easyrule.php" method="post">
66
	<div class="panel panel-default">
67
		<div class="panel-heading">
68
			<h2 class="panel-title">
69
				<?=gettext("Confirmation Required to Add EasyRule");?>
70
			</h2>
71
		</div>
72
		<div class="panel-body">
73
			<div class="content">
74
<?php
75
if (!$confirmed && !empty($_REQUEST['action'])) { ?>
76
	<?php if ($_REQUEST['action'] == 'block'): ?>
77
				<b><?=gettext("Rule Type")?>:</b> <?=htmlspecialchars(ucfirst(gettext($_REQUEST['action'])))?>
78
				<br/><b><?=gettext("Interface")?>:</b> <?=htmlspecialchars(strtoupper($_REQUEST['int']))?>
79
				<input type="hidden" name="int" value="<?=htmlspecialchars($_REQUEST['int'])?>" />
80
				<br/><b><?= gettext("Source") ?>:</b> <?=htmlspecialchars($_REQUEST['src'])?>
81
				<input type="hidden" name="src" value="<?=htmlspecialchars($_REQUEST['src'])?>" />
82
				<br/><b><?=gettext("IP Protocol")?>:</b> <?=htmlspecialchars(ucfirst($_REQUEST['ipproto']))?>
83
				<input type="hidden" name="ipproto" value="<?=htmlspecialchars($_REQUEST['ipproto'])?>" />
84
	<?php elseif ($_REQUEST['action'] == 'pass'): ?>
85
				<b><?=gettext("Rule Type")?>:</b> <?=htmlspecialchars(ucfirst(gettext($_REQUEST['action'])))?>
86
				<br/><b><?=gettext("Interface")?>:</b> <?=htmlspecialchars(strtoupper($_REQUEST['int']))?>
87
				<input type="hidden" name="int" value="<?=htmlspecialchars($_REQUEST['int'])?>" />
88
				<br/><b><?=gettext("Protocol")?>:</b> <?=htmlspecialchars(strtoupper($_REQUEST['proto']))?>
89
				<input type="hidden" name="proto" value="<?=htmlspecialchars($_REQUEST['proto'])?>" />
90
				<br/><b><?=gettext("Source")?>:</b> <?=htmlspecialchars($_REQUEST['src'])?>
91
				<input type="hidden" name="src" value="<?=htmlspecialchars($_REQUEST['src'])?>" />
92
				<br/><b><?=gettext("Destination")?>:</b> <?=htmlspecialchars($_REQUEST['dst'])?>
93
				<input type="hidden" name="dst" value="<?=htmlspecialchars($_REQUEST['dst'])?>" />
94
				<br/><b><?=gettext("Destination Port")?>:</b> <?=htmlspecialchars($_REQUEST['dstport'])?>
95
				<input type="hidden" name="dstport" value="<?=htmlspecialchars($_REQUEST['dstport'])?>" />
96
				<br/><b><?=gettext("IP Protocol")?>:</b> <?=htmlspecialchars(ucfirst($_REQUEST['ipproto']))?>
97
				<input type="hidden" name="ipproto" value="<?=htmlspecialchars($_REQUEST['ipproto'])?>" />
98
	<?php	else:
99
			$message = gettext("Invalid action specified.");
100
		endif; ?>
101
				<br/><br/>
102
	<?php if (empty($message)): ?>
103
				<input type="hidden" name="action" value="<?=htmlspecialchars($_REQUEST['action'])?>" />
104
				<input type="hidden" name="confirmed" value="true" />
105
				<button type="submit" class="btn btn-success" name="erconfirm" id="erconfirm" value="<?=gettext("Confirm")?>">
106
					<i class="fa-solid fa-check icon-embed-btn"></i>
107
					<?=gettext("Confirm")?>
108
				</button>
109
	<?php endif;
110
}
111

    
112
if ($message) {
113
	print_info_box($message);
114
} elseif (empty($_REQUEST['action'])) {
115
	print_info_box(
116
		gettext('This is the EasyRule status page, mainly used to display errors when adding rules.') . ' ' .
117
		gettext('There apparently was not an error, and this page was navigated to directly without any instructions for what it should do.') .
118
		'<br /><br />' .
119
		gettext('This page is meant to be called from the block/pass buttons on the Firewall Logs page') .
120
		', <a href="status_logs_filter.php">' . gettext("Status") . ' &gt; ' . gettext('System Logs') . ', ' . gettext('Firewall Tab') . '</a>.<br />');
121
}
122
?>
123
			</div>
124
		</div>
125
	</div>
126
</form>
127
<?php include("foot.inc"); ?>
(35-35/228)