Project

General

Profile

Download (4.44 KB) Statistics
| Branch: | Tag: | Revision:
1 0ec2fdf0 Ermal Lu?i
<?php
2
/*
3 c5d81585 Renato Botelho
 * interfaces_groups.php
4 b9043cdc Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 b9043cdc Stephen Beaver
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 b9043cdc Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 b9043cdc Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 b9043cdc Stephen Beaver
 */
21 0ec2fdf0 Ermal Lu?i
22
##|+PRIV
23
##|*IDENT=page-interfaces-groups
24 5230f468 jim-p
##|*NAME=Interfaces: Groups
25 0ec2fdf0 Ermal Lu?i
##|*DESCR=Create interface groups
26
##|*MATCH=interfaces_groups.php*
27
##|-PRIV
28
29 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
30 654998ee Carlos Eduardo Ramos
require_once("functions.inc");
31 0ec2fdf0 Ermal Lu?i
32 4a588de1 Stephen Jones
if (!is_array($config['ifgroups'])) {
33
	$config['ifgroups'] = array();
34
}
35
36 2af86dda Phil Davis
if (!is_array($config['ifgroups']['ifgroupentry'])) {
37 0ec2fdf0 Ermal Lu?i
	$config['ifgroups']['ifgroupentry'] = array();
38 2af86dda Phil Davis
}
39 0ec2fdf0 Ermal Lu?i
40
$a_ifgroups = &$config['ifgroups']['ifgroupentry'];
41
42 e1a5d73c Steve Beaver
if ($_POST['act'] == "del") {
43
	if ($a_ifgroups[$_POST['id']]) {
44
		$members = explode(" ", $a_ifgroups[$_POST['id']]['members']);
45 42753d25 Ermal Lu?i
		foreach ($members as $ifs) {
46
			$realif = get_real_interface($ifs);
47 2af86dda Phil Davis
			if ($realif) {
48 e1a5d73c Steve Beaver
				mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_POST['id']]['ifname']);
49 2af86dda Phil Davis
			}
50 42753d25 Ermal Lu?i
		}
51 e1a5d73c Steve Beaver
		unset($a_ifgroups[$_POST['id']]);
52 0ec2fdf0 Ermal Lu?i
		write_config();
53
		header("Location: interfaces_groups.php");
54
		exit;
55
	}
56
}
57
58 26b4bef8 k-paulius
$pgtitle = array(gettext("Interfaces"), gettext("Interface Groups"));
59 b32dd0a6 jim-p
$shortcut_section = "interfaces";
60 0ec2fdf0 Ermal Lu?i
61 19013d43 Thane Gill
include("head.inc");
62 0ec2fdf0 Ermal Lu?i
63 19013d43 Thane Gill
$tab_array = array();
64 26b4bef8 k-paulius
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
65 719da9a2 Sjon Hortensius
$tab_array[] = array(gettext("Interface Groups"), true, "interfaces_groups.php");
66
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
67
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
68
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
69
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
70 26b4bef8 k-paulius
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
71
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
72 719da9a2 Sjon Hortensius
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
73 26b4bef8 k-paulius
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
74 19013d43 Thane Gill
display_top_tabs($tab_array);
75 0ec2fdf0 Ermal Lu?i
?>
76 060ed238 Stephen Beaver
<div class="panel panel-default">
77 70dc5cd6 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Interface Groups')?></h2></div>
78 060ed238 Stephen Beaver
	<div class="panel-body">
79
		<div class="table-responsive">
80 1c10ce97 PiBa-NL
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
81 060ed238 Stephen Beaver
				<thead>
82
					<tr>
83
						<th><?=gettext('Name');?></th>
84
						<th><?=gettext('Members');?></th>
85
						<th><?=gettext('Description');?></th>
86 70dc5cd6 Phil Davis
						<th><?=gettext('Actions');?></th>
87 060ed238 Stephen Beaver
					</tr>
88
				</thead>
89
				<tbody>
90 e41d7a1c Sjon Hortensius
<?php foreach ($a_ifgroups as $i => $ifgroupentry): ?>
91 060ed238 Stephen Beaver
					<tr>
92
						<td>
93
							<?=htmlspecialchars($ifgroupentry['ifname']); ?>
94
						</td>
95
						<td>
96 2ec0d736 sbeaver
<?php
97
		$members_arr = explode(" ", $ifgroupentry['members']);
98 f593f80b Phil Davis
		$iflist = get_configured_interface_with_descr(true);
99 2ec0d736 sbeaver
		$memberses_arr = array();
100 aa82505e Phil Davis
		foreach ($members_arr as $memb) {
101 2ec0d736 sbeaver
			$memberses_arr[] = $iflist[$memb] ? $iflist[$memb] : $memb;
102 aa82505e Phil Davis
		}
103 2ec0d736 sbeaver
104
		unset($iflist);
105
		$memberses = implode(", ", $memberses_arr);
106
		echo $memberses;
107 aa82505e Phil Davis
		if (count($members_arr) >= 10) {
108 e41d7a1c Sjon Hortensius
			echo '&hellip;';
109 2ec0d736 sbeaver
		}
110
?>
111 060ed238 Stephen Beaver
						</td>
112
						<td>
113
							<?=htmlspecialchars($ifgroupentry['descr']);?>
114
						</td>
115
						<td>
116 4401107f Steve Beaver
							<a class="fa fa-pencil"	title="<?=gettext('Edit group')?>"	href="interfaces_groups_edit.php?id=<?=$i; ?>"></a>
117 e1a5d73c Steve Beaver
							<a class="fa fa-trash"	title="<?=gettext('Delete group')?>"	href="interfaces_groups.php?act=del&amp;id=<?=$i; ?>" usepost></a>
118 060ed238 Stephen Beaver
						</td>
119
					</tr>
120 e41d7a1c Sjon Hortensius
<?php endforeach; ?>
121 060ed238 Stephen Beaver
				</tbody>
122
			</table>
123
		</div>
124
	</div>
125 2ec0d736 sbeaver
</div>
126
127 c10cb196 Stephen Beaver
<nav class="action-buttons">
128 4401107f Steve Beaver
	<a class="btn btn-success btn-sm" href="interfaces_groups_edit.php" role="button">
129 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
130 2ec8f0ba Stephen Beaver
		<?=gettext("Add");?>
131 5ff01d01 Sjon Hortensius
	</a>
132
</nav>
133
134 35681930 Stephen Beaver
<div class="infoblock">
135 7ae1b34f Phil Davis
	<?php print_info_box(sprintf(gettext('Interface Groups allow setting up rules for multiple interfaces without duplicating the rules.%s' .
136
					   'If members are removed from an interface group, the group rules are no longer applicable to that interface.'), '<br />'), 'info', false); ?>
137 2ec8f0ba Stephen Beaver
138
</div>
139 2ec0d736 sbeaver
<?php
140
141 01036a9a Stephen Beaver
include("foot.inc");