<?php

	$ts = time();  
	$ip = "none";
  if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    $ip = $_SERVER['HTTP_CLIENT_IP'];
  } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  } else {
    $ip = $_SERVER['REMOTE_ADDR'];
  }

  session_start(); 
  // if (!isset($_SESSION['relayup'])) {header("location:index.html?ts=$ts"); exit();}

  // if (!isset($_SESSION['relayup'])) {header("location: /");; exit();}
  if (!isset($_SESSION['relayup'])) {
    // Session is not valid
    http_response_code(401); // Unauthorized
    header('Content-Type: application/json');
    echo json_encode(["success" => false, "message" => "Session invalid or expired"]);
    exit();
}
  // echo json_encode(["success" => true, "message" => "Session Valid"]);
//  if (!isset($_SESSION['ip']))    {header("location:index.html?ts=$ts"); exit();}
//  if ($ip != $_SESSION['ip'])     {header("location:index.html?ts=$ts"); exit();}

  require './ZZ_versions.php';
  require './ZZ_webstatus.php';
?>