Fix some illegal offset errors. Issue #9366

This commit is contained in:
jim-p 2019-03-05 13:27:30 -05:00
parent 59449ddb79
commit b88050bbdd
7 changed files with 28 additions and 37 deletions

View File

@ -1241,7 +1241,7 @@ function filter_generate_optcfg_array() {
$FilterIflist['openvpn'] = $oic;
}
/* add interface groups */
if (is_array($config['ifgroups']['ifgroupentry'])) {
if (isset($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
$oc = array();
$oc['if'] = $ifgen['ifname'];
@ -3490,7 +3490,7 @@ EOD;
$tracker = $saved_tracker;
$isbridged = false;
if (is_array($config['bridges']['bridged'])) {
if (isset($config['bridges']['bridged']) && is_array($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $oc2) {
if (stristr($oc2['members'], $on)) {
$isbridged = true;

View File

@ -677,7 +677,7 @@ function interfaces_bridge_configure($checkmember = 0, $realif = "") {
global $config;
$i = 0;
if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
if (isset($config['bridges']['bridged']) && is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $bridge) {
if (empty($bridge['bridgeif'])) {
$bridge['bridgeif'] = "bridge{$i}";
@ -5267,7 +5267,7 @@ function DHCP_Config_File_Substitutions($ifcfg, $realif, $dhclientconf) {
function interfaces_group_setup() {
global $config;
if (!is_array($config['ifgroups']['ifgroupentry'])) {
if (!isset($config['ifgroups']['ifgroupentry']) || !is_array($config['ifgroups']['ifgroupentry'])) {
return;
}
@ -5298,7 +5298,7 @@ function interface_group_setup(&$groupname /* The parameter is an array */) {
function is_interface_group($if) {
global $config;
if (is_array($config['ifgroups']['ifgroupentry'])) {
if (isset($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $groupentry) {
if ($groupentry['ifname'] === $if) {
return true;
@ -5421,7 +5421,7 @@ function convert_friendly_interface_to_friendly_descr($interface) {
} else if (substr($interface, 0, 5) == '_lloc') {
return get_interface_linklocal($interface);
} else {
if (is_array($config['ifgroups']['ifgroupentry'])) {
if (isset($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
if ($ifgen['ifname'] === $interface) {
return $ifgen['ifname'];
@ -6006,7 +6006,7 @@ function link_interface_to_vips($int, $action = "", $vhid = '') {
function link_interface_to_bridge($int) {
global $config;
if (is_array($config['bridges']['bridged'])) {
if (isset($config['bridges']['bridged']) && is_array($config['bridges']['bridged'])) {
foreach ($config['bridges']['bridged'] as $bridge) {
if (in_array($int, explode(',', $bridge['members']))) {
return "{$bridge['bridgeif']}";
@ -6020,7 +6020,7 @@ function link_interface_to_group($int) {
$result = array();
if (is_array($config['ifgroups']['ifgroupentry'])) {
if (isset($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $group) {
if (in_array($int, explode(" ", $group['members']))) {
$result[$group['ifname']] = $int;
@ -7065,7 +7065,7 @@ function create_interface_list() {
$iflist = array();
// add group interfaces
if (is_array($config['ifgroups']['ifgroupentry'])) {
if (isset($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
if (have_ruleint_access($ifgen['ifname'])) {
$iflist[$ifgen['ifname']] = $ifgen['ifname'];

View File

@ -83,7 +83,7 @@ function start_service($name, $after_sync = false) {
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
foreach ($config['installedpackages']['service'] as $service) {
if (strtolower($service['name']) == strtolower($name)) {
if (isset($service['name']) && (strtolower($service['name']) == strtolower($name))) {
/* Avoid starting twice if this is called just after a
* package sync which starts the service itself. */
if ($after_sync && isset($service['starts_on_sync'])) {
@ -207,7 +207,7 @@ function is_service_running($service, $ps = "") {
if (is_array($config['installedpackages']['service'])) {
foreach ($config['installedpackages']['service'] as $aservice) {
if (strtolower($service) == strtolower($aservice['name'])) {
if (isset($aservice['name']) && (strtolower($service) == strtolower($aservice['name']))) {
if ($aservice['custom_php_service_status_command'] <> "") {
eval("\$rc={$aservice['custom_php_service_status_command']};");
return $rc;

View File

@ -911,7 +911,7 @@ EOPP;
// Handle pool-specific options
$dhcpdconf .= "\n";
// Ignore the first pool, which is the "overall" pool when $all_pools_idx is 0 - those are put outside the pool block later
if ($poolconf['numberoptions']['item'] && ($all_pools_idx > 0)) {
if (isset($poolconf['numberoptions']['item']) && is_array($poolconf['numberoptions']['item']) && ($all_pools_idx > 0)) {
// Use the "real" pool index from the config, excluding the "overall" pool, and based from 0.
// This matches the way $poolidx was used when generating the $custoptions string earlier.
$poolidx = $all_pools_idx - 1;
@ -1033,7 +1033,7 @@ EOD;
// Handle option, number rowhelper values
$dhcpdconf .= "\n";
if ($dhcpifconf['numberoptions']['item']) {
if (isset($dhcpifconf['numberoptions']['item']) && is_array($dhcpifconf['numberoptions']['item'])) {
foreach ($dhcpifconf['numberoptions']['item'] as $itemidx => $item) {
$item_value = base64_decode($item['value']);
if (empty($item['type']) || $item['type'] == "text") {
@ -1519,7 +1519,7 @@ EOD;
// Handle option, number rowhelper values
$dhcpdv6conf .= "\n";
if ($dhcpv6ifconf['numberoptions']['item']) {
if (isset($dhcpv6ifconf['numberoptions']['item']) && is_array($dhcpv6ifconf['numberoptions']['item'])) {
foreach ($dhcpv6ifconf['numberoptions']['item'] as $itemv6idx => $itemv6) {
$itemv6_value = base64_decode($itemv6['value']);
$dhcpdv6conf .= " option custom-{$dhcpv6if}-{$itemv6idx} \"{$itemv6_value}\";\n";
@ -1903,7 +1903,11 @@ function services_dyndns_configure($int = "") {
echo "services_dyndns_configure() being called $mt\n";
}
$dyndnscfg = $config['dyndnses']['dyndns'];
if (isset($config['dyndnses']['dyndns']) && is_array($config['dyndnses']['dyndns'])) {
$dyndnscfg = $config['dyndnses']['dyndns'];
} else {
return 0;
}
$gwgroups = return_gateway_groups_array(true);
if (is_array($dyndnscfg)) {
if (platform_booting()) {

View File

@ -154,9 +154,9 @@ function return_ext_menu($section) {
if ((!empty($config['installedpackages']['package'])) && (!empty($config['installedpackages']['menu']))) {
foreach ($config['installedpackages']['menu'] as $menu) {
if ($menu['name'] != "AutoConfigBackup") { // AutoConfigBackup was moved to a built-in function
if (isset($menu['name']) && ($menu['name'] != "AutoConfigBackup")) { // AutoConfigBackup was moved to a built-in function
// print('Name: ' . $menu['name'] . ', Pkg category: ' . $menu['category'] . ', Section: ' . $section . '<br />');
if ($menu['section'] == $section) {
if (isset($menu['section']) && ($menu['section'] == $section)) {
$ext_menu_entries[] = $menu;
}
}

View File

@ -30,38 +30,25 @@ require_once("/usr/local/www/widgets/include/dyn_dns_status.inc");
// Constructs a unique key that will identify a Dynamic DNS entry in the filter list.
if (!function_exists('get_dyndnsent_key')) {
function get_dyndnsent_key($dyndns) {
return $dyndns['id'];
return isset($dyndns['id']) ? $dyndns['id'] : null;
}
}
if (!function_exists('get_dyndns_hostname_text')) {
function get_dyndns_hostname_text($dyndns) {
global $dyndns_split_domain_types;
if (in_array($dyndns['type'], $dyndns_split_domain_types)) {
if (isset($dyndns['type']) && is_array($dyndns['type']) && in_array($dyndns['type'], $dyndns_split_domain_types)) {
return $dyndns['host'] . "." . $dyndns['domainname'];
}
return $dyndns['host'];
return isset($dyndns['host']) ? $dyndns['host'] : null;
}
}
if (!is_array($config['dyndnses'])) {
$config['dyndnses'] = array();
}
if (!is_array($config['dyndnses']['dyndns'])) {
$config['dyndnses']['dyndns'] = array();
}
init_config_arr(array('dyndnses', 'dyndns'));
$a_dyndns = $config['dyndnses']['dyndns'];
if (!is_array($config['dnsupdates'])) {
$config['dnsupdates'] = array();
}
if (!is_array($config['dnsupdates']['dnsupdate'])) {
$config['dnsupdates']['dnsupdate'] = array();
}
init_config_arr(array('dnsupdates', 'dnsupdate'));
$a_rfc2136 = $config['dnsupdates']['dnsupdate'];
$all_dyndns = array_merge($a_dyndns, $a_rfc2136);
@ -192,7 +179,7 @@ if (!function_exists('get_dyndns_service_text')) {
</thead>
<tbody>
<?php $dyndnsid = -1; $rfc2136id = -1; $rowid = -1; foreach ($all_dyndns as $dyndns):
if ($dyndns['type'] == '_rfc2136_') {
if (isset($dyndns['type']) && ($dyndns['type'] == '_rfc2136_')) {
$dblclick_location = 'services_rfc2136_edit.php';
$rfc2136id++;
$locationid = $rfc2136id;

View File

@ -23,7 +23,7 @@
require_once("guiconfig.inc");
require_once("/usr/local/www/widgets/include/wake_on_lan.inc");
if (is_array($config['wol']['wolentry'])) {
if (isset($config['wol']['wolentry']) && is_array($config['wol']['wolentry'])) {
$wolcomputers = $config['wol']['wolentry'];
} else {
$wolcomputers = array();