diff options
Diffstat (limited to 'html/maintenance.php')
-rw-r--r-- | html/maintenance.php | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/html/maintenance.php b/html/maintenance.php index 18230df..c74b924 100644 --- a/html/maintenance.php +++ b/html/maintenance.php @@ -31,36 +31,7 @@ if (array_key_exists('drop',$_GET) && ($_GET['drop']=='DROP')) { } if (array_key_exists('machine',$_GET)) { - $stm = $db -> prepare('SELECT COUNT(1) FROM machines WHERE machines.name=:name'); - $stm -> bindValue('name', $_GET['machine']); - $result = $stm -> execute(); - $result = $result -> fetchArray(); - $stm -> close(); - - if ($result[0] == 0) { - $stm = $db -> prepare('INSERT INTO machines (name) VALUES (:machine)'); - $stm -> bindValue('machine', $_GET['machine']); - $stm -> execute(); - $machine_id = $db -> lastInsertRowID(); - $stm -> close(); - - $stm = $db -> prepare( - 'INSERT INTO "values" (machine_id, state_id) VALUES (:machine, :state)' - ); - $stm -> bindValue('machine', $machine_id); - $result = $db -> query( - 'SELECT states.name, states.id FROM states' - ); - while ($row = $result -> fetchArray()) { - if ($row['name'] == 'running') - $running_id = $row['id']; - $stm -> bindValue('state', $row['id']); - $stm -> execute(); - } - $stm -> close(); - - $db -> add_key_for($machine_id, $running_id, 'self'); - } + $db -> add_machine($_GET['machine']); if (array_key_exists('new_key', $_GET) && array_key_exists('comment', $_GET)) $db -> add_key_for($_GET['machine'], $_GET['new_key'], $_GET['comment']); |