Commit 0145541f authored by Ad Schellevis's avatar Ad Schellevis

(legacy) fix more php issues in etc/inc

parent 8d561f62
...@@ -1228,7 +1228,7 @@ function auth_get_authserver_list() { ...@@ -1228,7 +1228,7 @@ function auth_get_authserver_list() {
$list = array(); $list = array();
if (is_array($config['system']['authserver'])) { if (isset($config['system']['authserver']) && is_array($config['system']['authserver'])) {
foreach ($config['system']['authserver'] as $authcfg) { foreach ($config['system']['authserver'] as $authcfg) {
/* Add support for disabled entries? */ /* Add support for disabled entries? */
$list[$authcfg['name']] = $authcfg; $list[$authcfg['name']] = $authcfg;
......
...@@ -48,17 +48,18 @@ $openssl_crl_status = array( ...@@ -48,17 +48,18 @@ $openssl_crl_status = array(
function & lookup_ca($refid) { function & lookup_ca($refid) {
global $config; global $config;
$false = false;
if (is_array($config['ca'])) if (is_array($config['ca']))
foreach ($config['ca'] as & $ca) foreach ($config['ca'] as & $ca)
if ($ca['refid'] == $refid) if ($ca['refid'] == $refid)
return $ca; return $ca;
return $false;
return false;
} }
function & lookup_ca_by_subject($subject) { function & lookup_ca_by_subject($subject) {
global $config; global $config;
$false = false;
if (is_array($config['ca'])) if (is_array($config['ca']))
foreach ($config['ca'] as & $ca) foreach ($config['ca'] as & $ca)
...@@ -68,37 +69,41 @@ function & lookup_ca_by_subject($subject) { ...@@ -68,37 +69,41 @@ function & lookup_ca_by_subject($subject) {
return $ca; return $ca;
} }
return false; return $false;
} }
function & lookup_cert($refid) { function & lookup_cert($refid) {
global $config; global $config;
$false = false;
if (is_array($config['cert'])) if (is_array($config['cert']))
foreach ($config['cert'] as & $cert) foreach ($config['cert'] as & $cert)
if ($cert['refid'] == $refid) if ($cert['refid'] == $refid)
return $cert; return $cert;
return false; return $false;
} }
function & lookup_cert_by_name($name) { function & lookup_cert_by_name($name) {
global $config; global $config;
$null = null;
if (is_array($config['cert'])) if (is_array($config['cert']))
foreach ($config['cert'] as & $cert) foreach ($config['cert'] as & $cert)
if ($cert['descr'] == $name) if ($cert['descr'] == $name)
return $cert; return $cert;
return $null;
} }
function & lookup_crl($refid) { function & lookup_crl($refid) {
global $config; global $config;
$false = false;
if (is_array($config['crl'])) if (is_array($config['crl']))
foreach ($config['crl'] as & $crl) foreach ($config['crl'] as & $crl)
if ($crl['refid'] == $refid) if ($crl['refid'] == $refid)
return $crl; return $crl;
return false; return $false;
} }
function ca_chain_array(& $cert) { function ca_chain_array(& $cert) {
...@@ -395,11 +400,11 @@ function cert_get_subject($str_crt, $decode = true) { ...@@ -395,11 +400,11 @@ function cert_get_subject($str_crt, $decode = true) {
ksort($v); ksort($v);
foreach ($v as $w) { foreach ($v as $w) {
$asubject = "{$a}={$w}"; $asubject = "{$a}={$w}";
$subject = (strlen($subject)) ? "{$asubject}, {$subject}" : $asubject; $subject = (isset($subject)) ? "{$asubject}, {$subject}" : $asubject;
} }
} else { } else {
$asubject = "{$a}={$v}"; $asubject = "{$a}={$v}";
$subject = (strlen($subject)) ? "{$asubject}, {$subject}" : $asubject; $subject = (isset($subject)) ? "{$asubject}, {$subject}" : $asubject;
} }
} }
...@@ -445,11 +450,11 @@ function cert_get_issuer($str_crt, $decode = true) { ...@@ -445,11 +450,11 @@ function cert_get_issuer($str_crt, $decode = true) {
ksort($v); ksort($v);
foreach ($v as $w) { foreach ($v as $w) {
$aissuer = "{$a}={$w}"; $aissuer = "{$a}={$w}";
$issuer = (strlen($issuer)) ? "{$aissuer}, {$issuer}" : $aissuer; $issuer = (isset($issuer)) ? "{$aissuer}, {$issuer}" : $aissuer;
} }
} else { } else {
$aissuer = "{$a}={$v}"; $aissuer = "{$a}={$v}";
$issuer = (strlen($issuer)) ? "{$aissuer}, {$issuer}" : $aissuer; $issuer = (isset($issuer)) ? "{$aissuer}, {$issuer}" : $aissuer;
} }
} }
...@@ -490,7 +495,11 @@ function cert_get_purpose($str_crt, $decode = true) { ...@@ -490,7 +495,11 @@ function cert_get_purpose($str_crt, $decode = true) {
$crt_details = openssl_x509_parse($str_crt); $crt_details = openssl_x509_parse($str_crt);
$purpose = array(); $purpose = array();
$purpose['ca'] = (stristr($crt_details['extensions']['basicConstraints'], 'CA:TRUE') === false) ? 'No': 'Yes'; $purpose['ca'] = (stristr($crt_details['extensions']['basicConstraints'], 'CA:TRUE') === false) ? 'No': 'Yes';
$purpose['server'] = ($crt_details['extensions']['nsCertType'] == "SSL Server") ? 'Yes': 'No'; if (isset($crt_details['extensions']['nsCertType']) && $crt_details['extensions']['nsCertType'] == "SSL Server") {
$purpose['server'] = 'Yes';
} else {
$purpose['server'] = 'No';
}
return $purpose; return $purpose;
} }
...@@ -524,7 +533,7 @@ function is_user_cert($certref) ...@@ -524,7 +533,7 @@ function is_user_cert($certref)
} }
foreach ($config['system']['user'] as $user) { foreach ($config['system']['user'] as $user) {
if (!is_array($user['cert'])) { if (!isset($user['cert']) || !is_array($user['cert'])) {
continue; continue;
} }
foreach ($user['cert'] as $cert) { foreach ($user['cert'] as $cert) {
...@@ -696,7 +705,7 @@ function cert_compare($cert1, $cert2) { ...@@ -696,7 +705,7 @@ function cert_compare($cert1, $cert2) {
function is_cert_revoked($cert, $crlref = "") { function is_cert_revoked($cert, $crlref = "") {
global $config; global $config;
if (!is_array($config['crl'])) if (!isset($config['crl']) || !is_array($config['crl']))
return false; return false;
if (!empty($crlref)) { if (!empty($crlref)) {
......
...@@ -838,8 +838,13 @@ function filter_generate_optcfg_array() ...@@ -838,8 +838,13 @@ function filter_generate_optcfg_array()
$oic['ipv6'] = get_interface_ipv6($if); $oic['ipv6'] = get_interface_ipv6($if);
if(!is_ipaddrv4($oc['ipaddr']) && !empty($oc['ipaddr'])) if(!is_ipaddrv4($oc['ipaddr']) && !empty($oc['ipaddr']))
$oic['type'] = $oc['ipaddr']; $oic['type'] = $oc['ipaddr'];
if(!is_ipaddrv6($oc['ipaddrv6']) && !empty($oc['ipaddrv6'])) if (isset($oc['ipaddrv6'])) {
$oic['type6'] = $oc['ipaddrv6']; if( !is_ipaddrv6($oc['ipaddrv6']) && !empty($oc['ipaddrv6'])) {
$oic['type6'] = $oc['ipaddrv6'];
}
} else {
$oic['type6'] = null;
}
if (!empty($oc['track6-interface'])) if (!empty($oc['track6-interface']))
$oic['track6-interface'] = $oc['track6-interface']; $oic['track6-interface'] = $oc['track6-interface'];
$oic['sn'] = get_interface_subnet($if); $oic['sn'] = get_interface_subnet($if);
...@@ -849,11 +854,31 @@ function filter_generate_optcfg_array() ...@@ -849,11 +854,31 @@ function filter_generate_optcfg_array()
$oic['descr'] = $ifdetail; $oic['descr'] = $ifdetail;
$oic['sa'] = gen_subnet($oic['ip'], $oic['sn']); $oic['sa'] = gen_subnet($oic['ip'], $oic['sn']);
$oic['sav6'] = gen_subnetv6($oic['ipv6'], $oic['snv6']); $oic['sav6'] = gen_subnetv6($oic['ipv6'], $oic['snv6']);
$oic['nonat'] = $oc['nonat']; if (isset($oc['nonat'])) {
$oic['alias-address'] = $oc['alias-address']; $oic['nonat'] = $oc['nonat'];
$oic['alias-subnet'] = $oc['alias-subnet']; } else {
$oic['gateway'] = $oc['gateway']; $oic['nonat'] = null;
$oic['gatewayv6'] = $oc['gatewayv6']; }
if (isset($oc['alias-address'])) {
$oic['alias-address'] = $oc['alias-address'];
} else {
$oic['alias-address'] = null;
}
if (isset($oc['alias-subnet'])) {
$oic['alias-subnet'] = $oc['alias-subnet'];
} else {
$oc['alias-subnet'] = null;
}
if (isset($oc['gateway'])) {
$oic['gateway'] = $oc['gateway'];
} else {
$oic['gateway'] = null ;
}
if (isset($oc['gatewayv6'])) {
$oic['gatewayv6'] = $oc['gatewayv6'];
} else {
$oic['gatewayv6'] = null;
}
$oic['spoofcheck'] = "yes"; $oic['spoofcheck'] = "yes";
$oic['bridge'] = link_interface_to_bridge($if); $oic['bridge'] = link_interface_to_bridge($if);
$vips = link_interface_to_vips($if); $vips = link_interface_to_vips($if);
...@@ -896,7 +921,7 @@ function filter_generate_optcfg_array() ...@@ -896,7 +921,7 @@ function filter_generate_optcfg_array()
$oic['sn'] = "32"; $oic['sn'] = "32";
$FilterIflist['pptp'] = $oic; $FilterIflist['pptp'] = $oic;
} }
if($config['l2tp']['mode'] == "server") { if(isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") {
$oic = array(); $oic = array();
$oic['if'] = 'l2tp'; $oic['if'] = 'l2tp';
$oic['descr'] = 'L2TP'; $oic['descr'] = 'L2TP';
...@@ -910,7 +935,7 @@ function filter_generate_optcfg_array() ...@@ -910,7 +935,7 @@ function filter_generate_optcfg_array()
$oic['virtual'] = true; $oic['virtual'] = true;
$FilterIflist['l2tp'] = $oic; $FilterIflist['l2tp'] = $oic;
} }
if (is_array($config['pppoes']['pppoe']) && (count($config['pppoes']['pppoe']) > 0)) { if (isset($config['pppoes']['pppoe']) && is_array($config['pppoes']['pppoe']) && (count($config['pppoes']['pppoe']) > 0)) {
$pppoeifs = array(); $pppoeifs = array();
foreach($config['pppoes']['pppoe'] as $pppoe) { foreach($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['mode'] == "server") { if ($pppoe['mode'] == "server") {
......
...@@ -388,7 +388,7 @@ function return_gateways_status($byname = false) ...@@ -388,7 +388,7 @@ function return_gateways_status($byname = false)
foreach($gateways_arr as $gwitem) { foreach($gateways_arr as $gwitem) {
if(!isset($gwitem['monitor_disable'])) if(!isset($gwitem['monitor_disable']))
continue; continue;
if(!is_ipaddr($gwitem['monitorip'])) { if(!isset($gwitem['monitorip']) || !is_ipaddr($gwitem['monitorip'])) {
$realif = $gwitem['interface']; $realif = $gwitem['interface'];
$tgtip = get_interface_gateway($realif); $tgtip = get_interface_gateway($realif);
if (!is_ipaddr($tgtip)) if (!is_ipaddr($tgtip))
...@@ -943,26 +943,28 @@ function get_interface_gateway($interface, &$dynamic = false) ...@@ -943,26 +943,28 @@ function get_interface_gateway($interface, &$dynamic = false)
$gw = NULL; $gw = NULL;
$gwcfg = $config['interfaces'][$interface]; if (isset($config['interfaces'][$interface])) {
if (!empty($gwcfg['gateway']) && is_array($config['gateways']['gateway_item'])) { $gwcfg = $config['interfaces'][$interface];
foreach($config['gateways']['gateway_item'] as $gateway) { if (isset($gwcfg['gateway']) && is_array($config['gateways']['gateway_item'])) {
if(($gateway['name'] == $gwcfg['gateway']) && (is_ipaddrv4($gateway['gateway']))) { foreach($config['gateways']['gateway_item'] as $gateway) {
$gw = $gateway['gateway']; if(($gateway['name'] == $gwcfg['gateway']) && (is_ipaddrv4($gateway['gateway']))) {
break; $gw = $gateway['gateway'];
break;
}
} }
} }
}
// for dynamic interfaces we handle them through the $interface_router file. // for dynamic interfaces we handle them through the $interface_router file.
if (!is_ipaddrv4($gw) && !is_ipaddrv4($gwcfg['ipaddr'])) { if (!is_ipaddrv4($gw) && !is_ipaddrv4($gwcfg['ipaddr'])) {
$realif = get_real_interface($interface); $realif = get_real_interface($interface);
if (file_exists("/tmp/{$realif}_router")) { if (file_exists("/tmp/{$realif}_router")) {
$gw = trim(file_get_contents("/tmp/{$realif}_router"), " \n"); $gw = trim(file_get_contents("/tmp/{$realif}_router"), " \n");
$dynamic = true; $dynamic = true;
}
if (file_exists("/tmp/{$realif}_defaultgw")) {
$dynamic = "default";
}
} }
if (file_exists("/tmp/{$realif}_defaultgw"))
$dynamic = "default";
} }
/* return gateway */ /* return gateway */
...@@ -985,7 +987,7 @@ function get_interface_gateway_v6($interface, &$dynamic = false) ...@@ -985,7 +987,7 @@ function get_interface_gateway_v6($interface, &$dynamic = false)
} }
// for dynamic interfaces we handle them through the $interface_router file. // for dynamic interfaces we handle them through the $interface_router file.
if (!is_ipaddrv6($gw) && !is_ipaddrv6($gwcfg['ipaddrv6'])) { if (!is_ipaddrv6($gw) && ( !isset($gwcfg['ipaddrv6']) || !is_ipaddrv6($gwcfg['ipaddrv6']))) {
$realif = get_real_interface($interface); $realif = get_real_interface($interface);
if (file_exists("/tmp/{$realif}_routerv6")) { if (file_exists("/tmp/{$realif}_routerv6")) {
$gw = trim(file_get_contents("/tmp/{$realif}_routerv6"), " \n"); $gw = trim(file_get_contents("/tmp/{$realif}_routerv6"), " \n");
......
...@@ -4146,6 +4146,7 @@ function convert_real_interface_to_friendly_interface_name($interface = "wan") { ...@@ -4146,6 +4146,7 @@ function convert_real_interface_to_friendly_interface_name($interface = "wan") {
/* attempt to resolve interface to friendly descr */ /* attempt to resolve interface to friendly descr */
function convert_friendly_interface_to_friendly_descr($interface) { function convert_friendly_interface_to_friendly_descr($interface) {
global $config; global $config;
$ifdesc = null;
switch ($interface) { switch ($interface) {
case "l2tp": case "l2tp":
...@@ -4752,8 +4753,9 @@ function find_interface_ipv6($interface, $flush = false) { ...@@ -4752,8 +4753,9 @@ function find_interface_ipv6($interface, $flush = false) {
$interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddr6']; $interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddr6'];
$interface_snv6_arr_cache[$interface] = $ifinfo['subnetbits6']; $interface_snv6_arr_cache[$interface] = $ifinfo['subnetbits6'];
} }
return $interface_ipv6_arr_cache[$interface];
} }
return $interface_ipv6_arr_cache[$interface]; return;
} }
/* /*
...@@ -4794,11 +4796,13 @@ function find_interface_subnet($interface, $flush = false) { ...@@ -4794,11 +4796,13 @@ function find_interface_subnet($interface, $flush = false) {
if (!isset($interface_sn_arr_cache[$interface]) or $flush) { if (!isset($interface_sn_arr_cache[$interface]) or $flush) {
$ifinfo = pfSense_get_interface_addresses($interface); $ifinfo = pfSense_get_interface_addresses($interface);
$interface_ip_arr_cache[$interface] = $ifinfo['ipaddr']; if (isset($ifinfo['ipaddr'])) {
$interface_sn_arr_cache[$interface] = $ifinfo['subnetbits']; $interface_ip_arr_cache[$interface] = $ifinfo['ipaddr'];
$interface_sn_arr_cache[$interface] = $ifinfo['subnetbits'];
return $interface_sn_arr_cache[$interface];
}
} }
return;
return $interface_sn_arr_cache[$interface];
} }
function find_interface_subnetv6($interface, $flush = false) { function find_interface_subnetv6($interface, $flush = false) {
...@@ -4811,11 +4815,13 @@ function find_interface_subnetv6($interface, $flush = false) { ...@@ -4811,11 +4815,13 @@ function find_interface_subnetv6($interface, $flush = false) {
if (!isset($interface_snv6_arr_cache[$interface]) or $flush) { if (!isset($interface_snv6_arr_cache[$interface]) or $flush) {
$ifinfo = pfSense_get_interface_addresses($interface); $ifinfo = pfSense_get_interface_addresses($interface);
$interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddr6']; if (isset($ifinfo['ipaddr6'])) {
$interface_snv6_arr_cache[$interface] = $ifinfo['subnetbits6']; $interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddr6'];
$interface_snv6_arr_cache[$interface] = $ifinfo['subnetbits6'];
return $interface_snv6_arr_cache[$interface];
}
} }
return;
return $interface_snv6_arr_cache[$interface];
} }
function ip_in_interface_alias_subnet($interface, $ipalias) { function ip_in_interface_alias_subnet($interface, $ipalias) {
...@@ -4984,7 +4990,12 @@ function interface_has_gatewayv6($friendly) { ...@@ -4984,7 +4990,12 @@ function interface_has_gatewayv6($friendly) {
if (!empty($config['interfaces'][$friendly])) { if (!empty($config['interfaces'][$friendly])) {
$ifname = &$config['interfaces'][$friendly]; $ifname = &$config['interfaces'][$friendly];
switch ($ifname['ipaddrv6']) { if (isset($ifname['ipaddrv6'])) {
$ipaddrv6 = $ifname['ipaddrv6'];
} else {
$ipaddrv6 = "";
}
switch ($ipaddrv6) {
case "slaac": case "slaac":
case "dhcp6": case "dhcp6":
case "6to4": case "6to4":
...@@ -5227,13 +5238,13 @@ function get_failover_interface($interface, $family = "all") { ...@@ -5227,13 +5238,13 @@ function get_failover_interface($interface, $family = "all") {
global $config; global $config;
/* shortcut to get_real_interface if we find it in the config */ /* shortcut to get_real_interface if we find it in the config */
if (is_array($config['interfaces'][$interface])) { if (isset($config['interfaces'][$interface]) && is_array($config['interfaces'][$interface])) {
return get_real_interface($interface, $family); return get_real_interface($interface, $family);
} }
/* compare against gateway groups */ /* compare against gateway groups */
$a_groups = return_gateway_groups_array(); $a_groups = return_gateway_groups_array();
if (is_array($a_groups[$interface])) { if (isset($a_groups[$interface]) && is_array($a_groups[$interface])) {
/* we found a gateway group, fetch the interface or vip */ /* we found a gateway group, fetch the interface or vip */
if ($a_groups[$interface][0]['vip'] <> "") if ($a_groups[$interface][0]['vip'] <> "")
return $a_groups[$interface][0]['vip']; return $a_groups[$interface][0]['vip'];
......
...@@ -1016,7 +1016,7 @@ function openvpn_get_active_servers($type="multipoint") { ...@@ -1016,7 +1016,7 @@ function openvpn_get_active_servers($type="multipoint") {
global $config, $g; global $config, $g;
$servers = array(); $servers = array();
if (is_array($config['openvpn']['openvpn-server'])) { if (isset($config['openvpn']['openvpn-server']) && is_array($config['openvpn']['openvpn-server'])) {
foreach ($config['openvpn']['openvpn-server'] as & $settings) { foreach ($config['openvpn']['openvpn-server'] as & $settings) {
if (empty($settings) || isset($settings['disable'])) if (empty($settings) || isset($settings['disable']))
continue; continue;
...@@ -1118,7 +1118,7 @@ function openvpn_get_active_clients() { ...@@ -1118,7 +1118,7 @@ function openvpn_get_active_clients() {
global $config, $g; global $config, $g;
$clients = array(); $clients = array();
if (is_array($config['openvpn']['openvpn-client'])) { if (isset($config['openvpn']['openvpn-client']) && is_array($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as & $settings) { foreach ($config['openvpn']['openvpn-client'] as & $settings) {
if (empty($settings) || isset($settings['disable'])) if (empty($settings) || isset($settings['disable']))
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
******/ ******/
function have_natpfruleint_access($if) { function have_natpfruleint_access($if) {
$security_url = "firewall_nat_edit.php?if=". strtolower($if); $security_url = "firewall_nat_edit.php?if=". strtolower($if);
if(isAllowedPage($security_url, $allowed)) if(isAllowedPage($security_url))
return true; return true;
return false; return false;
} }
...@@ -810,8 +810,9 @@ function is_dhcpv6_server_enabled() { ...@@ -810,8 +810,9 @@ function is_dhcpv6_server_enabled() {
function is_radvd_enabled() { function is_radvd_enabled() {
global $config; global $config;
if (!is_array($config['dhcpdv6'])) if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
$config['dhcpdv6'] = array(); $config['dhcpdv6'] = array();
}
$dhcpdv6cfg = $config['dhcpdv6']; $dhcpdv6cfg = $config['dhcpdv6'];
$Iflist = get_configured_interface_list(); $Iflist = get_configured_interface_list();
...@@ -1905,8 +1906,9 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false, ...@@ -1905,8 +1906,9 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false,
function calculate_ipv6_delegation_length($if) { function calculate_ipv6_delegation_length($if) {
global $config; global $config;
if(!is_array($config['interfaces'][$if])) if(!isset($config['interfaces'][$if]) || !is_array($config['interfaces'][$if])) {
return false; return false;
}
switch($config['interfaces'][$if]['ipaddrv6']) { switch($config['interfaces'][$if]['ipaddrv6']) {
case "6to4": case "6to4":
...@@ -2027,7 +2029,7 @@ function zte_simstate_to_string($state) { ...@@ -2027,7 +2029,7 @@ function zte_simstate_to_string($state) {
function get_configured_pppoe_server_interfaces() { function get_configured_pppoe_server_interfaces() {
global $config; global $config;
$iflist = array(); $iflist = array();
if (is_array($config['pppoes']['pppoe'])) { if (isset($config['pppoes']['pppoe']) && is_array($config['pppoes']['pppoe'])) {
foreach($config['pppoes']['pppoe'] as $pppoe) { foreach($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['mode'] == "server") { if ($pppoe['mode'] == "server") {
$int = "poes". $pppoe['pppoeid']; $int = "poes". $pppoe['pppoeid'];
......
...@@ -69,7 +69,7 @@ if (!function_exists('get_services')) { ...@@ -69,7 +69,7 @@ if (!function_exists('get_services')) {
$pconfig['description'] = gettext("NTP clock sync"); $pconfig['description'] = gettext("NTP clock sync");
$services[] = $pconfig; $services[] = $pconfig;
if (is_array($config['captiveportal'])) { if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
foreach ($config['captiveportal'] as $zone => $setting) { foreach ($config['captiveportal'] as $zone => $setting) {
if (isset($setting['enable'])) { if (isset($setting['enable'])) {
$pconfig = array(); $pconfig = array();
...@@ -125,7 +125,7 @@ if (!function_exists('get_services')) { ...@@ -125,7 +125,7 @@ if (!function_exists('get_services')) {
$services[] = $pconfig; $services[] = $pconfig;
} }
if (is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) { if (isset($config['igmpproxy']['igmpentry']) && is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) {
$pconfig = array(); $pconfig = array();
$pconfig['name'] = "igmpproxy"; $pconfig['name'] = "igmpproxy";
$pconfig['description'] = gettext("IGMP proxy"); $pconfig['description'] = gettext("IGMP proxy");
...@@ -169,7 +169,7 @@ if (!function_exists('get_services')) { ...@@ -169,7 +169,7 @@ if (!function_exists('get_services')) {
} }
} }
if (count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) { if (isset($config['load_balancer']['virtual_server']) && isset($config['load_balancer']['lbpool']) && count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
$pconfig = array(); $pconfig = array();
$pconfig['name'] = "relayd"; $pconfig['name'] = "relayd";
$pconfig['description'] = gettext("Server load balancing daemon"); $pconfig['description'] = gettext("Server load balancing daemon");
......
...@@ -1728,7 +1728,7 @@ function get_possible_traffic_source_addresses($include_ipv6_link_local=false) { ...@@ -1728,7 +1728,7 @@ function get_possible_traffic_source_addresses($include_ipv6_link_local=false) {
global $config; global $config;
$sourceips = get_possible_listen_ips($include_ipv6_link_local); $sourceips = get_possible_listen_ips($include_ipv6_link_local);
foreach (array('server', 'client') as $mode) { foreach (array('server', 'client') as $mode) {
if (is_array($config['openvpn']["openvpn-{$mode}"])) { if (isset($config['openvpn']["openvpn-{$mode}"]) && is_array($config['openvpn']["openvpn-{$mode}"])) {
foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) { foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
if (!isset($setting['disable'])) { if (!isset($setting['disable'])) {
$vpn = array(); $vpn = array();
......
...@@ -942,7 +942,11 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") ...@@ -942,7 +942,11 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
$dmesg_arr = array(); $dmesg_arr = array();
exec("/sbin/dmesg |grep $ifname | head -n1", $dmesg_arr); exec("/sbin/dmesg |grep $ifname | head -n1", $dmesg_arr);
preg_match_all("/<(.*?)>/i", $dmesg_arr[0], $dmesg); preg_match_all("/<(.*?)>/i", $dmesg_arr[0], $dmesg);
$toput['dmesg'] = $dmesg[1][0]; if (isset($dmesg[1][0])) {
$toput['dmesg'] = $dmesg[1][0];
} else {
$toput['dmesg'] = null;
}
$iflist[$ifname] = $toput; $iflist[$ifname] = $toput;
break; break;
case "ppp": case "ppp":
......
...@@ -464,15 +464,23 @@ function get_lb_summary() { ...@@ -464,15 +464,23 @@ function get_lb_summary() {
$relay_hosts=Array(); $relay_hosts=Array();
foreach( (array) $relayctl as $line) { foreach( (array) $relayctl as $line) {
$t = explode("\t", $line); $t = explode("\t", $line);
switch (trim($t[1])) { if (isset($t[1])) {
case "table": switch (trim($t[1])) {
$curpool=trim($t[2]); case "table":
break; $curpool=trim($t[2]);
case "host": break;
$curhost=trim($t[2]); case "host":
$relay_hosts[$curpool][$curhost]['avail']=trim($t[3]); $curhost=trim($t[2]);
$relay_hosts[$curpool][$curhost]['state']=trim($t[4]); if (!isset($relay_hosts[$curpool])) {
break; $relay_hosts[$curpool] = array();
}
if (!isset($relay_hosts[$curpool][$curhost])) {
$relay_hosts[$curpool][$curhost]['avail'] = array();
}
$relay_hosts[$curpool][$curhost]['avail']=trim($t[3]);
$relay_hosts[$curpool][$curhost]['state']=trim($t[4]);
break;
}
} }
} }
return $relay_hosts; return $relay_hosts;
......
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