Skip to content
Snippets Groups Projects
Commit 54a40019 authored by Lucio Zambon's avatar Lucio Zambon
Browse files

Update updater.php

parent 7bb7dbcd
No related branches found
No related tags found
No related merge requests found
......@@ -40,29 +40,30 @@ echo '<!doctype html>
}
die('</table>');
}
$base = (strpos($_SERVER['SERVER_NAME'], 'puma-01')!==false)? 'http://puma-01.elettra.eu/panther/updater.php?read&filename=': '/run/panther/';
if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
if ($_REQUEST['filename']=='preinjector.100.bpm') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm'));
list($trash, $f) = explode(':', file_get_contents($base.'elettra.100.bpm'));
$d = explode(';', $f);
die("[[".implode(',', array_slice($d, 0, 7)).'],['.implode(',', array_slice($d, 7, 7))."]]");
}
if ($_REQUEST['filename']=='preinjector.100.bpm.src') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm.src'), 2);
list($trash, $f) = explode(':', file_get_contents($base.'elettra.100.bpm.src'), 2);
$d = explode(',', $f);
die("[[".implode(',', array_slice($d, 0, 7)).'],['.implode(',', array_slice($d, 7, 7))."]]");
}
if ($_REQUEST['filename']=='bts.100.bpm') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm'));
list($trash, $f) = explode(':', file_get_contents($base.'elettra.100.bpm'));
$d = explode(';', $f);
die("[[".implode(',', array_slice($d, 14, 10)).'],['.implode(',', array_slice($d, 24, 10))."]]");
}
if ($_REQUEST['filename']=='bts.100.bpm.src') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm.src'), 2);
list($trash, $f) = explode(':', file_get_contents($base.'elettra.100.bpm.src'), 2);
$d = explode(',', $f);
die("[[".implode(',', array_slice($d, 14, 10)).'],['.implode(',', array_slice($d, 24, 10))."]]");
}
if ($_REQUEST['filename']=='sr.100.bpm') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm'));
list($trash, $f) = explode(':', file_get_contents($base.'elettra.100.bpm'));
$d = explode(';', $f);
die("[[".$d[34].'],['.$d[35]."]]");
}
......@@ -81,7 +82,8 @@ if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
}
if ($_REQUEST['filename']=='elettra.100.bpm') {
header('Content-Type: application/json');
list($trash, $f) = explode(':', strtr(file_get_contents('/run/panther/elettra.100.bpm'), array('e '=>'e')));
while (!is_numeric(substr($f, -1))) $f = substr($f, 0, strlen($f)-1);
list($trash, $f) = explode(':', strtr(file_get_contents($base.'elettra.100.bpm'), array('e '=>'e')));
$d = explode(';', $f);
die("{\"preinjector\":{\"Hor\":[".implode(',', array_slice($d, 0, 7)).'],"Ver":['.implode(',', array_slice($d, 7, 7))."]},\"bts\":{\"Hor\":[".implode(',', array_slice($d, 14, 10)).'],"Ver":['.implode(',', array_slice($d, 24, 10))."]},\"sr\":{\"Hor\":[".$d[34].'],"Ver":['.$d[35]."]}}");
}
......@@ -97,22 +99,22 @@ if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
$h[] = "\"srv-tango-sre-01:20000/sr/feedback/$name/HorPos\"";
$v[] = "\"srv-tango-sre-01:20000/sr/feedback/$name/VerPos\"";
}
list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm.src'), 2);
list($trash, $f) = explode(':', file_get_contents($base.'elettra.100.bpm.src'), 2);
$d = explode(',', $f);
die("{\"preinjector\":{\"Factor\":1000,\"Hor\":\n[\"".implode("\",\n\"", array_slice($d, 0, 7))."\"], \"Ver\":\n[\"".implode("\",\n\"", array_slice($d, 7, 7)).
"\"]},\n\"bts\":{\"Factor\":0.001,\"Hor\":\n[\"".implode("\",\n\"", array_slice($d, 14, 10))."\"],\"Ver\":\n[\"".implode("\",\n\"", array_slice($d, 24, 10)).
"\"]},\n\"sr\":{\"Factor\":1000,\"Hor\":[\n".implode(",\n", $h).'],"Ver":['.implode(',', $v)."\n]\n}\n}");
}
if ($_REQUEST['filename']=='fermi.1000.vlv') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/padres.1000.vlv'));
die(file_get_contents('/run/panther/fermi.1000.vlv').';'.$f);
list($trash, $f) = explode(':', file_get_contents($base.'padres.1000.vlv'));
die(file_get_contents($base.'fermi.1000.vlv').';'.$f);
}
if ($_REQUEST['filename']=='fermi.1000.vlv.src') {
list($trash, $f) = explode(':', file_get_contents('/run/panther/padres.1000.vlv.src'),2);
die(file_get_contents('/run/panther/fermi.1000.vlv.src').','.$f);
list($trash, $f) = explode(':', file_get_contents($base.'padres.1000.vlv.src'),2);
die(file_get_contents($base.'fermi.1000.vlv.src').','.$f);
}
if ($_REQUEST['filename']=='elettra.1000.vlv') {
$f = explode(';', file_get_contents('/run/panther/elettra.1000.vlv'));
$f = explode(';', file_get_contents($base.'elettra.1000.vlv'));
foreach ($f as $i=>$l) {
if (substr_count($l, ',')>15) {
$k = explode(',', $l);
......@@ -124,10 +126,10 @@ if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
die(implode(';', $f));
}
if ($_REQUEST['filename']=='elettra.1000.vlv.src') {
die(strtr(file_get_contents('/run/panther/elettra.1000.vlv.src'), array('rpcbridge/rpc2tangobridge'=>'sr', '_STAT_RF'=>'/state')));
die(strtr(file_get_contents($base.'elettra.1000.vlv.src'), array('rpcbridge/rpc2tangobridge'=>'sr', '_STAT_RF'=>'/state')));
}
if (!empty($_REQUEST['read']) || $_REQUEST['read']==='0') {
$f = explode(';',file_get_contents('/run/panther/'.$_REQUEST['filename']));
$f = explode(';',file_get_contents($base.$_REQUEST['filename']));
if ($_REQUEST['read']==='0') list($trash, $f[0]) = explode(':', $f[0]);
header('Content-Type: application/json');
$factor = 2000000000000;
......@@ -137,7 +139,7 @@ if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
die("[[".implode(',', $x).'],['.implode(',', $z)."]]");
die("[[{$f[$_REQUEST['read']-0]}],[{$f[$_REQUEST['read']+1]}]]");
}
readfile('/run/panther/'.$_REQUEST['filename']);
readfile($base.$_REQUEST['filename']);
exit();
}
if ($_SERVER['REMOTE_ADDR'] == '192.168.205.106' || $_SERVER['REMOTE_ADDR']=='192.168.205.25' || $_SERVER['REMOTE_ADDR'] == '192.168.205.149' || $_SERVER['REMOTE_ADDR'] == '192.168.205.157' || $_SERVER['REMOTE_ADDR'] == '192.168.205.158' || $_SERVER['REMOTE_ADDR'] == '192.168.205.159' || $_SERVER['REMOTE_ADDR'] == '192.168.205.166') {
......@@ -156,5 +158,11 @@ function multiply($factor, $array) {
}
return $array;
}
print_r($_SERVER);
$d = scandir('/run/panther');
echo "<table>\n";
foreach ($d as $srv) {
if ($srv=='.' || $srv=='..' || strpos($srv, '.src')) continue;
echo "<tr><td> $srv </td><td> <a href='./updater.php?read&filename=$srv'>data</a> </td><td> <a href='./updater.php?read&filename={$srv}.src'>src</a> </td><td> <a href='./updater.php?check&filename={$srv}'>check</a> </td></tr>\n";
}
echo "</table>\n";
?>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment