Project

General

Profile

Download (5.32 KB) Statistics
| Branch: | Tag: | Revision:
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 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * Originally Sponsored By Anathematic @ pfSense Forums
8
 * All rights reserved.
9 fd9ebcd5 Stephen Beaver
 *
10 b12ea3fb Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
14 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
15 fd9ebcd5 Stephen Beaver
 *
16 b12ea3fb Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 */
22 c0b6fdde jim-p
23 59c6e218 jim-p
##|+PRIV
24
##|*IDENT=page-firewall-easyrule
25 5230f468 jim-p
##|*NAME=Firewall: Easy Rule add/status
26 59c6e218 jim-p
##|*DESCR=Allow access to the 'Firewall: Easy Rule' add/status page.
27
##|*MATCH=easyrule.php*
28
##|-PRIV
29
30 c0b6fdde jim-p
require_once("guiconfig.inc");
31
require_once("easyrule.inc");
32 4ec77db3 Scott Ullrich
require_once("filter.inc");
33 8f2c6b94 Scott Ullrich
require_once("shaper.inc");
34 4ec77db3 Scott Ullrich
35 c0b6fdde jim-p
$retval = 0;
36
$message = "";
37 0f026089 jim-p
$confirmed = isset($_POST['confirmed']) && $_POST['confirmed'] == 'true';
38 c0b6fdde jim-p
39 0f026089 jim-p
/* $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 c0b6fdde jim-p
		case 'block':
46
			/* Check that we have a valid host */
47 0f026089 jim-p
			$message = easyrule_parse_block($_POST['int'], $_POST['src'], $_POST['ipproto']);
48 c0b6fdde jim-p
			break;
49
		case 'pass':
50 0f026089 jim-p
			$message = easyrule_parse_pass($_POST['int'], $_POST['proto'], $_POST['src'], $_POST['dst'], $_POST['dstport'], $_POST['ipproto']);
51 c0b6fdde jim-p
			break;
52 0f026089 jim-p
		default:
53
			$message = gettext("Invalid action specified.");
54 c0b6fdde jim-p
	}
55
}
56
57 45b4ffc6 Phil Davis
if (stristr($retval, "error") == true) {
58
	$message = $retval;
59
}
60 c0b6fdde jim-p
61 0f026089 jim-p
$pgtitle = array(gettext("Firewall"), gettext("Easy Rule"));
62 60d87435 Phil Davis
include("head.inc");
63 947141fd Phil Davis
if ($input_errors) {
64 01036a9a Stephen Beaver
	print_input_errors($input_errors);
65 947141fd Phil Davis
}
66 60d87435 Phil Davis
?>
67 0f026089 jim-p
<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 60d87435 Phil Davis
<?php
77 0f026089 jim-p
if (!$confirmed && !empty($_REQUEST['action'])) { ?>
78 cbb82e6b Steve Beaver
	<?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 0f026089 jim-p
	<?php	else:
101
			$message = gettext("Invalid action specified.");
102
		endif; ?>
103
				<br/><br/>
104
	<?php if (empty($message)): ?>
105 cbb82e6b Steve Beaver
				<input type="hidden" name="action" value="<?=htmlspecialchars($_REQUEST['action'])?>" />
106 0f026089 jim-p
				<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 60d87435 Phil Davis
	print_info_box(
118
		gettext('This is the Easy Rule status page, mainly used to display errors when adding rules.') . ' ' .
119 af3cc7d6 NOYB
		gettext('There apparently was not an error, and this page was navigated to directly without any instructions for what it should do.') .
120 60d87435 Phil Davis
		'<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 0f026089 jim-p
			</div>
126
		</div>
127
	</div>
128
</form>
129 01036a9a Stephen Beaver
<?php include("foot.inc"); ?>