123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- <html>
- <head>
- <link rel="shortcut icon" href="../pics/KATRINlogo.ico" />
- <title>High-Voltage Patch-Panel Configuration</title>
- <style type="text/css">
- body { font-family:Arial; }
- td { text-align:center; }
- td.left { text-align:left; }
- 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; }
- td.even {
- background-color: #C8C8C8;
- }
- td.odd {
- background-color: #FFFFFF;
- }
- tr.highlight:hover,
- tr.highlight:hover td {
- background-color: #F0E68C !important;
- }
- .container {
- display: block;
- position: relative;
- margin: 5px;
- margin-top: -7px;
- padding-left: 14px;
- cursor: pointer;
- font-size: 22px;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- }
- /* Hide the browser's default checkbox */
- .container input {
- position: absolute;
- opacity: 0;
- cursor: pointer;
- height: 0;
- width: 0;
- }
- /* Create a custom checkbox */
- .checkmark {
- position: absolute;
- top: 0;
- left: 0;
- height: 10px;
- width: 10px;
- background-color: #eee;
- border: 2px solid #ddd;
- border-radius: 7px;
- }
- /* On mouse-over, add a grey background color */
- .container:hover input ~ .checkmark {
- background-color: #FF8C00;
- border: 2px solid black;
- }
- /* On mouse-over, add a grey background color */
- .container:hover input:checked ~ .checkmark {
- background-color: #0000CD;
- border: 2px solid #0000CD;
- }
- /* When the checkbox is checked, add a blue background */
- .container input:checked ~ .checkmark {
- background-color: #0000CD;
- border: 2px solid #eee;
- }
- /* Create the checkmark/indicator (hidden when not checked) */
- .checkmark:after {
- content: "";
- position: absolute;
- display: none;
- }
- /* Show the checkmark when checked */
- .container input:checked ~ .checkmark:after {
- display: block;
- }
- /* Style the checkmark/indicator */
- .container .checkmark:after {
- left: 2px;
- top: 2px;
- width: 2px;
- height: 2px;
- border: solid white;
- border-width: 1px 2px 3px 2px;
- border-radius: 3px;
- }
- </style>
- </head>
- <body>
- <?php
- // offset between patch-panel channel $ch and adei channel $adei: $adei = $ch + $offset
- $offset = 2;
- // main-spectrometer rings
- $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" );
- ?>
- <?php
- // submit button
- if ($_POST["ok"] == "submit")
- {
- // write TXT patch-panel configuration
- $config = $_POST["configurationname"] != "" ? $_POST["configurationname"] : $_POST["configurationload"];
- $author = $_POST["author"] != "" ? $_POST["author"] : "(anonymous)";
- //$time = strtotime($_POST["validfrom"]);
- $time = strtotime($_POST["validfrom-date"] . " " . $_POST["validfrom-time"]);
- if ($time === FALSE) $filename = time() . ".txt"; else $filename = $time . ".txt";
- $handle = fopen("data/" . $filename, "w");
- if ($handle)
- {
- $content = "";
- for ($id = 0; $id < 44; $id++)
- {
- if ($_POST[$rings[$id]] == 22) $tempcontent = "IE";
- else $tempcontent = floatval($_POST[$rings[$id]]) + $offset;
- $content = $content . $tempcontent . "\r\n";
- }
- fwrite($handle, $content);
- fclose($handle);
- }
- // copy for SDS-STATUS-DISPLAY
- copy("data/" . $filename, "data/activeIEconfig.txt");
- // write CONF patch-panel configuration
- if ($_POST["configurationname"] != "")
- {
- $filename = $_POST["configurationname"] . ".conf";
- $handle = fopen("data/" . $filename, "w");
- if ($handle)
- {
- $content = "";
- for ($id = 0; $id < 44; $id++)
- {
- $tempcontent = floatval($_POST[$rings[$id]]);
- $content = $content . $tempcontent . "\r\n";
- }
- fwrite($handle, $content);
- fclose($handle);
- }
- }
- // update KDB database
- if (isset($_POST["database"])) {
- sleep(1);
- //require '../update_database.php';
- if ($time === FALSE) {
- shell_exec('cd .. ; php ./update_database.php "' . $config . '" "' . $author . '"');
- }
- else {
- shell_exec('cd .. ; php ./update_database.php "' . $config . '" "' . $author . '" "' . date('Y-m-d H:i:s', $time) . '"');
- }
- }
- }
- ?>
- <?php
- // load configuration
- $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 );
- if (!array_key_exists("configurationload", $_POST))
- $_POST["configurationload"] = "(active configuration)";
- #echo $_POST["configurationload"];
- if ($_POST["configurationload"] == "(active configuration)")
- {
- shell_exec('cd .. ; php ./poll_database.php');
- $handle = fopen("data/activeIEconfig.txt", "r");
- if ($handle)
- {
- $id = 0;
- while (($buffer = fgets($handle, 4096)) !== false)
- {
- $buffer = trim($buffer);
- if ($buffer == 'IE')
- $check[$id++] = 22;
- else
- $check[$id++] = intval($buffer) - 2;
- }
- fclose($handle);
- }
- }
- else if ($_POST["configurationload"] != "(new configuration)")
- {
- $filename = $_POST["configurationload"] . ".conf";
- $handle = fopen("data/" . $filename, "r");
- if ($handle)
- {
- $id = 0;
- while (($buffer = fgets($handle, 4096)) !== false)
- {
- $buffer = trim($buffer);
- $check[$id++] = $buffer;
- }
- fclose($handle);
- }
- }
- ?>
- <?php
- $adeiChannel[0] = array( "hv__katrin-hv_rep__0__95", "hv__katrin-hv_rep__0__71", "hv__katrin-hv_rep__0__79" );
- for ($id = 0; $id < 24; $id++)
- {
- $adeiChannel[1][$id] = "hv__katrin-hv_rep__1__" . (7 * $id + 3 + 7 * $offset);
- $adeiChannel[2][$id] = "hv__katrin-hv_rep__2__" . (7 * $id + 3 + 7 * $offset);
- }
- $username = getenv('PHP_ADEI_USERNAME');
- $password = getenv('PHP_ADEI_PASSWORD');
- $context = stream_context_create(array(
- 'http' => array(
- 'header' => "Authorization: Basic " . base64_encode("$username:$password")
- )
- ));
- for ($id = 0; $id < sizeof($adeiChannel); $id++)
- {
- $adeiChannels = "";
- for ($id2 = 0; $id2 < sizeof($adeiChannel[$id]); $id2++)
- {
- $adeiChannels = $adeiChannels . $adeiChannel[$id][$id2] . ",";
- }
- $adeiChannels = substr($adeiChannels, 0, strlen($adeiChannels) - 1);
- $fileip = file_get_contents("https://adei-katrin.kaas.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);
- //echo $fileip . "<br>";
- for ($id2 = sizeof($adeiChannel[$id]) - 1 ; $id2 > -1; $id2--)
- {
- $pos = strrpos($fileip, ",");
- $adeiValue[$id][$id2] = floatval(substr($fileip, $pos + 2));
- $fileip = substr($fileip, 0, $pos);
- //echo $id . "," . $id2 . "," . $adeiValue[$id][$id2] . "<br>";
- }
- }
- ?>
- <form method="post" action="index.php" name="myform">
- <font size="6">
- <a href="../index.php" title="Back to main page">
- <img style="margin-right: .5em; margin-bottom: -8px" src="../pics/katrin_logo_round.png" width="40px" height="40px">
- <a>
- <b>High-Voltage Patch-Panel Configuration</b>
- </font>
- <br><br>
- <table border="0" cellpadding="5" cellspacing="0" bgcolor="#C8C8C8">
- <tr>
- <td><b>configuration</b></td>
- <td>
- <select name="configurationload" size="1" onchange="myform.submit();">
- <option>(active configuration)</option>
- <?php
- if ($_POST["configurationload"] == "(new configuration)") echo '<option selected>'; else echo '<option>';
- echo '(new configuration)</option>';
- foreach (glob("data/*.conf") as $filename)
- {
- $buffer = substr($filename, 5, strlen($filename) - 10);
- if ($_POST["configurationload"] == $buffer) echo '<option selected>'; else echo '<option>';
- echo $buffer . '</option>';
- }
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td>name</td>
- <td>
- <input type="text" name="configurationname" size="35">
- </td>
- </tr>
- </table>
- <br>
- <table border="0" cellpadding="0" cellspacing="0">
- <tr bgcolor="#000000" height="1px"><td colspan="47"></td></tr>
- <tr>
- <th bgcolor="#C8C8C8" colspan="22"><b>W E S T</b></th>
- <th colspan="3"><b>PATCH PANEL</b></th>
- <th bgcolor="#C8C8C8" colspan="22"><b>E A S T</b></th>
- </tr>
- <tr>
- <?php
- for ($id=2; $id<7; $id++) {
- if ($id % 2 == 1) $class = "odd"; else $class = "even";
- echo '<td class="highlight ' . $class . '" colspan="2">0' . $id . '</td>';
- }
- echo '<td colspan="2">07-11</td>';
- for ($id=12; $id<17; $id++) {
- if ($id % 2 == 1) $class = "odd"; else $class = "even";
- echo '<td class="highlight ' . $class . '" colspan="2">' . $id . '</td>';
- }
- echo '<td> ADEI </td>';
- echo '<td> CH </td>';
- echo '<td> ADEI </td>';
- for ($id=2; $id<7; $id++) {
- if ($id % 2 == 1) $class = "odd"; else $class = "even";
- echo '<td class="highlight ' . $class . '" colspan="2">0' . $id . '</td>';
- }
- echo '<td colspan="2">07-11</td>';
- for ($id=12; $id<17; $id++) {
- if ($id % 2 == 1) $class = "odd"; else $class = "even";
- echo '<td class="highlight ' . $class . '" colspan="2">' . $id . '</td>';
- }
- ?>
- </tr>
- <tr>
- <?php
- for ($id=0; $id<11; $id++) {
- if ($id % 2 == 1) $class = "odd"; else $class = "even";
- echo '<td class="highlight ' . $class . '">o</td><td class="highlight ' . $class . '">i</td>';
- }
- echo '<td></td>';
- echo '<td></td>';
- echo '<td></td>';
- for ($id=0; $id<11; $id++) {
- if ($id % 2 == 1) $class = "odd"; else $class = "even";
- echo '<td class="highlight ' . $class . '">o</td><td class="highlight ' . $class . '">i</td>';
- }
- ?>
- </tr>
- <?php
- for ($ch=0; $ch<23; $ch++)
- {
- if ($ch % 5 == 0) echo '<tr bgcolor="#000000" height="1px"><td colspan="47"></td></tr>';
- $text = str_pad($ch, 2, 0, STR_PAD_LEFT);
- echo '<tr class="highlight">';
- for ($id=0; $id<22; $id++)
- {
- //if ($id % 4 == 2 || $id % 4 == 3) $color = "#FFFFFF"; else $color = "#C8C8C8";
- if ($id % 4 == 2 || $id % 4 == 3) $class = "odd"; else $class = "even";
- $checked = "";
- if ($check[$id] == $ch) $checked = 'checked="checked"';
- echo '<td class="highlight ' . $class . '"><label class="container"><input type="radio" name="' . $rings[$id] . '" value="' . $ch . '" ' . $checked . '><span class="checkmark"></span></label></td>';
- }
- $value = $adeiValue[1][$ch];
- if ($ch == 22) $value = $adeiValue[0][0] + $adeiValue[0][1];
- echo '<td>' . sprintf('%.0F', $value) . '</td>';
- echo '<th><b>';
- if ($ch == 22) echo 'IE';
- else echo $text;
- echo '</b></th>';
- $value = $adeiValue[2][$ch];
- if ($ch == 22) $value = $adeiValue[0][0] + $adeiValue[0][2];
- echo '<td>' . sprintf('%.0F', $value) . '</td>';
- for ($id=22; $id<44; $id++)
- {
- //if ($id % 4 == 0 || $id % 4 == 1) $color = "#FFFFFF"; else $color = "#C8C8C8";
- if ($id % 4 == 2 || $id % 4 == 3) $class = "even"; else $class = "odd";
- $checked = "";
- if ($check[$id] == $ch) $checked = 'checked="checked"';
- echo '<td class="highlight ' . $class . '"><label class="container"><input type="radio" name="' . $rings[$id] . '" value="' . $ch . '" ' . $checked . '><span class="checkmark"></span></label></td>';
- }
- echo '</tr>';
- }
- ?>
- <tr bgcolor="#000000" height="1px"><td colspan="47"></td></tr>
- </table>
- <br>
- <table border="0" cellpadding="5" cellspacing="0" bgcolor="#C8C8C8">
- <tr>
- <td><b>valid from</b></td>
- <td>
- <!-- <input type="text" name="validfrom" size="19" maxlength="19"> (YYYY-MM-DD HH:MM:SS) -->
- <input type="date" name="validfrom-date">
- <input type="time" name="validfrom-time">
- </td>
- </tr>
- </table>
- <br>
- <table border="0" cellpadding="5" cellspacing="0" bgcolor="#C8C8C8">
- <tr>
- <td width="200px"><b>elog entry</b></td>
- <td class="left">
- <input type="checkbox" name="elog" value="yes"> submit to ELOG
- </td>
- </tr>
- <tr>
- <td><b>database entry</b></td>
- <td class="left">
- <input type="checkbox" name="database" value="yes"> submit to KDB
- </td>
- </tr>
- <tr>
- <td>author<br/><sup>(click twice to open drop-down)</sup></td>
- <td class="left">
- <!--<select name="author" size="1">-->
- <input type="text" list="authorlist" name="author" size="50"/>
- <datalist id="authorlist">
- <option>---</option>
- <option>B. Bieringer</option>
- <option>C. Rodenbeck</option>
- <option>T. Thuemmler</option>
- <option>S. Wuestling</option>
- </datalist>
- <!--</select>-->
- </td>
- </tr>
- <tr>
- <td>comments</td>
- <td class="left">
- <textarea name="comments" cols="50" rows="5"></textarea>
- </td>
- </tr>
- </table>
- <br>
- <input type="submit" name="ok" value="submit">
- <input type="reset" value="reset">
- </form>
- </body>
- </html>
|