Project

General

Profile

Download (5.38 KB) Statistics
| Branch: | Tag: | Revision:
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 b63695db Scott Ullrich
76
$pgtitle = "Firewall: Aliases";
77
include("head.inc");
78
79 5b237745 Scott Ullrich
?>
80
81
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
82
<?php include("fbegin.inc"); ?>
83 da7ae7ef Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
84 5b237745 Scott Ullrich
<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 a0509c58 Scott Ullrich
<?php print_info_box_np("The alias list has been changed.<br>You must apply the changes in order for them to take effect.");?>
88 5b237745 Scott Ullrich
<?php endif; ?>
89 d2cfb7a4 Scott Ullrich
90
<table width="100%" border="0" cellpadding="0" cellspacing="0">
91
<tr>
92
  <td width="25%" class="listhdrr">Name</td>
93 1dc8c3eb Scott Ullrich
  <td width="25%" class="listhdrr">Values</td>
94
  <td width="25%" class="listhdr">Description</td>
95 d2cfb7a4 Scott Ullrich
  <td width="10%" class="list"></td>
96
</tr>
97
	  <?php $i = 0; foreach ($a_aliases as $alias): ?>
98
<tr>
99 20ba0ca5 Bill Marquette
  <td class="listlr" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
100 d2cfb7a4 Scott Ullrich
    <?=htmlspecialchars($alias['name']);?>
101
  </td>
102 20ba0ca5 Bill Marquette
  <td class="listr" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
103 7e65fc22 Scott Ullrich
      <?php
104
	$address = htmlspecialchars($alias['address']);
105
	$address = explode(" ", $address);
106
	$isfirst = 0;
107
	foreach ($address as $addy) {
108
		if($isfirst == 1) echo "<br>";
109
		echo $addy;
110
		$isfirst = 1;
111
	}
112
    ?>
113 d2cfb7a4 Scott Ullrich
  </td>
114 20ba0ca5 Bill Marquette
  <td class="listbg" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
115 7e65fc22 Scott Ullrich
    <font color="#FFFFFF">
116
    <?=htmlspecialchars($alias['descr']);?>&nbsp;
117 d2cfb7a4 Scott Ullrich
  </td>
118 725f5e5a Bill Marquette
  <td valign="middle" nowrap class="list">
119
    <table border="0" cellspacing="0" cellpadding="1"> 
120
      <tr>
121 ec3418ed Bill Marquette
        <td valign="middle"><a href="firewall_aliases_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="edit alias"></a></td>
122
        <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="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete alias"></a></td>
123 725f5e5a Bill Marquette
      </tr>
124
    </table>
125
  </td>
126 d2cfb7a4 Scott Ullrich
</tr>
127
	  <?php $i++; endforeach; ?>
128
<tr>
129
  <td class="list" colspan="3"></td>
130 725f5e5a Bill Marquette
  <td class="list">
131
    <table border="0" cellspacing="0" cellpadding="1">
132
      <tr>
133 ec3418ed Bill Marquette
        <td valign="middle"><a href="firewall_aliases_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="add a new alias"></a></td>
134 725f5e5a Bill Marquette
      </tr>
135
    </table>
136
  </td>
137 d2cfb7a4 Scott Ullrich
</tr>
138
<tr>
139
  <td class="tabcont" colspan="3">
140 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>
141 d2cfb7a4 Scott Ullrich
  </td>
142
</tr>
143
</table>
144
</form>
145 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
146
</body>
147
</html>