Project

General

Profile

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

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

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

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

    
17
	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

    
21
	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

    
54
		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

    
75
		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
<?php
88
	$pgtitle = "Firewall: NAT: Server NAT";
89
	include("head.inc");
90
?>
91
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
92
<?php include("fbegin.inc"); ?>
93
<p class="pgtitle">Firewall: NAT: Server NAT</p>
94
<form action="firewall_nat_server.php" method="post">
95
<?php if ($input_errors) print_input_errors($input_errors); ?>
96
<?php if ($savemsg) print_info_box($savemsg); ?>
97
<?php if (file_exists($d_natconfdirty_path)): ?><p>
98
<?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>
99
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
100
<?php endif; ?>
101
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
102
<?php
103
	$tab_array = array();
104
	$tab_array[0] = array("Inbound", false, "firewall_nat.php");
105
	$tab_array[1] = array("Server NAT", true, "firewall_nat_server.php");
106
	$tab_array[2] = array("1:1", false, "firewall_nat_1to1.php");
107
	$tab_array[3] = array("Outbound", false, "firewall_nat_out.php");
108
	$tab_array[4] = array("Outgoing Load Balancing", false, "firewall_nat_out_load_balancing.php");
109
	display_top_tabs($tab_array);
110
?>
111
  </td></tr>
112
  <tr>
113
    <td class="tabcont">
114
              <table width="80%" border="0" cellpadding="0" cellspacing="0">
115
                <tr>
116
                  <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
                <tr>
122
                  <td class="listlr" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
123
                    <?=$natent['ipaddr'];?>
124
                  </td>
125
                  <td class="listbg" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
126
                    <font color="#FFFFFF"><?=htmlspecialchars($natent['descr']);?>&nbsp;
127
                  </td>
128
                  <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
                <tr>
139
                  <td class="list" colspan="2"></td>
140
                  <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
              </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>
(35-35/127)