<?php
/**
 * Server Logout API
 * Handles server logout
 */

session_start();
require 'config.php';

header('Content-Type: application/json');

// Check if server is logged in
if (!isset($_SESSION['server_id'])) {
    sendResponse(false, 'Not authenticated', null);
}

$server_id = $_SESSION['server_id'];

// Update server status to offline
$update_sql = "UPDATE servers SET is_online = FALSE WHERE id = " . intval($server_id);
$conn->query($update_sql);

// Destroy session
session_destroy();

sendResponse(true, 'Logout successful', null);
?>
