From edb5e3a163b6e08fc480afafc441e3de05286e1e Mon Sep 17 00:00:00 2001 From: Konstantin Protzen Date: Wed, 22 Nov 2023 18:59:28 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Add=20random=20entryID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework/add/add.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/homework/add/add.php b/homework/add/add.php index fb72921..eca2057 100644 --- a/homework/add/add.php +++ b/homework/add/add.php @@ -38,9 +38,12 @@ // Create given-date $date_given = date("Y-m-d"); -// Add subject to DB and get inserted ID -if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, subject, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { - $stmt->bind_param('sisssss', $_SESSION["user_id"], $subject, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]); +// Generate id (8char random string) +$entryId = bin2hex(random_bytes(4)); + +// Add subject to DB +if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, entry_id, subject, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')) { + $stmt->bind_param('ssssssss', $_SESSION["user_id"], $entryId, $subject, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); exit("success"); From 4c78f5db254296dabc9ce1fee9befd196736af57 Mon Sep 17 00:00:00 2001 From: Konstantin Protzen Date: Wed, 22 Nov 2023 19:06:46 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20renamed=20db=20column?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homework/index.php b/homework/index.php index 2889adf..cf5db55 100644 --- a/homework/index.php +++ b/homework/index.php @@ -115,7 +115,7 @@ foreach ($hw_dategroup as $hw_entry) { echo '
'; echo '
'; - foreach ($subjects as $subject) if ($subject["id"] == $hw_entry["class"]) echo $subject["name"]; + foreach ($subjects as $subject) if ($subject["id"] == $hw_entry["subject"]) echo $subject["name"]; echo '
' . $hw_entry["text"] . '
'; echo '
'; if ($hw_entry["status"] == 0) echo '
';