false, "title" => "Missing parameters" ]; echo json_encode($response); exit; } // Get user from API key $sql = "SELECT * FROM user WHERE api_key = :apiKey"; $stmt = $db->prepare($sql); $stmt->bindValue(':apiKey', $apiKey); $result = $stmt->execute(); $user = $result->fetchArray(SQLITE3_ASSOC); // If the user is not found, return an error if (!$user) { $response = [ "success" => false, "title" => "Invalid API key" ]; echo json_encode($response); exit; } $userId = $user['id']; if ($userId !== 1) { $response = [ "success" => false, "title" => "Invalid user" ]; echo json_encode($response); exit; } $sql = "SELECT * FROM 'admin'"; $stmt = $db->prepare($sql); $stmt->bindValue(':userId', $userId); $result = $stmt->execute(); $admin_settings = $result->fetchArray(SQLITE3_ASSOC); if ($admin_settings) { unset($admin_settings['id']); // if the smtp_password is set, hide it if (isset($admin_settings['smtp_password'])) { $admin_settings['smtp_password'] = "********"; } } $response = [ "success" => true, "title" => "admin_settings", "admin_settings" => $admin_settings, "notes" => [] ]; echo json_encode($response); $db->close(); } else { $response = [ "success" => false, "title" => "Invalid request method" ]; echo json_encode($response); exit; } ?>