Project

General

Profile

Download (6.79 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
32 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-system-gateways
34
##|*NAME=System: Gateways page
35
##|*DESCR=Allow access to the 'System: Gateways' page.
36
##|*MATCH=system_gateways.php*
37
##|-PRIV
38
39
40 d173230c Seth Mos
require("guiconfig.inc");
41
42 b92305a6 --global
43 124aee67 Chris Buechler
$a_gateways = return_gateways_array();
44 b92305a6 --global
$a_gateways_arr = array();
45
foreach($a_gateways as $gw) {
46 3df6d458 Seth Mos
	$a_gateways_arr[] = $gw;
47 b92305a6 --global
}
48
$a_gateways = $a_gateways_arr;
49 d173230c Seth Mos
$changedesc = "Gateways: ";
50
51
if ($_POST) {
52
53
	$pconfig = $_POST;
54
55
	if ($_POST['apply']) {
56
57
		$retval = 0;
58
59
		$retval = system_routing_configure();
60
		$retval |= filter_configure();
61 13bbe450 Seth Mos
		/* reconfigure our gateway monitor */
62
		setup_gateways_monitor();
63 d173230c Seth Mos
64
		$savemsg = get_std_save_message($retval);
65
		if ($retval == 0) {
66
			if (file_exists($d_staticroutesdirty_path)) {
67
				unlink($d_staticroutesdirty_path);
68
			}
69
		}
70
	}
71
}
72
73
if ($_GET['act'] == "del") {
74
	if ($a_gateways[$_GET['id']]) {
75 124aee67 Chris Buechler
		/* remove the real entry */
76
		$realid = $a_gateways[$_GET['id']]['attribute'];
77
		$a_gateways = &$config['gateways']['gateway_item'];
78
79
		$changedesc .= "removed gateway {$realid}";
80
		unset($a_gateways[$realid]);
81 d173230c Seth Mos
		write_config($changedesc);
82
		touch($d_staticroutesdirty_path);
83
		header("Location: system_gateways.php");
84
		exit;
85
	}
86
}
87
88 124aee67 Chris Buechler
89 d88c6a9f Scott Ullrich
$pgtitle = array("System","Gateways");
90 d173230c Seth Mos
include("head.inc");
91
92
?>
93
94
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
95
<?php include("fbegin.inc"); ?>
96
<form action="system_gateways.php" method="post">
97
<input type="hidden" name="y1" value="1">
98
<?php if ($savemsg) print_info_box($savemsg); ?>
99
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
100
<?php print_info_box_np("The gateway configuration has been changed.<br>You must apply the changes in order for them to take 
101
effect.");?><br>
102
<?php endif; ?>
103
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
104
		<tr>
105
		  <td>
106
<?php
107
			$tab_array = array();
108
			$tab_array[0] = array("Gateways", true, "system_gateways.php");
109
			$tab_array[1] = array("Routes", false, "system_routes.php");
110 c67a0d18 Seth Mos
			$tab_array[2] = array("Groups", false, "system_gateway_groups.php");
111 db7b006f Seth Mos
			$tab_array[3] = array("Settings", false, "system_gateways_settings.php");
112 d173230c Seth Mos
			display_top_tabs($tab_array);
113
?>
114 40e59dbf Scott Ullrich
</td></tr>
115
 <tr>
116
   <td>
117
	<div id="mainarea">
118
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
119 d173230c Seth Mos
                <tr>
120
                  <td width="15%" class="listhdrr">Name</td>
121
                  <td width="15%" class="listhdrr">Interface</td>
122
                  <td width="20%" class="listhdrr">Gateway</td>
123
                  <td width="20%" class="listhdrr">Monitor IP</td>
124
                  <td width="30%" class="listhdr">Description</td>
125
                  <td width="10%" class="list">
126
			<table border="0" cellspacing="0" cellpadding="1">
127
			   <tr>
128
				<td width="17"></td>
129
				<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>
130
			   </tr>
131
			</table>
132
		  </td>
133
		</tr>
134
			  <?php $i = 0; foreach ($a_gateways as $gateway): ?>
135
                <tr>
136
                  <td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
137
                    <?php
138 81203d1d Ermal Lu?i
			echo $gateway['name'];
139 d173230c Seth Mos
			if(isset($gateway['defaultgw'])) {
140 124aee67 Chris Buechler
				echo " <strong>(default)<strong>";
141 d173230c Seth Mos
			}
142
			?>
143
			
144
                  </td>
145
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
146
                    <?php
147 81203d1d Ermal Lu?i
				echo htmlspecialchars(convert_real_interface_to_friendly_descr($gateway['interface']));
148
			?>
149 d173230c Seth Mos
                  </td>
150
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
151
				  <?php
152
					if(isset($gateway['interfacegateway'])) {
153
						echo strtoupper($gateway['interface']) . " ";
154
					} else {
155
						echo $gateway['gateway'] . " ";
156
					}
157
				  ?>
158
                  </td>
159
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
160
                    <?=htmlspecialchars($gateway['monitor']);?>&nbsp;
161
                  </td>
162
                  <td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
163 33300c73 Scott Ullrich
                    <?=htmlspecialchars($gateway['descr']);?>&nbsp;
164 d173230c Seth Mos
                  </td>
165
                  <td valign="middle" nowrap class="list">
166
			<table border="0" cellspacing="0" cellpadding="1">
167
			   <tr>
168
				<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>
169
				<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>
170
			   </tr>
171
			   <tr>
172
				<td width="17"></td>
173
				<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>
174
			   </tr>
175
			</table>
176
177
		</tr>
178
			  <?php $i++; endforeach; ?>
179
                <tr>
180
                  <td class="list" colspan="5"></td>
181
                  <td class="list">
182
			<table border="0" cellspacing="0" cellpadding="1">
183
			   <tr>
184
				<td width="17"></td>
185
				<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>
186
			   </tr>
187 40e59dbf Scott Ullrich
		                    </table>
188
				  </td>
189
		                </tr>
190 d173230c Seth Mos
			</table>
191 40e59dbf Scott Ullrich
			</div>
192
			</td>
193
		  </tr>
194
		</table>
195 d173230c Seth Mos
            </form>
196
<?php include("fend.inc"); ?>
197
</body>
198
</html>