1 |
d173230c
|
Seth Mos
|
<?php
|
2 |
124aee67
|
Chris Buechler
|
/* $Id$ */
|
3 |
d173230c
|
Seth Mos
|
/*
|
4 |
|
|
system_gateways.php
|
5 |
|
|
part of pfSense (http://pfsense.com)
|
6 |
|
|
|
7 |
6216690b
|
smos
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8 |
d173230c
|
Seth Mos
|
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 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: routing
|
33 |
|
|
*/
|
34 |
d173230c
|
Seth Mos
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-system-gateways
|
37 |
|
|
##|*NAME=System: Gateways page
|
38 |
|
|
##|*DESCR=Allow access to the 'System: Gateways' page.
|
39 |
|
|
##|*MATCH=system_gateways.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
d173230c
|
Seth Mos
|
require("guiconfig.inc");
|
43 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
44 |
|
|
require_once("filter.inc");
|
45 |
|
|
require_once("shaper.inc");
|
46 |
d173230c
|
Seth Mos
|
|
47 |
c795339e
|
Ermal Lu?i
|
$a_gateways = return_gateways_array(true);
|
48 |
b92305a6
|
--global
|
$a_gateways_arr = array();
|
49 |
f78302e8
|
Ermal
|
foreach ($a_gateways as $gw)
|
50 |
3df6d458
|
Seth Mos
|
$a_gateways_arr[] = $gw;
|
51 |
b92305a6
|
--global
|
$a_gateways = $a_gateways_arr;
|
52 |
616e1956
|
Seth Mos
|
|
53 |
|
|
if (!is_array($config['gateways']['gateway_item']))
|
54 |
|
|
$config['gateways']['gateway_item'] = array();
|
55 |
|
|
|
56 |
|
|
$a_gateway_item = &$config['gateways']['gateway_item'];
|
57 |
|
|
|
58 |
d173230c
|
Seth Mos
|
$changedesc = "Gateways: ";
|
59 |
|
|
|
60 |
|
|
if ($_POST) {
|
61 |
|
|
|
62 |
|
|
$pconfig = $_POST;
|
63 |
|
|
|
64 |
|
|
if ($_POST['apply']) {
|
65 |
|
|
|
66 |
|
|
$retval = 0;
|
67 |
|
|
|
68 |
|
|
$retval = system_routing_configure();
|
69 |
|
|
$retval |= filter_configure();
|
70 |
13bbe450
|
Seth Mos
|
/* reconfigure our gateway monitor */
|
71 |
|
|
setup_gateways_monitor();
|
72 |
d173230c
|
Seth Mos
|
|
73 |
|
|
$savemsg = get_std_save_message($retval);
|
74 |
a368a026
|
Ermal Lu?i
|
if ($retval == 0)
|
75 |
|
|
clear_subsystem_dirty('staticroutes');
|
76 |
d173230c
|
Seth Mos
|
}
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
if ($_GET['act'] == "del") {
|
80 |
|
|
if ($a_gateways[$_GET['id']]) {
|
81 |
124aee67
|
Chris Buechler
|
/* remove the real entry */
|
82 |
|
|
$realid = $a_gateways[$_GET['id']]['attribute'];
|
83 |
f78302e8
|
Ermal
|
$remove = true;
|
84 |
|
|
if (is_array($config['gateways']['gateway_group'])) {
|
85 |
|
|
foreach ($config['gateways']['gateway_group'] as $group) {
|
86 |
|
|
foreach ($group['item'] as $item) {
|
87 |
|
|
$items = explode("|", $item);
|
88 |
|
|
if ($items[0] == $a_gateways[$_GET['id']]['name']) {
|
89 |
|
|
$input_errors[] = "Gateway cannot be deleted because it is in use on Gateway Group '{$group['name']}'";
|
90 |
|
|
$remove = false;
|
91 |
|
|
break;
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
if (is_array($config['staticroutes']['route'])) {
|
98 |
|
|
foreach ($config['staticroutes']['route'] as $route) {
|
99 |
|
|
if ($route['gateway'] == $a_gateways[$_GET['id']]['name']) {
|
100 |
|
|
$input_errors[] = "Gateway cannot be deleted because it is in use on Static Routes '{$route['network']}'";
|
101 |
|
|
$remove = false;
|
102 |
|
|
break;
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
}
|
106 |
|
|
if ($remove == true) {
|
107 |
|
|
if ($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway'] == $a_gateways[$_GET['id']]['name'])
|
108 |
|
|
unset($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway']);
|
109 |
|
|
$changedesc .= "removed gateway {$realid}";
|
110 |
|
|
unset($a_gateway_item[$realid]);
|
111 |
|
|
write_config($changedesc);
|
112 |
|
|
mark_subsystem_dirty('staticroutes');
|
113 |
|
|
header("Location: system_gateways.php");
|
114 |
|
|
exit;
|
115 |
|
|
}
|
116 |
d173230c
|
Seth Mos
|
}
|
117 |
|
|
}
|
118 |
|
|
|
119 |
124aee67
|
Chris Buechler
|
|
120 |
f8513409
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Gateways"));
|
121 |
02ca24c9
|
jim-p
|
$statusurl = "status_gateways.php";
|
122 |
|
|
|
123 |
d173230c
|
Seth Mos
|
include("head.inc");
|
124 |
|
|
|
125 |
|
|
?>
|
126 |
|
|
|
127 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
128 |
|
|
<?php include("fbegin.inc"); ?>
|
129 |
f78302e8
|
Ermal
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
130 |
d173230c
|
Seth Mos
|
<form action="system_gateways.php" method="post">
|
131 |
|
|
<input type="hidden" name="y1" value="1">
|
132 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
133 |
a368a026
|
Ermal Lu?i
|
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
|
134 |
0e94685b
|
Renato Botelho
|
<?php print_info_box_np(gettext("The gateway configuration has been changed.") . "<br>" . gettext("You must apply the changes in order for them to take effect."));?><br>
|
135 |
d173230c
|
Seth Mos
|
<?php endif; ?>
|
136 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
137 |
|
|
<tr>
|
138 |
|
|
<td>
|
139 |
|
|
<?php
|
140 |
|
|
$tab_array = array();
|
141 |
f8513409
|
Carlos Eduardo Ramos
|
$tab_array[0] = array(gettext("Gateways"), true, "system_gateways.php");
|
142 |
|
|
$tab_array[1] = array(gettext("Routes"), false, "system_routes.php");
|
143 |
|
|
$tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php");
|
144 |
d173230c
|
Seth Mos
|
display_top_tabs($tab_array);
|
145 |
|
|
?>
|
146 |
40e59dbf
|
Scott Ullrich
|
</td></tr>
|
147 |
|
|
<tr>
|
148 |
|
|
<td>
|
149 |
|
|
<div id="mainarea">
|
150 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
151 |
d173230c
|
Seth Mos
|
<tr>
|
152 |
f8513409
|
Carlos Eduardo Ramos
|
<td width="15%" class="listhdrr"><?=gettext("Name"); ?></td>
|
153 |
|
|
<td width="15%" class="listhdrr"><?=gettext("Interface"); ?></td>
|
154 |
|
|
<td width="20%" class="listhdrr"><?=gettext("Gateway"); ?></td>
|
155 |
|
|
<td width="20%" class="listhdrr"><?=gettext("Monitor IP"); ?></td>
|
156 |
|
|
<td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
|
157 |
d173230c
|
Seth Mos
|
<td width="10%" class="list">
|
158 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
159 |
|
|
<tr>
|
160 |
|
|
<td width="17"></td>
|
161 |
|
|
<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>
|
162 |
|
|
</tr>
|
163 |
|
|
</table>
|
164 |
|
|
</td>
|
165 |
|
|
</tr>
|
166 |
|
|
<?php $i = 0; foreach ($a_gateways as $gateway): ?>
|
167 |
|
|
<tr>
|
168 |
|
|
<td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
169 |
|
|
<?php
|
170 |
81203d1d
|
Ermal Lu?i
|
echo $gateway['name'];
|
171 |
d173230c
|
Seth Mos
|
if(isset($gateway['defaultgw'])) {
|
172 |
124aee67
|
Chris Buechler
|
echo " <strong>(default)<strong>";
|
173 |
d173230c
|
Seth Mos
|
}
|
174 |
|
|
?>
|
175 |
|
|
|
176 |
|
|
</td>
|
177 |
|
|
<td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
178 |
|
|
<?php
|
179 |
81203d1d
|
Ermal Lu?i
|
echo htmlspecialchars(convert_real_interface_to_friendly_descr($gateway['interface']));
|
180 |
|
|
?>
|
181 |
d173230c
|
Seth Mos
|
</td>
|
182 |
|
|
<td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
183 |
|
|
<?php
|
184 |
|
|
if(isset($gateway['interfacegateway'])) {
|
185 |
|
|
echo strtoupper($gateway['interface']) . " ";
|
186 |
|
|
} else {
|
187 |
883c53c9
|
Ermal Lu?i
|
if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['gateway'] == "dynamic")) {
|
188 |
616e1956
|
Seth Mos
|
echo "dynamic";
|
189 |
|
|
} else {
|
190 |
|
|
echo $gateway['gateway'] . " ";
|
191 |
|
|
}
|
192 |
d173230c
|
Seth Mos
|
}
|
193 |
|
|
?>
|
194 |
|
|
</td>
|
195 |
|
|
<td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
196 |
616e1956
|
Seth Mos
|
<?php
|
197 |
883c53c9
|
Ermal Lu?i
|
if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['monitor'] == "dynamic")) {
|
198 |
616e1956
|
Seth Mos
|
echo "dynamic";
|
199 |
|
|
} else {
|
200 |
|
|
echo htmlspecialchars($gateway['monitor']) . " ";
|
201 |
|
|
}
|
202 |
|
|
?>
|
203 |
d173230c
|
Seth Mos
|
</td>
|
204 |
295ff120
|
Seth Mos
|
<?php if($gateway['attribute'] == "system") : ?>
|
205 |
|
|
<td class="listbgns" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
206 |
|
|
<?php else : ?>
|
207 |
137ea11c
|
Seth Mos
|
<td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
|
208 |
295ff120
|
Seth Mos
|
<?php endif; ?>
|
209 |
33300c73
|
Scott Ullrich
|
<?=htmlspecialchars($gateway['descr']);?>
|
210 |
d173230c
|
Seth Mos
|
</td>
|
211 |
295ff120
|
Seth Mos
|
|
212 |
d173230c
|
Seth Mos
|
<td valign="middle" nowrap class="list">
|
213 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
214 |
|
|
<tr>
|
215 |
|
|
<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>
|
216 |
295ff120
|
Seth Mos
|
<?php
|
217 |
|
|
if ($gateway['attribute'] != "system") : ?>
|
218 |
0e94685b
|
Renato Botelho
|
<td>
|
219 |
|
|
<a href="system_gateways.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway?"); ?>')">
|
220 |
|
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0">
|
221 |
|
|
</a>
|
222 |
|
|
</td>
|
223 |
295ff120
|
Seth Mos
|
<?php else : ?>
|
224 |
|
|
<td width='17'></td>
|
225 |
|
|
<?php endif; ?>
|
226 |
d173230c
|
Seth Mos
|
</tr>
|
227 |
|
|
<tr>
|
228 |
|
|
<td width="17"></td>
|
229 |
|
|
<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>
|
230 |
|
|
</tr>
|
231 |
|
|
</table>
|
232 |
|
|
|
233 |
|
|
</tr>
|
234 |
|
|
<?php $i++; endforeach; ?>
|
235 |
|
|
<tr>
|
236 |
|
|
<td class="list" colspan="5"></td>
|
237 |
|
|
<td class="list">
|
238 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
239 |
|
|
<tr>
|
240 |
|
|
<td width="17"></td>
|
241 |
|
|
<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>
|
242 |
|
|
</tr>
|
243 |
40e59dbf
|
Scott Ullrich
|
</table>
|
244 |
|
|
</td>
|
245 |
|
|
</tr>
|
246 |
d173230c
|
Seth Mos
|
</table>
|
247 |
40e59dbf
|
Scott Ullrich
|
</div>
|
248 |
|
|
</td>
|
249 |
|
|
</tr>
|
250 |
|
|
</table>
|
251 |
d173230c
|
Seth Mos
|
</form>
|
252 |
|
|
<?php include("fend.inc"); ?>
|
253 |
|
|
</body>
|
254 |
|
|
</html>
|