summaryrefslogtreecommitdiff
path: root/html/db.php
diff options
context:
space:
mode:
Diffstat (limited to 'html/db.php')
-rw-r--r--html/db.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/html/db.php b/html/db.php
index 7af33f9..f638286 100644
--- a/html/db.php
+++ b/html/db.php
@@ -25,9 +25,10 @@ class MyDB extends SQLite3 {
die();
return $result;
}
- function add_key() {
- $stm = $this -> prepare('INSERT INTO keys (key) VALUES (:key)');
+ function add_key($comment) {
+ $stm = $this -> prepare('INSERT INTO keys (key) VALUES (:key, :comment)');
$stm -> bindValue('key', bin2hex(random_bytes(64)));
+ $stm -> bindValue('comment', $comment);
$stm -> execute();
$key_id = $this -> lastInsertRowID();
$stm -> close();
@@ -62,8 +63,8 @@ class MyDB extends SQLite3 {
$stm -> close();
return $result['value_id'];
}
- function add_key_for($machine, $state) {
- $key_id = $this -> add_key();
+ function add_key_for($machine, $state, $comment) {
+ $key_id = $this -> add_key($comment);
$value_id = $this -> get_value_id_of($machine, $state);
$stm = $this -> prepare(
'INSERT INTO permissions (key_id, value_id) VALUES (:key,:value)');