Fix UUID generation and message for success in icon marketplace upload
This commit is contained in:
@@ -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();
|
||||||
@@ -92,4 +92,11 @@ function getPostData() {
|
|||||||
$decrypted[$decKey] = $decValue;
|
$decrypted[$decKey] = $decValue;
|
||||||
}
|
}
|
||||||
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));
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user