summaryrefslogtreecommitdiff
path: root/html/update.php
blob: 9e9d39b054ce57656e4af22a82c393a95749481d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

if (!array_key_exists('key', $_GET)) {
  echo 'key missing.' . "\n";
  die();
}

if (!array_key_exists('machine', $_GET)) {
  echo 'machine missing.' . "\n";
  die();
}

include "db.php";

$stm = $db -> prepare(
  'SELECT permissions.machine_id, permissions.state_id' .
  ' FROM permissions' .
  ' JOIN machines ON permissions.machine_id = machines.id' .
  ' JOIN states ON permissions.state_id = states.id' .
  ' JOIN keys ON permissions.key_id = keys.id' .
  ' WHERE machines.name = :machine' .
  ' AND states.name = :state' .
  ' AND keys.key = :key'
);
$stm -> bindValue('key', $_GET['key']);
$stm -> bindValue('machine', $_GET['machine']);

foreach ($_GET as $state => $value) {
  if (($state == 'key') || ($state == 'machine'))
    continue;
  $stm -> bindValue('state', $state);
  $stm -> bindValue('value', $value);
  $stm -> execute();
}

echo 'ok' . "\n";