Project

General

Profile

Download (8.32 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_gateways.php
5
	part of pfSense (http://pfsense.com)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.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
	pfSense_MODULE:	routing
33
*/
34

    
35
##|+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
require("guiconfig.inc");
43
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46

    
47
$a_gateways = return_gateways_array(true);
48
$a_gateways_arr = array();
49
foreach ($a_gateways as $gw)
50
	$a_gateways_arr[] = $gw;
51
$a_gateways = $a_gateways_arr;
52

    
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
$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
		/* reconfigure our gateway monitor */
71
		setup_gateways_monitor();
72

    
73
		$savemsg = get_std_save_message($retval);
74
		if ($retval == 0)
75
			clear_subsystem_dirty('staticroutes');
76
	}
77
}
78

    
79
if ($_GET['act'] == "del") {
80
	if ($a_gateways[$_GET['id']]) {
81
		/* remove the real entry */
82
		$realid = $a_gateways[$_GET['id']]['attribute'];
83
		$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
	}
117
}
118

    
119

    
120
$pgtitle = array(gettext("System"),gettext("Gateways"));
121
$statusurl = "status_gateways.php";
122

    
123
include("head.inc");
124

    
125
?>
126

    
127
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
128
<?php include("fbegin.inc"); ?>
129
<?php if ($input_errors) print_input_errors($input_errors); ?>
130
<form action="system_gateways.php" method="post">
131
<input type="hidden" name="y1" value="1">
132
<?php if ($savemsg) print_info_box($savemsg); ?>
133
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
134
<?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
<?php endif; ?>
136
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
137
		<tr>
138
		  <td>
139
<?php
140
			$tab_array = array();
141
			$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
			display_top_tabs($tab_array);
145
?>
146
</td></tr>
147
 <tr>
148
   <td>
149
	<div id="mainarea">
150
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
151
                <tr>
152
                  <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
                  <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
			echo $gateway['name'];
171
			if(isset($gateway['defaultgw']))
172
				echo " <strong>(default)<strong>";
173
		?>
174
                  </td>
175
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
176
		<?php
177
			echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($gateway['friendlyiface']));
178
		?>
179
                  </td>
180
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
181
		<?php
182
			echo $gateway['gateway'] . " ";
183
		?>
184
                  </td>
185
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
186
		<?php
187
			echo htmlspecialchars($gateway['monitor']) . " ";
188
		?>
189
                  </td>
190
		<?php if (is_numeric($gateway['attribute'])) : ?>
191
                  <td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
192
		<?php else : ?>
193
                  <td class="listbgns" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
194
		<?php endif; ?>
195
                    <?=htmlspecialchars($gateway['descr']);?>&nbsp;
196
                  </td>
197

    
198
                  <td valign="middle" nowrap class="list">
199
			<table border="0" cellspacing="0" cellpadding="1">
200
			   <tr>
201
				<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>
202
				<?php
203
				if (is_numeric($gateway['attribute'])) : ?>
204
					<td>
205
						<a href="system_gateways.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway?"); ?>')">
206
							<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0">
207
						</a>
208
					</td>
209
				<?php else : ?>
210
					<td width='17'></td>
211
				<?php endif; ?>
212
			   </tr>
213
			   <tr>
214
				<td width="17"></td>
215
				<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>
216
			   </tr>
217
			</table>
218

    
219
		</tr>
220
		  <?php $i++; endforeach; ?>
221
                <tr>
222
                  <td class="list" colspan="5"></td>
223
                  <td class="list">
224
			<table border="0" cellspacing="0" cellpadding="1">
225
			   <tr>
226
				<td width="17"></td>
227
				<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>
228
			   </tr>
229
		                    </table>
230
				  </td>
231
		                </tr>
232
			</table>
233
			</div>
234
			</td>
235
		  </tr>
236
		</table>
237
            </form>
238
<?php include("fend.inc"); ?>
239
</body>
240
</html>
(192-192/224)