Project

General

Profile

Download (8.01 KB) Statistics
| Branch: | Tag: | Revision:
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
	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 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
foreach($a_gateways as $gw) {
50 3df6d458 Seth Mos
	$a_gateways_arr[] = $gw;
51 b92305a6 --global
}
52
$a_gateways = $a_gateways_arr;
53 616e1956 Seth Mos
54
if (!is_array($config['gateways']['gateway_item']))
55
        $config['gateways']['gateway_item'] = array();
56
57
$a_gateway_item = &$config['gateways']['gateway_item'];
58
59 d173230c Seth Mos
$changedesc = "Gateways: ";
60
61
if ($_POST) {
62
63
	$pconfig = $_POST;
64
65
	if ($_POST['apply']) {
66
67
		$retval = 0;
68
69
		$retval = system_routing_configure();
70
		$retval |= filter_configure();
71 13bbe450 Seth Mos
		/* reconfigure our gateway monitor */
72
		setup_gateways_monitor();
73 d173230c Seth Mos
74
		$savemsg = get_std_save_message($retval);
75 a368a026 Ermal Lu?i
		if ($retval == 0)
76
			clear_subsystem_dirty('staticroutes');
77 d173230c Seth Mos
	}
78
}
79
80
if ($_GET['act'] == "del") {
81
	if ($a_gateways[$_GET['id']]) {
82 124aee67 Chris Buechler
		/* remove the real entry */
83
		$realid = $a_gateways[$_GET['id']]['attribute'];
84
85 9c6db17a Ermal Lu?i
		if ($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway'] == $a_gateways[$_GET['id']]['name'])
86
			unset($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway']);
87 124aee67 Chris Buechler
		$changedesc .= "removed gateway {$realid}";
88 883c53c9 Ermal Lu?i
		unset($a_gateway_item[$realid]);
89 d173230c Seth Mos
		write_config($changedesc);
90 a368a026 Ermal Lu?i
		mark_subsystem_dirty('staticroutes');
91 d173230c Seth Mos
		header("Location: system_gateways.php");
92
		exit;
93
	}
94
}
95
96 124aee67 Chris Buechler
97 f8513409 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Gateways"));
98 d173230c Seth Mos
include("head.inc");
99
100
?>
101
102
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
103
<?php include("fbegin.inc"); ?>
104
<form action="system_gateways.php" method="post">
105
<input type="hidden" name="y1" value="1">
106
<?php if ($savemsg) print_info_box($savemsg); ?>
107 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
108 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>
109 d173230c Seth Mos
<?php endif; ?>
110
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
111
		<tr>
112
		  <td>
113
<?php
114
			$tab_array = array();
115 f8513409 Carlos Eduardo Ramos
			$tab_array[0] = array(gettext("Gateways"), true, "system_gateways.php");
116
			$tab_array[1] = array(gettext("Routes"), false, "system_routes.php");
117
			$tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php");
118
			$tab_array[3] = array(gettext("Settings"), false, "system_gateways_settings.php");
119 d173230c Seth Mos
			display_top_tabs($tab_array);
120
?>
121 40e59dbf Scott Ullrich
</td></tr>
122
 <tr>
123
   <td>
124
	<div id="mainarea">
125
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
126 d173230c Seth Mos
                <tr>
127 f8513409 Carlos Eduardo Ramos
                  <td width="15%" class="listhdrr"><?=gettext("Name"); ?></td>
128
                  <td width="15%" class="listhdrr"><?=gettext("Interface"); ?></td>
129
                  <td width="20%" class="listhdrr"><?=gettext("Gateway"); ?></td>
130
                  <td width="20%" class="listhdrr"><?=gettext("Monitor IP"); ?></td>
131
                  <td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
132 d173230c Seth Mos
                  <td width="10%" class="list">
133
			<table border="0" cellspacing="0" cellpadding="1">
134
			   <tr>
135
				<td width="17"></td>
136
				<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>
137
			   </tr>
138
			</table>
139
		  </td>
140
		</tr>
141
			  <?php $i = 0; foreach ($a_gateways as $gateway): ?>
142
                <tr>
143
                  <td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
144
                    <?php
145 81203d1d Ermal Lu?i
			echo $gateway['name'];
146 d173230c Seth Mos
			if(isset($gateway['defaultgw'])) {
147 124aee67 Chris Buechler
				echo " <strong>(default)<strong>";
148 d173230c Seth Mos
			}
149
			?>
150
			
151
                  </td>
152
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
153
                    <?php
154 81203d1d Ermal Lu?i
				echo htmlspecialchars(convert_real_interface_to_friendly_descr($gateway['interface']));
155
			?>
156 d173230c Seth Mos
                  </td>
157
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
158
				  <?php
159
					if(isset($gateway['interfacegateway'])) {
160
						echo strtoupper($gateway['interface']) . " ";
161
					} else {
162 883c53c9 Ermal Lu?i
						if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['gateway'] == "dynamic")) {
163 616e1956 Seth Mos
							echo "dynamic";
164
						} else {
165
							echo $gateway['gateway'] . " ";
166
						}
167 d173230c Seth Mos
					}
168
				  ?>
169
                  </td>
170
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
171 616e1956 Seth Mos
                    <?php
172 883c53c9 Ermal Lu?i
			if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['monitor'] == "dynamic")) {
173 616e1956 Seth Mos
				echo "dynamic";
174
			} else {
175
				echo htmlspecialchars($gateway['monitor']) . " ";
176
			}
177
		    ?>
178 d173230c Seth Mos
                  </td>
179 295ff120 Seth Mos
		<?php if($gateway['attribute'] == "system") : ?>
180
                  <td class="listbgns" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
181
		<?php else : ?>
182 137ea11c Seth Mos
                  <td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
183 295ff120 Seth Mos
		<?php endif; ?>
184 33300c73 Scott Ullrich
                    <?=htmlspecialchars($gateway['descr']);?>&nbsp;
185 d173230c Seth Mos
                  </td>
186 295ff120 Seth Mos
187 d173230c Seth Mos
                  <td valign="middle" nowrap class="list">
188
			<table border="0" cellspacing="0" cellpadding="1">
189
			   <tr>
190
				<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>
191 295ff120 Seth Mos
				<?php
192
				if ($gateway['attribute'] != "system") : ?>
193 0e94685b Renato Botelho
					<td>
194
						<a href="system_gateways.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway?"); ?>')">
195
							<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0">
196
						</a>
197
					</td>
198 295ff120 Seth Mos
				<?php else : ?>
199
					<td width='17'></td>
200
				<?php endif; ?>
201 d173230c Seth Mos
			   </tr>
202
			   <tr>
203
				<td width="17"></td>
204
				<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>
205
			   </tr>
206
			</table>
207
208
		</tr>
209
			  <?php $i++; endforeach; ?>
210
                <tr>
211
                  <td class="list" colspan="5"></td>
212
                  <td class="list">
213
			<table border="0" cellspacing="0" cellpadding="1">
214
			   <tr>
215
				<td width="17"></td>
216
				<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>
217
			   </tr>
218 40e59dbf Scott Ullrich
		                    </table>
219
				  </td>
220
		                </tr>
221 d173230c Seth Mos
			</table>
222 40e59dbf Scott Ullrich
			</div>
223
			</td>
224
		  </tr>
225
		</table>
226 d173230c Seth Mos
            </form>
227
<?php include("fend.inc"); ?>
228
</body>
229
</html>