Project

General

Profile

Download (7.71 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
55
if (!is_array($config['gateways']['gateway_item']))
56
        $config['gateways']['gateway_item'] = array();
57
58
$a_gateway_item = &$config['gateways']['gateway_item'];
59
60 d173230c Seth Mos
$changedesc = "Gateways: ";
61
62
if ($_POST) {
63
64
	$pconfig = $_POST;
65
66
	if ($_POST['apply']) {
67
68
		$retval = 0;
69
70
		$retval = system_routing_configure();
71
		$retval |= filter_configure();
72 13bbe450 Seth Mos
		/* reconfigure our gateway monitor */
73
		setup_gateways_monitor();
74 d173230c Seth Mos
75
		$savemsg = get_std_save_message($retval);
76 a368a026 Ermal Lu?i
		if ($retval == 0)
77
			clear_subsystem_dirty('staticroutes');
78 d173230c Seth Mos
	}
79
}
80
81
if ($_GET['act'] == "del") {
82
	if ($a_gateways[$_GET['id']]) {
83 124aee67 Chris Buechler
		/* remove the real entry */
84
		$realid = $a_gateways[$_GET['id']]['attribute'];
85
		$a_gateways = &$config['gateways']['gateway_item'];
86
87
		$changedesc .= "removed gateway {$realid}";
88
		unset($a_gateways[$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 d88c6a9f Scott Ullrich
$pgtitle = array("System","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 d173230c Seth Mos
<?php print_info_box_np("The gateway configuration has been changed.<br>You must apply the changes in order for them to take 
109
effect.");?><br>
110
<?php endif; ?>
111
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
112
		<tr>
113
		  <td>
114
<?php
115
			$tab_array = array();
116
			$tab_array[0] = array("Gateways", true, "system_gateways.php");
117
			$tab_array[1] = array("Routes", false, "system_routes.php");
118 c67a0d18 Seth Mos
			$tab_array[2] = array("Groups", false, "system_gateway_groups.php");
119 db7b006f Seth Mos
			$tab_array[3] = array("Settings", false, "system_gateways_settings.php");
120 d173230c Seth Mos
			display_top_tabs($tab_array);
121
?>
122 40e59dbf Scott Ullrich
</td></tr>
123
 <tr>
124
   <td>
125
	<div id="mainarea">
126
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
127 d173230c Seth Mos
                <tr>
128
                  <td width="15%" class="listhdrr">Name</td>
129
                  <td width="15%" class="listhdrr">Interface</td>
130
                  <td width="20%" class="listhdrr">Gateway</td>
131
                  <td width="20%" class="listhdrr">Monitor IP</td>
132
                  <td width="30%" class="listhdr">Description</td>
133
                  <td width="10%" class="list">
134
			<table border="0" cellspacing="0" cellpadding="1">
135
			   <tr>
136
				<td width="17"></td>
137
				<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>
138
			   </tr>
139
			</table>
140
		  </td>
141
		</tr>
142
			  <?php $i = 0; foreach ($a_gateways as $gateway): ?>
143
                <tr>
144
                  <td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
145
                    <?php
146 81203d1d Ermal Lu?i
			echo $gateway['name'];
147 d173230c Seth Mos
			if(isset($gateway['defaultgw'])) {
148 124aee67 Chris Buechler
				echo " <strong>(default)<strong>";
149 d173230c Seth Mos
			}
150
			?>
151
			
152
                  </td>
153
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
154
                    <?php
155 81203d1d Ermal Lu?i
				echo htmlspecialchars(convert_real_interface_to_friendly_descr($gateway['interface']));
156
			?>
157 d173230c Seth Mos
                  </td>
158
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
159
				  <?php
160
					if(isset($gateway['interfacegateway'])) {
161
						echo strtoupper($gateway['interface']) . " ";
162
					} else {
163 616e1956 Seth Mos
						if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['gateway'] == dynamic)) {
164
							echo "dynamic";
165
						} else {
166
							echo $gateway['gateway'] . " ";
167
						}
168 d173230c Seth Mos
					}
169
				  ?>
170
                  </td>
171
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
172 616e1956 Seth Mos
                    <?php
173
			if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['gateway'] == dynamic) && ($a_gateway_item[$gateway['attribute']]['gateway'] == "")) {
174
				echo "dynamic";
175
			} else {
176
				echo htmlspecialchars($gateway['monitor']) . " ";
177
			}
178
		    ?>
179 d173230c Seth Mos
                  </td>
180 295ff120 Seth Mos
		<?php if($gateway['attribute'] == "system") : ?>
181
                  <td class="listbgns" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
182
		<?php else : ?>
183 137ea11c Seth Mos
                  <td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
184 295ff120 Seth Mos
		<?php endif; ?>
185 33300c73 Scott Ullrich
                    <?=htmlspecialchars($gateway['descr']);?>&nbsp;
186 d173230c Seth Mos
                  </td>
187 295ff120 Seth Mos
188 d173230c Seth Mos
                  <td valign="middle" nowrap class="list">
189
			<table border="0" cellspacing="0" cellpadding="1">
190
			   <tr>
191
				<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>
192 295ff120 Seth Mos
				<?php
193
				if ($gateway['attribute'] != "system") : ?>
194
					<td><a href="system_gateways.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this 
195
gateway?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
196
				<?php else : ?>
197
					<td width='17'></td>
198
				<?php endif; ?>
199 d173230c Seth Mos
			   </tr>
200
			   <tr>
201
				<td width="17"></td>
202
				<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>
203
			   </tr>
204
			</table>
205
206
		</tr>
207
			  <?php $i++; endforeach; ?>
208
                <tr>
209
                  <td class="list" colspan="5"></td>
210
                  <td class="list">
211
			<table border="0" cellspacing="0" cellpadding="1">
212
			   <tr>
213
				<td width="17"></td>
214
				<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>
215
			   </tr>
216 40e59dbf Scott Ullrich
		                    </table>
217
				  </td>
218
		                </tr>
219 d173230c Seth Mos
			</table>
220 40e59dbf Scott Ullrich
			</div>
221
			</td>
222
		  </tr>
223
		</table>
224 d173230c Seth Mos
            </form>
225
<?php include("fend.inc"); ?>
226
</body>
227
</html>