1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
firewall_aliases.php
|
5
|
Copyright (C) 2004 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
originially part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
require("guiconfig.inc");
|
35
|
|
36
|
if (!is_array($config['aliases']['alias']))
|
37
|
$config['aliases']['alias'] = array();
|
38
|
|
39
|
aliases_sort();
|
40
|
$a_aliases = &$config['aliases']['alias'];
|
41
|
|
42
|
if ($_POST) {
|
43
|
|
44
|
$pconfig = $_POST;
|
45
|
|
46
|
if ($_POST['apply']) {
|
47
|
$retval = 0;
|
48
|
if (!file_exists($d_sysrebootreqd_path)) {
|
49
|
config_lock();
|
50
|
/* reload all components that use aliases */
|
51
|
$retval = filter_configure();
|
52
|
$retval |= shaper_configure();
|
53
|
config_unlock();
|
54
|
}
|
55
|
$savemsg = get_std_save_message($retval);
|
56
|
if ($retval == 0) {
|
57
|
if (file_exists($d_aliasesdirty_path))
|
58
|
unlink($d_aliasesdirty_path);
|
59
|
}
|
60
|
}
|
61
|
}
|
62
|
|
63
|
if ($_GET['act'] == "del") {
|
64
|
if ($a_aliases[$_GET['id']]) {
|
65
|
unset($a_aliases[$_GET['id']]);
|
66
|
write_config();
|
67
|
touch($d_aliasesdirty_path);
|
68
|
header("Location: firewall_aliases.php");
|
69
|
exit;
|
70
|
}
|
71
|
}
|
72
|
?>
|
73
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
74
|
<html>
|
75
|
<head>
|
76
|
<title><?=gentitle("Firewall: Aliases");?></title>
|
77
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
78
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
79
|
</head>
|
80
|
|
81
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
82
|
<?php include("fbegin.inc"); ?>
|
83
|
<p class="pgtitle">Firewall: Aliases</p>
|
84
|
<form action="firewall_aliases.php" method="post">
|
85
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
86
|
<?php if (file_exists($d_aliasesdirty_path)): ?><p>
|
87
|
<?php print_info_box_np("The alias list has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
88
|
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
|
89
|
<?php endif; ?>
|
90
|
|
91
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
92
|
<tr>
|
93
|
<td width="25%" class="listhdrr">Name</td>
|
94
|
<td width="25%" class="listhdrr">Values</td>
|
95
|
<td width="25%" class="listhdr">Description</td>
|
96
|
<td width="10%" class="list"></td>
|
97
|
</tr>
|
98
|
<?php $i = 0; foreach ($a_aliases as $alias): ?>
|
99
|
<tr>
|
100
|
<td class="listlr">
|
101
|
<?=htmlspecialchars($alias['name']);?>
|
102
|
</td>
|
103
|
<td class="listr">
|
104
|
<?=htmlspecialchars($alias['address']);?>
|
105
|
</td>
|
106
|
<td class="listbg">
|
107
|
<font color="#FFFFFF"><?=htmlspecialchars($alias['descr']);?>
|
108
|
</td>
|
109
|
<td valign="middle" nowrap class="list"> <a href="firewall_aliases_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
|
110
|
<a href="firewall_aliases.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this alias? All elements that still use it will become invalid (e.g. filter rules)!')"><img src="x.gif" width="17" height="17" border="0"></a></td>
|
111
|
</tr>
|
112
|
<?php $i++; endforeach; ?>
|
113
|
<tr>
|
114
|
<td class="list" colspan="3"></td>
|
115
|
<td class="list"> <a href="firewall_aliases_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
|
116
|
</tr>
|
117
|
<tr>
|
118
|
<td class="tabcont" colspan="3">
|
119
|
<p><span class="vexpl"><span class="red"><strong>Note:<br></strong></span>Aliases act as placeholders for real IP addresses and can be used to minimize the number of changes that have to be made if a host or network address changes. You can enter the name of an alias instead of an IP address in all address fields that have a red background. The alias will be resolved to its current address according to the list below. If an alias cannot be resolved (e.g. because you deleted it), the corresponding element (e.g. filter/NAT/shaper rule) will be considered invalid and skipped.</span></p>
|
120
|
</td>
|
121
|
</tr>
|
122
|
</table>
|
123
|
</form>
|
124
|
<?php include("fend.inc"); ?>
|
125
|
</body>
|
126
|
</html>
|