-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.php
43 lines (33 loc) · 981 Bytes
/
helpers.php
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
35
36
37
38
39
40
41
42
43
<?php
function isServerValidated($conn, $server_id, $server_secret_key){
// Check that the server secret key matches the server id's secret key
$sql = "SELECT server_id FROM Servers WHERE server_id = ? AND server_secret_key = ?";
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param("is", $server_id, $server_secret_key);
$stmt->execute();
$result = $stmt->get_result();
// Ensure that the server is validated
if($result->num_rows == 0){
return false;
} else {
return true;
}
}
function getUserId($conn, $uuid){
// Check that the server secret key matches the server id's secret key
$sql = "SELECT user_id FROM Users WHERE uuid = ?";
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param("s", $uuid);
$stmt->execute();
$result = $stmt->get_result();
// Ensure that the server is validated
if($result->num_rows == 1){
$row = $result->fetch_assoc();
return $row["user_id"];
} else {
return -1;
}
}
?>