From 6ff3ae8789b13b73b3b268a52e73639ff7c7ebcd Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 13 Jan 2017 05:47:13 +0000 Subject: [PATCH] fix: Detection blank or unknown device types and update #5412 (#5414) * fix: Detection blank or unknown device types and update #5412 * Less ifs --- includes/common.php | 9 +++++---- includes/discovery/os.inc.php | 7 ------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/includes/common.php b/includes/common.php index cf00123f52..3cb9305ec2 100644 --- a/includes/common.php +++ b/includes/common.php @@ -1527,10 +1527,11 @@ function load_os(&$device) ); // Set type to a predefined type for the OS if it's not already set - if ($device['type'] == 'unknown' || $device['type'] == '') { - if ($config['os'][$device['os']]['type']) { - $device['type'] = $config['os'][$device['os']]['type']; - } + if ($config['os'][$device['os']]['type'] != $device['type']) { + log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system'); + $device['type'] = $config['os'][$device['os']]['type']; + dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id'])); + echo "Device type changed to " . $device['type'] . "!\n"; } if ($config['os'][$device['os']]['group']) { diff --git a/includes/discovery/os.inc.php b/includes/discovery/os.inc.php index da181b998e..afe5d2ae50 100644 --- a/includes/discovery/os.inc.php +++ b/includes/discovery/os.inc.php @@ -15,10 +15,3 @@ if ($icon != $device['icon']) { $sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id'])); echo "Changed Icon! : $icon\n"; } - -if ($config['os'][$device['os']]['type'] != $device['type']) { - log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system'); - $device['type'] = $config['os'][$device['os']]['type']; - $sql = dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id'])); - echo "Changed Type! : ".$device['type'].PHP_EOL; -}