From 52d3b59d43d1c4894a38d47b9606c0f1cff95156 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 25 Jun 2018 21:02:25 +0000 Subject: Added group parameter to PHP pages and started on Load functionality. --- www/add.php | 7 +++++-- www/css/main.css | 3 +-- www/edit.php | 3 +++ www/get.php | 3 ++- www/index.html | 8 +++++++- www/scripts/main.js | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 6 deletions(-) diff --git a/www/add.php b/www/add.php index fe21344..7b9d99f 100644 --- a/www/add.php +++ b/www/add.php @@ -28,13 +28,16 @@ try $db = ConnectDB(); $description = $_REQUEST["description"]; + $group = $_REQUEST["group"]; $username = $_REQUEST["username"]; $password = $_REQUEST["password"]; $cmd = $db->prepare("INSERT INTO pm_store " . - "(description, username, password) values " . - "(:description, :username, :password)"); + "(description, groupname, username, password) ". + "values " . + "(:description, :group, :username, :password)"); $cmd->bindParam(":description", $description); + $cmd->bindParam(":group", $group); $cmd->bindParam(":username", $username); $cmd->bindParam(":password", $password); $cmd->execute(); diff --git a/www/css/main.css b/www/css/main.css index abc572b..558da6c 100644 --- a/www/css/main.css +++ b/www/css/main.css @@ -4,11 +4,10 @@ body font-size: large; } -span.smalltext +.smalltext { font-size: small; } - /* vim: sw=4 ts=4 */ diff --git a/www/edit.php b/www/edit.php index 9e78e88..7bcd604 100644 --- a/www/edit.php +++ b/www/edit.php @@ -29,15 +29,18 @@ try $id = $_REQUEST["id"]; $description = $_REQUEST["description"]; + $group = $_REQUEST["group"]; $username = $_REQUEST["username"]; $password = $_REQUEST["password"]; $cmd = $db->prepare("UPDATE pm_store " . "set description=:description, " . + "groupname=:group, " . "username=:username, " . "password=:password where id = :id"); $cmd->bindParam(":id", $id); $cmd->bindParam(":description", $description); + $cmd->bindParam(":group", $group); $cmd->bindParam(":username", $username); $cmd->bindParam(":password", $password); $cmd->execute(); diff --git a/www/get.php b/www/get.php index 268bf5b..d42e57e 100644 --- a/www/get.php +++ b/www/get.php @@ -29,11 +29,12 @@ try $index = 0; - foreach ($db->query("SELECT * FROM pm_store") as $row) + foreach ($db->query("SELECT * FROM pm_store ORDER BY id") as $row) { $data = array(); $data["id"] = $row["id"]; $data["description"] = $row["description"]; + $data["group"] = $row["groupname"]; $data["username"] = $row["username"]; $data["password"] = $row["password"]; diff --git a/www/index.html b/www/index.html index ad0c0ed..512ac8f 100644 --- a/www/index.html +++ b/www/index.html @@ -13,7 +13,13 @@ Passphrase:     - + +
+Group: + +   +
diff --git a/www/scripts/main.js b/www/scripts/main.js index e3c1f7b..d8f03ca 100644 --- a/www/scripts/main.js +++ b/www/scripts/main.js @@ -1,4 +1,6 @@ +var globalDb; + function AESEncrypt(source, phrase) { var encryptedAES = CryptoJS.AES.encrypt(source, phrase); @@ -13,4 +15,40 @@ function AESDecrypt(source, phrase) return decryptedBytes.toString(CryptoJS.enc.Latin1); } +function WebRequest(url, func, args) +{ + var f; + + for(f = 0; f < args.length; f += 2) + { + if (f == 0) + { + url += "?"; + } + else + { + url += "#"; + } + + url += args[f] + "="; + url += encodeURIComponent(args[f+1]); + } + + var req = new XMLHttpRequest(); + + req.addEventListener("load", func); + req.open("GET", url); + req.send(); +} + +function DoLoadAsync() +{ + globalDb = JSON.parse(this.responseText); +} + +function DoLoad() +{ + WebRequest("get.php", DoLoadAsync, []); +} + // vim: sw=4 ts=4 -- cgit v1.2.3