summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2022-07-28 11:29:48 +0200
committerErich Eckner <git@eckner.net>2022-07-28 11:29:48 +0200
commitdf0ace6fac9927e9d35182b07f97731de1ffe976 (patch)
treee0ec2d6873e1991ab03b13414fafebde4be2a187
parent677a1b1593d46c39b54e14f78f33b95512155602 (diff)
downloadcolocation-df0ace6fac9927e9d35182b07f97731de1ffe976.tar.xz
lights_out_machines: find name fuzzier
-rw-r--r--html/maintenance.php15
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');
}