<?php

# Load state and test switch
$state = json_decode(file_get_contents("state.json"), true);
$switch = $state["switch"];

# Load open/closed level depending on switch
$data = file_get_contents( $switch ? "01.json" : "01_closed.json");

// Patch php filenames with timestamps to defeat cache
//   destination.php --> destination.number.php
$tstamp = round(microtime(true)*100);  # 0.01 sec resolution
$data = str_replace(".php", ".".$tstamp.".php", $data);

header('Content-type: application/json');
echo($data);
exit;
    
    
?>