php8.x - fix some deprecation warnings

This commit is contained in:
Ad Schellevis 2023-02-12 19:12:30 +01:00
parent 9d5e1edb95
commit a9ecea3dcd
3 changed files with 8 additions and 6 deletions

View File

@ -443,7 +443,7 @@ function openvpn_add_keyfile($data, &$conf, $mode_id, $directive, $opt = '')
{
$fpath = "/var/etc/openvpn/{$mode_id}.{$directive}";
openvpn_create_dirs();
$data = str_replace("\r", "", base64_decode($data));
$data = !empty($data) ? str_replace("\r", "", base64_decode($data)) : '';
file_put_contents($fpath, str_replace("\n\n", "\n", $data));
@chmod($fpath, 0600);
@ -542,8 +542,8 @@ function openvpn_reconfigure($mode, $settings, $device_only = false)
// server specific settings
if ($mode == 'server') {
list($ip, $cidr) = explode('/', $settings['tunnel_network']);
list($ipv6, $prefix) = explode('/', $settings['tunnel_networkv6']);
list($ip, $cidr) = explode('/', $settings['tunnel_network'] ?? '');
list($ipv6, $prefix) = explode('/', $settings['tunnel_networkv6'] ?? '');
$mask = gen_subnet_mask($cidr);
// client connect and disconnect handling
@ -1520,7 +1520,7 @@ function openvpn_refresh_crls()
if (!empty($settings['crlref'])) {
$crl = lookup_crl($settings['crlref']);
$fpath = "/var/etc/openvpn/server{$settings['vpnid']}.crl-verify";
file_put_contents($fpath, base64_decode($crl['text']));
file_put_contents($fpath, !empty($crl['text']) ? base64_decode($crl['text']) : '');
@chmod($fpath, 0644);
}
break;

View File

@ -110,7 +110,9 @@ function vxlan_configure_do($verbose = false, $device = null)
$current_settings['vxlanid'] = $interfaces_details[$device_name]['vxlan']['vni'];
$current_settings['vxlanlocal'] = explode(":", $interfaces_details[$device_name]['vxlan']['local'])[0];
$current_settings['vxlanremote'] = explode(":", $interfaces_details[$device_name]['vxlan']['remote'])[0];
$current_settings['vxlangroup'] = explode(":", $interfaces_details[$device_name]['vxlan']['group'])[0];
if (!empty($interfaces_details[$device_name]['vxlan']['group'])) {
$current_settings['vxlangroup'] = explode(":", $interfaces_details[$device_name]['vxlan']['group'])[0];
}
}
// gather settings, detect changes
$ifcnfcmd = '/sbin/ifconfig %s';

View File

@ -65,7 +65,7 @@ class NetworkValidator extends BaseValidator
foreach ($values as $value) {
// parse filter options
$filterOpt = 0;
switch (strtolower($this->getOption('version'))) {
switch (strtolower($this->getOption('version') ?? '')) {
case "ipv4":
$filterOpt |= FILTER_FLAG_IPV4;
break;