Commit 75cf7115 authored by Franco Fichtner's avatar Franco Fichtner

src: more is_array() -> isset() conversions

parent 1b981539
...@@ -2799,7 +2799,7 @@ EOD; ...@@ -2799,7 +2799,7 @@ EOD;
} }
$isbridged = false; $isbridged = false;
if(is_array($config['bridges']['bridged'])) { if (isset($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $oc2) { foreach ($config['bridges']['bridged'] as $oc2) {
if(stristr($oc2['members'], $on)) { if(stristr($oc2['members'], $on)) {
$isbridged = true; $isbridged = true;
......
...@@ -457,11 +457,12 @@ function interfaces_create_wireless_clones() { ...@@ -457,11 +457,12 @@ function interfaces_create_wireless_clones() {
} }
function interfaces_bridge_configure($checkmember = 0, $realif = "") { function interfaces_bridge_configure($checkmember = 0, $realif = '')
{
global $config; global $config;
$i = 0; $i = 0;
if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) { if (isset($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $bridge) { foreach ($config['bridges']['bridged'] as $bridge) {
if (empty($bridge['bridgeif'])) if (empty($bridge['bridgeif']))
$bridge['bridgeif'] = "bridge{$i}"; $bridge['bridgeif'] = "bridge{$i}";
...@@ -4435,14 +4436,16 @@ function find_ip_interface($ip, $bits = null) { ...@@ -4435,14 +4436,16 @@ function find_ip_interface($ip, $bits = null) {
* find_virtual_ip_alias($ip): return the virtual IP alias where an IP is found * find_virtual_ip_alias($ip): return the virtual IP alias where an IP is found
* (or if $bits is specified, where an IP within the subnet is found) * (or if $bits is specified, where an IP within the subnet is found)
*/ */
function find_virtual_ip_alias($ip, $bits = null) { function find_virtual_ip_alias($ip, $bits = null)
{
global $config; global $config;
if (!is_array($config['virtualip']['vip'])) { if (!isset($config['virtualip']['vip'])) {
return false; return false;
} }
if (!is_ipaddr($ip)) if (!is_ipaddr($ip)) {
return false; return false;
}
$isv6ip = is_ipaddrv6($ip); $isv6ip = is_ipaddrv6($ip);
...@@ -4469,9 +4472,11 @@ function find_virtual_ip_alias($ip, $bits = null) { ...@@ -4469,9 +4472,11 @@ function find_virtual_ip_alias($ip, $bits = null) {
/* /*
* find_carp_interface($ip): return the carp interface where an ip is defined * find_carp_interface($ip): return the carp interface where an ip is defined
*/ */
function find_carp_interface($ip) { function find_carp_interface($ip)
{
global $config; global $config;
if (is_array($config['virtualip']['vip'])) {
if (isset($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) { foreach ($config['virtualip']['vip'] as $vip) {
if ($vip['mode'] == "carp") { if ($vip['mode'] == "carp") {
if(is_ipaddrv4($ip)) { if(is_ipaddrv4($ip)) {
...@@ -4491,11 +4496,12 @@ function find_carp_interface($ip) { ...@@ -4491,11 +4496,12 @@ function find_carp_interface($ip) {
} }
} }
if ($if) if ($if) {
return $if; return $if;
} }
} }
} }
}
} }
...@@ -4507,14 +4513,16 @@ function find_carp_interface($ip) { ...@@ -4507,14 +4513,16 @@ function find_carp_interface($ip) {
* RESULT * RESULT
* $carp_ints * $carp_ints
******/ ******/
function link_ip_to_carp_interface($ip) { function link_ip_to_carp_interface($ip)
{
global $config; global $config;
if (!is_ipaddr($ip)) if (!is_ipaddr($ip)) {
return; return;
}
$carp_ints = ""; $carp_ints = '';
if (is_array($config['virtualip']['vip'])) { if (isset($config['virtualip']['vip'])) {
$first = 0; $first = 0;
$carp_int = array(); $carp_int = array();
foreach ($config['virtualip']['vip'] as $vip) { foreach ($config['virtualip']['vip'] as $vip) {
...@@ -4527,20 +4535,23 @@ function link_ip_to_carp_interface($ip) { ...@@ -4527,20 +4535,23 @@ function link_ip_to_carp_interface($ip) {
} }
} }
} }
if (!empty($carp_int)) if (!empty($carp_int)) {
$carp_ints = implode(" ", array_unique($carp_int)); $carp_ints = implode(" ", array_unique($carp_int));
} }
}
return $carp_ints; return $carp_ints;
} }
function link_interface_to_track6($int, $action = "") { function link_interface_to_track6($int, $action = '')
{
global $config; global $config;
if (empty($int)) if (empty($int)) {
return; return;
}
if (is_array($config['interfaces'])) { if (isset($config['interfaces'])) {
$list = array(); $list = array();
foreach ($config['interfaces'] as $ifname => $ifcfg) { foreach ($config['interfaces'] as $ifname => $ifcfg) {
if (!isset($ifcfg['enable'])) if (!isset($ifcfg['enable']))
...@@ -4556,13 +4567,15 @@ function link_interface_to_track6($int, $action = "") { ...@@ -4556,13 +4567,15 @@ function link_interface_to_track6($int, $action = "") {
} }
} }
function link_interface_to_vlans($int, $action = "") { function link_interface_to_vlans($int, $action = '')
{
global $config; global $config;
if (empty($int)) if (empty($int)) {
return; return;
}
if (is_array($config['vlans']['vlan'])) { if (isset($config['vlans']['vlan'])) {
$ifaces = array(); $ifaces = array();
foreach ($config['vlans']['vlan'] as $vlan) { foreach ($config['vlans']['vlan'] as $vlan) {
if ($int == $vlan['if']) { if ($int == $vlan['if']) {
...@@ -4572,24 +4585,27 @@ function link_interface_to_vlans($int, $action = "") { ...@@ -4572,24 +4585,27 @@ function link_interface_to_vlans($int, $action = "") {
$ifaces[$vlan['tag']] = $vlan; $ifaces[$vlan['tag']] = $vlan;
} }
} }
if (!empty($ifaces)) if (!empty($ifaces)) {
return $ifaces; return $ifaces;
} }
}
} }
function link_interface_to_vips($int, $action = "") { function link_interface_to_vips($int, $action = '')
{
global $config; global $config;
if (isset($config['virtualip']['vip'])) { if (isset($config['virtualip']['vip'])) {
$result = array(); $result = array();
foreach ($config['virtualip']['vip'] as $vip) { foreach ($config['virtualip']['vip'] as $vip) {
if ($int == $vip['interface']) { if ($int == $vip['interface']) {
if ($action == "update") if ($action == 'update') {
interfaces_vips_configure($int); interfaces_vips_configure($int);
else } else {
$result[] = $vip; $result[] = $vip;
} }
} }
}
return $result; return $result;
} }
} }
...@@ -4602,10 +4618,11 @@ function link_interface_to_vips($int, $action = "") { ...@@ -4602,10 +4618,11 @@ function link_interface_to_vips($int, $action = "") {
* RESULT * RESULT
* bridge[0-99] * bridge[0-99]
******/ ******/
function link_interface_to_bridge($int) { function link_interface_to_bridge($int)
{
global $config; global $config;
if (is_array($config['bridges']['bridged'])) { if (isset($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $bridge) { foreach ($config['bridges']['bridged'] as $bridge) {
if (in_array($int, explode(',', $bridge['members']))) if (in_array($int, explode(',', $bridge['members'])))
return "{$bridge['bridgeif']}"; return "{$bridge['bridgeif']}";
...@@ -4613,12 +4630,13 @@ function link_interface_to_bridge($int) { ...@@ -4613,12 +4630,13 @@ function link_interface_to_bridge($int) {
} }
} }
function link_interface_to_group($int) { function link_interface_to_group($int)
{
global $config; global $config;
$result = array(); $result = array();
if (is_array($config['ifgroups']['ifgroupentry'])) { if (isset($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $group) { foreach ($config['ifgroups']['ifgroupentry'] as $group) {
if (in_array($int, explode(" ", $group['members']))) if (in_array($int, explode(" ", $group['members'])))
$result[$group['ifname']] = $int; $result[$group['ifname']] = $int;
...@@ -4628,12 +4646,13 @@ function link_interface_to_group($int) { ...@@ -4628,12 +4646,13 @@ function link_interface_to_group($int) {
return $result; return $result;
} }
function link_interface_to_gre($interface) { function link_interface_to_gre($interface)
{
global $config; global $config;
$result = array(); $result = array();
if (is_array($config['gres']['gre'])) { if (isset($config['gres']['gre'])) {
foreach ($config['gres']['gre'] as $gre) foreach ($config['gres']['gre'] as $gre)
if($gre['if'] == $interface) if($gre['if'] == $interface)
$result[] = $gre; $result[] = $gre;
...@@ -4642,12 +4661,13 @@ function link_interface_to_gre($interface) { ...@@ -4642,12 +4661,13 @@ function link_interface_to_gre($interface) {
return $result; return $result;
} }
function link_interface_to_gif($interface) { function link_interface_to_gif($interface)
{
global $config; global $config;
$result = array(); $result = array();
if (is_array($config['gifs']['gif'])) { if (isset($config['gifs']['gif'])) {
foreach ($config['gifs']['gif'] as $gif) foreach ($config['gifs']['gif'] as $gif)
if($gif['if'] == $interface) if($gif['if'] == $interface)
$result[] = $gif; $result[] = $gif;
...@@ -5228,5 +5248,3 @@ function get_failover_interface($interface, $family = "all") { ...@@ -5228,5 +5248,3 @@ function get_failover_interface($interface, $family = "all") {
function remove_ifindex($ifname) { function remove_ifindex($ifname) {
return preg_replace("/[0-9]+$/", "", $ifname); return preg_replace("/[0-9]+$/", "", $ifname);
} }
?>
...@@ -86,7 +86,7 @@ function interface_assign_description($portinfo, $portname) { ...@@ -86,7 +86,7 @@ function interface_assign_description($portinfo, $portname) {
$portlist = get_interface_list(); $portlist = get_interface_list();
/* add wireless clone interfaces */ /* add wireless clone interfaces */
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) { if (isset($config['wireless']['clone'])) {
foreach ($config['wireless']['clone'] as $clone) { foreach ($config['wireless']['clone'] as $clone) {
$portlist[$clone['cloneif']] = $clone; $portlist[$clone['cloneif']] = $clone;
$portlist[$clone['cloneif']]['iswlclone'] = true; $portlist[$clone['cloneif']]['iswlclone'] = true;
...@@ -94,7 +94,7 @@ if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'] ...@@ -94,7 +94,7 @@ if (is_array($config['wireless']['clone']) && count($config['wireless']['clone']
} }
/* add VLAN interfaces */ /* add VLAN interfaces */
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { if (isset($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) { foreach ($config['vlans']['vlan'] as $vlan) {
$portlist[$vlan['vlanif']] = $vlan; $portlist[$vlan['vlanif']] = $vlan;
$portlist[$vlan['vlanif']]['isvlan'] = true; $portlist[$vlan['vlanif']]['isvlan'] = true;
...@@ -102,7 +102,7 @@ if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { ...@@ -102,7 +102,7 @@ if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
} }
/* add Bridge interfaces */ /* add Bridge interfaces */
if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) { if (isset($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $bridge) { foreach ($config['bridges']['bridged'] as $bridge) {
$portlist[$bridge['bridgeif']] = $bridge; $portlist[$bridge['bridgeif']] = $bridge;
$portlist[$bridge['bridgeif']]['isbridge'] = true; $portlist[$bridge['bridgeif']]['isbridge'] = true;
...@@ -110,7 +110,7 @@ if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged ...@@ -110,7 +110,7 @@ if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged
} }
/* add GIF interfaces */ /* add GIF interfaces */
if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) { if (isset($config['gifs']['gif'])) {
foreach ($config['gifs']['gif'] as $gif) { foreach ($config['gifs']['gif'] as $gif) {
$portlist[$gif['gifif']] = $gif; $portlist[$gif['gifif']] = $gif;
$portlist[$gif['gifif']]['isgif'] = true; $portlist[$gif['gifif']]['isgif'] = true;
...@@ -118,7 +118,7 @@ if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) { ...@@ -118,7 +118,7 @@ if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) {
} }
/* add GRE interfaces */ /* add GRE interfaces */
if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) { if (isset($config['gres']['gre'])) {
foreach ($config['gres']['gre'] as $gre) { foreach ($config['gres']['gre'] as $gre) {
$portlist[$gre['greif']] = $gre; $portlist[$gre['greif']] = $gre;
$portlist[$gre['greif']]['isgre'] = true; $portlist[$gre['greif']]['isgre'] = true;
...@@ -126,7 +126,7 @@ if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) { ...@@ -126,7 +126,7 @@ if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) {
} }
/* add LAGG interfaces */ /* add LAGG interfaces */
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) { if (isset($config['laggs']['lagg'])) {
foreach ($config['laggs']['lagg'] as $lagg) { foreach ($config['laggs']['lagg'] as $lagg) {
$portlist[$lagg['laggif']] = $lagg; $portlist[$lagg['laggif']] = $lagg;
$portlist[$lagg['laggif']]['islagg'] = true; $portlist[$lagg['laggif']]['islagg'] = true;
...@@ -139,7 +139,7 @@ if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) { ...@@ -139,7 +139,7 @@ if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
} }
/* add QinQ interfaces */ /* add QinQ interfaces */
if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry'])) { if (isset($config['qinqs']['qinqentry'])) {
foreach ($config['qinqs']['qinqentry'] as $qinq) { foreach ($config['qinqs']['qinqentry'] as $qinq) {
$portlist["vlan{$qinq['tag']}"]['descr'] = "VLAN {$qinq['tag']}"; $portlist["vlan{$qinq['tag']}"]['descr'] = "VLAN {$qinq['tag']}";
$portlist["vlan{$qinq['tag']}"]['isqinq'] = true; $portlist["vlan{$qinq['tag']}"]['isqinq'] = true;
...@@ -153,7 +153,7 @@ if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry ...@@ -153,7 +153,7 @@ if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry
} }
/* add PPP interfaces */ /* add PPP interfaces */
if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { if (isset($config['ppps']['ppp'])) {
foreach ($config['ppps']['ppp'] as $pppid => $ppp) { foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
$portname = $ppp['if']; $portname = $ppp['if'];
$portlist[$portname] = $ppp; $portlist[$portname] = $ppp;
...@@ -169,13 +169,17 @@ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { ...@@ -169,13 +169,17 @@ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
} }
$ovpn_descrs = array(); $ovpn_descrs = array();
if (is_array($config['openvpn'])) { if (isset($config['openvpn'])) {
if (is_array($config['openvpn']['openvpn-server'])) if (isset($config['openvpn']['openvpn-server'])) {
foreach ($config['openvpn']['openvpn-server'] as $s) foreach ($config['openvpn']['openvpn-server'] as $s) {
$ovpn_descrs[$s['vpnid']] = $s['description']; $ovpn_descrs[$s['vpnid']] = $s['description'];
if (is_array($config['openvpn']['openvpn-client'])) }
foreach ($config['openvpn']['openvpn-client'] as $c) }
if (isset($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as $c) {
$ovpn_descrs[$c['vpnid']] = $c['description']; $ovpn_descrs[$c['vpnid']] = $c['description'];
}
}
} }
if (isset($_POST['add_x']) && isset($_POST['if_add'])) { if (isset($_POST['add_x']) && isset($_POST['if_add'])) {
...@@ -262,10 +266,11 @@ if (isset($_POST['add_x']) && isset($_POST['if_add'])) { ...@@ -262,10 +266,11 @@ if (isset($_POST['add_x']) && isset($_POST['if_add'])) {
$errstr .= " " . $ifn; $errstr .= " " . $ifn;
$input_errors[] = $errstr; $input_errors[] = $errstr;
} else if (count($ifnames) == 1 && preg_match('/^bridge[0-9]/', $portname) && is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) { } else if (count($ifnames) == 1 && preg_match('/^bridge[0-9]/', $portname) && isset($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $bridge) { foreach ($config['bridges']['bridged'] as $bridge) {
if ($bridge['bridgeif'] != $portname) if ($bridge['bridgeif'] != $portname) {
continue; continue;
}
$members = explode(",", strtoupper($bridge['members'])); $members = explode(",", strtoupper($bridge['members']));
foreach ($members as $member) { foreach ($members as $member) {
...@@ -278,7 +283,7 @@ if (isset($_POST['add_x']) && isset($_POST['if_add'])) { ...@@ -278,7 +283,7 @@ if (isset($_POST['add_x']) && isset($_POST['if_add'])) {
} }
} }
if (is_array($config['vlans']['vlan'])) { if (isset($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) { foreach ($config['vlans']['vlan'] as $vlan) {
if (does_interface_exist($vlan['if']) == false) if (does_interface_exist($vlan['if']) == false)
$input_errors[] = "Vlan parent interface {$vlan['if']} does not exist anymore so vlan id {$vlan['tag']} cannot be created please fix the issue before continuing."; $input_errors[] = "Vlan parent interface {$vlan['if']} does not exist anymore so vlan id {$vlan['tag']} cannot be created please fix the issue before continuing.";
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Ermal Luçi Copyright (C) 2008 Ermal Luçi
...@@ -28,8 +29,13 @@ ...@@ -28,8 +29,13 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
if (!is_array($config['bridges']['bridged'])) if (!is_array($config['bridges'])) {
$config['bridges'] = array();
}
if (!is_array($config['bridges']['bridged'])) {
$config['bridges']['bridged'] = array(); $config['bridges']['bridged'] = array();
}
$a_bridges = &$config['bridges']['bridged'] ; $a_bridges = &$config['bridges']['bridged'] ;
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Ermal Luçi Copyright (C) 2008 Ermal Luçi
...@@ -30,8 +31,13 @@ require_once("guiconfig.inc"); ...@@ -30,8 +31,13 @@ require_once("guiconfig.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_bridge.php'); $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces_bridge.php');
if (!is_array($config['bridges']['bridged'])) if (!is_array($config['bridges'])) {
$config['bridges'] = array();
}
if (!is_array($config['bridges']['bridged'])) {
$config['bridges']['bridged'] = array(); $config['bridges']['bridged'] = array();
}
$a_bridges = &$config['bridges']['bridged']; $a_bridges = &$config['bridges']['bridged'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment