forked from freifunk-franken/simple-babelweb
minified html
This commit is contained in:
parent
9ec1e3f63d
commit
fc0e788ee1
112
index.php
112
index.php
|
@ -3,7 +3,6 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Simple Babelweb</title>
|
<title>Simple Babelweb</title>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
table {
|
table {
|
||||||
font-family: monospace, sans-serif;
|
font-family: monospace, sans-serif;
|
||||||
|
@ -20,20 +19,19 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
$addr = "::1";
|
$addr = "::1";
|
||||||
$port = "33123";
|
$port = "33123";
|
||||||
|
|
||||||
$msg = "dump\r\n";
|
$msg = "dump\r\n";
|
||||||
$sock = socket_create(AF_INET6,SOCK_STREAM,0) or die("Cannot create socket");
|
$sock = socket_create(AF_INET6, SOCK_STREAM, 0) or die("Cannot create socket");
|
||||||
socket_connect($sock,$addr,$port) or die("Cannot connect to socket");
|
socket_connect($sock, $addr, $port) or die("Cannot connect to socket");
|
||||||
$read = socket_read($sock,1024);
|
$read = socket_read($sock, 1024);
|
||||||
$data = explode(PHP_EOL, $read);
|
$data = explode(PHP_EOL, $read);
|
||||||
|
|
||||||
# dump anfordern
|
# dump anfordern
|
||||||
socket_write($sock,$msg,strlen($msg));
|
socket_write($sock, $msg, strlen($msg));
|
||||||
|
|
||||||
# Daten einlesen
|
# Daten einlesen
|
||||||
$interface = array();
|
$interface = array();
|
||||||
|
@ -42,21 +40,20 @@
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
$read = socket_read($sock, 1024, PHP_NORMAL_READ);
|
$read = socket_read($sock, 1024, PHP_NORMAL_READ);
|
||||||
if (preg_match("/interface\b/", $read)) {
|
if (preg_match("/interface\b/", $read)) { $interface[] = $read; }
|
||||||
$interface[] = $read;
|
if (preg_match("/neighbour\b/", $read)) { $neighbour[] = $read; }
|
||||||
}
|
if (preg_match("/xroute\b/", $read)) { $xroute[] = $read; }
|
||||||
if (preg_match("/neighbour\b/", $read)) {
|
if (preg_match("/\broute\b/", $read)){ break 1; }
|
||||||
$neighbour[] = $read;
|
|
||||||
}
|
|
||||||
if (preg_match("/xroute\b/", $read)) {
|
|
||||||
$xroute[] = $read;
|
|
||||||
}
|
|
||||||
if (preg_match("/\broute\b/", $read)){
|
|
||||||
break 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
socket_close($sock);
|
socket_close($sock);
|
||||||
|
|
||||||
|
$output['data'] = array(
|
||||||
|
'name' => $data[0],
|
||||||
|
'version' => $data[1],
|
||||||
|
'host' => $data[2],
|
||||||
|
'id' => $data[3],
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($interface as $temp) {
|
foreach ($interface as $temp) {
|
||||||
$tempdata = explode(" ", $temp);
|
$tempdata = explode(" ", $temp);
|
||||||
$output['interfaces'][] = array(
|
$output['interfaces'][] = array(
|
||||||
|
@ -91,19 +88,15 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_REQUEST['format'] == 'json') {
|
if($_REQUEST['format'] == 'json') { echo json_encode($output); }
|
||||||
echo json_encode($output);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
# Ausgabe
|
# Ausgabe
|
||||||
echo "<h1>Simple Babelweb</h1>";
|
echo "<h1>Simple Babelweb</h1>";
|
||||||
echo "<table>";
|
echo "<table>";
|
||||||
for($i = 0; $i < count($data); ++$i) {
|
echo "<tr><td>".$output['data']['name']."</td></tr>";
|
||||||
if ($data[$i] == "ok") {
|
echo "<tr><td>".$output['data']['version']."</td></tr>";
|
||||||
break;
|
echo "<tr><td>".$output['data']['host']."</td></tr>";
|
||||||
}
|
echo "<tr><td>".$output['data']['id']."</td></tr>";
|
||||||
echo "<tr><td>$data[$i]</td></tr>";
|
|
||||||
}
|
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
||||||
echo "<H2>Interfaces</H2>";
|
echo "<H2>Interfaces</H2>";
|
||||||
|
@ -115,51 +108,46 @@
|
||||||
<th>ipv4</th>
|
<th>ipv4</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
foreach($output['interfaces'] as $interface) {
|
foreach($output['interfaces'] as $interface) {
|
||||||
echo "<tr><td>".$interface['interface']."</td>".
|
echo "<tr>";
|
||||||
"<td>".$interface['up']."</td>".
|
foreach($interface as $temp) { echo "<td>$temp</td>"; }
|
||||||
"<td>".$interface['ipv6']."</td>".
|
echo "</tr>";
|
||||||
"<td>".$interface['ipv4']."</td></tr>";
|
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
||||||
echo "<H2>Neighbours</H2>";
|
echo "<H2>Neighbours</H2>";
|
||||||
echo '<table>
|
echo '<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>neighbour</th>
|
<th>neighbour</th>
|
||||||
<th>address</th>
|
<th>address</th>
|
||||||
<th>interface</th>
|
<th>interface</th>
|
||||||
<th>reach</th>
|
<th>reach</th>
|
||||||
<th>rxcost</th>
|
<th>rxcost</th>
|
||||||
<th>txcost</th>
|
<th>txcost</th>
|
||||||
<th>rtt</th>
|
<th>rtt</th>
|
||||||
<th>rttcost</th>
|
<th>rttcost</th>
|
||||||
<th>cost</th>
|
<th>cost</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
foreach($output['neighbours'] as $neighbour) {
|
foreach($output['neighbours'] as $neighbour) {
|
||||||
echo "<tr><td>".$neighbour['neighbour']."</td>".
|
echo "<tr>";
|
||||||
"<td>".$neighbour['address']."</td>".
|
foreach($neighbour as $temp) { echo "<td>$temp</td>"; }
|
||||||
"<td>".$neighbour['interface']."</td>".
|
echo "</tr>";
|
||||||
"<td>".$neighbour['reach']."</td>".
|
|
||||||
"<td>".$neighbour['rxcost']."</td>".
|
|
||||||
"<td>".$neighbour['txcost']."</td>".
|
|
||||||
"<td>".$neighbour['rtt']."</td>".
|
|
||||||
"<td>".$neighbour['rttcost']."</td>".
|
|
||||||
"<td>".$neighbour['cost']."</td></tr>";
|
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
||||||
echo "<H2>Redistributed routes</H2>";
|
echo "<H2>Redistributed routes</H2>";
|
||||||
echo '<table>
|
echo '<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>prefix</th>
|
<th>prefix</th>
|
||||||
<th>from</th>
|
<th>from</th>
|
||||||
<th>metric</th>
|
<th>metric</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
foreach($output['xroutes'] as $xroute) {
|
foreach($output['xroutes'] as $xroute) {
|
||||||
echo "<tr><td>".$xroute['prefix']."</td>".
|
echo "<tr>";
|
||||||
"<td>".$xroute['from']."</td>".
|
foreach($xroute as $temp) { echo "<td>$temp</td>"; }
|
||||||
"<td>".$xroute['metric']."</td></tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue