Project

General

Profile

Download (6.2 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2 19ae0929 Scott Ullrich
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	firewall_nat_server.php
6
	part of m0n0wall (http://m0n0.ch/wall)
7 19ae0929 Scott Ullrich
8 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 19ae0929 Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 19ae0929 Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 19ae0929 Scott Ullrich
17 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 19ae0929 Scott Ullrich
21 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
require("guiconfig.inc");
34
35
if (!is_array($config['nat']['servernat'])) {
36
	$config['nat']['servernat'] = array();
37
}
38
$a_snat = &$config['nat']['servernat'];
39
nat_server_rules_sort();
40
41
if ($_POST) {
42
43
	$pconfig = $_POST;
44
45
	if ($_POST['apply']) {
46
		$retval = 0;
47
		if (!file_exists($d_sysrebootreqd_path)) {
48
			config_lock();
49
			$retval |= filter_configure();
50
			config_unlock();
51
		}
52
		$savemsg = get_std_save_message($retval);
53 19ae0929 Scott Ullrich
54 5b237745 Scott Ullrich
		if ($retval == 0) {
55
			if (file_exists($d_natconfdirty_path))
56
				unlink($d_natconfdirty_path);
57
			if (file_exists($d_filterconfdirty_path))
58
				unlink($d_filterconfdirty_path);
59
		}
60
	}
61
}
62
63
if ($_GET['act'] == "del") {
64
	if ($a_snat[$_GET['id']]) {
65
		/* make sure no inbound NAT mappings reference this entry */
66
		if (is_array($config['nat']['rule'])) {
67
			foreach ($config['nat']['rule'] as $rule) {
68
				if ($rule['external-address'] == $a_snat[$_GET['id']]['ipaddr']) {
69
					$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one inbound NAT mapping.";
70
					break;
71
				}
72
			}
73
		}
74 19ae0929 Scott Ullrich
75 5b237745 Scott Ullrich
		if (!$input_errors) {
76
			unset($a_snat[$_GET['id']]);
77
			write_config();
78
			touch($d_natconfdirty_path);
79
			header("Location: firewall_nat_server.php");
80
			exit;
81
		}
82
	}
83
}
84
?>
85
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
86
<html>
87
<head>
88 e8074dcd Bill Marquette
<title><?=gentitle("Firewall: NAT: Server NAT");?></title>
89 5b237745 Scott Ullrich
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
90
<link href="gui.css" rel="stylesheet" type="text/css">
91
</head>
92
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95 e8074dcd Bill Marquette
<p class="pgtitle">Firewall: NAT: Server NAT</p>
96 5b237745 Scott Ullrich
<form action="firewall_nat_server.php" method="post">
97
<?php if ($input_errors) print_input_errors($input_errors); ?>
98
<?php if ($savemsg) print_info_box($savemsg); ?>
99
<?php if (file_exists($d_natconfdirty_path)): ?><p>
100
<?php print_info_box_np("The NAT configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
101
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
102
<?php endif; ?>
103
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
104
  <ul id="tabnav">
105
    <li class="tabinact"><a href="firewall_nat.php">Inbound</a></li>
106
    <li class="tabact">Server NAT</li>
107
    <li class="tabinact"><a href="firewall_nat_1to1.php">1:1</a></li>
108
    <li class="tabinact"><a href="firewall_nat_out.php">Outbound</a></li>
109 c55b323d Scott Ullrich
    <li class="tabinact"><a href="firewall_nat_out_load_balancing.php">Outbound Load Balancing</a></li>
110 5b237745 Scott Ullrich
  </ul>
111
  </td></tr>
112 19ae0929 Scott Ullrich
  <tr>
113 5b237745 Scott Ullrich
    <td class="tabcont">
114
              <table width="80%" border="0" cellpadding="0" cellspacing="0">
115 19ae0929 Scott Ullrich
                <tr>
116 5b237745 Scott Ullrich
                  <td width="40%" class="listhdrr">External IP address</td>
117
                  <td width="50%" class="listhdr">Description</td>
118
                  <td width="10%" class="list"></td>
119
				</tr>
120
			  <?php $i = 0; foreach ($a_snat as $natent): ?>
121 19ae0929 Scott Ullrich
                <tr>
122 b261bc51 Bill Marquette
                  <td class="listlr" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
123 5b237745 Scott Ullrich
                    <?=$natent['ipaddr'];?>
124
                  </td>
125 b261bc51 Bill Marquette
                  <td class="listbg" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
126 19ae0929 Scott Ullrich
                    <font color="#FFFFFF"><?=htmlspecialchars($natent['descr']);?>&nbsp;
127 5b237745 Scott Ullrich
                  </td>
128 c39b8aa6 Bill Marquette
                  <td class="list" nowrap>
129
                    <table border="0" cellspacing="0" cellpadding="1">
130
                      <tr>
131
                        <td valign="middle"><a href="firewall_nat_server_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a></td>
132
                        <td valign="middle"><a href="firewall_nat_server.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
133
                      </tr>
134
                    </table>
135
                  </td>
136
                </tr>
137
                <?php $i++; endforeach; ?>
138 19ae0929 Scott Ullrich
                <tr>
139 5b237745 Scott Ullrich
                  <td class="list" colspan="2"></td>
140 c39b8aa6 Bill Marquette
                  <td class="list">
141
                    <table border="0" cellspacing="0" cellpadding="1">
142
                      <tr>
143
                        <td valign="middle"><a href="firewall_nat_server_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
144
                      </tr>
145
                    </table>
146
                  </td>
147
                </tr>
148 5b237745 Scott Ullrich
              </table>
149
			        <p><span class="vexpl"><span class="red"><strong>Note:<br>
150
                      </strong></span>The external IP addresses defined on this page may be used in <a href="firewall_nat.php">inbound NAT</a> mappings. Depending on the way your WAN connection is setup, you may also need <a href="services_proxyarp.php">proxy ARP</a>.</span></p>
151
</td>
152
  </tr>
153
</table>
154
            </form>
155
<?php include("fend.inc"); ?>
156
</body>
157
</html>