1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
|
|
firewall_aliases.php
|
6 |
4d875b4f
|
Scott Ullrich
|
Copyright (C) 2004 Scott Ullrich
|
7 |
|
|
All rights reserved.
|
8 |
f0fe3d30
|
Scott Ullrich
|
|
9 |
4d875b4f
|
Scott Ullrich
|
originially part of m0n0wall (http://m0n0.ch/wall)
|
10 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
All rights reserved.
|
12 |
f0fe3d30
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
14 |
|
|
modification, are permitted provided that the following conditions are met:
|
15 |
f0fe3d30
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
17 |
|
|
this list of conditions and the following disclaimer.
|
18 |
f0fe3d30
|
Scott Ullrich
|
|
19 |
5b237745
|
Scott Ullrich
|
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 |
f0fe3d30
|
Scott Ullrich
|
|
23 |
5b237745
|
Scott Ullrich
|
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 |
|
|
require("guiconfig.inc");
|
36 |
|
|
|
37 |
|
|
if (!is_array($config['aliases']['alias']))
|
38 |
|
|
$config['aliases']['alias'] = array();
|
39 |
|
|
|
40 |
|
|
aliases_sort();
|
41 |
|
|
$a_aliases = &$config['aliases']['alias'];
|
42 |
|
|
|
43 |
|
|
if ($_POST) {
|
44 |
|
|
|
45 |
|
|
$pconfig = $_POST;
|
46 |
|
|
|
47 |
|
|
if ($_POST['apply']) {
|
48 |
|
|
$retval = 0;
|
49 |
|
|
if (!file_exists($d_sysrebootreqd_path)) {
|
50 |
|
|
config_lock();
|
51 |
|
|
/* reload all components that use aliases */
|
52 |
|
|
$retval = filter_configure();
|
53 |
|
|
config_unlock();
|
54 |
|
|
}
|
55 |
b2774343
|
Scott Ullrich
|
if(stristr($retval, "error") <> true)
|
56 |
|
|
$savemsg = get_std_save_message($retval);
|
57 |
|
|
else
|
58 |
|
|
$savemsg = $retval;
|
59 |
5b237745
|
Scott Ullrich
|
if ($retval == 0) {
|
60 |
|
|
if (file_exists($d_aliasesdirty_path))
|
61 |
|
|
unlink($d_aliasesdirty_path);
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
if ($_GET['act'] == "del") {
|
67 |
|
|
if ($a_aliases[$_GET['id']]) {
|
68 |
|
|
unset($a_aliases[$_GET['id']]);
|
69 |
|
|
write_config();
|
70 |
|
|
touch($d_aliasesdirty_path);
|
71 |
|
|
header("Location: firewall_aliases.php");
|
72 |
|
|
exit;
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
?>
|
76 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
77 |
|
|
<html>
|
78 |
|
|
<head>
|
79 |
|
|
<title><?=gentitle("Firewall: Aliases");?></title>
|
80 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
81 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
82 |
|
|
</head>
|
83 |
|
|
|
84 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
85 |
|
|
<?php include("fbegin.inc"); ?>
|
86 |
|
|
<p class="pgtitle">Firewall: Aliases</p>
|
87 |
|
|
<form action="firewall_aliases.php" method="post">
|
88 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
89 |
|
|
<?php if (file_exists($d_aliasesdirty_path)): ?><p>
|
90 |
|
|
<?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>
|
91 |
|
|
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
|
92 |
|
|
<?php endif; ?>
|
93 |
d2cfb7a4
|
Scott Ullrich
|
|
94 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
95 |
|
|
<tr>
|
96 |
|
|
<td width="25%" class="listhdrr">Name</td>
|
97 |
1dc8c3eb
|
Scott Ullrich
|
<td width="25%" class="listhdrr">Values</td>
|
98 |
|
|
<td width="25%" class="listhdr">Description</td>
|
99 |
d2cfb7a4
|
Scott Ullrich
|
<td width="10%" class="list"></td>
|
100 |
|
|
</tr>
|
101 |
|
|
<?php $i = 0; foreach ($a_aliases as $alias): ?>
|
102 |
|
|
<tr>
|
103 |
20ba0ca5
|
Bill Marquette
|
<td class="listlr" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
|
104 |
d2cfb7a4
|
Scott Ullrich
|
<?=htmlspecialchars($alias['name']);?>
|
105 |
|
|
</td>
|
106 |
20ba0ca5
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
|
107 |
7e65fc22
|
Scott Ullrich
|
<?php
|
108 |
|
|
$address = htmlspecialchars($alias['address']);
|
109 |
|
|
$address = explode(" ", $address);
|
110 |
|
|
$isfirst = 0;
|
111 |
|
|
foreach ($address as $addy) {
|
112 |
|
|
if($isfirst == 1) echo "<br>";
|
113 |
|
|
echo $addy;
|
114 |
|
|
$isfirst = 1;
|
115 |
|
|
}
|
116 |
|
|
?>
|
117 |
d2cfb7a4
|
Scott Ullrich
|
</td>
|
118 |
20ba0ca5
|
Bill Marquette
|
<td class="listbg" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
|
119 |
7e65fc22
|
Scott Ullrich
|
<font color="#FFFFFF">
|
120 |
|
|
<?=htmlspecialchars($alias['descr']);?>
|
121 |
d2cfb7a4
|
Scott Ullrich
|
</td>
|
122 |
725f5e5a
|
Bill Marquette
|
<td valign="middle" nowrap class="list">
|
123 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
124 |
|
|
<tr>
|
125 |
|
|
<td valign="middle"><a href="firewall_aliases_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a></td>
|
126 |
|
|
<td><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>
|
127 |
|
|
</tr>
|
128 |
|
|
</table>
|
129 |
|
|
</td>
|
130 |
d2cfb7a4
|
Scott Ullrich
|
</tr>
|
131 |
|
|
<?php $i++; endforeach; ?>
|
132 |
|
|
<tr>
|
133 |
|
|
<td class="list" colspan="3"></td>
|
134 |
725f5e5a
|
Bill Marquette
|
<td class="list">
|
135 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
136 |
|
|
<tr>
|
137 |
|
|
<td valign="middle"><a href="firewall_aliases_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
|
138 |
|
|
</tr>
|
139 |
|
|
</table>
|
140 |
|
|
</td>
|
141 |
d2cfb7a4
|
Scott Ullrich
|
</tr>
|
142 |
|
|
<tr>
|
143 |
|
|
<td class="tabcont" colspan="3">
|
144 |
10681748
|
Bill Marquette
|
<p><span class="vexpl"><span class="red"><strong>Note:<br></strong></span>Aliases act as placeholders for real Hosts, Networks or Ports. They can be used to minimize the number of changes that have to be made if a host, network or port changes. You can enter the name of an alias instead of the host, network or port in all fields that have a red background. The alias will be resolved according to the list above. 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>
|
145 |
d2cfb7a4
|
Scott Ullrich
|
</td>
|
146 |
|
|
</tr>
|
147 |
|
|
</table>
|
148 |
|
|
</form>
|
149 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
150 |
|
|
</body>
|
151 |
|
|
</html>
|