diff options
-rw-r--r-- | html/maintenance.php | 15 |
1 files changed, 14 insertions, 1 deletions
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'); } |