index.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <html>
  2. <head>
  3. <title>KATRIN Spectrometer and Detector Section Status Overview</title>
  4. <style type="text/css">
  5. body { font-family:Calibri,Arial; }
  6. a:link { text-decoration:none; }
  7. a:visited { text-decoration:none; }
  8. a:hover { text-decoration:none; }
  9. a:active { text-decoration:none; }
  10. a:focus { text-decoration:none; }
  11. </style>
  12. <head>
  13. <link rel="stylesheet" href="pics/beamline_noMoS.png" />
  14. <link rel="stylesheet" href="pics/spectrometer.png" />
  15. <link rel="stylesheet" href="pics/katrin_logo.jpg" />
  16. <link rel="stylesheet" href="pics/newEmail.png" />
  17. <!--
  18. <style>
  19. body {
  20. background-image: url("pics/bg.png");
  21. background-repeat: no-repeat;
  22. }
  23. </style>
  24. -->
  25. </head>
  26. <?php
  27. // get client ip adress to check whether computer is on-site or not
  28. if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  29. $ip = $_SERVER['HTTP_CLIENT_IP'];
  30. } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  31. $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  32. } else { $ip = $_SERVER['REMOTE_ADDR']; }
  33. $onsite = false;
  34. $slowrefresh = false;
  35. if (substr($ip, 0, 6) == "141.52")
  36. { if (substr($ip, 0, 9) == "141.52.16")
  37. { echo '<meta http-equiv="refresh" content="10">'; $onsite = true; }
  38. else echo '<meta http-equiv="refresh" content="30">'; $onsite = true; }
  39. else { echo '<meta http-equiv="refresh" content="120">'; $slowrefresh= true; }
  40. ?>
  41. <?php
  42. // poll ADEI values at 60 sec interval
  43. $lastRunLog = 'lastrun.log';
  44. $lastRun = 0;
  45. if (file_exists($lastRunLog)) {
  46. $lastRun = file_get_contents($lastRunLog);
  47. }
  48. if (time() - $lastRun >= 60) {
  49. file_put_contents($lastRunLog, time());
  50. // fork process
  51. umask(0);
  52. $pid = pcntl_fork();
  53. if ($pid < 0) {
  54. print('fork failed');
  55. exit(1);
  56. }
  57. if ($pid == 0) {
  58. // child process -- only do data polling
  59. $sid = posix_setsid();
  60. if ($sid < 0) exit(2);
  61. include('poll_adei_data.php');
  62. include('poll_HV_data.php');
  63. exit(0);
  64. }
  65. else {
  66. // parent process -- continue building website
  67. }
  68. }
  69. ?>
  70. </head>
  71. <body style="background-color:white;">
  72. <?php
  73. // set time zone to local German time
  74. date_default_timezone_set('Europe/Berlin');
  75. // include helper functions
  76. include "SDS_status_functions.php";
  77. // include channel list
  78. include "SDS_status_channels.php";
  79. // include aircoil settings
  80. include "aircoils_settings.php";
  81. // include HV data
  82. if ((include "ADEI_HV_readings.php") == 0)
  83. { usleep(400000); include "ADEI_HV_readings.php"; };
  84. // read cached ADEI data
  85. $valuesincluded = 0;
  86. $loop = 0;
  87. $includeflag = 0;
  88. do {
  89. $includeflag = include 'ADEIvalues.php';
  90. $loop++;
  91. if ($valuesincluded == 0) usleep(100000);
  92. }
  93. while (($loop < 21) && ($includeflag+$valuesincluded < 2));
  94. if ($valuesincluded == 0) $extraction_time = "Request timed out!".PHP_EOL;
  95. //echo $loop." ".$includeflag." ".$valuesincluded.PHP_EOL;
  96. // ########## TIME STAMP ##########
  97. echo '<font size="6" color="#000000"><b>KATRIN Spectrometer and Detector Section Status Overview</b></font><br>';
  98. echo '<font size="4" color="#000000">Page refreshed:&emsp;' . date(DATE_RFC850) . '</font><br>';
  99. echo '<font size="4" color="#000000">Data extracted:&ensp;&thinsp;&thinsp;&thinsp;' . $extraction_time . ' </font><br>';
  100. echo '<font size="4" color="#FFFFFF">&emsp; &emsp; &emsp; Client IP:' . $ip . ' </font><br>';
  101. //('. date("s", time() - $extraction_timestamp).'&thinsp;s old data)<br>';
  102. if ($errorcount >0) echo "<br> <br> <br> <br>".$errormessage;
  103. ?>
  104. <!--
  105. <div style="position:absolute; top:0px; left:0px">
  106. <img src="pics/bg.png">
  107. -->
  108. <div style="position:absolute; top:150px; left:2px">
  109. <img src="pics/beamline_noMoS.png">
  110. <div style="position:absolute; top:20px; left:315px">
  111. <img src="pics/spectrometer.png" width="1130" height="596">
  112. </div>
  113. <div style="position:absolute; top:-140px; left:1585px">
  114. <img src="pics/katrin_logo.jpg" width="100" height="100">
  115. </div>
  116. <!--
  117. <div style="position: absolute; top: 60px; left:1670px">
  118. <iframe src="https://uhr.ptb.de" scrolling="no" style="height: 230px; border: 0px none; width: 230px; margin-bottom: 0px; margin-left: 0px;">
  119. </iframe>
  120. </div>
  121. -->
  122. <a href="mailto:thuemmler@kit.edu">
  123. <div title="send email to Thomas Thuemmler" style="position:absolute; top:-50px; left:8px">
  124. <img src="pics/newEmail.png" width="23" height="23">
  125. </div>
  126. </a>
  127. <?php
  128. // include SDS status main page
  129. if ($valuesincluded == 1) include "SDS_status_main.php";
  130. ?>
  131. </body>
  132. </html>