<html>
<head>

<title>KATRIN Spectrometer and Detector Section Status Overview</title>

<style type="text/css">
	body      { font-family:Calibri,Arial; }
	a:link    { text-decoration:none; }
	a:visited { text-decoration:none; }
	a:hover   { text-decoration:none; }
	a:active  { text-decoration:none; }
	a:focus   { text-decoration:none; }
</style>

<head>
  <link rel="stylesheet" href="pics/beamline_cw2017.png" />
  <link rel="stylesheet" href="pics/spectrometer.png" />
  <link rel="stylesheet" href="pics/katrin_logo.jpg" />
  <link rel="stylesheet" href="pics/newEmail.png" />
</head>

<?php
  // get client ip adress to check whether computer is on-site or not

  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']; }

$onsite = false;
$slowrefresh = false;

if (substr($ip, 0, 6) == "141.52")
     { if (substr($ip, 0, 9) == "141.52.16")
         { echo '<meta http-equiv="refresh" content="10">'; $onsite = true; }
       else echo '<meta http-equiv="refresh" content="30">'; $onsite = true; }
else { echo '<meta http-equiv="refresh" content="120">'; $slowrefresh= true; }

?>

</head>
<body>

<?php

      // include helper functions
      include "SDS_status_functions.php";

      // include channel list
      include "SDS_status_channels.php";

      // read cached ADEI data
      $valuesincluded = 0;
      $loop = 0;
      $includeflag = 0;
      do {
        $includeflag = include 'ADEIvalues.php'; 
        $loop++;
        if ($valuesincluded == 0) usleep(100000);
        }
      while (($loop < 21) && ($includeflag+$valuesincluded < 2));
      if ($valuesincluded == 0) $extraction_time = "Request timed out!".PHP_EOL;
      //echo $loop."  ".$includeflag."  ".$valuesincluded.PHP_EOL;
      

	// ########## TIME STAMP ##########

	echo '<font size="6" color="#000000"><b>KATRIN Spectrometer and Detector Section Status Overview</b></font><br>';
	echo '<font size="4" color="#000000">Page refreshed:&emsp;' . date(DATE_RFC822) . '</font><br>';
	echo '<font size="4" color="#000000">Data extracted:&ensp;&thinsp;&thinsp;&thinsp;' . $extraction_time . ' </font><br>';
//('.  date("s", time() - $extraction_timestamp).'&thinsp;s old data)<br>';
        if ($errorcount >0) echo $errormessage;
?>


<div style="position:absolute; top:150px; left:0px">
<img src="pics/beamline_cw2017.png">

<div style="position:absolute; top:20px; left:315px">
<img src="pics/spectrometer.png" width="1130" height="596">
</div>

<div style="position:absolute; top:-140px; left:1800px">
<img src="pics/katrin_logo.jpg" width="100" height="100">
</div>

<div style="position: absolute; top: 60px; left:1670px">
<iframe src="https://uhr.ptb.de" scrolling="no" style="height: 230px; border: 0px none; width: 230px; margin-bottom: 0px; margin-left: 0px;">
</iframe>
</div>

<a href="mailto:thuemmler@kit.edu">
<div title="send email to Thomas Thuemmler" style="position:absolute; top:-50px; left:8px">
<img src="pics/newEmail.png" width="23" height="23">
</div>
</a>

<?php
    // include SDS status main page
    if ($valuesincluded == 1) include "SDS_status_main.php";
?>


</body>
</html>
