Add device vendor (if available) to info string shown in the select dropdown

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-05-14 18:35:47 +02:00
parent 3e1a1f59aa
commit 8c53844ef3
+14 -2
View File
@@ -208,7 +208,7 @@ if ($_POST['action'] == 'get_groups') {
$QUERYDB = getQueriesDBFilename();
$FTLdb = SQLite3_connect($QUERYDB);
$query = $FTLdb->query('SELECT DISTINCT id,hwaddr FROM network;');
$query = $FTLdb->query('SELECT DISTINCT id,hwaddr,macVendor FROM network;');
if (!$query) {
throw new Exception('Error while querying FTL\'s database: ' . $db->lastErrorMsg());
}
@@ -222,7 +222,19 @@ if ($_POST['action'] == 'get_groups') {
while ($res_names = $query_names->fetchArray(SQLITE3_ASSOC)) {
array_push($names, utf8_encode($res_names["name"]));
}
$ips[strtoupper($res['hwaddr'])] = implode(",", $names);
$extrainfo = "";
// Add device vendor to info string (if available)
if (strlen($res["macVendor"]) > 0) {
$extrainfo = "vendor: ".htmlspecialchars($res["macVendor"]);
if (count($names) > 0)
$extrainfo .= ", ";
}
// Add list of associated host names to info string (if available)
if(count($names) === 1)
$extrainfo .= "hostname: ".$names[0];
else if(count($names) > 0)
$extrainfo .= "hostnames: ".implode(", ", $names);
$ips[strtoupper($res['hwaddr'])] = $extrainfo;
}
$FTLdb->close();