www/includes/db_profile_mash.php

changeset 785
aa79acfdf8a9
parent 768
ae1195153fa2
--- a/www/includes/db_profile_mash.php	Sun Feb 06 20:06:46 2022 +0100
+++ b/www/includes/db_profile_mash.php	Thu Feb 10 22:15:10 2022 +0100
@@ -25,7 +25,14 @@
 	if (isset($_POST['update'])) {
 		$sql  = "UPDATE";
 	}
-	$sql .= " `profile_mash` SET name='" . mysqli_real_escape_string($connect, $_POST['name']);
+	$sql .= " `profile_mash` SET ";
+	if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) {
+                $sql .= "uuid='" . $_POST['uuid'];
+        } else {
+                $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
+                $sql .= "uuid='" . $uuid;
+        }
+	$sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
 	$sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
 	$array = $_POST['steps'];
 	$comma = FALSE;
@@ -74,7 +81,7 @@
 
 } else {
 	// SELECT COMMAND
-	$query = "SELECT record,JSON_QUOTE(name),JSON_QUOTE(notes),steps FROM profile_mash ORDER BY name";
+	$query = "SELECT record,JSON_QUOTE(name),JSON_QUOTE(notes),steps,JSON_QUOTE(uuid) FROM profile_mash ORDER BY name";
 	$result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
 	$mashprofiles = '[';
 	$comma = FALSE;
@@ -87,7 +94,8 @@
 		$mashprofile  = '{"record":' . $row['record'];
 		$mashprofile .= ',"name":'  . $row['JSON_QUOTE(name)'];
 		$mashprofile .= ',"notes":' . $row['JSON_QUOTE(notes)'];
-		$mashprofile .= ',"steps":' . $row['steps'] . '}';
+		$mashprofile .= ',"steps":' . $row['steps'];
+	        $mashprofile .= ',"uuid":'  . $row['JSON_QUOTE(uuid)'] . '}';
 		$mashprofiles .= $mashprofile;
 	}
 	$mashprofiles .= ']';

mercurial