Project

General

Profile

Download (5.32 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * easyrule.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7
 * Originally Sponsored By Anathematic @ pfSense Forums
8
 * All rights reserved.
9
 *
10
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13
 *
14
 * http://www.apache.org/licenses/LICENSE-2.0
15
 *
16
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21
 */
22

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

    
30
require_once("guiconfig.inc");
31
require_once("easyrule.inc");
32
require_once("filter.inc");
33
require_once("shaper.inc");
34

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

    
39
/* $specialsrcdst must be a defined global for functions being called. */
40
global $specialsrcdst;
41
$specialsrcdst = explode(" ", "any pppoe l2tp openvpn");
42

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

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

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

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