From df0ace6fac9927e9d35182b07f97731de1ffe976 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 28 Jul 2022 11:29:48 +0200 Subject: lights_out_machines: find name fuzzier --- html/maintenance.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/html/maintenance.php b/html/maintenance.php index c7f608f..39b0724 100644 --- a/html/maintenance.php +++ b/html/maintenance.php @@ -69,7 +69,20 @@ if (array_key_exists('lights_out_machines', $_GET)) { $power_id = $db -> get_state_id('power'); $ping_id = $db -> get_state_id('ping'); while ($row = $result -> fetchArray()) { - $machine_id = $db -> get_machine_id(substr($row['machine'],0,-3)); + unset($machine_id); + foreach ($db -> get_machines() as $machine) { + if ($machine['machine'] == substr($row['machine'],0,-3)) { + $machine_id = $machine['machine_id']; + break; + } + } + if (!isset($machine_id)) + foreach ($db -> get_machines() as $machine) { + if ($machine['machine'] == substr($row['machine'],0,strlen($machine['machine']))) { + $machine_id = $machine['machine_id']; + break; + } + } $db -> add_key_for($machine_id, $power_id, 'lights-out'); $db -> add_key_for($machine_id, $ping_id, 'lights-out'); } -- cgit v1.2.3-54-g00ecf