Project

General

Profile

Download (4.54 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * interfaces_groups.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

    
24
##|+PRIV
25
##|*IDENT=page-interfaces-groups
26
##|*NAME=Interfaces: Groups
27
##|*DESCR=Create interface groups
28
##|*MATCH=interfaces_groups.php*
29
##|-PRIV
30

    
31
require_once("guiconfig.inc");
32
require_once("functions.inc");
33

    
34
if ($_POST['act'] == "del") {
35
	if (is_numericint($_POST['id']) && config_get_path("ifgroups/ifgroupentry/{$_POST['id']}")) {
36
		$members = explode(" ", config_get_path("ifgroups/ifgroupentry/{$_POST['id']}/members"));
37
		foreach ($members as $ifs) {
38
			$realif = get_real_interface($ifs);
39
			if ($realif) {
40
				mwexec("/sbin/ifconfig {$realif} -group " . config_get_path("ifgroups/ifgroupentry/{$_POST['id']}/ifname"));
41
			}
42
		}
43
		config_del_path("ifgroups/ifgroupentry/{$_POST['id']}");
44
		write_config("Interface Group deleted");
45
		header("Location: interfaces_groups.php");
46
		exit;
47
	}
48
}
49

    
50
$pgtitle = array(gettext("Interfaces"), gettext("Interface Groups"));
51
$shortcut_section = "interfaces";
52

    
53
include("head.inc");
54

    
55
$tab_array = array();
56
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
57
$tab_array[] = array(gettext("Interface Groups"), true, "interfaces_groups.php");
58
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
59
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
60
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
61
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
62
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
63
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
64
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
65
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
66
display_top_tabs($tab_array);
67
?>
68
<div class="panel panel-default">
69
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Interface Groups')?></h2></div>
70
	<div class="panel-body">
71
		<div class="table-responsive">
72
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
73
				<thead>
74
					<tr>
75
						<th><?=gettext('Name');?></th>
76
						<th><?=gettext('Members');?></th>
77
						<th><?=gettext('Description');?></th>
78
						<th><?=gettext('Actions');?></th>
79
					</tr>
80
				</thead>
81
				<tbody>
82
<?php foreach (config_get_path('ifgroups/ifgroupentry', []) as $i => $ifgroupentry): ?>
83
					<tr>
84
						<td>
85
							<?=htmlspecialchars($ifgroupentry['ifname']); ?>
86
						</td>
87
						<td>
88
<?php
89
		$members_arr = explode(" ", $ifgroupentry['members']);
90
		$iflist = get_configured_interface_with_descr(true);
91
		$memberses_arr = array();
92
		foreach ($members_arr as $memb) {
93
			$memberses_arr[] = $iflist[$memb] ? $iflist[$memb] : $memb;
94
		}
95

    
96
		unset($iflist);
97
		$memberses = implode(", ", $memberses_arr);
98
		echo htmlspecialchars($memberses);
99
		if (count($members_arr) >= 10) {
100
			echo '&hellip;';
101
		}
102
?>
103
						</td>
104
						<td>
105
							<?=htmlspecialchars($ifgroupentry['descr']);?>
106
						</td>
107
						<td>
108
							<a class="fa-solid fa-pencil"	title="<?=gettext('Edit group')?>"	href="interfaces_groups_edit.php?id=<?=$i; ?>"></a>
109
							<a class="fa-solid fa-trash-can"	title="<?=gettext('Delete group')?>"	href="interfaces_groups.php?act=del&amp;id=<?=$i; ?>" usepost></a>
110
						</td>
111
					</tr>
112
<?php endforeach; ?>
113
				</tbody>
114
			</table>
115
		</div>
116
	</div>
117
</div>
118

    
119
<nav class="action-buttons">
120
	<a class="btn btn-success btn-sm" href="interfaces_groups_edit.php" role="button">
121
		<i class="fa-solid fa-plus icon-embed-btn"></i>
122
		<?=gettext("Add");?>
123
	</a>
124
</nav>
125

    
126
<div class="infoblock">
127
	<?php print_info_box(sprintf(gettext('Interface Groups allow setting up rules for multiple interfaces without duplicating the rules.%s' .
128
					   'If members are removed from an interface group, the group rules are no longer applicable to that interface.'), '<br />'), 'info', false); ?>
129

    
130
</div>
131
<?php
132

    
133
include("foot.inc");
(81-81/232)