1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
system_gateways.php
|
5
|
part of pfSense (http://pfsense.com)
|
6
|
|
7
|
Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
|
32
|
require("guiconfig.inc");
|
33
|
|
34
|
if (!is_array($config['gateways']['gateway_item']))
|
35
|
$config['gateways']['gateway_item'] = array();
|
36
|
|
37
|
$a_gateways = &$config['gateways']['gateway_item'];
|
38
|
$changedesc = "Gateways: ";
|
39
|
|
40
|
if ($_POST) {
|
41
|
|
42
|
$pconfig = $_POST;
|
43
|
|
44
|
if ($_POST['apply']) {
|
45
|
|
46
|
$retval = 0;
|
47
|
|
48
|
$retval = system_routing_configure();
|
49
|
$retval |= filter_configure();
|
50
|
|
51
|
$savemsg = get_std_save_message($retval);
|
52
|
if ($retval == 0) {
|
53
|
if (file_exists($d_staticroutesdirty_path)) {
|
54
|
config_lock();
|
55
|
unlink($d_staticroutesdirty_path);
|
56
|
config_unlock();
|
57
|
}
|
58
|
}
|
59
|
}
|
60
|
}
|
61
|
|
62
|
if ($_GET['act'] == "del") {
|
63
|
if ($a_gateways[$_GET['id']]) {
|
64
|
$changedesc .= "removed gateway {$_GET['id']}";
|
65
|
unset($a_gateways[$_GET['id']]);
|
66
|
write_config($changedesc);
|
67
|
touch($d_staticroutesdirty_path);
|
68
|
header("Location: system_gateways.php");
|
69
|
exit;
|
70
|
}
|
71
|
}
|
72
|
|
73
|
$pgtitle = "System: Gateways";
|
74
|
include("head.inc");
|
75
|
|
76
|
?>
|
77
|
|
78
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
79
|
<?php include("fbegin.inc"); ?>
|
80
|
<p class="pgtitle"><?=$pgtitle?></p>
|
81
|
<form action="system_gateways.php" method="post">
|
82
|
<input type="hidden" name="y1" value="1">
|
83
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
84
|
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
|
85
|
<?php print_info_box_np("The gateway configuration has been changed.<br>You must apply the changes in order for them to take
|
86
|
effect.");?><br>
|
87
|
<?php endif; ?>
|
88
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
89
|
<tr>
|
90
|
<td>
|
91
|
<?php
|
92
|
$tab_array = array();
|
93
|
$tab_array[0] = array("Gateways", true, "system_gateways.php");
|
94
|
$tab_array[1] = array("Routes", false, "system_routes.php");
|
95
|
display_top_tabs($tab_array);
|
96
|
?>
|
97
|
</td>
|
98
|
</tr>
|
99
|
<tr>
|
100
|
<td width="15%" class="listhdrr">Name</td>
|
101
|
<td width="15%" class="listhdrr">Interface</td>
|
102
|
<td width="20%" class="listhdrr">Gateway</td>
|
103
|
<td width="20%" class="listhdrr">Monitor IP</td>
|
104
|
<td width="30%" class="listhdr">Description</td>
|
105
|
<td width="10%" class="list">
|
106
|
<table border="0" cellspacing="0" cellpadding="1">
|
107
|
<tr>
|
108
|
<td width="17"></td>
|
109
|
<td><a href="system_gateways_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
110
|
</tr>
|
111
|
</table>
|
112
|
</td>
|
113
|
</tr>
|
114
|
<?php $i = 0; foreach ($a_gateways as $gateway): ?>
|
115
|
<tr>
|
116
|
<td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
117
|
<?php
|
118
|
echo $gateway['name'];
|
119
|
if(isset($gateway['defaultgw'])) {
|
120
|
echo " <strong>(default)<strong>";
|
121
|
}
|
122
|
?>
|
123
|
|
124
|
</td>
|
125
|
<td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
126
|
<?php
|
127
|
$iflabels = array('wan' => 'WAN', 'lan' => 'LAN');
|
128
|
for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
|
129
|
$iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
|
130
|
echo htmlspecialchars($iflabels[$gateway['interface']]); ?>
|
131
|
</td>
|
132
|
<td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
133
|
<?php
|
134
|
if(isset($gateway['interfacegateway'])) {
|
135
|
echo strtoupper($gateway['interface']) . " ";
|
136
|
} else {
|
137
|
echo $gateway['gateway'] . " ";
|
138
|
}
|
139
|
?>
|
140
|
</td>
|
141
|
<td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
142
|
<?=htmlspecialchars($gateway['monitor']);?>
|
143
|
</td>
|
144
|
<td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
145
|
<font color="#FFFFFF"><?=htmlspecialchars($gateway['descr']);?>
|
146
|
</td>
|
147
|
<td valign="middle" nowrap class="list">
|
148
|
<table border="0" cellspacing="0" cellpadding="1">
|
149
|
<tr>
|
150
|
<td><a href="system_gateways_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
|
151
|
<td><a href="system_gateways.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this gateway?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
152
|
</tr>
|
153
|
<tr>
|
154
|
<td width="17"></td>
|
155
|
<td><a href="system_gateways_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
156
|
</tr>
|
157
|
</table>
|
158
|
|
159
|
</tr>
|
160
|
<?php $i++; endforeach; ?>
|
161
|
<tr>
|
162
|
<td class="list" colspan="5"></td>
|
163
|
<td class="list">
|
164
|
<table border="0" cellspacing="0" cellpadding="1">
|
165
|
<tr>
|
166
|
<td width="17"></td>
|
167
|
<td><a href="system_gateways_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
168
|
</tr>
|
169
|
</table>
|
170
|
</td>
|
171
|
</tr>
|
172
|
</table>
|
173
|
</form>
|
174
|
<?php include("fend.inc"); ?>
|
175
|
</body>
|
176
|
</html>
|