Project

General

Profile

Download (7.8 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) 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
	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
}
52
$a_gateways = $a_gateways_arr;
53

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

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

    
80
if ($_GET['act'] == "del") {
81
	if ($a_gateways[$_GET['id']]) {
82
		/* remove the real entry */
83
		$realid = $a_gateways[$_GET['id']]['attribute'];
84

    
85
		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
		$changedesc .= "removed gateway {$realid}";
88
		unset($a_gateway_item[$realid]);
89
		write_config($changedesc);
90
		mark_subsystem_dirty('staticroutes');
91
		header("Location: system_gateways.php");
92
		exit;
93
	}
94
}
95

    
96

    
97
$pgtitle = array("System","Gateways");
98
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
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
108
<?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
			$tab_array[2] = array("Groups", false, "system_gateway_groups.php");
119
			$tab_array[3] = array("Settings", false, "system_gateways_settings.php");
120
			display_top_tabs($tab_array);
121
?>
122
</td></tr>
123
 <tr>
124
   <td>
125
	<div id="mainarea">
126
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
127
                <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
			echo $gateway['name'];
147
			if(isset($gateway['defaultgw'])) {
148
				echo " <strong>(default)<strong>";
149
			}
150
			?>
151
			
152
                  </td>
153
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
154
                    <?php
155
				echo htmlspecialchars(convert_real_interface_to_friendly_descr($gateway['interface']));
156
			?>
157
                  </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
						if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['gateway'] == "dynamic")) {
164
							echo "dynamic";
165
						} else {
166
							echo $gateway['gateway'] . " ";
167
						}
168
					}
169
				  ?>
170
                  </td>
171
                  <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
172
                    <?php
173
			if(is_numeric($gateway['attribute']) && ($a_gateway_item[$gateway['attribute']]['monitor'] == "dynamic")) {
174
				echo "dynamic";
175
			} else {
176
				echo htmlspecialchars($gateway['monitor']) . " ";
177
			}
178
		    ?>
179
                  </td>
180
		<?php if($gateway['attribute'] == "system") : ?>
181
                  <td class="listbgns" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
182
		<?php else : ?>
183
                  <td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
184
		<?php endif; ?>
185
                    <?=htmlspecialchars($gateway['descr']);?>&nbsp;
186
                  </td>
187

    
188
                  <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
				<?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
			   </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
		                    </table>
217
				  </td>
218
		                </tr>
219
			</table>
220
			</div>
221
			</td>
222
		  </tr>
223
		</table>
224
            </form>
225
<?php include("fend.inc"); ?>
226
</body>
227
</html>
(184-184/217)