blob: ac8f4716d4a436e4244d981c3a39ba1aebe69759 (
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
37
38
39
40
41
42
43
44
|
<?php
if (!array_key_exists('key', $_GET)) {
echo 'key missing.' . "\n";
die();
}
if (!array_key_exists('machine', $_GET)) {
echo 'machine missing.' . "\n";
die();
}
$db = new SQLite3('/srv/http/vhosts/eckner.net/colocation.eckner.net/backend/sqlite.db');
$stm = $db -> prepare(
'SELECT permissions.name' .
' FROM machines' .
' JOIN granted_permissions ON granted_permissions.machine_id = machines.id' .
' JOIN keys on granted_permissions.key_id = keys.id' .
' JOIN permissions on granted_permissions.permission_id = permissions.id' .
' WHERE keys.key=:key' .
' AND machines.name=:machine');
$stm -> bindValue('key', $_GET['key']);
$stm -> bindValue('machine', $_GET['machine']);
$result = $stm -> execute();
while($row = $result -> fetchArray()) {
if (!array_key_exists($row['name'], $_GET))
continue;
$value = $_GET[$row['name']];
if (($value != 0) && ($value != 1))
continue;
$updstm = $db -> prepare(
'UPDATE machines SET ' . $row['name'] . ' = :value WHERE machines.name=:machine'
);
$updstm -> bindValue('value', $value);
$updstm -> bindValue('machine', $_GET['machine']);
$updstm -> execute();
$updstm -> close();
}
$stm -> close();
|