Small API Improvements

This commit is contained in:
Lncvrt committed 2025-03-02 13:11:20 -07:00
1 parent b5aa0fd219
commit c2fb61afaa
18 files changed
+44 -74

No files matched your search

+1 -4
View File
@@ -23,7 +23,7 @@ function generateRandomString($length) {
return $randomString;
}
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
$session = $_COOKIE['session'] ?? '';
if (isset($session) && empty($session)) {
$response = [
@@ -64,7 +64,4 @@ if ($result->num_rows > 0) {
header('Content-Type: application/json');
die(json_encode($response));
}
$stmt->close();
$conn->close();
?>
+1 -1
View File
@@ -15,7 +15,7 @@ if ($conn->connect_error) {
die(json_encode($response));
}
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
$session = $_COOKIE['session'] ?? '';
$stmt = $conn->prepare("SELECT * FROM users WHERE session = ?");
$stmt->bind_param("s", $session);
+1 -4
View File
@@ -14,7 +14,7 @@ if ($conn->connect_error) {
die(json_encode($response));
}
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
$session = $_COOKIE['session'] ?? '';
if (isset($session) && empty($session)) {
$response = [
@@ -51,7 +51,4 @@ if ($result->num_rows > 0) {
header('Content-Type: application/json');
die(json_encode($response));
}
$stmt->close();
$conn->close();
?>
+1 -1
View File
@@ -14,7 +14,7 @@ if ($conn->connect_error) {
die(json_encode($response));
}
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
$session = $_COOKIE['session'] ?? '';
if (isset($session) && empty($session)) {
$response = [
+1 -1
View File
@@ -14,7 +14,7 @@ if ($conn->connect_error) {
die(json_encode($response));
}
$key = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
$key = $_SERVER['HTTP_KEY'] ?? '';
$stmt = $conn->prepare("SELECT * FROM users WHERE api_key = ?");
$stmt->bind_param("s", $key);
+7 -11
View File
@@ -15,12 +15,12 @@ if ($conn->connect_error) {
die(json_encode($response));
}
$apiKey = isset($_POST['key']) ? $_POST['key'] : null;
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : null;
$country = isset($_POST['country']) ? $_POST['country'] : null;
$timezone = isset($_POST['timezone']) ? $_POST['timezone'] : null;
$dateformat = isset($_POST['dateformat']) ? $_POST['dateformat'] : null;
$timeformat = isset($_POST['timeformat']) ? $_POST['timeformat'] : null;
$apiKey = $_POST['key'] ?? null;
$session = $_COOKIE['session'] ?? null;
$country = $_POST['country'] ?? null;
$timezone = $_POST['timezone'] ?? null;
$dateformat = $_POST['dateformat'] ?? null;
$timeformat = $_POST['timeformat'] ?? null;
$query = "UPDATE users SET ";
$params = [];
@@ -31,7 +31,6 @@ if ($country !== null) {
if (!in_array($country, $countries)) {
$country = null;
die('{"success": false, "response": "Invalid country" }');
return;
}
$query .= "country = ?, ";
@@ -141,7 +140,4 @@ if ($stmt->execute()) {
header('Content-Type: application/json');
die(json_encode($response));
}
$stmt->close();
$stmt->close();
$conn->close();
?>