<?php
session_start();

if (!isset($_REQUEST['scheduleMode'])) {
    http_response_code(400);
    echo 'Missing scheduleMode';
    exit;
}

$raw   = trim((string)$_REQUEST['scheduleMode']);
$lower = strtolower($raw);

// Normalise to string "0"/"1" ONLY
if ($lower === 'light' || $raw === '1') {
    $_SESSION['scheduleMode'] = '1';
} elseif ($lower === 'default' || $raw === '0') {
    $_SESSION['scheduleMode'] = '0';
} else {
    http_response_code(400);
    echo 'Invalid mode';
    exit;
}

echo 'ok';
