<?php

header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

if(!isset($_REQUEST['hostname'])) {
  $hostname = "host not known";
} else {
  $hostname = $_REQUEST['hostname'];
}

$settings = json_decode(file_get_contents("../settings.json"), true);

if(isset($settings['screens'][$hostname])) {
  header("Location: /screen/screenRender.php?hostname=$hostname");
  exit;
} else {
  date_default_timezone_set("UTC");
  $num = rand(1,8);
}

?>
<!DOCTYPE html>
<html>
<head>
	<title>NOC Screen</title>
	<style type="text/css">

	body { background-repeat: no-repeat; background-image: url('/screen/background-00<?php echo $num; ?>.jpg'); background-size: cover; }

	.content {
		width:200px;
		height:125px;
		position:absolute;
		left:50%;
		top:50%;
		margin:-75px 0 0 -135px;
		color: white;
	}

	.sitename {
		position: absolute;
		left: 0%;
		bottom: 0%;
		margin: 15px 15px 15px 15px;
		padding: 10px;
		color: rgb(21,55,96);
		font-family: sans-serif;
		font-size: 48px;
		text-align: left;
		background-color: rgba(202,202,202,0.6);
		border-radius: 15px;
	}
	</style>
	<meta http-equiv="refresh" content="60">
</head>

<body>

<div class="content">

</div>

<div class="sitename">
<center><img src='/screen/logo.png' alt='' width=150px valign=middle /><font style='font-size: 81px;'>&nbsp;<b>screen ip</b></font></center>
<center><b><font style='font-size: 64px;'><?=$_SERVER['REMOTE_ADDR'];?></font></b><br/>unadopted - <?=$hostname?> - will refresh in 60 seconds</center>
</div>
</body>
</html>

