Project

General

Profile

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

    
26
##|+PRIV
27
##|*IDENT=page-interfaces-vlan
28
##|*NAME=Interfaces: VLAN
29
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
30
##|*MATCH=interfaces_vlan_new_prof.php*
31
##|-PRIV
32

    
33
require_once("guiconfig.inc");
34
require_once("interfaces_fast.inc");
35

    
36
global $profile;
37
//$timealla = microtime(true);
38

    
39
if (!is_array($config['vlans']['vlan'])) {
40
	$config['vlans']['vlan'] = array();
41
}
42

    
43
$a_vlans = &$config['vlans']['vlan'] ;
44

    
45
if ($_POST['act'] == "del") {
46
	if (!isset($_POST['id'])) {
47
		$input_errors[] = gettext("Wrong parameters supplied");
48
	} else if (empty($a_vlans[$_POST['id']])) {
49
		$input_errors[] = gettext("Wrong index supplied");
50
	/* check if still in use */
51
	} else if (vlan_inuse($a_vlans[$_POST['id']])) {
52
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
53
	} else {
54
		if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
55
			pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
56
		}
57
		unset($a_vlans[$_POST['id']]);
58

    
59
		write_config();
60

    
61
		header("Location: interfaces_vlan.php");
62
		exit;
63
	}
64
}
65

    
66

    
67
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
68
$shortcut_section = "interfaces";
69
include('head.inc');
70

    
71
if ($input_errors) print_input_errors($input_errors);
72

    
73
$tab_array = array();
74
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
75
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
76
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
77
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
78
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
79
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
80
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
81
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
82
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
83
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
84
display_top_tabs($tab_array);
85

    
86
?>
87
<form action="interfaces_vlan_new_prof.php" method="post">
88
	<input id="act" type="hidden" name="act" value="" />
89
	<input id="id" type="hidden" name="id" value=""/>
90

    
91
	<div class="panel panel-default">
92
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('VLAN Interfaces')?></h2></div>
93
		<div class="panel-body">
94
			<div class="table-responsive">
95
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
96
					<thead>
97
						<tr>
98
							<th><?=gettext('Interface');?></th>
99
							<th><?=gettext('VLAN tag');?></th>
100
							<th><?=gettext('Priority');?></th>
101
							<th><?=gettext('Description');?></th>
102
							<th><?=gettext('Actions');?></th>
103
						</tr>
104
					</thead>
105
					<tbody>
106
<?php
107
	$i = 0;
108
	//$timea = microtime(true);
109
	$gettext_array = array('edit'=>gettext('Edit VLAN'),'del'=>gettext('Delete VLAN'));
110
	$ifaces = convert_real_interface_to_friendly_interface_name_fast(array());
111
	foreach ($a_vlans as $vlan) {
112
?>
113
						<tr>
114
							<td>
115
<?php
116
	printf("%s", htmlspecialchars($vlan['if']));
117
	//$iface = convert_real_interface_to_friendly_interface_name($vlan['if']);
118
	//if (isset($iface) && strlen($iface) > 0)
119
	//	printf(" (%s)", htmlspecialchars($iface));
120
	if (isset($ifaces[$vlan['if']]) && strlen($ifaces[$vlan['if']]) > 0)
121
		printf(" (%s)", htmlspecialchars($ifaces[$vlan['if']]));
122
?>
123
							</td>
124
							<td><?=htmlspecialchars($vlan['tag']);?></td>
125
							<td><?=htmlspecialchars($vlan['pcp']);?></td>
126
							<td><?=htmlspecialchars($vlan['descr']);?></td>
127
							<td>
128
								<a class="fa fa-pencil"	title="<?=$gettext_array['edit']?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
129
								<a class="fa fa-trash no-confirm"	title="<?=$gettext_array['del']?>"	role="button" id="del-<?=$i?>"></a>
130
							</td>
131
						</tr>
132
<?php
133
			$i++;
134
	}
135
	/*$timeb = microtime(true);
136
	$profile['vlan_list'] = $timeb - $tima;*/
137
?>
138
					</tbody>
139
				</table>
140
			</div>
141
		</div>
142
	</div>
143

    
144
	<nav class="action-buttons">
145
		<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
146
			<i class="fa fa-plus icon-embed-btn"></i>
147
			<?=gettext('Add'); ?>
148
		</a>
149
	</nav>
150

    
151
</form>
152

    
153
<div class="infoblock">
154
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
155
		'VLAN tagging properly. %1$sOn cards that do not explicitly support it, VLAN '.
156
		'tagging will still work, but the reduced MTU may cause problems.%1$sSee the '.
157
		'%2$s handbook for information on supported cards.'), '<br />', $g['product_name']), 'info', false); ?>
158
</div>
159

    
160
<?php
161
	$delmsg = gettext("Are you sure you want to delete this VLAN?");
162
?>
163

    
164
<script type="text/javascript">
165
//<![CDATA[
166
events.push(function() {
167
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
168
	$('[id^=del-]').click(function(event) {
169
		if (confirm("<?=$delmsg?>")) {
170
			$('#act').val('del');
171
			$('#id').val(this.id.replace("del-", ""));
172
			$(this).parents('form').submit();
173
		}
174
	});
175

    
176
});
177
//]]>
178
</script>
179
<?php
180
/*$timeallb = microtime(true);
181
$profile['total'] = $timeallb - $timealla;
182
print_r($profile);*/
183
include("foot.inc");
(87-87/231)