commit 87489e5cce8520ac4c240fec41f60301b38c59a3
Author: loonylion <therealloonylion@yahoo.co.uk>
Date:   Mon Jan 8 18:50:37 2018 +0000

    re-adding changes made to fix bug#6400, includes fixes for bug#8222 and bug#8223 that were introduced with the initial commit of this code.
    
    original pull request was #3868

diff --git a/src/etc/inc/interfaces_fast.inc b/src/etc/inc/interfaces_fast.inc
new file mode 100644
index 0000000000..2f61504645
--- /dev/null
+++ b/src/etc/inc/interfaces_fast.inc
@@ -0,0 +1,270 @@
+<?php
+/*
+ * interfaces_fast.inc
+ *
+ * part of pfSense (https://www.pfsense.org)
+ * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate) (pfSense)
+ * Copyright (c) 2017 Peter Schofield (parts of this file)
+ * All rights reserved.
+ *
+ * originally based on m0n0wall (http://m0n0.ch/wall)
+ * Copyright (c) 2004 Manuel Kasper <mk@neon1.net>.
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * This file contains rewrites of several functions, from both interfaces.inc
+ * and interfaces_assign.php. The general purpose of these rewrites is not
+ * necessarily to be faster in and of themselves, though they may be, but to
+ * replace functions called multiple times with a function that's called only
+ * once. This results in a significant speedup because there are far fewer
+ * function calls, fewer loops and suchlike. It does, however, increase memory
+ * usage somewhat, but it shouldn't be significant in the grand scheme of things.
+ *
+ *
+ * Functions in this file may not require/use parameters when called, however 
+ * in most cases they will accept parameters as per their original forms, for 
+ * consistency.
+ 
+ */
+require_once('interfaces.inc');
+/*
+* does_interface_exist_fast
+Returns an array of interfaces which exist on the system.
+The $interface parameter is not used, but is accepted for
+consistency with the function it replaces.
+*/
+function does_interface_exist_fast($interface='', $flush = true) {
+	global $config;
+
+	$ints = get_interface_arr($flush);
+	return array_flip($ints);
+}
+
+/*
+ * convert_real_interface_to_friendly_interface_name_fast($interface): convert fxp0 -> wan, etc.
+ Returns an array of interfaces and friendly names.
+ */
+function convert_real_interface_to_friendly_interface_name_fast() {
+	global $config;
+
+	$out = array();
+	/* XXX: For speed reasons reference directly the interface array */
+	$ifdescrs = &$config['interfaces'];
+	$iffriendlynames = array_keys($ifdescrs);
+	$out = array_flip(get_real_interface_fast($iffriendlynames));
+	return $out;
+}
+
+/* 
+ * get_real_interface_fast($interfaces, ...)
+ * Exactly the same as it's namesake, except it takes an array of interfaces and returns an array
+ *
+ */
+
+function get_real_interface_fast($interfaces = array(), $family = "all", $realv6iface = false, $flush = true) {
+	global $config, $g;
+
+	$existing_ifs = does_interface_exist_fast();
+
+	$out = array();
+	foreach ($interfaces as $interface) {
+		$wanif = NULL;
+
+		switch ($interface) {
+			case "l2tp":
+				$wanif = "l2tp";
+				break;
+			case "pptp":
+				$wanif = "pptp";
+				break;
+			case "pppoe":
+				$wanif = "pppoe";
+				break;
+			case "openvpn":
+				$wanif = "openvpn";
+				break;
+			case "IPsec":
+			case "ipsec":
+			case "enc0":
+				$wanif = "enc0";
+				break;
+			case "ppp":
+				$wanif = "ppp";
+				break;
+			default:
+				if (substr($interface, 0, 4) == '_vip') {
+					$wanif = get_configured_vip_interface($interface);
+					if (!empty($wanif)) {
+						$wanif = get_real_interface($wanif);
+					}
+					break;
+				} else if (substr($interface, 0, 5) == '_lloc') {
+					$interface = substr($interface, 5);
+				} else if (strstr($interface, "_vlan") || isset($existing_ifs[$interface])) {
+					/*
+					 * If a real interface was already passed simply
+					 * pass the real interface back.  This encourages
+					 * the usage of this function in more cases so that
+					 * we can combine logic for more flexibility.
+					 */
+					$wanif = $interface;
+					break;
+				}
+
+				if (empty($config['interfaces'][$interface])) {
+					break;
+				}
+
+				$cfg = &$config['interfaces'][$interface];
+
+				if ($family == "inet6") {
+					switch ($cfg['ipaddrv6']) {
+						case "6rd":
+						case "6to4":
+							$wanif = "{$interface}_stf";
+							break;
+						case 'pppoe':
+						case 'ppp':
+						case 'l2tp':
+						case 'pptp':
+							if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) {
+								$wanif = interface_get_wireless_clone($cfg['if']);
+							} else {
+								$wanif = $cfg['if'];
+							}
+							break;
+						default:
+							switch ($cfg['ipaddr']) {
+								case 'pppoe':
+								case 'ppp':
+								case 'l2tp':
+								case 'pptp':
+									if (isset($cfg['dhcp6usev4iface']) && $realv6iface === false) {
+										$wanif = $cfg['if'];
+									} else {
+										$parents = get_parent_interface($interface);
+										if (!empty($parents[0])) {
+											$wanif = $parents[0];
+										} else {
+											$wanif = $cfg['if'];
+										}
+									}
+									break;
+								default:
+									if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) {
+										$wanif = interface_get_wireless_clone($cfg['if']);
+									} else {
+										$wanif = $cfg['if'];
+									}
+									break;
+							}
+							break;
+					}
+				} else {
+					// Wireless cloned NIC support (FreeBSD 8+)
+					// interface name format: $parentnic_wlanparentnic#
+					// example: ath0_wlan0
+					if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) {
+						$wanif = interface_get_wireless_clone($cfg['if']);
+					} else {
+						$wanif = $cfg['if'];
+					}
+				}
+				break;
+		}
+		$out[$interface] = $wanif;
+	}
+
+	return $out;
+}
+/*
+ * interface_assign_description_fast($portlist, $friendlyifnames)
+ *
+ * This function replaces the function defined in interfaces_assign.php
+ *
+ * I created this version of the function because in interfaces_assign.php
+ * the interface_assign_description() function is used twice, in both cases
+ * being called for every iteration through the array of interfaces, and 
+ * was seemingly dragging the performance of the HTML generation code down 
+ * when faced with a large number of VLAN interfaces.
+ *
+ * Although this function internally recreates the loop that its namesake was
+ * called in; the fact it's only called once rather than once per interface * 2
+ * has resulted in a significant speed gain with a large number of optional 
+ * interfaces configured.
+ *
+ * $portlist is the same $portlist as defined in interfaces_assign.php, call this
+ * function after all the optional interfaces are added to $portlist.
+ *
+ * $friendlyifnames is a global variable of my own making, created by calling
+ * convert_real_interface_to_friendly_interface_name_fast() on the keys of $portlist.
+ *
+ * Return value of this function is an associative array of interface descriptions
+ * indexed by the unique name of the interface.
+ *
+ */
+function interface_assign_description_fast($portlist, $friendlyifnames) {
+	global $ovpn_descrs;
+	$out = array();
+	$gettext = gettext('on');
+	foreach($portlist as $portname => $portinfo) {
+		if ($portinfo['isvlan']) {
+			$descr = sprintf('VLAN %1$s '.$gettext.' %2$s', $portinfo['tag'], $portinfo['if']);
+			$iface = $friendlyifnames[$portinfo['if']];
+			if (isset($iface) && strlen($iface) > 0) {
+				$descr .= " - $iface";
+			}
+			if ($portinfo['descr']) {
+				$descr .= " (" . $portinfo['descr'] . ")";
+			}
+		} elseif ($portinfo['iswlclone']) {
+			$descr = $portinfo['cloneif'];
+			if ($portinfo['descr']) {
+				$descr .= " (" . $portinfo['descr'] . ")";
+			}
+		} elseif ($portinfo['isppp']) {
+			$descr = $portinfo['descr'];
+		} elseif ($portinfo['isbridge']) {
+			$descr = strtoupper($portinfo['bridgeif']);
+			if ($portinfo['descr']) {
+				$descr .= " (" . $portinfo['descr'] . ")";
+			}
+		} elseif ($portinfo['isgre']) {
+			$descr = "GRE {$portinfo['remote-addr']}";
+			if ($portinfo['descr']) {
+				$descr .= " (" . $portinfo['descr'] . ")";
+			}
+		} elseif ($portinfo['isgif']) {
+			$descr = "GIF {$portinfo['remote-addr']}";
+			if ($portinfo['descr']) {
+				$descr .= " (" . $portinfo['descr'] . ")";
+			}
+		} elseif ($portinfo['islagg']) {
+			$descr = strtoupper($portinfo['laggif']);
+			if ($portinfo['descr']) {
+				$descr .= " (" . $portinfo['descr'] . ")";
+			}
+		} elseif ($portinfo['isqinq']) {
+			$descr = $portinfo['descr'];
+		} elseif (substr($portname, 0, 4) == 'ovpn') {
+			$descr = $portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")";
+		} else {
+			$descr = $portname . " (" . $portinfo['mac'] . ")";
+		}
+		$out[$portname] = htmlspecialchars($descr);
+	}
+	return $out;
+}
+?>
\ No newline at end of file
diff --git a/src/usr/local/www/interfaces_assign.php b/src/usr/local/www/interfaces_assign.php
index 32016accc7..3dd4a90f51 100644
--- a/src/usr/local/www/interfaces_assign.php
+++ b/src/usr/local/www/interfaces_assign.php
@@ -3,7 +3,7 @@
  * interfaces_assign.php
  *
  * part of pfSense (https://www.pfsense.org)
- * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
+ * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
  * All rights reserved.
  *
  * originally based on m0n0wall (http://m0n0.ch/wall)
@@ -31,6 +31,8 @@
 ##|*MATCH=interfaces_assign.php*
 ##|-PRIV
 
+//$timealla = microtime(true);
+
 $pgtitle = array(gettext("Interfaces"), gettext("Interface Assignments"));
 $shortcut_section = "interfaces";
 
@@ -42,56 +44,12 @@ require_once("ipsec.inc");
 require_once("vpn.inc");
 require_once("captiveportal.inc");
 require_once("rrd.inc");
+require_once("interfaces_fast.inc");
 
-function interface_assign_description($portinfo, $portname) {
-	global $ovpn_descrs;
-	if ($portinfo['isvlan']) {
-		$descr = sprintf(gettext('VLAN %1$s on %2$s'), $portinfo['tag'], $portinfo['if']);
-		$iface = convert_real_interface_to_friendly_interface_name($portinfo['if']);
-		if (isset($iface) && strlen($iface) > 0) {
-			$descr .= " - $iface";
-		}
-		if ($portinfo['descr']) {
-			$descr .= " (" . $portinfo['descr'] . ")";
-		}
-	} elseif ($portinfo['iswlclone']) {
-		$descr = $portinfo['cloneif'];
-		if ($portinfo['descr']) {
-			$descr .= " (" . $portinfo['descr'] . ")";
-		}
-	} elseif ($portinfo['isppp']) {
-		$descr = $portinfo['descr'];
-	} elseif ($portinfo['isbridge']) {
-		$descr = strtoupper($portinfo['bridgeif']);
-		if ($portinfo['descr']) {
-			$descr .= " (" . $portinfo['descr'] . ")";
-		}
-	} elseif ($portinfo['isgre']) {
-		$descr = "GRE {$portinfo['remote-addr']}";
-		if ($portinfo['descr']) {
-			$descr .= " (" . $portinfo['descr'] . ")";
-		}
-	} elseif ($portinfo['isgif']) {
-		$descr = "GIF {$portinfo['remote-addr']}";
-		if ($portinfo['descr']) {
-			$descr .= " (" . $portinfo['descr'] . ")";
-		}
-	} elseif ($portinfo['islagg']) {
-		$descr = strtoupper($portinfo['laggif']);
-		$descr .= " (" . $portinfo['mac'] . ")";
-		if ($portinfo['descr']) {
-			$descr .= " - " . $portinfo['descr'];
-		}
-	} elseif ($portinfo['isqinq']) {
-		$descr = $portinfo['descr'];
-	} elseif (substr($portname, 0, 4) == 'ovpn') {
-		$descr = $portname . " (" . $ovpn_descrs[substr($portname, 5)] . ")";
-	} else {
-		$descr = $portname . " (" . $portinfo['mac'] . ")";
-	}
+global $friendlyifnames;
 
-	return htmlspecialchars($descr);
-}
+/*moved most gettext calls to here, we really don't want to be repeatedly calling gettext() within loops if it can be avoided.*/
+$gettextArray = array('add'=>gettext('Add'),'addif'=>gettext('Add interface'),'delete'=>gettext('Delete'),'deleteif'=>gettext('Delete interface'),'edit'=>gettext('Edit'),'on'=>gettext('on'));
 
 /*
 	In this file, "port" refers to the physical port name,
@@ -101,6 +59,11 @@ function interface_assign_description($portinfo, $portname) {
 /* get list without VLAN interfaces */
 $portlist = get_interface_list();
 
+/*another *_fast function from interfaces_fast.inc. These functions are basically the same as the 
+ones they're named after, except they (usually) take an array and (always) return an array. This means that they only
+need to be called once per script run, the returned array contains all the data necessary for repeated use */
+$friendlyifnames = convert_real_interface_to_friendly_interface_name_fast();
+
 /* add wireless clone interfaces */
 if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) {
 	foreach ($config['wireless']['clone'] as $clone) {
@@ -111,6 +74,7 @@ if (is_array($config['wireless']['clone']) && count($config['wireless']['clone']
 
 /* add VLAN interfaces */
 if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
+	//$timea = microtime(true);
 	foreach ($config['vlans']['vlan'] as $vlan) {
 		$portlist[$vlan['vlanif']] = $vlan;
 		$portlist[$vlan['vlanif']]['isvlan'] = true;
@@ -142,14 +106,16 @@ if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) {
 }
 
 /* add LAGG interfaces */
-$lagglist = get_lagg_interface_list();
-$portlist = array_merge($portlist, $lagglist);
-foreach ($lagglist as $laggif => $lagg) {
-	/* LAGG members cannot be assigned */
-	$laggmembers = explode(',', $lagg['members']);
-	foreach ($laggmembers as $lagm) {
-		if (isset($portlist[$lagm])) {
-			unset($portlist[$lagm]);
+if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
+	foreach ($config['laggs']['lagg'] as $lagg) {
+		$portlist[$lagg['laggif']] = $lagg;
+		$portlist[$lagg['laggif']]['islagg'] = true;
+		/* LAGG members cannot be assigned */
+		$lagifs = explode(',', $lagg['members']);
+		foreach ($lagifs as $lagif) {
+			if (isset($portlist[$lagif])) {
+				unset($portlist[$lagif]);
+			}
 		}
 	}
 }
@@ -162,8 +128,8 @@ if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry
 		/* QinQ members */
 		$qinqifs = explode(' ', $qinq['members']);
 		foreach ($qinqifs as $qinqif) {
-			$portlist["{$qinq['vlanif']}.{$qinqif}"]['descr'] = "QinQ {$qinqif} on VLAN {$qinq['tag']} on {$qinq['if']}";
-			$portlist["{$qinq['vlanif']}.{$qinqif}"]['isqinq'] = true;
+			$portlist["{$qinq['vlanif']}_{$qinqif}"]['descr'] = "QinQ {$qinqif} on VLAN {$qinq['tag']} on {$qinq['if']}";
+			$portlist["{$qinq['vlanif']}_{$qinqif}"]['isqinq'] = true;
 		}
 	}
 }
@@ -203,6 +169,9 @@ if (is_array($config['openvpn'])) {
 	}
 }
 
+
+$ifdescrs = interface_assign_description_fast($portlist,$friendlyifnames);
+
 if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) {
 	/* Be sure this port is not being used */
 	$portused = false;
@@ -227,7 +196,7 @@ if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) {
 			$newifname = 'opt' . $i;
 			$descr = "OPT" . $i;
 		}
-
+		
 		$config['interfaces'][$newifname] = array();
 		$config['interfaces'][$newifname]['descr'] = $descr;
 		$config['interfaces'][$newifname]['if'] = $_POST['if_add'];
@@ -236,6 +205,7 @@ if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) {
 			interface_sync_wireless_clones($config['interfaces'][$newifname], false);
 		}
 
+		
 		uksort($config['interfaces'], "compare_interface_friendly_names");
 
 		/* XXX: Do not remove this. */
@@ -365,7 +335,6 @@ if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) {
 				}
 			}
 		}
-
 		write_config();
 
 		enable_rrd_graphing();
@@ -441,18 +410,13 @@ if (isset($_REQUEST['add']) && isset($_REQUEST['if_add'])) {
 
 /* Create a list of unused ports */
 $unused_portlist = array();
-foreach ($portlist as $portname => $portinfo) {
-	$portused = false;
-	foreach ($config['interfaces'] as $ifname => $ifdata) {
-		if ($ifdata['if'] == $portname) {
-			$portused = true;
-			break;
-		}
-	}
-	if ($portused === false) {
-		$unused_portlist[$portname] = $portinfo;
-	}
-}
+$portArray = array_keys($portlist);
+
+$ifaceArray = array_column($config['interfaces'],'if');
+$unused = array_diff($portArray,$ifaceArray);
+$unused = array_flip($unused);
+$unused_portlist = array_intersect_key($portlist,$unused);//*/
+unset($unused,$portArray,$ifaceArray);
 
 include("head.inc");
 
@@ -501,6 +465,17 @@ $tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
 $tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
 $tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
 display_top_tabs($tab_array);
+
+/*Generate the port select box only once. 
+Not indenting the HTML to produce smaller code
+and faster page load times */
+
+$portselect='';
+foreach ($portlist as $portname => $portinfo) {
+	$portselect.='<option value="'.$portname.'"'; 
+	$portselect.=">".$ifdescrs[$portname]."</option>\n";
+}
+
 ?>
 <form action="interfaces_assign.php" method="post">
 	<div class="table-responsive">
@@ -514,6 +489,7 @@ display_top_tabs($tab_array);
 	</thead>
 	<tbody>
 <?php
+	$i=0;
 	foreach ($config['interfaces'] as $ifname => $iface):
 		if ($iface['descr']) {
 			$ifdescr = $iface['descr'];
@@ -525,23 +501,23 @@ display_top_tabs($tab_array);
 			<td><a href="/interfaces.php?if=<?=$ifname?>"><?=$ifdescr?></a></td>
 			<td>
 				<select name="<?=$ifname?>" id="<?=$ifname?>" class="form-control">
-<?php foreach ($portlist as $portname => $portinfo):?>
-					<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>>
-						<?=interface_assign_description($portinfo, $portname)?>
-					</option>
-<?php endforeach;?>
+<?php 
+/*port select menu generation loop replaced with pre-prepared select menu to reduce page generation time */
+echo str_replace('value="'.$iface['if'].'">','value="'.$iface['if'].'" selected>',$portselect);
+?>
 				</select>
 			</td>
 			<td>
 <?php if ($ifname != 'wan'):?>
-				<button type="submit" name="del[<?=$ifname?>]" class="btn btn-danger btn-sm" title="<?=gettext("Delete interface")?>">
+				<button type="submit" name="del[<?=$ifname?>]" class="btn btn-danger btn-sm" title="<?=$gettextArray['deleteif']?>">
 					<i class="fa fa-trash icon-embed-btn"></i>
-					<?=gettext("Delete")?>
+					<?=$gettextArray["delete"]?>
 				</button>
 <?php endif;?>
 			</td>
 		</tr>
-<?php endforeach;
+<?php $i++; 
+endforeach;
 	if (count($config['interfaces']) < count($portlist)):
 ?>
 		<tr>
@@ -550,17 +526,18 @@ display_top_tabs($tab_array);
 			</th>
 			<td>
 				<select name="if_add" id="if_add" class="form-control">
-<?php foreach ($unused_portlist as $portname => $portinfo):?>
-					<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>>
-						<?=interface_assign_description($portinfo, $portname)?>
-					</option>
-<?php endforeach;?>
+<?php
+/* HTML not indented to save on transmission/render time */
+foreach ($unused_portlist as $portname => $portinfo):?>
+<option value="<?=$portname?>" <?=($portname == $iface['if']) ? ' selected': ''?>><?=$ifdescrs[$portname]?></option>
+<?php endforeach;
+?>
 				</select>
 			</td>
 			<td>
 				<button type="submit" name="add" title="<?=gettext("Add selected interface")?>" value="add interface" class="btn btn-success btn-sm" >
 					<i class="fa fa-plus icon-embed-btn"></i>
-					<?=gettext("Add")?>
+					<?=$gettextArray["add"]?>
 				</button>
 			</td>
 		</tr>
diff --git a/src/usr/local/www/interfaces_vlan.php b/src/usr/local/www/interfaces_vlan.php
index a8cffacf2a..f84d2b0879 100644
--- a/src/usr/local/www/interfaces_vlan.php
+++ b/src/usr/local/www/interfaces_vlan.php
@@ -3,7 +3,7 @@
  * interfaces_vlan.php
  *
  * part of pfSense (https://www.pfsense.org)
- * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
+ * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
  * All rights reserved.
  *
  * originally based on m0n0wall (http://m0n0.ch/wall)
@@ -27,16 +27,19 @@
 ##|*IDENT=page-interfaces-vlan
 ##|*NAME=Interfaces: VLAN
 ##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
-##|*MATCH=interfaces_vlan.php*
+##|*MATCH=interfaces_vlan_new_prof.php*
 ##|-PRIV
 
 require_once("guiconfig.inc");
+require_once("interfaces_fast.inc");
+
+global $profile;
 
 if (!is_array($config['vlans']['vlan'])) {
 	$config['vlans']['vlan'] = array();
 }
 
-$a_vlans = &$config['vlans']['vlan'];
+$a_vlans = &$config['vlans']['vlan'] ;
 
 if ($_POST['act'] == "del") {
 	if (!isset($_POST['id'])) {
@@ -101,23 +104,24 @@ display_top_tabs($tab_array);
 					<tbody>
 <?php
 	$i = 0;
+	$gettext_array = array('edit'=>gettext('Edit VLAN'),'del'=>gettext('Delete VLAN'));
+	$ifaces = convert_real_interface_to_friendly_interface_name_fast(array());
 	foreach ($a_vlans as $vlan) {
 ?>
 						<tr>
 							<td>
 <?php
 	printf("%s", htmlspecialchars($vlan['if']));
-	$iface = convert_real_interface_to_friendly_interface_name($vlan['if']);
-	if (isset($iface) && strlen($iface) > 0)
-		printf(" (%s)", htmlspecialchars($iface));
+	if (isset($ifaces[$vlan['if']]) && strlen($ifaces[$vlan['if']]) > 0)
+		printf(" (%s)", htmlspecialchars($ifaces[$vlan['if']]));
 ?>
 							</td>
 							<td><?=htmlspecialchars($vlan['tag']);?></td>
 							<td><?=htmlspecialchars($vlan['pcp']);?></td>
 							<td><?=htmlspecialchars($vlan['descr']);?></td>
 							<td>
-								<a class="fa fa-pencil"	title="<?=gettext('Edit VLAN')?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
-								<a class="fa fa-trash no-confirm"	title="<?=gettext('Delete VLAN')?>"	role="button" id="del-<?=$i?>"></a>
+								<a class="fa fa-pencil"	title="<?=$gettext_array['edit']?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
+								<a class="fa fa-trash no-confirm"	title="<?=$gettext_array['del']?>"	role="button" id="del-<?=$i?>"></a>
 							</td>
 						</tr>
 <?php
