From 0e9df927307ec69060f5005c329e4c24fa2e5b5c Mon Sep 17 00:00:00 2001 From: fusionate Date: Thu, 25 May 2023 15:42:50 +0000 Subject: [PATCH] Device Vendor - Defaults: Updates for PHP 8.1 --- app/devices/device_vendor_restore.php | 57 ++++++++++++++------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/app/devices/device_vendor_restore.php b/app/devices/device_vendor_restore.php index bee19ace54..ab3345e2c9 100644 --- a/app/devices/device_vendor_restore.php +++ b/app/devices/device_vendor_restore.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2016 - 2022 + Portions created by the Initial Developer are Copyright (C) 2016-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -71,6 +71,7 @@ if ($num_rows == 0) { //get the vendor array + $x = 0; require_once $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/devices/app_config.php'; //get the groups and create an array to use the name to get the uuid @@ -87,7 +88,7 @@ unset($sql); //create insert array - $x = 0; $z = 0; + $x = $z = 0; foreach ($vendors as $vendor) { //insert the data into the database $device_vendor_uuid = uuid(); @@ -97,32 +98,34 @@ //add the device vendor functions $y = 0; - foreach ($vendor['functions'] as $function) { - //add the device vendor function - $device_vendor_function_uuid = uuid(); - $array['device_vendors'][$x]['device_vendor_functions'][$y]['device_vendor_uuid'] = $device_vendor_uuid; - $array['device_vendors'][$x]['device_vendor_functions'][$y]['device_vendor_function_uuid'] = $device_vendor_function_uuid; - //$array['device_vendors'][$x]['device_vendor_functions'][$y]['label'] = $function['label']; - $array['device_vendors'][$x]['device_vendor_functions'][$y]['type'] = $function['type']; - $array['device_vendors'][$x]['device_vendor_functions'][$y]['subtype'] = $function['subtype']; - $array['device_vendors'][$x]['device_vendor_functions'][$y]['value'] = $function['value']; - $array['device_vendors'][$x]['device_vendor_functions'][$y]['enabled'] = 'true'; - $array['device_vendors'][$x]['device_vendor_functions'][$y]['description'] = $function['description']; + if (!empty($vendor['functions']) && is_array($vendor['functions']) && @sizeof($vendor['functions']) != 0) { + foreach ($vendor['functions'] as $function) { + //add the device vendor function + $device_vendor_function_uuid = uuid(); + $array['device_vendors'][$x]['device_vendor_functions'][$y]['device_vendor_uuid'] = $device_vendor_uuid; + $array['device_vendors'][$x]['device_vendor_functions'][$y]['device_vendor_function_uuid'] = $device_vendor_function_uuid; + //$array['device_vendors'][$x]['device_vendor_functions'][$y]['label'] = $function['label']; + $array['device_vendors'][$x]['device_vendor_functions'][$y]['type'] = $function['type'] ?? null; + $array['device_vendors'][$x]['device_vendor_functions'][$y]['subtype'] = $function['subtype'] ?? null; + $array['device_vendors'][$x]['device_vendor_functions'][$y]['value'] = $function['value']; + $array['device_vendors'][$x]['device_vendor_functions'][$y]['enabled'] = 'true'; + $array['device_vendors'][$x]['device_vendor_functions'][$y]['description'] = $function['description'] ?? null; - //add the device vendor function groups - if (is_array($function['groups']) && @sizeof($function['groups']) != 0) { - foreach ($function['groups'] as $group_name) { - $device_vendor_function_group_uuid = uuid(); - $array['device_vendor_function_groups'][$z]['device_vendor_function_group_uuid'] = $device_vendor_function_group_uuid; - $array['device_vendor_function_groups'][$z]['device_vendor_function_uuid'] = $device_vendor_function_uuid; - $array['device_vendor_function_groups'][$z]['device_vendor_uuid'] = $device_vendor_uuid; - $array['device_vendor_function_groups'][$z]['group_name'] = $group_name; - $array['device_vendor_function_groups'][$z]['group_uuid'] = $group_uuids[$group_name]; - $z++; + //add the device vendor function groups + if (is_array($function['groups']) && @sizeof($function['groups']) != 0) { + foreach ($function['groups'] as $group_name) { + $device_vendor_function_group_uuid = uuid(); + $array['device_vendor_function_groups'][$z]['device_vendor_function_group_uuid'] = $device_vendor_function_group_uuid; + $array['device_vendor_function_groups'][$z]['device_vendor_function_uuid'] = $device_vendor_function_uuid; + $array['device_vendor_function_groups'][$z]['device_vendor_uuid'] = $device_vendor_uuid; + $array['device_vendor_function_groups'][$z]['group_name'] = $group_name; + $array['device_vendor_function_groups'][$z]['group_uuid'] = $group_uuids[$group_name]; + $z++; + } } - } - //increment the device vendor function index - $y++; + //increment the device vendor function index + $y++; + } } //increment the devic vendor index @@ -157,4 +160,4 @@ header('Location: device_vendors.php'); exit; -?> +?> \ No newline at end of file