Project

General

Profile

Download (5.32 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
	firewall_aliases.php
6
	Copyright (C) 2004 Scott Ullrich
7
	All rights reserved.
8

    
9
	originially part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

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

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

    
19
	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

    
23
	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
		if(stristr($retval, "error") <> true)
56
		    $savemsg = get_std_save_message($retval);
57
		else
58
		    $savemsg = $retval;
59
		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
$pgtitle = "Firewall: Aliases";
77
include("head.inc");
78

    
79
?>
80

    
81
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
82
<?php include("fbegin.inc"); ?>
83
<p class="pgtitle"><?=$pgtitle?></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.");?>
88
<?php endif; ?>
89

    
90
<table width="100%" border="0" cellpadding="0" cellspacing="0">
91
<tr>
92
  <td width="25%" class="listhdrr">Name</td>
93
  <td width="25%" class="listhdrr">Values</td>
94
  <td width="25%" class="listhdr">Description</td>
95
  <td width="10%" class="list"></td>
96
</tr>
97
	  <?php $i = 0; foreach ($a_aliases as $alias): ?>
98
<tr>
99
  <td class="listlr" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
100
    <?=htmlspecialchars($alias['name']);?>
101
  </td>
102
  <td class="listr" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
103
      <?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
  </td>
114
  <td class="listbg" ondblclick="document.location='firewall_aliases_edit.php?id=<?=$i;?>';">
115
    <font color="#FFFFFF">
116
    <?=htmlspecialchars($alias['descr']);?>&nbsp;
117
  </td>
118
  <td valign="middle" nowrap class="list">
119
    <table border="0" cellspacing="0" cellpadding="1"> 
120
      <tr>
121
        <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"></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"></a></td>
123
      </tr>
124
    </table>
125
  </td>
126
</tr>
127
	  <?php $i++; endforeach; ?>
128
<tr>
129
  <td class="list" colspan="3"></td>
130
  <td class="list">
131
    <table border="0" cellspacing="0" cellpadding="1">
132
      <tr>
133
        <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"></a></td>
134
      </tr>
135
    </table>
136
  </td>
137
</tr>
138
<tr>
139
  <td class="tabcont" colspan="3">
140
   <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
  </td>
142
</tr>
143
</table>
144
</form>
145
<?php include("fend.inc"); ?>
146
</body>
147
</html>
(31-31/144)