Project

General

Profile

Download (6.67 KB) Statistics
| Branch: | Tag: | Revision:
1 36e81b98 Seth Mos
<?php
2
/* $Id$ */
3
/*
4
	firewall_nat_npt.php
5 97b18166 Chris Buechler
	part of pfSense (https://www.pfsense.org)
6 36e81b98 Seth Mos
7
	Copyright (C) 2011 Seth Mos <seth.mos@dds.nl>.
8
	All rights reserved.
9 29aef6c4 Jim Thompson
10 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
11 29aef6c4 Jim Thompson
	All rights reserved.
12 36e81b98 Seth Mos
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34
/*
35
	pfSense_MODULE:	nat
36
*/
37
38
##|+PRIV
39
##|*IDENT=page-firewall-nat-npt
40
##|*NAME=Firewall: NAT: NPT page
41
##|*DESCR=Allow access to the 'Firewall: NAT: NPT' page.
42
##|*MATCH=firewall_nat_npt.php*
43
##|-PRIV
44
45
require("guiconfig.inc");
46
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49
50
if (!is_array($config['nat']['npt'])) {
51
	$config['nat']['npt'] = array();
52
}
53
$a_npt = &$config['nat']['npt'];
54
55
if ($_POST) {
56
57
	$pconfig = $_POST;
58
59
	if ($_POST['apply']) {
60
		$retval = 0;
61
		$retval |= filter_configure();
62
		$savemsg = get_std_save_message($retval);
63
64
		if ($retval == 0) {
65
			clear_subsystem_dirty('natconf');
66
			clear_subsystem_dirty('filter');
67
		}
68
	}
69
}
70
71
if ($_GET['act'] == "del") {
72
	if ($a_npt[$_GET['id']]) {
73
		unset($a_npt[$_GET['id']]);
74 37ba954d Phil Davis
		if (write_config()) {
75 3a343d73 jim-p
			mark_subsystem_dirty('natconf');
76 37ba954d Phil Davis
		}
77 36e81b98 Seth Mos
		header("Location: firewall_nat_npt.php");
78
		exit;
79
	}
80
}
81
82
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("NPt"));
83
include("head.inc");
84
85
?>
86
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
87
<?php include("fbegin.inc"); ?>
88
<form action="firewall_nat_npt.php" method="post">
89
<?php if ($savemsg) print_info_box($savemsg); ?>
90 193079e4 Colin Fleming
<?php if (is_subsystem_dirty('natconf')): ?>
91 8cd558b6 ayvis
<?php print_info_box_np(gettext("The NAT configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
92 36e81b98 Seth Mos
<?php endif; ?>
93 37ba954d Phil Davis
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall nat npt"> 
94
	<tr><td>
95 36e81b98 Seth Mos
<?php
96
	$tab_array = array();
97
	$tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php");
98
	$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
99
	$tab_array[] = array(gettext("Outbound"), false, "firewall_nat_out.php");
100
	$tab_array[] = array(gettext("NPt"), true, "firewall_nat_npt.php");
101
	display_top_tabs($tab_array);
102
?>
103 37ba954d Phil Davis
	</td></tr>
104
	<tr>
105
		<td>
106
			<div id="mainarea">
107
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
108
					<tr>
109
						<td width="10%" class="listhdrr"><?=gettext("Interface"); ?></td>
110
						<td width="20%" class="listhdrr"><?=gettext("External Prefix"); ?></td>
111
						<td width="15%" class="listhdrr"><?=gettext("Internal prefix"); ?></td>
112
						<td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
113
						<td width="10%" class="list">
114
							<table border="0" cellspacing="0" cellpadding="1" summary="add">
115
								<tr>
116
									<td width="17"></td>
117
									<td valign="middle"><a href="firewall_nat_npt_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add rule"); ?>" alt="add" /></a></td>
118
								</tr>
119
							</table>
120
						</td>
121
					</tr>
122
<?php
123
	$textse = "</span>";
124
125
	$i = 0; 
126
	foreach ($a_npt as $natent):
127
128
		if (isset($natent['disabled'])) {
129
			$textss = "<span class=\"gray\">";
130
		} else {
131
			$textss = "<span>";
132
		}
133
?>
134
					<tr>
135
						<td class="listlr" ondblclick="document.location='firewall_nat_npt_edit.php?id=<?=$i;?>';">
136
<?php
137
		echo $textss;
138
		if (!$natent['interface']) {
139
			echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
140
		} else {
141
			echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
142
		}
143
		echo $textse;
144
?>
145
						</td>
146
<?php
147
		$source_net = pprint_address($natent['source']);
148
		$source_cidr = strstr($source_net, '/');
149
		$destination_net = pprint_address($natent['destination']);
150
		$destination_cidr = strstr($destination_net, '/');
151
?>
152
						<td class="listr" ondblclick="document.location='firewall_nat_npt_edit.php?id=<?=$i;?>';">
153
							<?php 		echo $textss . $destination_net . $textse; ?>
154
						</td>
155
						<td class="listr" ondblclick="document.location='firewall_nat_npt_edit.php?id=<?=$i;?>';">
156
							<?php 		echo $textss . $source_net . $textse; ?>
157
						</td>
158
						<td class="listbg" ondblclick="document.location='firewall_nat_npt_edit.php?id=<?=$i;?>';">
159
							<?=$textss;?>
160
							<?=htmlspecialchars($natent['descr']);?>&nbsp;
161
							<?=$textse;?>
162
						</td>
163
						<td class="list nowrap">
164
							<table border="0" cellspacing="0" cellpadding="1" summary="edit">
165
								<tr>
166
									<td valign="middle"><a href="firewall_nat_npt_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit rule"); ?>" alt="edit" /></a></td>
167
									<td valign="middle"><a href="firewall_nat_npt.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule"); ?>" alt="delete" /></a></td>
168
								</tr>
169
							</table>
170
						</td>
171
					</tr>
172
<?php
173
		$i++;
174
	endforeach;
175
?>
176
					<tr>
177
						<td class="list" colspan="4"></td>
178
						<td class="list">
179
							<table border="0" cellspacing="0" cellpadding="1" summary="add">
180
								<tr>
181
									<td width="17"></td>
182
									<td valign="middle"><a href="firewall_nat_npt_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add rule"); ?>" alt="add" /></a></td>
183
								</tr>
184
							</table>
185
						</td>
186
					</tr>
187
				</table>
188
			</div>
189
		</td>
190
	</tr>
191 36e81b98 Seth Mos
</table>
192
</form>
193
<?php include("fend.inc"); ?>
194
</body>
195
</html>