From bdc7f088337a606fcd50ab448f0a79278aabfc84 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 30 Dec 2022 14:00:42 +0100 Subject: [PATCH] PHP 8.1 support (round 2) --- plugins/dynamix/nchan/update_2 | 2 +- plugins/dynamix/scripts/diagnostics | 6 +++--- plugins/dynamix/scripts/monitor | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/dynamix/nchan/update_2 b/plugins/dynamix/nchan/update_2 index 22d204427..0dc373d82 100755 --- a/plugins/dynamix/nchan/update_2 +++ b/plugins/dynamix/nchan/update_2 @@ -190,7 +190,7 @@ function device_smart(&$disk, &$fail, &$smart) { exec("awk 'NR>7{print $1,$2,$4,$6,$9,$10}' ".escapeshellarg($file)." 2>/dev/null", $codes); foreach ($codes as $code) { if (!$code || !is_numeric($code[0])) continue; - [$id,$class,$value,$thres,$when,$raw] = explode(' ',$code); + [$id,$class,$value,$thres,$when,$raw] = my_explode(' ',$code,7); $failing = strpos($when,'FAILING_NOW')!==false; if (!$failing && !in_array($id,$events)) continue; if ($failing || ($select ? $thres>0 && $value<=$thres*$level : $raw>0)) $title .= normalize($class,$failing?$when:$raw); diff --git a/plugins/dynamix/scripts/diagnostics b/plugins/dynamix/scripts/diagnostics index ca7df1dca..ab65a8a14 100755 --- a/plugins/dynamix/scripts/diagnostics +++ b/plugins/dynamix/scripts/diagnostics @@ -118,7 +118,7 @@ function geturls_certdetails($file, $hostname, $ip="") { $data = implode("\n", $data); // determine cn preg_match('/ *commonName *= (.*)/', $data, $matches); - $cn = trim($matches[1]); + $cn = trim($matches[1]??''); if (strpos($cn, ".myunraid.net") !== false) { $type = 'myunraid.net'; $iphost = str_replace('.','-',$ip); @@ -136,7 +136,7 @@ function geturls_certdetails($file, $hostname, $ip="") { // replace wildcard with hostname $cn = str_replace('*', $hostname, $cn); $cn_priv = $cn; - if (strpos($data, "Self-signed") !== false){ + if (strpos($data??'', "Self-signed") !== false){ $type = 'self-signed'; } else { $type = 'user-provided'; @@ -471,7 +471,7 @@ foreach ($devices as $device) { // create pool btrfs information foreach ($pools as $pool) { - if (strpos($disks[$pool]['fsType'],'btrfs')!==false) { + if (strpos($disks[$pool]['fsType']??'','btrfs')!==false) { run("echo 'Pool: $pool'|todos >>".escapeshellarg("/$diag/system/btrfs-usage.txt")); run("/sbin/btrfs filesystem usage -T /mnt/$pool 2>/dev/null|todos >>".escapeshellarg("/$diag/system/btrfs-usage.txt")); } diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index ee3174218..6247bc415 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -74,7 +74,7 @@ function check_smart(&$disk,$port,$text,$info) { $item = 'smart'; foreach ($codes as $code) { if (!$code || !is_numeric($code[0])) continue; - [$id,$class,$value,$thres,$when,$raw] = explode(' ',$code); + [$id,$class,$value,$thres,$when,$raw] = my_explode(' ',$code,7); $fail = strpos($when,'FAILING_NOW')!==false; if (!$fail && !in_array($id,$events)) continue; $word = str_replace(['_',' (-)'],[' ',''],strtolower("$class ($when)"));