Project

General

Profile

Download (7.91 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_gateway_groups.php
5
	part of pfSense (https://www.pfsense.org)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	All rights reserved.
10

    
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13

    
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16

    
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20

    
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
/*
33
	pfSense_MODULE:	routing
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-system-gatewaygroups
38
##|*NAME=System: Gateway Groups page
39
##|*DESCR=Allow access to the 'System: Gateway Groups' page.
40
##|*MATCH=system_gateway_groups.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44
require_once("functions.inc");
45
require_once("filter.inc");
46
require_once("shaper.inc");
47
require_once("openvpn.inc");
48

    
49
if (!is_array($config['gateways']['gateway_group']))
50
	$config['gateways']['gateway_group'] = array();
51

    
52
$a_gateway_groups = &$config['gateways']['gateway_group'];
53
$a_gateways = &$config['gateways']['gateway_item'];
54
$changedesc = gettext("Gateway Groups") . ": ";
55

    
56
if ($_POST) {
57

    
58
	$pconfig = $_POST;
59

    
60
	if ($_POST['apply']) {
61

    
62
		$retval = 0;
63

    
64
		$retval = system_routing_configure();
65
		send_multiple_events(array("service reload dyndnsall", "service reload ipsecdns", "filter reload"));
66

    
67
		/* reconfigure our gateway monitor */
68
		setup_gateways_monitor();
69

    
70
		$savemsg = get_std_save_message($retval);
71
		if ($retval == 0)
72
			clear_subsystem_dirty('staticroutes');
73

    
74
		foreach ($a_gateway_groups as $gateway_group) {
75
			$gw_subsystem = 'gwgroup.' . $gateway_group['name'];
76
			if (is_subsystem_dirty($gw_subsystem)) {
77
				openvpn_resync_gwgroup($gateway_group['name']);
78
				clear_subsystem_dirty($gw_subsystem);
79
			}
80
		}
81
	}
82
}
83

    
84
if ($_GET['act'] == "del") {
85
	if ($a_gateway_groups[$_GET['id']]) {
86
		$changedesc .= gettext("removed gateway group") . " {$_GET['id']}";
87
		foreach ($config['filter']['rule'] as $idx => $rule) {
88
			if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name'])
89
				unset($config['filter']['rule'][$idx]['gateway']);
90
		}
91
		unset($a_gateway_groups[$_GET['id']]);
92
		write_config($changedesc);
93
		mark_subsystem_dirty('staticroutes');
94
		header("Location: system_gateway_groups.php");
95
		exit;
96
	}
97
}
98

    
99
$pgtitle = array(gettext("System"),gettext("Gateway Groups"));
100
$shortcut_section = "gateway-groups";
101

    
102
include("head.inc");
103

    
104
?>
105

    
106
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
107
<?php include("fbegin.inc"); ?>
108
<form action="system_gateway_groups.php" method="post">
109
<input type="hidden" name="y1" value="1" />
110
<?php if ($savemsg) print_info_box($savemsg); ?>
111
<?php if (is_subsystem_dirty('staticroutes')): ?><br/>
112
<?php print_info_box_np(sprintf(gettext("The gateway configuration has been changed.%sYou must apply the changes in order for them to take effect."), "<br />"));?><br /><br />
113
<?php endif; ?>
114
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system groups">
115
		<tr>
116
		  <td>
117
<?php
118
			$tab_array = array();
119
			$tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php");
120
			$tab_array[1] = array(gettext("Routes"), false, "system_routes.php");
121
			$tab_array[2] = array(gettext("Groups"), true, "system_gateway_groups.php");
122
			display_top_tabs($tab_array);
123
?>
124
</td></tr>
125
 <tr>
126
   <td>
127
	<div id="mainarea">
128
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
129
		<thead>
130
                <tr>
131
                  <td width="15%" class="listhdrr"><?=gettext("Group Name");?></td>
132
                  <td width="15%" class="listhdrr"><?=gettext("Gateways");?></td>
133
                  <td width="20%" class="listhdrr"><?=gettext("Priority");?></td>
134
                  <td width="30%" class="listhdr"><?=gettext("Description");?></td>
135
                  <td width="10%" class="list">
136
			<table border="0" cellspacing="0" cellpadding="1" summary="icons">
137
			   <tr>
138
				<td width="17"></td>
139
				<td><a href="system_gateway_groups_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td>
140
			   </tr>
141
			</table>
142
		  </td>
143
		</tr>
144
		</thead>
145
		<tfoot>
146
                  <tr><td class="list" colspan="4"></td>
147
                  <td class="list">
148
			<table border="0" cellspacing="0" cellpadding="1" summary="edit">
149
			   <tr>
150
				<td width="17"></td>
151
				<td><a href="system_gateway_groups_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td>
152
			   </tr>
153
		                    </table>
154
				  </td>
155
		                </tr>
156
		</tfoot>
157
		<tbody>
158
			  <?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
159
                <tr>
160
                  <td class="listlr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
161
                    <?php
162
			echo $gateway_group['name'];
163
		?>
164
                  </td>
165
                  <td class="listr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
166
                    <?php
167
			foreach($gateway_group['item'] as $item) {
168
				$itemsplit = explode("|", $item);
169
				echo htmlspecialchars(strtoupper($itemsplit[0])) . "<br />\n";
170
			}
171
		    ?>
172
                  </td>
173
                  <td class="listr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
174
		    <?php
175
			foreach($gateway_group['item'] as $item) {
176
				$itemsplit = explode("|", $item);
177
				echo "Tier ". htmlspecialchars($itemsplit[1]) . "<br />\n";
178
			}
179
		    ?>
180
                  </td>
181
                  <td class="listbg" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
182
				<?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
183
                  </td>
184
                  <td valign="middle" class="list nowrap">
185
			<table border="0" cellspacing="0" cellpadding="1" summary="edit">
186
			   <tr>
187
				<td><a href="system_gateway_groups_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a></td>
188
				<td><a href="system_gateway_groups.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway group?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
189
			   </tr>
190
			   <tr>
191
				<td width="17"></td>
192
				<td><a href="system_gateway_groups_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="duplicate" /></a></td>
193
			   </tr>
194
			</table>
195
                  </td>
196
		</tr>
197
			  <?php $i++; endforeach; ?>
198
                <tr style="display:none;"><td></td></tr>
199
		</tbody>
200
			</table>
201
			</div>
202
			</td>
203
		  </tr>
204
		</table>
205
            </form>
206
	<p><b><?=gettext("Note:");?></b>  <?=gettext("Remember to use these Gateway Groups in firewall rules in order to enable load balancing, failover, or policy-based routing. Without rules directing traffic into the Gateway Groups, they will not be used.");?></p>
207
<?php include("fend.inc"); ?>
208
</body>
209
</html>
(220-220/256)