From d13f2dc7fc1e7a1a5239fc9b7cb29016823ed9f0 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Sun, 26 Mar 2023 20:27:26 -0300 Subject: [PATCH] Fix a few PHP 8 warnings Signed-off-by: RD WebDesign --- scripts/pi-hole/php/func.php | 2 +- settings.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/pi-hole/php/func.php b/scripts/pi-hole/php/func.php index 1c6652aa4..d10ad9bfe 100644 --- a/scripts/pi-hole/php/func.php +++ b/scripts/pi-hole/php/func.php @@ -635,7 +635,7 @@ function getGateway() if (array_key_exists('FTLnotrunning', $gateway)) { $ret = array('ip' => -1); } else { - $ret = array_combine(array('ip', 'iface'), explode(' ', $gateway[0])); + $ret = array_combine(array('ip', 'iface'), array_pad(explode(' ', $gateway[0]), 2, '')); } return $ret; diff --git a/settings.php b/settings.php index 2f21449ae..22a7e7ea9 100644 --- a/settings.php +++ b/settings.php @@ -428,16 +428,18 @@ } } else { $DHCP = false; + $DHCPstart = ''; + $DHCPend = ''; + $DHCProuter = ''; + // Try to guess initial settings if ($IPv4GW !== 'unknown') { $DHCPparts = explode('.', $IPv4GW); - $DHCPstart = $DHCPparts[0].'.'.$DHCPparts[1].'.'.$DHCPparts[2].'.201'; - $DHCPend = $DHCPparts[0].'.'.$DHCPparts[1].'.'.$DHCPparts[2].'.251'; - $DHCProuter = $IPv4GW; - } else { - $DHCPstart = ''; - $DHCPend = ''; - $DHCProuter = ''; + if (isset($DHCPparts[0]) && isset($DHCPparts[1]) && isset($DHCPparts[2])) { + $DHCPstart = $DHCPparts[0].'.'.$DHCPparts[1].'.'.$DHCPparts[2].'.201'; + $DHCPend = $DHCPparts[0].'.'.$DHCPparts[1].'.'.$DHCPparts[2].'.251'; + $DHCProuter = $IPv4GW; + } } $DHCPleasetime = 24; $DHCPIPv6 = false;