From cd14afb5d3cf88f8442178846969c2570ca15c2e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 15 Jul 2022 13:58:31 +0200 Subject: initial commit --- backend/.gitignore | 1 + html/index.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 backend/.gitignore create mode 100644 html/index.php diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..c65ee56 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1 @@ +sqlite.db diff --git a/html/index.php b/html/index.php new file mode 100644 index 0000000..0964dc3 --- /dev/null +++ b/html/index.php @@ -0,0 +1,52 @@ + prepare('SELECT COUNT(1) FROM machines WHERE machines.name=:name'); + $stm -> bindValue('name', $_GET['new']); + $result = $stm -> execute(); + $result = $result -> fetchArray(); + $stm -> close(); + + if ($result[0] == 0) { + $stm = $db -> prepare('INSERT INTO machines (name,key,online) VALUES (:name,:key,0)'); + $stm -> bindValue('name', $_GET['new']); + $stm -> bindValue('key', bin2hex(random_bytes(64))); + $stm -> execute(); + $stm -> close(); + } + + $stm = $db -> prepare('SELECT machines.key FROM machines WHERE machines.name=:name'); + $stm -> bindValue('name', $_GET['new']); + $result = $stm -> execute(); + $result = $result -> fetchArray(); + echo 'key = ' . $result['key'] . "\n"; + die(); + } +} + +$columns = array('name', 'online', 'last_update'); + +$result = $db -> query('SELECT machines.name,machines.online,machines.last_update FROM machines;'); + +echo '' . "\n"; +echo '' . "\n"; +echo '' . "\n"; +echo ' ' . "\n"; +foreach ($columns as $column) { + echo ' ' . "\n"; +} +echo ' ' . "\n"; + +while ($row = $result -> fetchArray()) { + echo ' ' . "\n"; + foreach ($columns as $column) { + echo ' ' . "\n"; + } + echo ' ' . "\n"; +} +echo '
' . $column . '
' . $row[$column] . '
' . "\n"; +echo '' . "\n"; +echo '' . "\n"; -- cgit v1.2.3-54-g00ecf