-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsetcode.php
More file actions
34 lines (30 loc) · 949 Bytes
/
setcode.php
File metadata and controls
34 lines (30 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
//Disable Including the File
if (get_included_files()[0] != __FILE__) {
return;
}
include_once "main.php";
include_once "database.php";
$GameId = "11579308676";
if (!isset($_POST["SecretKey"]) or !isset($_POST["UserId"]) or !isset($_POST["Code"])) {
http_response_code(400);
exit("400 Bad Request");
}
$SecretKey = strval($_POST["UserId"]).$GameId.strval($_POST["Code"]);
$SecretKey = hash("sha256", $SecretKey);
if (strtolower($_POST["SecretKey"]) != $SecretKey) {
http_response_code(401);
exit("401 Unauthorized");
}
if (str_word_count($_POST["Code"]) != 16) {
exit(json_encode([
"success" => false,
"error" => "Code Must be 16 Words"
]));
}
$code = strtolower($_POST["Code"]);
$userId = strval($_POST["UserId"]);
$conn->queryPrepared("UPDATE `user` SET `description` = ? WHERE `user_id` = ?", [$code, $userId]);
exit(json_encode([
"success" => true
]));