Fix UUID generation and message for success in icon marketplace upload

This commit is contained in:
2025-08-24 21:55:53 -07:00
parent b80be97f18
commit a503506f3b
2 changed files with 9 additions and 5 deletions

View File

@@ -1,11 +1,8 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
require __DIR__ . '/../../../../vendor/autoload.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion(); checkClientDatabaseVersion();
use Ramsey\Uuid\Uuid;
$post = getPostData(); $post = getPostData();
$token = $post['token'] ?? ''; $token = $post['token'] ?? '';
$username = $post['username'] ?? ''; $username = $post['username'] ?? '';
@@ -47,7 +44,7 @@ if ($result->fetch_assoc()) {
} }
$stmt->close(); $stmt->close();
$uuid = Uuid::uuid4()->toString(); $uuid = uuidv4();
$stmt = $conn->prepare("INSERT INTO marketplaceicons (uuid, userId, data, hash, price, name, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmt = $conn->prepare("INSERT INTO marketplaceicons (uuid, userId, data, hash, price, name, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sissisi", $uuid, $id, $filecontent, $hash, $price, $name, $time); $stmt->bind_param("sissisi", $uuid, $id, $filecontent, $hash, $price, $name, $time);
@@ -55,6 +52,6 @@ $stmt->execute();
$insertId = $conn->insert_id; $insertId = $conn->insert_id;
$stmt->close(); $stmt->close();
echo encrypt(json_encode(["success" => true])); echo encrypt(json_encode(["success" => true, "message" => "Icon uploaded successfully! It will be reviewed and accepted or denied soon"]));
$conn->close(); $conn->close();

View File

@@ -93,3 +93,10 @@ function getPostData() {
} }
return $decrypted; return $decrypted;
} }
function uuidv4() {
$data = random_bytes(16);
$data[6] = chr((ord($data[6]) & 0x0f) | 0x40);
$data[8] = chr((ord($data[8]) & 0x3f) | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}