index.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <html>
  2. <head>
  3. <title>High-Voltage Patch-Panel Configuration</title>
  4. <style type="text/css">
  5. body { font-family:Arial; }
  6. td { text-align:center; }
  7. a:link { text-decoration:none; }
  8. a:visited { text-decoration:none; }
  9. a:hover { text-decoration:none; }
  10. a:active { text-decoration:none; }
  11. a:focus { text-decoration:none; }
  12. </style>
  13. </head>
  14. <body>
  15. <?php
  16. // offset between patch-panel channel $ch and adei channel $adei: $adei = $ch + $offset
  17. $offset = 2;
  18. // main-spectrometer rings
  19. $rings = array( "w02o", "w02i", "w03o", "w03i", "w04o", "w04i", "w05o", "w05i", "w06o", "w06i", "w07o", "w07i", "w12o", "w12i", "w13o", "w13i", "w14o", "w14i", "w15o", "w15i", "w16o", "w16i", "e02o", "e02i", "e03o", "e03i", "e04o", "e04i", "e05o", "e05i", "e06o", "e06i", "e07o", "e07i", "e12o", "e12i", "e13o", "e13i", "e14o", "e14i", "e15o", "e15i", "e16o", "e16i" );
  20. ?>
  21. <?php
  22. // submit button
  23. if ($_POST["ok"] == "submit")
  24. {
  25. // write TXT patch-panel configuration
  26. $time = strtotime($_POST["validfrom"]);
  27. if ($time === FALSE) $filename = time() . ".txt"; else $filename = $time . ".txt";
  28. $handle = fopen("data/" . $filename, "w");
  29. if ($handle)
  30. {
  31. $content = "";
  32. for ($id = 0; $id < 44; $id++)
  33. {
  34. if ($_POST[$rings[$id]] == 22) $tempcontent = "IE"; else $tempcontent = floatval($_POST[$rings[$id]]) + $offset;
  35. $content = $content . $tempcontent . "\r\n";
  36. }
  37. fwrite($handle, $content);
  38. fclose($handle);
  39. }
  40. // copy for SDS-STATUS-DISPLAY
  41. copy($filename, "ringstoadei.txt");
  42. // write CONF patch-panel configuration
  43. if ($_POST["configurationname"] != "")
  44. {
  45. $filename = $_POST["configurationname"] . ".conf";
  46. $handle = fopen("data/" . $filename, "w");
  47. if ($handle)
  48. {
  49. $content = "";
  50. for ($id = 0; $id < 44; $id++)
  51. {
  52. $tempcontent = floatval($_POST[$rings[$id]]);
  53. $content = $content . $tempcontent . "\r\n";
  54. }
  55. fwrite($handle, $content);
  56. fclose($handle);
  57. }
  58. }
  59. }
  60. ?>
  61. <?php
  62. // load configuration
  63. if ($_POST["configurationload"] != "" && $_POST["configurationload"] != "new configuration")
  64. {
  65. $filename = $_POST["configurationload"] . ".conf";
  66. $handle = fopen("data/" . $filename, "r");
  67. if ($handle)
  68. {
  69. while (($buffer = fgets($handle, 4096)) !== false)
  70. {
  71. $buffer = trim($buffer);
  72. $check[count($check)] = $buffer;
  73. }
  74. fclose($handle);
  75. }
  76. }
  77. else
  78. {
  79. $check = array( 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22 );
  80. }
  81. ?>
  82. <?php
  83. $adeiChannel[0] = array( "hv__katrin-hv_rep__0__95", "hv__katrin-hv_rep__0__71", "hv__katrin-hv_rep__0__79" );
  84. for ($id = 0; $id < 24; $id++)
  85. {
  86. $adeiChannel[1][$id] = "hv__katrin-hv_rep__1__" . (7 * $id + 3 + 7 * $offset);
  87. $adeiChannel[2][$id] = "hv__katrin-hv_rep__2__" . (7 * $id + 3 + 7 * $offset);
  88. }
  89. $username = 'katrin';
  90. $password = 'neutrino';
  91. $context = stream_context_create(array(
  92. 'http' => array(
  93. 'header' => "Authorization: Basic " . base64_encode("$username:$password")
  94. )
  95. ));
  96. for ($id = 0; $id < sizeof($adeiChannel); $id++)
  97. {
  98. $adeiChannels = "";
  99. for ($id2 = 0; $id2 < sizeof($adeiChannel[$id]); $id2++)
  100. {
  101. $adeiChannels = $adeiChannels . $adeiChannel[$id][$id2] . ",";
  102. }
  103. $adeiChannels = substr($adeiChannels, 0, strlen($adeiChannels) - 1);
  104. $fileip = file_get_contents("https://adei-katrin.kit.edu/adei/services/getdata.php?db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&virtual=srctree&srctree=" . $adeiChannels . "&window=60&format=csv", false, $context);
  105. //echo $fileip . "<br>";
  106. for ($id2 = sizeof($adeiChannel[$id]) - 1 ; $id2 > -1; $id2--)
  107. {
  108. $pos = strrpos($fileip, ",");
  109. $adeiValue[$id][$id2] = floatval(substr($fileip, $pos + 2));
  110. $fileip = substr($fileip, 0, $pos);
  111. //echo $id . "," . $id2 . "," . $adeiValue[$id][$id2] . "<br>";
  112. }
  113. }
  114. ?>
  115. <form method="post" action="index.php" name="myform">
  116. <font size="6"><b>High-Voltage Patch-Panel Configuration</b></font>
  117. <br><br>
  118. <table border="0" cellpadding="5" cellspacing="0" bgcolor="#C8C8C8">
  119. <tr>
  120. <td><b>configuration</b></td>
  121. <td>
  122. <select name="configurationload" size="1" onchange="myform.submit();">
  123. <option>new configuration</option>
  124. <?php
  125. foreach (glob("data/*.conf") as $filename)
  126. {
  127. $buffer = substr($filename, 5, strlen($filename) - 10);
  128. if ($_POST["configurationload"] == $buffer) echo '<option selected>'; else echo '<option>';
  129. echo $buffer . '</option>';
  130. }
  131. ?>
  132. </select>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>name</td>
  137. <td>
  138. <input type="text" name="configurationname" size="35">
  139. </td>
  140. </tr>
  141. </table>
  142. <br>
  143. <table border="0" cellpadding="0" cellspacing="0">
  144. <tr bgcolor="#000000" height="1px"><td colspan="47"></td></tr>
  145. <tr>
  146. <td bgcolor="#C8C8C8" colspan="22"><b>W E S T</b></td>
  147. <td colspan="3"><b>PATCH PANEL</b></td>
  148. <td bgcolor="#C8C8C8" colspan="22"><b>E A S T</b></td>
  149. </tr>
  150. <tr>
  151. <?php
  152. for ($id=2; $id<7; $id++) { if ($id % 2 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8"; echo '<td bgcolor="' . $color . '" colspan="2">0' . $id . '</td>'; }
  153. echo '<td colspan="2">07-11</td>';
  154. for ($id=12; $id<17; $id++) { if ($id % 2 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8"; echo '<td bgcolor="' . $color . '" colspan="2">' . $id . '</td>'; }
  155. echo '<td>&nbsp;ADEI&nbsp;</td>';
  156. echo '<td>&nbsp;CH&nbsp;</td>';
  157. echo '<td>&nbsp;ADEI&nbsp;</td>';
  158. for ($id=2; $id<7; $id++) { if ($id % 2 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8"; echo '<td bgcolor="' . $color . '" colspan="2">0' . $id . '</td>'; }
  159. echo '<td colspan="2">07-11</td>';
  160. for ($id=12; $id<17; $id++) { if ($id % 2 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8"; echo '<td bgcolor="' . $color . '" colspan="2">' . $id . '</td>'; }
  161. ?>
  162. </tr>
  163. <tr>
  164. <?php
  165. for ($id=0; $id<11; $id++) { if ($id % 2 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8"; echo '<td bgcolor="' . $color . '">o</td><td bgcolor="' . $color . '">i</td>'; }
  166. echo '<td></td>';
  167. echo '<td></td>';
  168. echo '<td></td>';
  169. for ($id=0; $id<11; $id++) { if ($id % 2 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8"; echo '<td bgcolor="' . $color . '">o</td><td bgcolor="' . $color . '">i</td>'; }
  170. ?>
  171. </tr>
  172. <?php
  173. for ($ch=0; $ch<23; $ch++)
  174. {
  175. if ($ch % 5 == 0) echo '<tr bgcolor="#000000" height="1px"><td colspan="47"></td></tr>';
  176. $text = str_pad($ch, 2, 0, STR_PAD_LEFT);
  177. echo '<tr>';
  178. for ($id=0; $id<22; $id++)
  179. {
  180. if ($id % 4 == 2 || $id % 4 == 3) $color = "#FFFFFF"; else $color = "#C8C8C8";
  181. $checked = "";
  182. if ($check[$id] == $ch) $checked = 'checked="checked"';
  183. echo '<td bgcolor="' . $color . '"><input type="radio" name="' . $rings[$id] . '" value="' . $ch . '" ' . $checked . '></td>';
  184. }
  185. $value = $adeiValue[1][$ch];
  186. if ($ch == 22) $value = $adeiValue[0][0] + $adeiValue[0][1];
  187. echo '<td>' . sprintf('%.0F', $value) . '</td>';
  188. echo '<td><b>';
  189. if ($ch == 22) echo 'IE';
  190. else echo $text;
  191. echo '</b></td>';
  192. $value = $adeiValue[2][$ch];
  193. if ($ch == 22) $value = $adeiValue[0][0] + $adeiValue[0][2];
  194. echo '<td>' . sprintf('%.0F', $value) . '</td>';
  195. for ($id=22; $id<44; $id++)
  196. {
  197. if ($id % 4 == 0 || $id % 4 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8";
  198. $checked = "";
  199. if ($check[$id] == $ch) $checked = 'checked="checked"';
  200. echo '<td bgcolor="' . $color . '"><input type="radio" name="' . $rings[$id] . '" value="' . $ch . '" ' . $checked . '></td>';
  201. }
  202. echo '</tr>';
  203. }
  204. ?>
  205. <tr bgcolor="#000000" height="1px"><td colspan="47"></td></tr>
  206. </table>
  207. <br>
  208. <table border="0" cellpadding="5" cellspacing="0" bgcolor="#C8C8C8">
  209. <tr>
  210. <td><b>valid from</b></td>
  211. <td>
  212. <input type="text" name="validfrom" size="19" maxlength="19"> (YYYY-MM-DD HH:MM:SS)
  213. </td>
  214. </tr>
  215. </table>
  216. <br>
  217. <table border="0" cellpadding="5" cellspacing="0" bgcolor="#C8C8C8">
  218. <tr>
  219. <td><b>elog entry</b></td>
  220. <td>
  221. <input type="checkbox" name="elog" value="yes"> write & submit
  222. </td>
  223. </tr>
  224. <tr>
  225. <td>author</td>
  226. <td>
  227. <select name="author" size="1">
  228. <option>---</option>
  229. <option>M. Erhard</option>
  230. <option>M. Kraus</option>
  231. <option>K. Schlösser</option>
  232. <option>T. Thümmler</option>
  233. <option>S. Wüstling</option>
  234. </select>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td>comments</td>
  239. <td>
  240. <textarea name="comments" cols="50" rows="5"></textarea>
  241. </td>
  242. </tr>
  243. </table>
  244. <br>
  245. <input type="submit" name="ok" value="submit">
  246. <input type="reset" value="reset">
  247. </form>
  248. </body>
  249. </html>