Project

General

Profile

Download (5.53 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	firewall_nat_server.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
if (!is_array($config['nat']['servernat'])) {
35
	$config['nat']['servernat'] = array();
36
}
37
$a_snat = &$config['nat']['servernat'];
38
nat_server_rules_sort();
39

    
40
if ($_POST) {
41

    
42
	$pconfig = $_POST;
43

    
44
	if ($_POST['apply']) {
45
		$retval = 0;
46
		if (!file_exists($d_sysrebootreqd_path)) {
47
			config_lock();
48
			$retval |= filter_configure();
49
			config_unlock();
50
		}
51
		$savemsg = get_std_save_message($retval);
52

    
53
		if ($retval == 0) {
54
			if (file_exists($d_natconfdirty_path))
55
				unlink($d_natconfdirty_path);
56
			if (file_exists($d_filterconfdirty_path))
57
				unlink($d_filterconfdirty_path);
58
		}
59
	}
60
}
61

    
62
if ($_GET['act'] == "del") {
63
	if ($a_snat[$_GET['id']]) {
64
		/* make sure no inbound NAT mappings reference this entry */
65
		if (is_array($config['nat']['rule'])) {
66
			foreach ($config['nat']['rule'] as $rule) {
67
				if ($rule['external-address'] == $a_snat[$_GET['id']]['ipaddr']) {
68
					$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one inbound NAT mapping.";
69
					break;
70
				}
71
			}
72
		}
73

    
74
		if (!$input_errors) {
75
			unset($a_snat[$_GET['id']]);
76
			write_config();
77
			touch($d_natconfdirty_path);
78
			header("Location: firewall_nat_server.php");
79
			exit;
80
		}
81
	}
82
}
83
?>
84
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
85
<html>
86
<head>
87
<title><?=gentitle("Firewall: NAT");?></title>
88
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
89
<link href="gui.css" rel="stylesheet" type="text/css">
90
</head>
91

    
92
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
93
<?php include("fbegin.inc"); ?>
94
<p class="pgtitle">Firewall: NAT</p>
95
<form action="firewall_nat_server.php" method="post">
96
<?php if ($input_errors) print_input_errors($input_errors); ?>
97
<?php if ($savemsg) print_info_box($savemsg); ?>
98
<?php if (file_exists($d_natconfdirty_path)): ?><p>
99
<?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>
100
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
101
<?php endif; ?>
102
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
103
  <ul id="tabnav">
104
    <li class="tabinact"><a href="firewall_nat.php">Inbound</a></li>
105
    <li class="tabact">Server NAT</li>
106
    <li class="tabinact"><a href="firewall_nat_1to1.php">1:1</a></li>
107
    <li class="tabinact"><a href="firewall_nat_out.php">Outbound</a></li>
108
    <li class="tabinact"><a href="firewall_nat_out_load_balancing.php">Outbound Load Balancing</a></li>
109
  </ul>
110
  </td></tr>
111
  <tr>
112
    <td class="tabcont">
113
              <table width="80%" border="0" cellpadding="0" cellspacing="0">
114
                <tr>
115
                  <td width="40%" class="listhdrr">External IP address</td>
116
                  <td width="50%" class="listhdr">Description</td>
117
                  <td width="10%" class="list"></td>
118
				</tr>
119
			  <?php $i = 0; foreach ($a_snat as $natent): ?>
120
                <tr>
121
                  <td class="listlr">
122
                    <?=$natent['ipaddr'];?>
123
                  </td>
124
                  <td class="listbg">
125
                    <font color="#FFFFFF"><?=htmlspecialchars($natent['descr']);?>&nbsp;
126
                  </td>
127
                  <td class="list" nowrap> <a href="firewall_nat_server_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
128
                     &nbsp;<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>
129
				</tr>
130
			  <?php $i++; endforeach; ?>
131
                <tr>
132
                  <td class="list" colspan="2"></td>
133
                  <td class="list"> <a href="firewall_nat_server_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
134
				</tr>
135
              </table>
136
			        <p><span class="vexpl"><span class="red"><strong>Note:<br>
137
                      </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>
138
</td>
139
  </tr>
140
</table>
141
            </form>
142
<?php include("fend.inc"); ?>
143
</body>
144
</html>
(27-27/99)