Project

General

Profile

Download (5.41 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-2020 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: Easy Rule add/status
28
##|*DESCR=Allow access to the 'Firewall: Easy Rule' 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
/* $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
		case 'block':
48
			/* Check that we have a valid host */
49
			$message = easyrule_parse_block($_POST['int'], $_POST['src'], $_POST['ipproto']);
50
			break;
51
		case 'pass':
52
			$message = easyrule_parse_pass($_POST['int'], $_POST['proto'], $_POST['src'], $_POST['dst'], $_POST['dstport'], $_POST['ipproto']);
53
			break;
54
		default:
55
			$message = gettext("Invalid action specified.");
56
	}
57
}
58

    
59
if (stristr($retval, "error") == true) {
60
	$message = $retval;
61
}
62

    
63
$pgtitle = array(gettext("Firewall"), gettext("Easy Rule"));
64
include("head.inc");
65
if ($input_errors) {
66
	print_input_errors($input_errors);
67
}
68
?>
69
<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
<?php
79
if (!$confirmed && !empty($_REQUEST['action'])) { ?>
80
	<?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
	<?php	else:
103
			$message = gettext("Invalid action specified.");
104
		endif; ?>
105
				<br/><br/>
106
	<?php if (empty($message)): ?>
107
				<input type="hidden" name="action" value="<?=htmlspecialchars($_REQUEST['action'])?>" />
108
				<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
	print_info_box(
120
		gettext('This is the Easy Rule status page, mainly used to display errors when adding rules.') . ' ' .
121
		gettext('There apparently was not an error, and this page was navigated to directly without any instructions for what it should do.') .
122
		'<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") . ' &gt; ' . gettext('System Logs') . ', ' . gettext('Firewall Tab') . '</a>.<br />');
125
}
126
?>
127
			</div>
128
		</div>
129
	</div>
130
</form>
131
<?php include("foot.inc"); ?>
(36-36/230)